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