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