Mercurial > hg > octave-jordi
annotate libinterp/octave.cc @ 21052:b702efa70fb5 draft default tip shane
Adding --json-sock option; publishes octave_link events to a UNIX socket.
author | Shane F. Carr <shane.carr@wustl.edu> |
---|---|
date | Mon, 04 Jan 2016 08:51:31 +0000 |
parents | 3e7cfee5f786 |
children |
rev | line source |
---|---|
1 | 1 /* |
2 | |
19696
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19601
diff
changeset
|
3 Copyright (C) 1993-2015 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
23 // Born February 20, 1992. | |
24 | |
240 | 25 #ifdef HAVE_CONFIG_H |
1192 | 26 #include <config.h> |
1 | 27 #endif |
28 | |
1355 | 29 #include <cassert> |
17811
ef4fc092c86b
set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents:
17792
diff
changeset
|
30 #include <clocale> |
1355 | 31 #include <cstdlib> |
32 #include <cstring> | |
33 #include <ctime> | |
34 | |
3503 | 35 #include <iostream> |
1355 | 36 |
17570
1c7d768c3847
don't fork if there is no controlling tty
John W. Eaton <jwe@octave.org>
parents:
17568
diff
changeset
|
37 #include <fcntl.h> |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
38 #include <getopt.h> |
12335
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
39 #include <sys/types.h> |
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
40 #include <unistd.h> |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
41 |
2926 | 42 #include "cmd-edit.h" |
3690 | 43 #include "f77-fcn.h" |
4097 | 44 #include "file-ops.h" |
2926 | 45 #include "file-stat.h" |
240 | 46 #include "lo-error.h" |
2926 | 47 #include "oct-env.h" |
1907 | 48 #include "str-vec.h" |
223 | 49 |
15475
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
50 #include "builtins.h" |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
51 #include "defaults.h" |
3933 | 52 #include "Cell.h" |
1355 | 53 #include "defun.h" |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
54 #include "display.h" |
1355 | 55 #include "error.h" |
56 #include "file-io.h" | |
15473
457a2ff2a71b
set Vinfo_file and Vinfo_program variables directly from command line options
John W. Eaton <jwe@octave.org>
parents:
15472
diff
changeset
|
57 #include "help.h" |
1 | 58 #include "input.h" |
21052
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
59 #include "json-main.h" |
1 | 60 #include "lex.h" |
5832 | 61 #include "load-path.h" |
17755
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
62 #include "load-save.h" |
4113 | 63 #include "octave.h" |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
64 #include "oct-conf.h" |
1742 | 65 #include "oct-hist.h" |
5654 | 66 #include "oct-map.h" |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
67 #include "oct-mutex.h" |
20939
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20938
diff
changeset
|
68 #include "ovl.h" |
2375 | 69 #include "ops.h" |
17777
ae8905fbf1f8
move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents:
17755
diff
changeset
|
70 #include "options-usage.h" |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
71 #include "ov.h" |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
14619
diff
changeset
|
72 #include "ov-classdef.h" |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
73 #include "ov-range.h" |
1670 | 74 #include "toplev.h" |
1 | 75 #include "parse.h" |
562 | 76 #include "procstream.h" |
1355 | 77 #include "sighandlers.h" |
78 #include "sysdep.h" | |
1 | 79 #include "unwind-prot.h" |
1355 | 80 #include "utils.h" |
81 #include "variables.h" | |
2492 | 82 #include <version.h> |
1 | 83 |
4159 | 84 // Kluge. |
5990 | 85 extern "C" F77_RET_T |
11518 | 86 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL, |
87 const octave_idx_type& | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
88 F77_CHAR_ARG_LEN_DECL); |
4159 | 89 |
2910 | 90 extern void install_builtins (void); |
91 | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
92 int octave_cmdline_argc; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
93 char **octave_cmdline_argv; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
94 int octave_embedded; |
21052
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
95 json_main* _json_main; |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
96 |
1907 | 97 // The command-line options. |
98 static string_vector octave_argv; | |
1 | 99 |
5780 | 100 // The name used to invoke Octave. |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
101 static std::string octave_program_invocation_name; |
5780 | 102 |
103 // The last component of octave_program_invocation_name. | |
104 static std::string octave_program_name; | |
105 | |
16210
78365c56a762
make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
106 // TRUE means we are using readline. |
78365c56a762
make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
107 // (--no-line-editing) |
78365c56a762
make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
108 static bool line_editing = true; |
78365c56a762
make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents:
16208
diff
changeset
|
109 |
2239 | 110 // TRUE means we read ~/.octaverc and ./.octaverc. |
111 // (--norc; --no-init-file; -f) | |
112 static bool read_init_files = true; | |
113 | |
114 // TRUE means we read the site-wide octaverc files. | |
115 // (--norc; --no-site-file; -f) | |
2240 | 116 static bool read_site_files = true; |
1 | 117 |
6365 | 118 // TRUE means we set the initial path to configured defaults. |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
119 // (--no-init-path) |
6365 | 120 static bool set_initial_path = true; |
121 | |
3019 | 122 // TRUE means we don't print the usual startup message. |
616 | 123 // (--quiet; --silent; -q) |
2239 | 124 static bool inhibit_startup_message = false; |
1 | 125 |
3019 | 126 // If TRUE, print verbose info in some cases. |
1825 | 127 // (--verbose; -V) |
2239 | 128 static bool verbose_flag = false; |
1825 | 129 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
130 // If TRUE, force the GUI to start. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
131 // (--force-gui) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
132 static bool force_gui_option = false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
133 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
134 // If TRUE don't start the GUI. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
135 // (--no-gui) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
136 static bool no_gui_option = false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
137 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
138 // If TRUE, force readline command line editing. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
139 // (--line-editing) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
140 static bool forced_line_editing = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
141 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
142 // If TRUE, initialize history list from saved history file. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
143 // (--no-history; -H) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
144 static bool read_history_file = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
145 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
146 // The value of "path" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
147 // (--path; -p) |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
148 static std::list<std::string> command_line_path; |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
149 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
150 // The value for "EXEC_PATH" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
151 // (--exec-path) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
152 static std::string exec_path; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
153 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
154 // The value for "IMAGE_PATH" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
155 // (--image-path) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
156 static std::string image_path; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
157 |
21052
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
158 // The value for "JSON_SOCK" specified on the command line. |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
159 // (--json-sock) |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
160 static std::string json_sock_path; |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
161 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
162 // If TRUE, ignore the window system even if it is available. |
16774
8d188159ce5f
Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents:
16753
diff
changeset
|
163 // (--no-window-system, -W) |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
164 static bool no_window_system = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
165 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
166 // The code to evaluate at startup |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
167 // (--eval CODE) |
5189 | 168 static std::string code_to_eval; |
169 | |
170 // If TRUE, don't exit after evaluating code given by --eval option. | |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
171 // (--persist) |
5189 | 172 static bool persist = false; |
4356 | 173 |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
174 // If TRUE, the GUI should be started. |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
175 static bool start_gui = false; |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
176 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
177 // If TRUE use traditional (maximally MATLAB compatible) settings |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
178 // (--traditional) |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
179 static bool traditional = false; |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
180 |
19849
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
181 // TRUE if this is a program and no interpreter and interaction is |
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
182 // needed. For example, an octave program with shebang line, or code |
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
183 // from eval without persist. |
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
184 static bool an_octave_program = false; |
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
185 |
1355 | 186 // Store the command-line options for later use. |
187 | |
188 static void | |
189 intern_argv (int argc, char **argv) | |
190 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
191 assert (symbol_table::at_top_level ()); |
4892 | 192 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16210
diff
changeset
|
193 symbol_table::assign (".nargin.", argc - 1); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
194 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
195 symbol_table::mark_hidden (".nargin."); |
3195 | 196 |
10485
b4e14e628fc9
Truncate argv() for scripts used without command line parameters. Bug #29423
Judd Storrs <jstorrs@gmail.com>
parents:
10370
diff
changeset
|
197 if (argc > 0) |
1355 | 198 { |
7336 | 199 octave_argv.resize (argc - 1); |
3933 | 200 |
2495 | 201 // Skip program name in argv. |
3933 | 202 int i = argc; |
203 while (--i > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
204 octave_argv[i-1] = *(argv+i); |
1355 | 205 } |
206 } | |
207 | |
5654 | 208 DEFUN (__version_info__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
209 "-*- texinfo -*-\n\ |
20852
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20848
diff
changeset
|
210 @deftypefn {} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\ |
6945 | 211 Undocumented internal function.\n\ |
5654 | 212 @end deftypefn") |
213 { | |
11066
e678346a47d9
toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
214 static octave_map vinfo; |
5654 | 215 |
216 int nargin = args.length (); | |
217 | |
20848
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
218 if (nargin != 0 && nargin != 4) |
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
219 print_usage (); |
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
220 |
20938
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
221 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
222 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
223 if (nargin == 0) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
224 retval = vinfo; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
225 else if (nargin == 4) |
5654 | 226 { |
6639 | 227 if (vinfo.nfields () == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
228 { |
20938
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
229 vinfo.assign ("Name", args(0)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
230 vinfo.assign ("Version", args(1)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
231 vinfo.assign ("Release", args(2)); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
232 vinfo.assign ("Date", args(3)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
233 } |
5781 | 234 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
235 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
236 octave_idx_type n = vinfo.numel () + 1; |
5654 | 237 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
238 vinfo.resize (dim_vector (n, 1)); |
5781 | 239 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
240 octave_value idx (n); |
5781 | 241 |
20938
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
242 vinfo.assign (idx, "Name", Cell (octave_value (args(0)))); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
243 vinfo.assign (idx, "Version", Cell (octave_value (args(1)))); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
244 vinfo.assign (idx, "Release", Cell (octave_value (args(2)))); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
245 vinfo.assign (idx, "Date", Cell (octave_value (args(3)))); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
246 } |
5654 | 247 } |
248 | |
249 return retval; | |
250 } | |
251 | |
252 static void | |
253 initialize_version_info (void) | |
254 { | |
255 octave_value_list args; | |
256 | |
5658 | 257 args(3) = OCTAVE_RELEASE_DATE; |
258 args(2) = OCTAVE_RELEASE; | |
5654 | 259 args(1) = OCTAVE_VERSION; |
260 args(0) = "GNU Octave"; | |
261 | |
262 F__version_info__ (args, 0); | |
263 } | |
264 | |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
265 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
266 gripe_safe_source_exception (const std::string& file, const std::string& msg) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
267 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
268 std::cerr << "error: " << msg << "\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
269 << "error: execution of " << file << " failed\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
270 << "error: trying to make my way to a command prompt" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
271 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
272 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
273 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
274 // Execute commands from a file and catch potential exceptions in a consistent |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
275 // way. This function should be called anywhere we might parse and execute |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
276 // commands from a file before before we have entered the main loop in |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
277 // toplev.cc. |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
278 |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
279 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
280 safe_source_file (const std::string& file_name, |
21016
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
281 const std::string& context = "", |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
282 bool verbose = false, bool require_file = true, |
21016
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
283 const std::string& warn_for = "") |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
284 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
285 try |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
286 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
287 source_file (file_name, context, verbose, require_file, warn_for); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
288 } |
20534
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20486
diff
changeset
|
289 catch (const octave_interrupt_exception&) |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
290 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
291 recover_from_exception (); |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
292 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
293 octave_stdout << "\n"; |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
294 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
295 if (quitting_gracefully) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
296 clean_up_and_exit (exit_status); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
297 } |
20534
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20486
diff
changeset
|
298 catch (const octave_execution_exception&) |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
299 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
300 recover_from_exception (); |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
301 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
302 gripe_safe_source_exception (file_name, "unhandled execution exception"); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
303 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
304 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
305 |
581 | 306 // Initialize by reading startup files. |
307 | |
1 | 308 static void |
309 execute_startup_files (void) | |
310 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
311 unwind_protect frame; |
315 | 312 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
313 std::string context; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
314 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
315 bool verbose = (verbose_flag && ! inhibit_startup_message); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
316 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
317 bool require_file = false; |
578 | 318 |
2239 | 319 if (read_site_files) |
1 | 320 { |
2239 | 321 // Execute commands from the site-wide configuration file. |
322 // First from the file $(prefix)/lib/octave/site/m/octaverc | |
323 // (if it exists), then from the file | |
3597 | 324 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755 | 325 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
326 safe_source_file (Vlocal_site_defaults_file, context, verbose, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
327 require_file); |
1755 | 328 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
329 safe_source_file (Vsite_defaults_file, context, verbose, require_file); |
1 | 330 } |
331 | |
2239 | 332 if (read_init_files) |
333 { | |
2512 | 334 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
19596
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19528
diff
changeset
|
335 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
336 // .octaverc is assumed. |
2239 | 337 |
4804 | 338 bool home_rc_already_executed = false; |
2512 | 339 |
3523 | 340 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512 | 341 |
2926 | 342 if (initfile.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
343 initfile = ".octaverc"; |
2512 | 344 |
3523 | 345 std::string home_dir = octave_env::get_home_directory (); |
2926 | 346 |
4804 | 347 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
348 | |
349 std::string local_rc; | |
2239 | 350 |
5781 | 351 if (! home_rc.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
352 { |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
353 safe_source_file (home_rc, context, verbose, require_file); |
2239 | 354 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
355 // Names alone are not enough. |
2239 | 356 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
357 file_stat fs_home_rc (home_rc); |
2239 | 358 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
359 if (fs_home_rc) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
360 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
361 // We want to check for curr_dir after executing home_rc |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
362 // because doing that may change the working directory. |
4804 | 363 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
364 local_rc = octave_env::make_absolute (initfile); |
4804 | 365 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
366 home_rc_already_executed = same_file (home_rc, local_rc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
367 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
368 } |
2239 | 369 |
370 if (! home_rc_already_executed) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
371 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
372 if (local_rc.empty ()) |
10250 | 373 local_rc = octave_env::make_absolute (initfile); |
4804 | 374 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
375 safe_source_file (local_rc, context, verbose, require_file); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
376 } |
2239 | 377 } |
1 | 378 } |
379 | |
5189 | 380 static int |
381 execute_eval_option_code (const std::string& code) | |
382 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
383 unwind_protect frame; |
5189 | 384 |
7202 | 385 octave_save_signal_mask (); |
386 | |
387 can_interrupt = true; | |
388 | |
389 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
390 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
391 octave_bad_alloc_hook = 0; |
7202 | 392 |
393 octave_catch_interrupts (); | |
394 | |
395 octave_initialized = true; | |
396 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
397 frame.protect_var (interactive); |
5189 | 398 |
399 interactive = false; | |
400 | |
401 int parse_status = 0; | |
402 | |
6487 | 403 try |
404 { | |
405 eval_string (code, false, parse_status, 0); | |
406 } | |
20534
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20486
diff
changeset
|
407 catch (const octave_interrupt_exception&) |
7202 | 408 { |
409 recover_from_exception (); | |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
410 |
7202 | 411 octave_stdout << "\n"; |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
412 |
9383 | 413 if (quitting_gracefully) |
414 clean_up_and_exit (exit_status); | |
7202 | 415 } |
20534
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20486
diff
changeset
|
416 catch (const octave_execution_exception&) |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
417 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
418 recover_from_exception (); |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
419 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
420 std::cerr << "error: unhandled execution exception -- eval failed" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
421 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
422 } |
5189 | 423 |
424 return parse_status; | |
425 } | |
426 | |
427 static void | |
428 execute_command_line_file (const std::string& fname) | |
429 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
430 unwind_protect frame; |
5189 | 431 |
7202 | 432 octave_save_signal_mask (); |
433 | |
434 can_interrupt = true; | |
435 | |
436 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
437 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
438 octave_bad_alloc_hook = 0; |
7202 | 439 |
440 octave_catch_interrupts (); | |
441 | |
442 octave_initialized = true; | |
443 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
444 frame.protect_var (interactive); |
5189 | 445 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
446 frame.protect_var (octave_program_invocation_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
447 frame.protect_var (octave_program_name); |
5189 | 448 |
449 interactive = false; | |
450 | |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
451 octave_program_invocation_name = fname; |
5189 | 452 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
453 size_t pos = fname.find_last_of (file_ops::dir_sep_chars ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
454 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
455 octave_program_name |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
456 = (pos != std::string::npos) ? fname.substr (pos+1) : fname; |
5189 | 457 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
458 std::string context; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
459 bool verbose = false; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
460 bool require_file = true; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
461 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
462 safe_source_file (fname, context, verbose, require_file, "octave"); |
5189 | 463 } |
464 | |
21039
3e7cfee5f786
maint: Rename attributes GCC_ATTR_XXX to OCTAVE_XXX.
Rik <rik@octave.org>
parents:
21036
diff
changeset
|
465 OCTAVE_NORETURN static void |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
466 lo_error_handler (const char *fmt, ...) |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
467 { |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
468 va_list args; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
469 va_start (args, fmt); |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9724
diff
changeset
|
470 verror_with_cfn (fmt, args); |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
471 va_end (args); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
472 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
473 octave_throw_execution_exception (); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
474 } |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
475 |
21039
3e7cfee5f786
maint: Rename attributes GCC_ATTR_XXX to OCTAVE_XXX.
Rik <rik@octave.org>
parents:
21036
diff
changeset
|
476 OCTAVE_NORETURN static void |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
477 lo_error_with_id_handler (const char *id, const char *fmt, ...) |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
478 { |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
479 va_list args; |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
480 va_start (args, fmt); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
481 verror_with_id_cfn (id, fmt, args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
482 va_end (args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
483 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
484 octave_throw_execution_exception (); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
485 } |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
486 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
487 static void |
721 | 488 initialize_error_handlers () |
489 { | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
490 set_liboctave_error_handler (lo_error_handler); |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
491 set_liboctave_error_with_id_handler (lo_error_with_id_handler); |
3325 | 492 set_liboctave_warning_handler (warning); |
5781 | 493 set_liboctave_warning_with_id_handler (warning_with_id); |
721 | 494 } |
495 | |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
496 // What internal options get configured by --traditional. |
1410 | 497 |
498 static void | |
499 maximum_braindamage (void) | |
500 { | |
5189 | 501 persist = true; |
502 | |
15475
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
503 FPS1 (octave_value (">> ")); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
504 FPS2 (octave_value ("")); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
505 FPS4 (octave_value ("")); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
506 Fbeep_on_error (octave_value (true)); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
507 Fconfirm_recursive_rmdir (octave_value (false)); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
508 Fcrash_dumps_octave_core (octave_value (false)); |
19390
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19029
diff
changeset
|
509 Fdisable_diagonal_matrix (octave_value (true)); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19029
diff
changeset
|
510 Fdisable_permutation_matrix (octave_value (true)); |
19393
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19390
diff
changeset
|
511 Fdisable_range (octave_value (true)); |
15475
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
512 Ffixed_point_format (octave_value (true)); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
513 Fhistory_timestamp_format_string (octave_value ("%%-- %D %I:%M %p --%%")); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
514 Fpage_screen_output (octave_value (false)); |
da6c37ed0b42
eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents:
15474
diff
changeset
|
515 Fprint_empty_dimensions (octave_value (false)); |
19390
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
19029
diff
changeset
|
516 Fsave_default_options (octave_value ("-mat-binary")); |
18152
ab26db8da20a
set struct levels to print to 0 for --traditional (bug #40955)
John W. Eaton <jwe@octave.org>
parents:
18129
diff
changeset
|
517 Fstruct_levels_to_print (octave_value (0)); |
5904 | 518 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9383
diff
changeset
|
519 disable_warning ("Octave:abbreviated-property-match"); |
19029
9ef10e6a5987
make "file found in path" warnings consistent
John W. Eaton <jwe@octave.org>
parents:
18158
diff
changeset
|
520 disable_warning ("Octave:data-file-in-path"); |
5904 | 521 disable_warning ("Octave:function-name-clash"); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
522 disable_warning ("Octave:possible-matlab-short-circuit-operator"); |
1410 | 523 } |
524 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
525 // EMBEDDED is declared int instead of bool because this function is |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
526 // declared extern "C". |
581 | 527 |
1 | 528 int |
4368 | 529 octave_main (int argc, char **argv, int embedded) |
1 | 530 { |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
531 octave_process_command_line (argc, argv); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
532 |
16540
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
533 sysdep_init (); |
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
534 |
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
535 install_defaults (); |
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
536 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
537 octave_initialize_interpreter (argc, argv, embedded); |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
538 |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
539 return octave_execute_interpreter (); |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
540 } |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
541 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
542 void |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
543 octave_process_command_line (int argc, char **argv) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
544 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
545 octave_cmdline_argc = argc; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
546 octave_cmdline_argv = argv; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
547 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
548 while (true) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
549 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
550 int long_idx; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
551 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
552 int optc = getopt_long (argc, argv, short_opts, long_opts, &long_idx); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
553 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
554 if (optc < 0) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
555 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
556 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
557 switch (optc) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
558 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
559 case '?': |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
560 // Unrecognized option. getopt_long already printed a message about |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
561 // it, so we will just print the usage string and exit. |
17777
ae8905fbf1f8
move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents:
17755
diff
changeset
|
562 octave_print_terse_usage_and_exit (); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
563 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
564 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
565 case 'H': |
16876
9e0618443c2b
Rename saving_history() to history_save().
Rik <rik@octave.org>
parents:
16875
diff
changeset
|
566 Fhistory_save (octave_value (false)); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
567 read_history_file = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
568 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
569 |
16774
8d188159ce5f
Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents:
16753
diff
changeset
|
570 case 'W': |
8d188159ce5f
Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents:
16753
diff
changeset
|
571 no_window_system = true; |
8d188159ce5f
Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents:
16753
diff
changeset
|
572 break; |
8d188159ce5f
Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents:
16753
diff
changeset
|
573 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
574 case 'V': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
575 verbose_flag = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
576 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
577 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
578 case 'd': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
579 // This is the same as yydebug in parse.y. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
580 octave_debug++; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
581 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
582 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
583 case 'f': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
584 read_init_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
585 read_site_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
586 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
587 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
588 case 'h': |
17777
ae8905fbf1f8
move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents:
17755
diff
changeset
|
589 octave_print_verbose_usage_and_exit (); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
590 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
591 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
592 case 'i': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
593 forced_interactive = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
594 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
595 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
596 case 'p': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
597 if (optarg) |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
598 command_line_path.push_back (optarg); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
599 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
600 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
601 case 'q': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
602 inhibit_startup_message = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
603 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
604 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
605 case 'x': |
15477
8b5fc510c6d6
don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents:
15476
diff
changeset
|
606 { |
8b5fc510c6d6
don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents:
15476
diff
changeset
|
607 int val = ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE; |
8b5fc510c6d6
don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents:
15476
diff
changeset
|
608 Fecho_executing_commands (octave_value (val)); |
8b5fc510c6d6
don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents:
15476
diff
changeset
|
609 } |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
610 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
611 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
612 case 'v': |
17777
ae8905fbf1f8
move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents:
17755
diff
changeset
|
613 octave_print_version_and_exit (); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
614 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
615 |
15470
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
616 case BUILT_IN_DOCSTRINGS_FILE_OPTION: |
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
617 if (optarg) |
15480
c7d7d43f26bb
call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents:
15479
diff
changeset
|
618 Fbuilt_in_docstrings_file (octave_value (optarg)); |
15470
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
619 break; |
bf0857c789f4
initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
620 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
621 case DOC_CACHE_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
622 if (optarg) |
15480
c7d7d43f26bb
call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents:
15479
diff
changeset
|
623 Fdoc_cache_file (octave_value (optarg)); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
624 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
625 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
626 case EVAL_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
627 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
628 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
629 if (code_to_eval.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
630 code_to_eval = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
631 else |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
632 code_to_eval += std::string (" ") + optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
633 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
634 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
635 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
636 case EXEC_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
637 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
638 exec_path = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
639 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
640 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
641 case FORCE_GUI_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
642 force_gui_option = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
643 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
644 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
645 case IMAGE_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
646 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
647 image_path = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
648 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
649 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
650 case INFO_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
651 if (optarg) |
15480
c7d7d43f26bb
call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents:
15479
diff
changeset
|
652 Finfo_file (octave_value (optarg)); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
653 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
654 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
655 case INFO_PROG_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
656 if (optarg) |
15480
c7d7d43f26bb
call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents:
15479
diff
changeset
|
657 Finfo_program (octave_value (optarg)); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
658 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
659 |
16877
5482cd26311a
Rename enable_jit_compiler to jit_enable, enable_jit_debugging to debug_jit.
Rik <rik@octave.org>
parents:
16876
diff
changeset
|
660 case DEBUG_JIT_OPTION: |
5482cd26311a
Rename enable_jit_compiler to jit_enable, enable_jit_debugging to debug_jit.
Rik <rik@octave.org>
parents:
16876
diff
changeset
|
661 Fdebug_jit (octave_value (true)); |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
662 break; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
663 |
17792
26e9312e6928
Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
664 case JIT_COMPILER_OPTION: |
26e9312e6928
Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
665 Fjit_enable (octave_value (true)); |
26e9312e6928
Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
666 break; |
26e9312e6928
Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
667 |
21052
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
668 case JSON_SOCK_OPTION: |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
669 if (optarg) |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
670 json_sock_path = optarg; |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
671 break; |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
672 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
673 case LINE_EDITING_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
674 forced_line_editing = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
675 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
676 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
677 case NO_GUI_OPTION: |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
678 no_gui_option = true; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
679 break; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
680 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
681 case NO_INIT_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
682 read_init_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
683 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
684 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
685 case NO_INIT_PATH_OPTION: |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
686 set_initial_path = false; |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
687 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
688 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
689 case NO_LINE_EDITING_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
690 line_editing = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
691 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
692 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
693 case NO_SITE_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
694 read_site_files = 0; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
695 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
696 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
697 case PERSIST_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
698 persist = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
699 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
700 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
701 case TEXI_MACROS_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
702 if (optarg) |
15480
c7d7d43f26bb
call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents:
15479
diff
changeset
|
703 Ftexi_macros_file (octave_value (optarg)); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
704 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
705 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
706 case TRADITIONAL_OPTION: |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
707 traditional = true; |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
708 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
709 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
710 default: |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
711 // getopt_long should print a message about unrecognized options and |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
712 // return '?', which is handled above. If we end up here, it is |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
713 // because there was an option but we forgot to handle it. |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
714 // That should be fatal. |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
715 panic_impossible (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
716 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
717 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
718 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
719 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
720 // Check for various incompatible argument pairs |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
721 if (force_gui_option && no_gui_option) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
722 { |
20956
9db35d2042be
maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
723 warning ("only one of --force-gui and --no-gui may be used"); |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
724 |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
725 octave_print_terse_usage_and_exit (); |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
726 } |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
727 |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
728 bool script_file = (argc - optind) > 0; |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
729 if (! code_to_eval.empty () && script_file) |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
730 { |
20956
9db35d2042be
maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
731 warning ("--eval \"CODE\" and script file are mutually exclusive options"); |
17777
ae8905fbf1f8
move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents:
17755
diff
changeset
|
732 |
ae8905fbf1f8
move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents:
17755
diff
changeset
|
733 octave_print_terse_usage_and_exit (); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
734 } |
20486
779c1d85cf90
Initialize interpreter correctly with script and --traditional (bug #45921)
Mike Miller <mtmiller@octave.org>
parents:
19949
diff
changeset
|
735 an_octave_program = ((script_file || ! code_to_eval.empty ()) |
779c1d85cf90
Initialize interpreter correctly with script and --traditional (bug #45921)
Mike Miller <mtmiller@octave.org>
parents:
19949
diff
changeset
|
736 && ! persist && ! traditional); |
19849
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
737 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
738 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
739 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
740 // EMBEDDED is declared int instead of bool because this function is |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
741 // declared extern "C". |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
742 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
743 void |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
744 octave_initialize_interpreter (int argc, char **argv, int embedded) |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
745 { |
17811
ef4fc092c86b
set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents:
17792
diff
changeset
|
746 // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting |
ef4fc092c86b
set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents:
17792
diff
changeset
|
747 setlocale (LC_NUMERIC, "C"); |
17849
e432697a0621
octave.cc: Set LC_TIME to C locale so that dates always compute correctly.
Rik <rik@octave.org>
parents:
17828
diff
changeset
|
748 setlocale (LC_TIME, "C"); |
19949
e75a0fe1eee2
Set LC_NUMERIC and LC_TIME environment variables to 'C' (bug 44469).
Rik <rik@octave.org>
parents:
19856
diff
changeset
|
749 octave_env::putenv ("LC_NUMERIC", "C"); |
e75a0fe1eee2
Set LC_NUMERIC and LC_TIME environment variables to 'C' (bug 44469).
Rik <rik@octave.org>
parents:
19856
diff
changeset
|
750 octave_env::putenv ("LC_TIME", "C"); |
17811
ef4fc092c86b
set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents:
17792
diff
changeset
|
751 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
752 octave_embedded = embedded; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
753 |
3019 | 754 octave_env::set_program_name (argv[0]); |
755 | |
5780 | 756 octave_program_invocation_name = octave_env::get_program_invocation_name (); |
757 octave_program_name = octave_env::get_program_name (); | |
758 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
759 octave_thread::init (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
760 |
16540
63b144e6a3d0
partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents:
16528
diff
changeset
|
761 set_default_prompts (); |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
762 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
763 // Initialize default warning state before --traditional option |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
764 // that may reset them. |
18124
60dee9205bb5
set default warning state before modifying for --traditional option
John W. Eaton <jwe@octave.org>
parents:
17849
diff
changeset
|
765 |
60dee9205bb5
set default warning state before modifying for --traditional option
John W. Eaton <jwe@octave.org>
parents:
17849
diff
changeset
|
766 initialize_default_warning_state (); |
60dee9205bb5
set default warning state before modifying for --traditional option
John W. Eaton <jwe@octave.org>
parents:
17849
diff
changeset
|
767 |
16528
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
768 if (traditional) |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
769 maximum_braindamage (); |
9bc1f8278966
allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents:
16485
diff
changeset
|
770 |
5844 | 771 init_signals (); |
772 | |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
773 octave_ieee_init (); |
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
774 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
775 // The idea here is to force xerbla to be referenced so that we will link to |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
776 // our own version instead of the one provided by the BLAS library. But |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
777 // octave_NaN should never be -1, so we should never actually call xerbla. |
4159 | 778 |
779 if (octave_NaN == -1) | |
11157
c75130f19440
octave.cc: fix call to xerbla
John W. Eaton <jwe@octave.org>
parents:
11140
diff
changeset
|
780 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6)); |
4159 | 781 |
721 | 782 initialize_error_handlers (); |
223 | 783 |
4368 | 784 if (! embedded) |
785 install_signal_handlers (); | |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
786 else |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
787 quit_allowed = false; |
2205 | 788 |
789 initialize_file_io (); | |
790 | |
2375 | 791 install_types (); |
792 | |
793 install_ops (); | |
2205 | 794 |
795 install_builtins (); | |
796 | |
15843
622f3f794162
Re-instate classdef bootstrapping.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15838
diff
changeset
|
797 install_classdef (); |
622f3f794162
Re-instate classdef bootstrapping.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15838
diff
changeset
|
798 |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
799 for (std::list<std::string>::const_iterator it = command_line_path.begin (); |
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
800 it != command_line_path.end (); it++) |
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
801 load_path::set_command_line_path (*it); |
777 | 802 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
803 if (! exec_path.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
804 set_exec_path (exec_path); |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
805 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
806 if (! image_path.empty ()) |
15327 | 807 set_image_path (image_path); |
777 | 808 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
809 if (no_window_system) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
810 display_info::no_window_system (); |
1410 | 811 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
812 // Is input coming from a terminal? If so, we are probably interactive. |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
813 |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9753
diff
changeset
|
814 // If stdin is not a tty, then we are reading commands from a pipe or |
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9753
diff
changeset
|
815 // a redirected file. |
16208
ed91ab4d4515
eliminate stdin_is_tty global variable
John W. Eaton <jwe@octave.org>
parents:
16203
diff
changeset
|
816 bool stdin_is_tty = gnulib::isatty (fileno (stdin)); |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9753
diff
changeset
|
817 |
19849
f81a1da191e4
Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents:
19848
diff
changeset
|
818 interactive = (! embedded && ! an_octave_program && stdin_is_tty |
14160 | 819 && gnulib::isatty (fileno (stdout))); |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
820 |
19848
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
821 // Check if the user forced an interactive session. If he |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
822 // unnecessarily did so, reset forced_interactive to false. |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
823 if (forced_interactive) |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
824 { |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
825 if (interactive) |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
826 forced_interactive = false; |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
827 else |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
828 interactive = true; |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
829 } |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
830 |
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
831 if ((! interactive || forced_interactive) && ! forced_line_editing) |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
832 line_editing = false; |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
833 |
19601
f3ac54ac2c6a
also skip startup message if session is not interactive
John W. Eaton <jwe@octave.org>
parents:
19599
diff
changeset
|
834 // Also skip start-up message unless session is interactive. |
19848
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
835 if (! interactive) |
19601
f3ac54ac2c6a
also skip startup message if session is not interactive
John W. Eaton <jwe@octave.org>
parents:
19599
diff
changeset
|
836 inhibit_startup_message = true; |
f3ac54ac2c6a
also skip startup message if session is not interactive
John W. Eaton <jwe@octave.org>
parents:
19599
diff
changeset
|
837 |
9321
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
838 // Force default line editor if we don't want readline editing. |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
839 if (! line_editing) |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
840 command_editor::force_default_editor (); |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
841 |
1358 | 842 // These can come after command line args since none of them set any |
843 // defaults that might be changed by command line options. | |
581 | 844 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
845 if (line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
846 initialize_command_input (); |
315 | 847 |
4217 | 848 octave_interpreter_ready = true; |
849 | |
5654 | 850 initialize_version_info (); |
851 | |
21052
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
852 if (!json_sock_path.empty ()) { |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
853 _json_main = new json_main(json_sock_path); |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
854 _json_main->run_loop_on_new_thread(); |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
855 } |
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
856 |
8099
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
857 // Make all command-line arguments available to startup files, |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
858 // including PKG_ADD files. |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
859 |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
860 intern_argv (argc, argv); |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
861 |
6365 | 862 load_path::initialize (set_initial_path); |
4217 | 863 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
864 initialize_history (read_history_file); |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
865 } |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
866 |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
867 int |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
868 octave_execute_interpreter (void) |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
869 { |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
870 if (! inhibit_startup_message) |
17510
7542f4496974
eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents:
16877
diff
changeset
|
871 std::cout << octave_startup_message () << "\n" << std::endl; |
1651 | 872 |
17755
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
873 octave_prepare_hdf5 (); |
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
874 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
875 execute_startup_files (); |
1 | 876 |
578 | 877 if (! inhibit_startup_message && reading_startup_message_printed) |
3538 | 878 std::cout << std::endl; |
578 | 879 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
880 // Execute any code specified with --eval 'CODE' |
5189 | 881 if (! code_to_eval.empty ()) |
149 | 882 { |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
883 int parse_status = 0; |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
884 |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
885 try |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
886 { |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
887 parse_status = execute_eval_option_code (code_to_eval); |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
888 } |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
889 catch (const octave_execution_exception&) |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
890 { |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
891 recover_from_exception (); |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
892 |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
893 parse_status = 1; |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
894 } |
5189 | 895 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
896 if (! persist) |
16753
f8f35ddc49a2
exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents:
16540
diff
changeset
|
897 { |
f8f35ddc49a2
exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents:
16540
diff
changeset
|
898 quitting_gracefully = true; |
f8f35ddc49a2
exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents:
16540
diff
changeset
|
899 |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
900 clean_up_and_exit (parse_status); |
16753
f8f35ddc49a2
exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents:
16540
diff
changeset
|
901 } |
1 | 902 } |
903 | |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
904 // If there is an extra argument, see if it names a file to read. |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
905 // Additional arguments are taken as command line options for the script. |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
906 |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
907 int last_arg_idx = optind; |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
908 int remaining_args = octave_cmdline_argc - last_arg_idx; |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
909 |
5189 | 910 if (remaining_args > 0) |
911 { | |
912 // If we are running an executable script (#! /bin/octave) then | |
913 // we should only see the args passed to the script. | |
914 | |
20746
ee2743bd07a8
eliminate various compiler warnings
John W. Eaton <jwe@octave.org>
parents:
20742
diff
changeset
|
915 exit_status = 0; |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
916 |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
917 try |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
918 { |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
919 intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx); |
5189 | 920 |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
921 execute_command_line_file (octave_cmdline_argv[last_arg_idx]); |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
922 } |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
923 catch (const octave_execution_exception&) |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
924 { |
20755
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
925 recover_from_exception (); |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20746
diff
changeset
|
926 |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
927 exit_status = 1; |
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
928 } |
5189 | 929 |
930 if (! persist) | |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
931 { |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
932 quitting_gracefully = true; |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
933 |
20742
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20534
diff
changeset
|
934 clean_up_and_exit (exit_status); |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
935 } |
5189 | 936 } |
937 | |
938 // Avoid counting commands executed from startup files. | |
939 | |
940 command_editor::reset_current_command_number (1); | |
941 | |
942 // Now argv should have the full set of args. | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
943 intern_argv (octave_cmdline_argc, octave_cmdline_argv); |
5189 | 944 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
945 // Force input to be echoed if not really interactive, |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
946 // but the user has forced interactive behavior. |
1 | 947 |
19848
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19696
diff
changeset
|
948 if (forced_interactive) |
287 | 949 { |
2926 | 950 command_editor::blink_matching_paren (false); |
1588 | 951 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
952 // FIXME: is this the right thing to do? |
15477
8b5fc510c6d6
don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents:
15476
diff
changeset
|
953 Fecho_executing_commands (octave_value (ECHO_CMD_LINE)); |
287 | 954 } |
1 | 955 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
956 if (octave_embedded) |
5502 | 957 { |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
958 // FIXME: Do we need to do any cleanup here before returning? |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
959 // If we don't, what will happen to Octave functions that have been |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
960 // registered to execute with atexit, for example? |
5502 | 961 |
962 return 1; | |
963 } | |
4368 | 964 |
5189 | 965 int retval = main_loop (); |
1 | 966 |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
967 quitting_gracefully = true; |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
968 |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
969 clean_up_and_exit (retval, true); |
4247 | 970 |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
971 return retval; |
1 | 972 } |
973 | |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
974 static bool |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
975 check_starting_gui (void) |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
976 { |
17828
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
977 if (no_window_system) |
15160
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
978 return false; |
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
979 |
17828
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
980 std::string err_msg; |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
981 if (! display_info::display_available (err_msg)) |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
982 { |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
983 if (! (inhibit_startup_message || err_msg.empty ())) |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
984 warning (err_msg.c_str ()); |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
985 |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
986 return false; |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
987 } |
6b787e274eb1
make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents:
17811
diff
changeset
|
988 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
989 if (force_gui_option) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
990 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
991 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
992 if (no_gui_option) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
993 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
994 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
995 if (persist) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
996 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
997 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
998 // If stdin is not a tty, then assume we are reading commands from a pipe or |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
999 // a redirected file and the GUI should not start. If this is not the case |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1000 // (for example, starting from a desktop "launcher" with no terminal) and you |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1001 // want to start the GUI, you may use the --force-gui option to start the GUI. |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1002 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1003 if (! gnulib::isatty (fileno (stdin))) |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1004 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1005 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1006 // If we have code to eval or execute from a file, and we are going to exit |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1007 // immediately after executing it, don't start the gui. |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1008 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1009 int last_arg_idx = optind; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1010 int remaining_args = octave_cmdline_argc - last_arg_idx; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1011 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1012 if (! code_to_eval.empty () || remaining_args > 0) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1013 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1014 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1015 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1016 } |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1017 |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1018 // Return int instead of bool because this function is declared extern "C". |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1019 |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1020 int |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1021 octave_starting_gui (void) |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1022 { |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1023 start_gui = check_starting_gui (); |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1024 return start_gui; |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1025 } |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1026 |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1027 DEFUN (isguirunning, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1028 "-*- texinfo -*-\n\ |
20852
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20848
diff
changeset
|
1029 @deftypefn {} {} isguirunning ()\n\ |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1030 Return true if Octave is running in GUI mode and false otherwise.\n\ |
19856
bf511802add7
doc: Add have_window_system() to documentation.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1031 @seealso{have_window_system}\n\ |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1032 @end deftypefn") |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1033 { |
20848
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
1034 if (args.length () != 0) |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1035 print_usage (); |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1036 |
21052
b702efa70fb5
Adding --json-sock option; publishes octave_link events to a UNIX socket.
Shane F. Carr <shane.carr@wustl.edu>
parents:
21039
diff
changeset
|
1037 return ovl (octave_link::enabled()); |
15702
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1038 } |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1039 |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1040 /* |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1041 %!assert (islogical (isguirunning ())) |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1042 %!error isguirunning (1) |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1043 */ |
534b6f7108b7
Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents:
15490
diff
changeset
|
1044 |
5780 | 1045 DEFUN (argv, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1046 "-*- texinfo -*-\n\ |
20852
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20848
diff
changeset
|
1047 @deftypefn {} {} argv ()\n\ |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1048 Return the command line arguments passed to Octave.\n\ |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1049 \n\ |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1050 For example, if you invoked Octave using the command\n\ |
5780 | 1051 \n\ |
1052 @example\n\ | |
1053 octave --no-line-editing --silent\n\ | |
1054 @end example\n\ | |
1055 \n\ | |
1056 @noindent\n\ | |
1057 @code{argv} would return a cell array of strings with the elements\n\ | |
10840 | 1058 @option{--no-line-editing} and @option{--silent}.\n\ |
5780 | 1059 \n\ |
19524
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1060 If you write an executable Octave script, @code{argv} will return the list\n\ |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1061 of arguments passed to the script. @xref{Executable Octave Programs}, for\n\ |
18377fc879d0
Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents:
19393
diff
changeset
|
1062 an example of how to create an executable Octave script.\n\ |
5780 | 1063 @end deftypefn") |
1064 { | |
20848
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
1065 if (args.length () != 0) |
5823 | 1066 print_usage (); |
5780 | 1067 |
20938
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
1068 return ovl (Cell (octave_argv)); |
5780 | 1069 } |
1070 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1071 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1072 %!assert (iscellstr (argv ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1073 %!error argv (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1074 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1075 |
5780 | 1076 DEFUN (program_invocation_name, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1077 "-*- texinfo -*-\n\ |
20852
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20848
diff
changeset
|
1078 @deftypefn {} {} program_invocation_name ()\n\ |
5780 | 1079 Return the name that was typed at the shell prompt to run Octave.\n\ |
1080 \n\ | |
1081 If executing a script from the command line (e.g., @code{octave foo.m})\n\ | |
1082 or using an executable Octave script, the program name is set to the\n\ | |
1083 name of the script. @xref{Executable Octave Programs}, for an example of\n\ | |
1084 how to create an executable Octave script.\n\ | |
1085 @seealso{program_name}\n\ | |
1086 @end deftypefn") | |
1087 { | |
20848
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
1088 if (args.length () != 0) |
5823 | 1089 print_usage (); |
5780 | 1090 |
20938
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
1091 return ovl (octave_program_invocation_name); |
5780 | 1092 } |
1093 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1094 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1095 %!assert (ischar (program_invocation_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1096 %!error program_invocation_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1097 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1098 |
5780 | 1099 DEFUN (program_name, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
1100 "-*- texinfo -*-\n\ |
20852
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20848
diff
changeset
|
1101 @deftypefn {} {} program_name ()\n\ |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8273
diff
changeset
|
1102 Return the last component of the value returned by\n\ |
5780 | 1103 @code{program_invocation_name}.\n\ |
1104 @seealso{program_invocation_name}\n\ | |
1105 @end deftypefn") | |
1106 { | |
20848
994c0859ab8b
maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents:
20755
diff
changeset
|
1107 if (args.length () != 0) |
5823 | 1108 print_usage (); |
5780 | 1109 |
20938
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
1110 return ovl (octave_program_name); |
5780 | 1111 } |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1112 |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1113 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1114 %!assert (ischar (program_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1115 %!error program_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1116 */ |