Mercurial > hg > octave-nkf
annotate libinterp/octave.cc @ 15467:049e8bbff782
maint: periodic merge of stable to default
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Oct 2012 18:30:44 -0400 |
parents | src/octave.cc@d174210ce1ec src/octave.cc@5930d41cade1 |
children | bf0857c789f4 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14074
diff
changeset
|
3 Copyright (C) 1993-2012 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> |
30 #include <cstdlib> | |
31 #include <cstring> | |
32 #include <ctime> | |
33 | |
3503 | 34 #include <iostream> |
1355 | 35 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
36 #include <getopt.h> |
12335
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
37 #include <sys/types.h> |
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
38 #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
|
39 |
2926 | 40 #include "cmd-edit.h" |
3690 | 41 #include "f77-fcn.h" |
4097 | 42 #include "file-ops.h" |
2926 | 43 #include "file-stat.h" |
240 | 44 #include "lo-error.h" |
2926 | 45 #include "oct-env.h" |
3019 | 46 #include "pathsearch.h" |
1907 | 47 #include "str-vec.h" |
223 | 48 |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
49 #include "defaults.h" |
3933 | 50 #include "Cell.h" |
1355 | 51 #include "defun.h" |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
52 #include "display.h" |
1355 | 53 #include "error.h" |
54 #include "file-io.h" | |
1 | 55 #include "input.h" |
56 #include "lex.h" | |
5832 | 57 #include "load-path.h" |
4113 | 58 #include "octave.h" |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
59 #include "oct-conf.h" |
1742 | 60 #include "oct-hist.h" |
5654 | 61 #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
|
62 #include "oct-mutex.h" |
3195 | 63 #include "oct-obj.h" |
2375 | 64 #include "ops.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
|
65 #include "ov.h" |
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
|
66 #include "ov-range.h" |
1670 | 67 #include "toplev.h" |
1 | 68 #include "parse.h" |
562 | 69 #include "procstream.h" |
1355 | 70 #include "sighandlers.h" |
71 #include "sysdep.h" | |
1 | 72 #include "unwind-prot.h" |
1355 | 73 #include "utils.h" |
74 #include "variables.h" | |
2492 | 75 #include <version.h> |
1 | 76 |
4159 | 77 // Kluge. |
5990 | 78 extern "C" F77_RET_T |
11518 | 79 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL, |
80 const octave_idx_type& | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
81 F77_CHAR_ARG_LEN_DECL); |
4159 | 82 |
2910 | 83 extern void install_builtins (void); |
84 | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
85 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
|
86 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
|
87 int octave_embedded; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
88 |
1907 | 89 // The command-line options. |
90 static string_vector octave_argv; | |
1 | 91 |
5780 | 92 // The name used to invoke Octave. |
93 static std::string | |
94 octave_program_invocation_name; | |
95 | |
96 // The last component of octave_program_invocation_name. | |
97 static std::string octave_program_name; | |
98 | |
2239 | 99 // TRUE means we read ~/.octaverc and ./.octaverc. |
100 // (--norc; --no-init-file; -f) | |
101 static bool read_init_files = true; | |
102 | |
103 // TRUE means we read the site-wide octaverc files. | |
104 // (--norc; --no-site-file; -f) | |
2240 | 105 static bool read_site_files = true; |
1 | 106 |
6365 | 107 // 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
|
108 // (--no-init-path) |
6365 | 109 static bool set_initial_path = true; |
110 | |
3019 | 111 // TRUE means we don't print the usual startup message. |
616 | 112 // (--quiet; --silent; -q) |
2239 | 113 static bool inhibit_startup_message = false; |
1 | 114 |
3019 | 115 // TRUE means we turn on compatibility options. |
1410 | 116 // (--traditional) |
2239 | 117 static bool traditional = false; |
1410 | 118 |
3019 | 119 // If TRUE, print verbose info in some cases. |
1825 | 120 // (--verbose; -V) |
2239 | 121 static bool verbose_flag = false; |
1825 | 122 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
123 // If TRUE, force the GUI to start. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
124 // (--force-gui) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
125 static bool force_gui_option = false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
126 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
127 // If TRUE don't start the GUI. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
128 // (--no-gui) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
129 static bool no_gui_option = false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
130 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
131 // If TRUE, disable the JIT compiler. |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
132 // (--no-jit-compiler) |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
133 static bool no_jit_compiler_option = false; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
134 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
135 // If TRUE, enable JIT compiler debugging/tracing. |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
136 // (--jit-debug) |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
137 static bool jit_debug_option = false; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
138 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
139 // If TRUE, force readline command line editing. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
140 // (--line-editing) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
141 static bool forced_line_editing = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
142 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
143 // 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
|
144 // (--no-history; -H) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
145 static bool read_history_file = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
146 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
147 // 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
|
148 // (--path; -p) |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
149 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
|
150 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
151 // Flags used to determine what commands should be echoed when they are |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
152 // parsed and executed. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
153 // (--echo-commands; -x) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
154 static int echo_executing_commands = 0; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
155 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
156 // The file used for the doc string cache. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
157 // (--doc-cache-file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
158 static std::string doc_cache_file; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
159 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
160 // 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
|
161 // (--exec-path) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
162 static std::string exec_path; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
163 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
164 // 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
|
165 // (--image-path) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
166 static std::string image_path; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
167 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
168 // The value for "info_file" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
169 // (--info-file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
170 static std::string info_file; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
171 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
172 // The value for "info_program" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
173 // (--info-program) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
174 static std::string info_program; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
175 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
176 // If TRUE, ignore the window system even if it is available. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
177 // (--no-window-system) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
178 static bool no_window_system = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
179 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
180 // The value for "texi_macros_file" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
181 // (--texi-macros-file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
182 static std::string texi_macros_file; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
183 |
1 | 184 // Usage message |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
185 static const char *usage_string = |
11140 | 186 "octave [-HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
187 [--exec-path path] [--force-gui] [--help] [--image-path path]\n\ |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
188 [--info-file file] [--info-program prog] [--interactive]\n\ |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
189 [--jit-debug] [--line-editing] [--no-gui] [--no-history]\n\ |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
190 [--no-init-file] [--no-init-path] [--no-jit-compiler]\n\ |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
191 [--no-line-editing] [--no-site-file] [--no-window-system]\n\ |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
192 [-p path] [--path path] [--silent] [--traditional]\n\ |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
193 [--verbose] [--version] [file]"; |
1 | 194 |
1358 | 195 // This is here so that it's more likely that the usage message and |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14160
diff
changeset
|
196 // the real set of options will agree. Note: the '+' must come first |
1410 | 197 // to prevent getopt from permuting arguments! |
11140 | 198 static const char *short_opts = "+HVdfhip:qvx"; |
139 | 199 |
5189 | 200 // The code to evaluate at startup (--eval CODE) |
201 static std::string code_to_eval; | |
202 | |
203 // If TRUE, don't exit after evaluating code given by --eval option. | |
204 static bool persist = false; | |
4356 | 205 |
1103 | 206 // Long options. See the comments in getopt.h for the meanings of the |
207 // fields in this structure. | |
8861 | 208 #define DOC_CACHE_FILE_OPTION 1 |
209 #define EVAL_OPTION 2 | |
210 #define EXEC_PATH_OPTION 3 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
211 #define FORCE_GUI_OPTION 4 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
212 #define IMAGE_PATH_OPTION 5 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
213 #define INFO_FILE_OPTION 6 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
214 #define INFO_PROG_OPTION 7 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
215 #define JIT_DEBUG_OPTION 8 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
216 #define LINE_EDITING_OPTION 9 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
217 #define NO_GUI_OPTION 10 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
218 #define NO_INIT_FILE_OPTION 11 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
219 #define NO_INIT_PATH_OPTION 12 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
220 #define NO_JIT_COMPILER_OPTION 13 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
221 #define NO_LINE_EDITING_OPTION 14 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
222 #define NO_SITE_FILE_OPTION 15 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
223 #define NO_WINDOW_SYSTEM_OPTION 16 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
224 #define PERSIST_OPTION 17 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
225 #define TEXI_MACROS_FILE_OPTION 18 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
226 #define TRADITIONAL_OPTION 19 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
227 struct option long_opts[] = |
139 | 228 { |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
229 { "braindead", no_argument, 0, TRADITIONAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
230 { "debug", no_argument, 0, 'd' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
231 { "doc-cache-file", required_argument, 0, DOC_CACHE_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
232 { "echo-commands", no_argument, 0, 'x' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
233 { "eval", required_argument, 0, EVAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
234 { "exec-path", required_argument, 0, EXEC_PATH_OPTION }, |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
235 { "force-gui", no_argument, 0, FORCE_GUI_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
236 { "help", no_argument, 0, 'h' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
237 { "image-path", required_argument, 0, IMAGE_PATH_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
238 { "info-file", required_argument, 0, INFO_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
239 { "info-program", required_argument, 0, INFO_PROG_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
240 { "interactive", no_argument, 0, 'i' }, |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
241 { "jit-debug", no_argument, 0, JIT_DEBUG_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
242 { "line-editing", no_argument, 0, LINE_EDITING_OPTION }, |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
243 { "no-gui", no_argument, 0, NO_GUI_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
244 { "no-history", no_argument, 0, 'H' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
245 { "no-init-file", no_argument, 0, NO_INIT_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
246 { "no-init-path", no_argument, 0, NO_INIT_PATH_OPTION }, |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
247 { "no-jit", no_argument, 0, NO_JIT_COMPILER_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
248 { "no-line-editing", no_argument, 0, NO_LINE_EDITING_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
249 { "no-site-file", no_argument, 0, NO_SITE_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
250 { "no-window-system", no_argument, 0, NO_WINDOW_SYSTEM_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
251 { "norc", no_argument, 0, 'f' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
252 { "path", required_argument, 0, 'p' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
253 { "persist", no_argument, 0, PERSIST_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
254 { "quiet", no_argument, 0, 'q' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
255 { "silent", no_argument, 0, 'q' }, |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14564
diff
changeset
|
256 { "texi-macros-file", required_argument, 0, TEXI_MACROS_FILE_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
257 { "traditional", no_argument, 0, TRADITIONAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
258 { "verbose", no_argument, 0, 'V' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
259 { "version", no_argument, 0, 'v' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
260 { 0, 0, 0, 0 } |
139 | 261 }; |
1 | 262 |
1355 | 263 // Store the command-line options for later use. |
264 | |
265 static void | |
266 intern_argv (int argc, char **argv) | |
267 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
268 assert (symbol_table::at_top_level ()); |
4892 | 269 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
270 symbol_table::varref (".nargin.") = argc - 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
271 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
272 symbol_table::mark_hidden (".nargin."); |
3195 | 273 |
10485
b4e14e628fc9
Truncate argv() for scripts used without command line parameters. Bug #29423
Judd Storrs <jstorrs@gmail.com>
parents:
10370
diff
changeset
|
274 if (argc > 0) |
1355 | 275 { |
7336 | 276 octave_argv.resize (argc - 1); |
3933 | 277 |
2495 | 278 // Skip program name in argv. |
3933 | 279 int i = argc; |
280 while (--i > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
281 octave_argv[i-1] = *(argv+i); |
1355 | 282 } |
283 } | |
284 | |
1792 | 285 static void |
286 initialize_pathsearch (void) | |
287 { | |
288 // This may seem odd, but doing it this way means that we don't have | |
289 // to modify the kpathsea library... | |
290 | |
3523 | 291 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141 | 292 |
293 // For backward compatibility. | |
1792 | 294 |
2926 | 295 if (odb.empty ()) |
3141 | 296 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792 | 297 |
3141 | 298 if (odb.empty ()) |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
299 odb = Vdata_dir + file_ops::dir_sep_str () + "octave:" |
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
300 + Vlibexec_dir + file_ops::dir_sep_str () + "octave"; |
1792 | 301 } |
302 | |
5654 | 303 DEFUN (__version_info__, args, , |
304 "-*- texinfo -*-\n\ | |
6678 | 305 @deftypefn {Built-in Function} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\ |
6945 | 306 Undocumented internal function.\n\ |
5654 | 307 @end deftypefn") |
308 { | |
309 octave_value retval; | |
310 | |
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
|
311 static octave_map vinfo; |
5654 | 312 |
313 int nargin = args.length (); | |
314 | |
5658 | 315 if (nargin == 4) |
5654 | 316 { |
6639 | 317 if (vinfo.nfields () == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
318 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
319 vinfo.assign ("Name", args (0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
320 vinfo.assign ("Version", args (1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
321 vinfo.assign ("Release", args (2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
322 vinfo.assign ("Date", args (3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
323 } |
5781 | 324 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
325 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
326 octave_idx_type n = vinfo.numel () + 1; |
5654 | 327 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
328 vinfo.resize (dim_vector (n, 1)); |
5781 | 329 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
330 octave_value idx (n); |
5781 | 331 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
332 vinfo.assign (idx, "Name", Cell (octave_value (args (0)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
333 vinfo.assign (idx, "Version", Cell (octave_value (args (1)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
334 vinfo.assign (idx, "Release", Cell (octave_value (args (2)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
335 vinfo.assign (idx, "Date", Cell (octave_value (args (3)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
336 } |
5654 | 337 } |
338 else if (nargin == 0) | |
339 retval = vinfo; | |
340 else | |
5823 | 341 print_usage (); |
5654 | 342 |
343 return retval; | |
344 } | |
345 | |
346 static void | |
347 initialize_version_info (void) | |
348 { | |
349 octave_value_list args; | |
350 | |
5658 | 351 args(3) = OCTAVE_RELEASE_DATE; |
352 args(2) = OCTAVE_RELEASE; | |
5654 | 353 args(1) = OCTAVE_VERSION; |
354 args(0) = "GNU Octave"; | |
355 | |
356 F__version_info__ (args, 0); | |
357 } | |
358 | |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
359 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
360 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
|
361 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
362 std::cerr << "error: " << msg << "\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
363 << "error: execution of " << file << " failed\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
364 << "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
|
365 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
366 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
367 |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
368 // Execute commands from a file and catch potential exceptions in a |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
369 // consistent way. This function should be called anywhere we might |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
370 // parse and execute commands from a file before before we have entered |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
371 // the main loop in toplev.cc. |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
372 |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
373 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
374 safe_source_file (const std::string& file_name, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
375 const std::string& context = std::string (), |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
376 bool verbose = false, bool require_file = true, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
377 const std::string& warn_for = std::string ()) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
378 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
379 try |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
380 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
381 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
|
382 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
383 catch (octave_interrupt_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
384 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
385 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
386 octave_stdout << "\n"; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
387 if (quitting_gracefully) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
388 clean_up_and_exit (exit_status); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
389 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
390 catch (octave_execution_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
391 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
392 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
393 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
|
394 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
395 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
396 |
581 | 397 // Initialize by reading startup files. |
398 | |
1 | 399 static void |
400 execute_startup_files (void) | |
401 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
402 unwind_protect frame; |
315 | 403 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
404 frame.protect_var (input_from_startup_file); |
1651 | 405 |
3019 | 406 input_from_startup_file = true; |
315 | 407 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
408 std::string context; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
409 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
410 bool verbose = (verbose_flag && ! inhibit_startup_message); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
411 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
412 bool require_file = false; |
578 | 413 |
2239 | 414 if (read_site_files) |
1 | 415 { |
2239 | 416 // Execute commands from the site-wide configuration file. |
417 // First from the file $(prefix)/lib/octave/site/m/octaverc | |
418 // (if it exists), then from the file | |
3597 | 419 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755 | 420 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
421 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
|
422 require_file); |
1755 | 423 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
424 safe_source_file (Vsite_defaults_file, context, verbose, require_file); |
1 | 425 } |
426 | |
2239 | 427 if (read_init_files) |
428 { | |
2512 | 429 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
430 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc | |
431 // is assumed. | |
2239 | 432 |
4804 | 433 bool home_rc_already_executed = false; |
2512 | 434 |
3523 | 435 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512 | 436 |
2926 | 437 if (initfile.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
438 initfile = ".octaverc"; |
2512 | 439 |
3523 | 440 std::string home_dir = octave_env::get_home_directory (); |
2926 | 441 |
4804 | 442 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
443 | |
444 std::string local_rc; | |
2239 | 445 |
5781 | 446 if (! home_rc.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
447 { |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
448 safe_source_file (home_rc, context, verbose, require_file); |
2239 | 449 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
450 // Names alone are not enough. |
2239 | 451 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
452 file_stat fs_home_rc (home_rc); |
2239 | 453 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
454 if (fs_home_rc) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
455 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
456 // 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
|
457 // because doing that may change the working directory. |
4804 | 458 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
459 local_rc = octave_env::make_absolute (initfile); |
4804 | 460 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
461 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
|
462 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
463 } |
2239 | 464 |
465 if (! home_rc_already_executed) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
466 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
467 if (local_rc.empty ()) |
10250 | 468 local_rc = octave_env::make_absolute (initfile); |
4804 | 469 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
470 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
|
471 } |
2239 | 472 } |
1 | 473 } |
474 | |
5189 | 475 static int |
476 execute_eval_option_code (const std::string& code) | |
477 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
478 unwind_protect frame; |
5189 | 479 |
7202 | 480 octave_save_signal_mask (); |
481 | |
482 can_interrupt = true; | |
483 | |
484 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
485 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
486 octave_bad_alloc_hook = 0; |
7202 | 487 |
488 octave_catch_interrupts (); | |
489 | |
490 octave_initialized = true; | |
491 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
492 frame.protect_var (interactive); |
5189 | 493 |
494 interactive = false; | |
495 | |
496 int parse_status = 0; | |
497 | |
6487 | 498 try |
499 { | |
500 eval_string (code, false, parse_status, 0); | |
501 } | |
7202 | 502 catch (octave_interrupt_exception) |
503 { | |
504 recover_from_exception (); | |
505 octave_stdout << "\n"; | |
9383 | 506 if (quitting_gracefully) |
507 clean_up_and_exit (exit_status); | |
7202 | 508 } |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
509 catch (octave_execution_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
510 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
511 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
512 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
|
513 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
514 } |
5189 | 515 |
516 return parse_status; | |
517 } | |
518 | |
519 static void | |
520 execute_command_line_file (const std::string& fname) | |
521 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
522 unwind_protect frame; |
5189 | 523 |
7202 | 524 octave_save_signal_mask (); |
525 | |
526 can_interrupt = true; | |
527 | |
528 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
529 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
530 octave_bad_alloc_hook = 0; |
7202 | 531 |
532 octave_catch_interrupts (); | |
533 | |
534 octave_initialized = true; | |
535 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
536 frame.protect_var (interactive); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
537 frame.protect_var (reading_script_file); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
538 frame.protect_var (input_from_command_line_file); |
5189 | 539 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
540 frame.protect_var (curr_fcn_file_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
541 frame.protect_var (curr_fcn_file_full_name); |
5189 | 542 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
543 frame.protect_var (octave_program_invocation_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
544 frame.protect_var (octave_program_name); |
5189 | 545 |
546 interactive = false; | |
547 reading_script_file = true; | |
548 input_from_command_line_file = true; | |
549 | |
550 curr_fcn_file_name = fname; | |
551 curr_fcn_file_full_name = curr_fcn_file_name; | |
552 | |
5780 | 553 octave_program_invocation_name = curr_fcn_file_name; |
5189 | 554 |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
555 size_t pos = curr_fcn_file_name.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
|
556 |
8021 | 557 std::string tmp = (pos != std::string::npos) |
5189 | 558 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
559 | |
5780 | 560 octave_program_name = tmp; |
5189 | 561 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
562 std::string context; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
563 bool verbose = false; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
564 bool require_file = true; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
565 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
566 safe_source_file (fname, context, verbose, require_file, "octave"); |
5189 | 567 } |
568 | |
581 | 569 // Usage message with extra help. |
570 | |
1 | 571 static void |
572 verbose_usage (void) | |
573 { | |
3922 | 574 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613 | 575 \n\ |
10731
f5dbac015606
Add [FILE] to octave usage string (bug #30258).
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
576 Usage: octave [options] [FILE]\n\ |
1613 | 577 \n\ |
578 Options:\n\ | |
1119 | 579 \n\ |
3180 | 580 --debug, -d Enter parser debugging mode.\n\ |
8923
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
581 --doc-cache-file FILE Use doc cache file FILE.\n\ |
3180 | 582 --echo-commands, -x Echo commands as they are executed.\n\ |
5191 | 583 --eval CODE Evaluate CODE. Exit when done unless --persist.\n\ |
1613 | 584 --exec-path PATH Set path for executing subprograms.\n\ |
15223
6ec6ddebb1a6
include --force-gui and --no-gui options in --help output
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
585 --force-gui Force graphical user interface to start.\n\ |
11140 | 586 --help, -h, Print short help message and exit.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
587 --image-path PATH Add PATH to head of image search path.\n\ |
1613 | 588 --info-file FILE Use top-level info file FILE.\n\ |
589 --info-program PROGRAM Use PROGRAM for reading info files.\n\ | |
3180 | 590 --interactive, -i Force interactive behavior.\n\ |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
591 --jit-debug Enable JIT compiler debugging/tracing.\n\ |
6938 | 592 --line-editing Force readline use for command-line editing.\n\ |
15223
6ec6ddebb1a6
include --force-gui and --no-gui options in --help output
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
593 --no-gui Disable the graphical user interface.\n\ |
3180 | 594 --no-history, -H Don't save commands to the history list\n\ |
2470 | 595 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
596 --no-init-path Don't initialize function search path.\n\ |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
597 --no-jit-compiler Disable the JIT compiler.\n\ |
2212 | 598 --no-line-editing Don't use readline for command-line editing.\n\ |
2470 | 599 --no-site-file Don't read the site-wide octaverc file.\n\ |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
600 --no-window-system Disable window system, including graphics.\n\ |
3238 | 601 --norc, -f Don't read any initialization files.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
602 --path PATH, -p PATH Add PATH to head of function search path.\n\ |
5189 | 603 --persist Go interactive after --eval or reading from FILE.\n\ |
3180 | 604 --silent, -q Don't print message at startup.\n\ |
14619
be12c85c6ce7
Print useful help message for texi_macros_file on command line.
Rik <octave@nomad.inbox5.com>
parents:
14614
diff
changeset
|
605 --texi-macros-file FILE Use Texinfo macros in FILE for makeinfo command.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
606 --traditional Set variables for closer MATLAB compatibility.\n\ |
3180 | 607 --verbose, -V Enable verbose output in some cases.\n\ |
608 --version, -v Print version number and exit.\n\ | |
1119 | 609 \n\ |
5190 | 610 FILE Execute commands from FILE. Exit when done\n\ |
5191 | 611 unless --persist is also specified.\n\ |
4829 | 612 \n" |
613 OCTAVE_WWW_STATEMENT "\n\ | |
4356 | 614 \n" |
615 OCTAVE_CONTRIB_STATEMENT "\n\ | |
616 \n" | |
617 OCTAVE_BUGS_STATEMENT "\n"; | |
285 | 618 |
613 | 619 exit (0); |
1 | 620 } |
621 | |
581 | 622 // Terse usage messsage. |
623 | |
1 | 624 static void |
625 usage (void) | |
626 { | |
11140 | 627 std::cerr << "\nusage: " << usage_string << "\n\n"; |
1 | 628 exit (1); |
629 } | |
630 | |
631 static void | |
632 print_version_and_exit (void) | |
633 { | |
3922 | 634 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1 | 635 exit (0); |
636 } | |
637 | |
721 | 638 static void |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
639 lo_error_handler (const char *fmt, ...) |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
640 { |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
641 va_list args; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
642 va_start (args, fmt); |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9724
diff
changeset
|
643 verror_with_cfn (fmt, args); |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
644 va_end (args); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
645 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
646 octave_throw_execution_exception (); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
647 } |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
648 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
649 static void |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
650 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
|
651 { |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
652 va_list args; |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
653 va_start (args, fmt); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
654 verror_with_id_cfn (id, fmt, args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
655 va_end (args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
656 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
657 octave_throw_execution_exception (); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
658 } |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
659 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
660 static void |
721 | 661 initialize_error_handlers () |
662 { | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
663 set_liboctave_error_handler (lo_error_handler); |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
664 set_liboctave_error_with_id_handler (lo_error_with_id_handler); |
3325 | 665 set_liboctave_warning_handler (warning); |
5781 | 666 set_liboctave_warning_with_id_handler (warning_with_id); |
721 | 667 } |
668 | |
1410 | 669 // What happens on --traditional. |
670 | |
671 static void | |
672 maximum_braindamage (void) | |
673 { | |
5189 | 674 persist = true; |
675 | |
5794 | 676 bind_internal_variable ("PS1", ">> "); |
677 bind_internal_variable ("PS2", ""); | |
15439
5930d41cade1
set PS4 to "" instead for --traditional mode
John W. Eaton <jwe@octave.org>
parents:
15327
diff
changeset
|
678 bind_internal_variable ("PS4", ""); |
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
|
679 bind_internal_variable ("allow_noninteger_range_as_index", true); |
5794 | 680 bind_internal_variable ("beep_on_error", true); |
8473
4dd0213bb883
octave.cc (maximum_braindamage): set confirm_recursive_rmdir to false
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
681 bind_internal_variable ("confirm_recursive_rmdir", false); |
5794 | 682 bind_internal_variable ("crash_dumps_octave_core", false); |
683 bind_internal_variable ("default_save_options", "-mat-binary"); | |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
684 bind_internal_variable ("do_braindead_shortcircuit_evaluation", true); |
5794 | 685 bind_internal_variable ("fixed_point_format", true); |
686 bind_internal_variable ("history_timestamp_format_string", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
687 "%%-- %D %I:%M %p --%%"); |
5794 | 688 bind_internal_variable ("page_screen_output", false); |
689 bind_internal_variable ("print_empty_dimensions", false); | |
5904 | 690 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9383
diff
changeset
|
691 disable_warning ("Octave:abbreviated-property-match"); |
6159 | 692 disable_warning ("Octave:fopen-file-in-path"); |
5904 | 693 disable_warning ("Octave:function-name-clash"); |
6159 | 694 disable_warning ("Octave:load-file-in-path"); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
695 disable_warning ("Octave:possible-matlab-short-circuit-operator"); |
1410 | 696 } |
697 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
698 // 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
|
699 // declared extern "C". |
581 | 700 |
1 | 701 int |
4368 | 702 octave_main (int argc, char **argv, int embedded) |
1 | 703 { |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
704 octave_process_command_line (argc, argv); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
705 |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
706 install_defaults (); |
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
707 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
708 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
|
709 |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
710 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
|
711 } |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
712 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
713 void |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
714 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
|
715 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
716 octave_cmdline_argc = argc; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
717 octave_cmdline_argv = argv; |
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 while (true) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
720 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
721 int long_idx; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
722 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
723 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
|
724 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
725 if (optc < 0) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
726 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
727 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
728 switch (optc) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
729 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
730 case '?': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
731 // Unrecognized option. getopt_long already printed a |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
732 // message about that, so we will just print the usage string |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
733 // and exit. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
734 usage (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
735 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
736 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
737 case 'H': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
738 read_history_file = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
739 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
740 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
741 case 'V': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
742 verbose_flag = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
743 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
744 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
745 case 'd': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
746 // 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
|
747 octave_debug++; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
748 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
749 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
750 case 'f': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
751 read_init_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
752 read_site_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
753 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
754 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
755 case 'h': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
756 verbose_usage (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
757 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
758 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
759 case 'i': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
760 forced_interactive = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
761 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
762 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
763 case 'p': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
764 if (optarg) |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
765 command_line_path.push_back (optarg); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
766 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
767 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
768 case 'q': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
769 inhibit_startup_message = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
770 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
771 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
772 case 'x': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
773 echo_executing_commands |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
774 = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
775 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
776 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
777 case 'v': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
778 print_version_and_exit (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
779 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
780 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
781 case DOC_CACHE_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
782 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
783 doc_cache_file = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
784 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
785 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
786 case EVAL_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
787 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
788 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
789 if (code_to_eval.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
790 code_to_eval = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
791 else |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
792 code_to_eval += std::string (" ") + optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
793 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
794 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
795 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
796 case EXEC_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
797 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
798 exec_path = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
799 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
800 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
801 case FORCE_GUI_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
802 force_gui_option = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
803 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
804 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
805 case IMAGE_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
806 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
807 image_path = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
808 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
809 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
810 case INFO_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
811 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
812 info_file = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
813 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
814 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
815 case INFO_PROG_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
816 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
817 info_program = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
818 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
819 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
820 case JIT_DEBUG_OPTION: |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
821 jit_debug_option = true; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
822 break; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
823 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
824 case LINE_EDITING_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
825 forced_line_editing = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
826 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
827 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
828 case NO_GUI_OPTION: |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
829 no_gui_option = true; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
830 break; |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
831 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
832 case NO_INIT_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
833 read_init_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
834 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
835 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
836 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
|
837 set_initial_path = false; |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
838 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
839 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
840 case NO_JIT_COMPILER_OPTION: |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
841 no_jit_compiler_option = true; |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
842 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
843 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
844 case NO_LINE_EDITING_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
845 line_editing = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
846 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
847 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
848 case NO_SITE_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
849 read_site_files = 0; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
850 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
851 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
852 case NO_WINDOW_SYSTEM_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
853 no_window_system = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
854 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
855 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
856 case PERSIST_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
857 persist = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
858 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
859 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
860 case TEXI_MACROS_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
861 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
862 texi_macros_file = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
863 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
864 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
865 case TRADITIONAL_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
866 traditional = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
867 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
868 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
869 default: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
870 // getopt_long should print a message about unrecognized |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
871 // options and return '?', which is handled above. So if we |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
872 // end up here, it is because there was an option but we |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
873 // forgot to handle it. That should be fatal. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
874 panic_impossible (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
875 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
876 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
877 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
878 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
879 if (force_gui_option && no_gui_option) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
880 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
881 error ("error: only one of --force-gui and --no-gui may be used"); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
882 usage (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
883 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
884 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
885 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
886 // 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
|
887 // declared extern "C". |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
888 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
889 void |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
890 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
|
891 { |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
892 octave_embedded = embedded; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
893 |
3019 | 894 octave_env::set_program_name (argv[0]); |
895 | |
5780 | 896 octave_program_invocation_name = octave_env::get_program_invocation_name (); |
897 octave_program_name = octave_env::get_program_name (); | |
898 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
899 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
|
900 |
2205 | 901 // The order of these calls is important. The call to |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
902 // install_builtins must come before the option settings are processed |
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
903 // because some command line options override defaults by calling |
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
904 // bind_internal_variable. |
721 | 905 |
5844 | 906 init_signals (); |
907 | |
1 | 908 sysdep_init (); |
909 | |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
910 octave_ieee_init (); |
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
911 |
4159 | 912 // The idea here is to force xerbla to be referenced so that we will |
913 // link to our own version instead of the one provided by the BLAS | |
914 // library. But octave_NaN should never be -1, so we should never | |
915 // actually call xerbla. | |
916 | |
917 if (octave_NaN == -1) | |
11157
c75130f19440
octave.cc: fix call to xerbla
John W. Eaton <jwe@octave.org>
parents:
11140
diff
changeset
|
918 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6)); |
4159 | 919 |
721 | 920 initialize_error_handlers (); |
223 | 921 |
5794 | 922 initialize_default_warning_state (); |
923 | |
1792 | 924 initialize_pathsearch (); |
1744 | 925 |
4368 | 926 if (! embedded) |
927 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
|
928 else |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
929 quit_allowed = false; |
2205 | 930 |
931 initialize_file_io (); | |
932 | |
2375 | 933 install_types (); |
934 | |
935 install_ops (); | |
2205 | 936 |
937 install_builtins (); | |
938 | |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
939 if (! read_history_file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
940 bind_internal_variable ("saving_history", false); |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
941 |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
942 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
|
943 it != command_line_path.end (); it++) |
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
944 load_path::set_command_line_path (*it); |
777 | 945 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
946 if (echo_executing_commands) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
947 bind_internal_variable ("echo_executing_commands", |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
948 echo_executing_commands); |
777 | 949 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
950 if (! doc_cache_file.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
951 bind_internal_variable ("doc_cache_file", doc_cache_file); |
8861 | 952 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
953 if (! exec_path.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
954 set_exec_path (exec_path); |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
955 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
956 if (! image_path.empty ()) |
15327 | 957 set_image_path (image_path); |
777 | 958 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
959 if (! info_file.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
960 bind_internal_variable ("info_file", info_file); |
2239 | 961 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
962 if (! info_program.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
963 bind_internal_variable ("info_program", info_program); |
9336
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
964 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
965 if (no_window_system) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
966 display_info::no_window_system (); |
1410 | 967 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
968 if (! texi_macros_file.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
969 bind_internal_variable ("texi_macros_file", texi_macros_file); |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
970 |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
971 if (jit_debug_option) |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
972 bind_internal_variable ("enable_jit_debugging", true); |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
973 |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
974 if (no_jit_compiler_option) |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
975 bind_internal_variable ("enable_jit_compiler", false); |
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15290
diff
changeset
|
976 |
2077 | 977 // Make sure we clean up when we exit. Also allow users to register |
978 // functions. If we don't have atexit or on_exit, we're going to | |
979 // leave some junk files around if we exit abnormally. | |
980 | |
981 atexit (do_octave_atexit); | |
1 | 982 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
983 // Is input coming from a terminal? If so, we are probably |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
984 // interactive. |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
985 |
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
|
986 // 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
|
987 // a redirected file. |
14160 | 988 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
|
989 |
14160 | 990 interactive = (! embedded && stdin_is_tty |
991 && 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
|
992 |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
993 if (! interactive && ! forced_line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
994 line_editing = false; |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
995 |
9321
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
996 // 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
|
997 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
|
998 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
|
999 |
1358 | 1000 // These can come after command line args since none of them set any |
1001 // defaults that might be changed by command line options. | |
581 | 1002 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
1003 if (line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
1004 initialize_command_input (); |
315 | 1005 |
1410 | 1006 if (traditional) |
1007 maximum_braindamage (); | |
1008 | |
4217 | 1009 octave_interpreter_ready = true; |
1010 | |
5654 | 1011 initialize_version_info (); |
1012 | |
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
|
1013 // 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
|
1014 // 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
|
1015 |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
1016 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
|
1017 |
6365 | 1018 load_path::initialize (set_initial_path); |
4217 | 1019 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
1020 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
|
1021 } |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1022 |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1023 int |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1024 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
|
1025 { |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1026 if (! inhibit_startup_message) |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1027 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
1651 | 1028 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
1029 execute_startup_files (); |
1 | 1030 |
578 | 1031 if (! inhibit_startup_message && reading_startup_message_printed) |
3538 | 1032 std::cout << std::endl; |
578 | 1033 |
1358 | 1034 // If there is an extra argument, see if it names a file to read. |
1035 // Additional arguments are taken as command line options for the | |
1036 // script. | |
1 | 1037 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
1038 int last_arg_idx = optind; |
3019 | 1039 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1040 int remaining_args = octave_cmdline_argc - last_arg_idx; |
3019 | 1041 |
5189 | 1042 if (! code_to_eval.empty ()) |
149 | 1043 { |
5189 | 1044 int parse_status = execute_eval_option_code (code_to_eval); |
1045 | |
5242 | 1046 if (! (persist || remaining_args > 0)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1047 clean_up_and_exit (parse_status || error_state ? 1 : 0); |
1 | 1048 } |
1049 | |
5189 | 1050 if (remaining_args > 0) |
1051 { | |
1052 // If we are running an executable script (#! /bin/octave) then | |
1053 // we should only see the args passed to the script. | |
1054 | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1055 intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx); |
5189 | 1056 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1057 execute_command_line_file (octave_cmdline_argv[last_arg_idx]); |
5189 | 1058 |
1059 if (! persist) | |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1060 { |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1061 quitting_gracefully = true; |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1062 |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1063 clean_up_and_exit (error_state ? 1 : 0); |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1064 } |
5189 | 1065 } |
1066 | |
1067 // Avoid counting commands executed from startup files. | |
1068 | |
1069 command_editor::reset_current_command_number (1); | |
1070 | |
1071 // 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
|
1072 intern_argv (octave_cmdline_argc, octave_cmdline_argv); |
5189 | 1073 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1074 if (! octave_embedded) |
5189 | 1075 switch_to_buffer (create_buffer (get_input_from_stdin ())); |
1076 | |
1358 | 1077 // Force input to be echoed if not really interactive, but the user |
1078 // has forced interactive behavior. | |
1 | 1079 |
1907 | 1080 if (! interactive && forced_interactive) |
287 | 1081 { |
2926 | 1082 command_editor::blink_matching_paren (false); |
1588 | 1083 |
5775 | 1084 // FIXME -- is this the right thing to do? |
1588 | 1085 |
5794 | 1086 bind_internal_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287 | 1087 } |
1 | 1088 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1089 if (octave_embedded) |
5502 | 1090 { |
5775 | 1091 // FIXME -- do we need to do any cleanup here before |
5502 | 1092 // returning? If we don't, what will happen to Octave functions |
1093 // that have been registered to execute with atexit, for example? | |
1094 | |
1095 return 1; | |
1096 } | |
4368 | 1097 |
5189 | 1098 int retval = main_loop (); |
1 | 1099 |
1005 | 1100 if (retval == 1 && ! error_state) |
1101 retval = 0; | |
1102 | |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1103 quitting_gracefully = true; |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1104 |
1 | 1105 clean_up_and_exit (retval); |
4247 | 1106 |
1107 return 0; | |
1 | 1108 } |
1109 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1110 // Return int instead of bool because this function is declared |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1111 // extern "C". |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1112 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1113 int |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1114 octave_starting_gui (void) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1115 { |
15290
99db33cae82b
don't start the GUI if window system is disabled
Mike Miller <mtmiller@ieee.org>
parents:
15262
diff
changeset
|
1116 if (no_window_system || ! display_info::display_available ()) |
15160
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
1117 return false; |
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
1118 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1119 if (force_gui_option) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1120 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1121 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1122 if (no_gui_option) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1123 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1124 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1125 if (persist) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1126 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1127 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1128 // If stdin is not a tty, then assume we are reading commands from a |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1129 // pipe or a redirected file and the GUI should not start. If this is |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1130 // not the case (for example, starting from a desktop "launcher" with |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1131 // no terminal) and you want to start the GUI, you may use the |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1132 // --force-gui option to start the GUI. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1133 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1134 if (! gnulib::isatty (fileno (stdin))) |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1135 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1136 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1137 // If we have code to eval or execute from a file, and we are going to |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1138 // exit immediately after executing it, don't start the gui. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1139 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1140 int last_arg_idx = optind; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1141 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
|
1142 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1143 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
|
1144 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1145 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1146 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1147 } |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1148 |
5780 | 1149 DEFUN (argv, args, , |
1150 "-*- texinfo -*-\n\ | |
1151 @deftypefn {Built-in Function} {} argv ()\n\ | |
1152 Return the command line arguments passed to Octave. For example,\n\ | |
1153 if you invoked Octave using the command\n\ | |
1154 \n\ | |
1155 @example\n\ | |
1156 octave --no-line-editing --silent\n\ | |
1157 @end example\n\ | |
1158 \n\ | |
1159 @noindent\n\ | |
1160 @code{argv} would return a cell array of strings with the elements\n\ | |
10840 | 1161 @option{--no-line-editing} and @option{--silent}.\n\ |
5780 | 1162 \n\ |
1163 If you write an executable Octave script, @code{argv} will return the\n\ | |
1164 list of arguments passed to the script. @xref{Executable Octave Programs},\n\ | |
1165 for an example of how to create an executable Octave script.\n\ | |
1166 @end deftypefn") | |
1167 { | |
1168 octave_value retval; | |
1169 | |
1170 if (args.length () == 0) | |
1171 retval = Cell (octave_argv); | |
1172 else | |
5823 | 1173 print_usage (); |
5780 | 1174 |
1175 return retval; | |
1176 } | |
1177 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1178 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1179 %!assert (iscellstr (argv ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1180 %!error argv (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1181 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1182 |
5780 | 1183 DEFUN (program_invocation_name, args, , |
1184 "-*- texinfo -*-\n\ | |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9584
diff
changeset
|
1185 @deftypefn {Built-in Function} {} program_invocation_name ()\n\ |
5780 | 1186 Return the name that was typed at the shell prompt to run Octave.\n\ |
1187 \n\ | |
1188 If executing a script from the command line (e.g., @code{octave foo.m})\n\ | |
1189 or using an executable Octave script, the program name is set to the\n\ | |
1190 name of the script. @xref{Executable Octave Programs}, for an example of\n\ | |
1191 how to create an executable Octave script.\n\ | |
1192 @seealso{program_name}\n\ | |
1193 @end deftypefn") | |
1194 { | |
1195 octave_value retval; | |
1196 | |
1197 if (args.length () == 0) | |
1198 retval = octave_program_invocation_name; | |
1199 else | |
5823 | 1200 print_usage (); |
5780 | 1201 |
1202 return retval; | |
1203 } | |
1204 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1205 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1206 %!assert (ischar (program_invocation_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1207 %!error program_invocation_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1208 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1209 |
5780 | 1210 DEFUN (program_name, args, , |
1211 "-*- texinfo -*-\n\ | |
1212 @deftypefn {Built-in Function} {} program_name ()\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8273
diff
changeset
|
1213 Return the last component of the value returned by\n\ |
5780 | 1214 @code{program_invocation_name}.\n\ |
1215 @seealso{program_invocation_name}\n\ | |
1216 @end deftypefn") | |
1217 { | |
1218 octave_value retval; | |
1219 | |
1220 if (args.length () == 0) | |
1221 retval = octave_program_name; | |
1222 else | |
5823 | 1223 print_usage (); |
5780 | 1224 |
1225 return retval; | |
1226 } | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1227 |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1228 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1229 %!assert (ischar (program_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1230 %!error program_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1231 */ |