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