annotate libinterp/octave.cc @ 29655:32f4357ac8d9

maint: merge stable to default.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 12 May 2021 19:28:54 +0200
parents 60315909c884 d13d090cb03a
children bc19d9360bac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
3 // Copyright (C) 1993-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26 // Born February 20, 1992.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21723
diff changeset
28 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21220
diff changeset
29 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
31
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
32 #include <iostream>
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 22090
diff changeset
33 #include <string>
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
34
4097
596f88296519 [project @ 2002-10-09 20:26:27 by jwe]
jwe
parents: 4051
diff changeset
35 #include "file-ops.h"
22064
bd4f3d2ce52f provide wrapper for getopt
John W. Eaton <jwe@octave.org>
parents: 22051
diff changeset
36 #include "getopt-wrapper.h"
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 223
diff changeset
37 #include "lo-error.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
38 #include "oct-env.h"
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
39 #include "str-vec.h"
223
82c050e70f7a [project @ 1993-11-14 10:58:11 by jwe]
jwe
parents: 206
diff changeset
40
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3922
diff changeset
41 #include "Cell.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
42 #include "defun.h"
9335
f2d354df53ee new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
43 #include "display.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
44 #include "error.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
45 #include "input.h"
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 22090
diff changeset
46 #include "interpreter.h"
4113
f4bf4833e6c7 [project @ 2002-10-17 19:58:42 by jwe]
jwe
parents: 4101
diff changeset
47 #include "octave.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1711
diff changeset
48 #include "oct-hist.h"
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
49 #include "oct-map.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
50 #include "ovl.h"
17777
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
51 #include "options-usage.h"
10613
e103fb2182ce use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents: 10605
diff changeset
52 #include "ov.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53 #include "parse.h"
22186
9aff1ce307b1 do system dependent and default variable inits early (bug #)
John W. Eaton <jwe@octave.org>
parents: 22101
diff changeset
54 #include "sysdep.h"
1410
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
55
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
56 namespace octave
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
57 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
58 cmdline_options::cmdline_options (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
59 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
60 m_all_args.resize (1);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
61 m_all_args[0] = "";
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
62 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
63
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
64 cmdline_options::cmdline_options (int argc, char **argv)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
65 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
66 // Save raw program arguments.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
67 m_all_args = string_vector (argv, argc);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
68
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
69 while (true)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
70 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
71 int long_idx;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
72
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
73 int optc = octave_getopt_long_wrapper (argc, argv, short_opts,
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
74 long_opts, &long_idx);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
75
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
76 if (optc < 0)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
77 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
78
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
79 switch (optc)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
80 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
81 case '?':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
82 // Unrecognized option. getopt_long already printed a message about
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
83 // it, so we will just print the usage string and exit.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
84 octave_print_terse_usage_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
85 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
86
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
87 case 'H':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
88 m_read_history_file = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
89 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
90
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
91 case 'W':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
92 m_no_window_system = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
93 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
94
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
95 case 'V':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
96 m_verbose_flag = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
97 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
98
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
99 case 'd':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
100 // This is the same as yydebug in parse.y.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
101 octave_debug++;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
102 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
103
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
104 case 'f':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
105 m_read_init_files = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
106 m_read_site_files = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
107 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
108
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
109 case 'h':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
110 octave_print_verbose_usage_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
111 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
112
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
113 case 'i':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
114 m_forced_interactive = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
115 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
116
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
117 case 'p':
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
118 if (octave_optarg_wrapper ())
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
119 m_command_line_path.push_back (octave_optarg_wrapper ());
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
120 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
121
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
122 case 'q':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
123 m_inhibit_startup_message = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
124 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
125
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
126 case 'x':
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
127 m_echo_commands = true;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
128 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
129
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
130 case 'v':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
131 octave_print_version_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
132 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
133
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
134 case BUILT_IN_DOCSTRINGS_FILE_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
135 if (octave_optarg_wrapper ())
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
136 m_docstrings_file = octave_optarg_wrapper ();;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
137 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
138
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
139 case DOC_CACHE_FILE_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
140 if (octave_optarg_wrapper ())
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
141 m_doc_cache_file = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
142 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
143
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
144 case EVAL_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
145 if (octave_optarg_wrapper ())
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
146 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
147 if (m_code_to_eval.empty ())
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
148 m_code_to_eval = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
149 else
23857
4d4ba038d103 Restore processing multiple '--eval' lines when launching Octave (bug #51708).
Rik <rik@octave.org>
parents: 23819
diff changeset
150 m_code_to_eval += (std::string (" ")
4d4ba038d103 Restore processing multiple '--eval' lines when launching Octave (bug #51708).
Rik <rik@octave.org>
parents: 23819
diff changeset
151 + octave_optarg_wrapper ());
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
152 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
153 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
154
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
155 case EXEC_PATH_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
156 if (octave_optarg_wrapper ())
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
157 m_exec_path = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
158 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
159
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
160 case EXPERIMENTAL_TERMINAL_WIDGET_OPTION:
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
161 m_experimental_terminal_widget = true;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
162 break;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
163
27823
83dd2bc500f0 Remove deprecated FORCE_GUI_OPTION from getopts parsing.
Rik <rik@octave.org>
parents: 27301
diff changeset
164 case GUI_OPTION:
24874
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
165 m_gui = true;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
166 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
167
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
168 case IMAGE_PATH_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
169 if (octave_optarg_wrapper ())
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
170 m_image_path = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
171 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
172
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
173 case INFO_FILE_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
174 if (octave_optarg_wrapper ())
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
175 m_info_file = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
176 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
177
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
178 case INFO_PROG_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
179 if (octave_optarg_wrapper ())
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
180 m_info_program = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
181 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
182
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
183 case DEBUG_JIT_OPTION:
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
184 m_debug_jit = true;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
185 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
186
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
187 case JIT_COMPILER_OPTION:
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
188 m_jit_compiler = true;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
189 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
190
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
191 case LINE_EDITING_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
192 m_forced_line_editing = m_line_editing = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
193 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
194
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
195 case NO_GUI_OPTION:
24878
4fdb160b47fb Keep the '--no-gui' option as the inverse of '--gui'
Mike Miller <mtmiller@octave.org>
parents: 24874
diff changeset
196 m_gui = false;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
197 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
198
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
199 case NO_INIT_FILE_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
200 m_read_init_files = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
201 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
202
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
203 case NO_INIT_PATH_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
204 m_set_initial_path = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
205 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
206
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
207 case NO_LINE_EDITING_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
208 m_line_editing = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
209 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
210
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
211 case NO_SITE_FILE_OPTION:
26701
e000879eabef maint: Use bool values true/false rather than 0/1 in C++.
Rik <rik@octave.org>
parents: 26377
diff changeset
212 m_read_site_files = false;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
213 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
214
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
215 case PERSIST_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
216 m_persist = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
217 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
218
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
219 case SERVER_OPTION:
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
220 m_server = true;
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
221 break;
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
222
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
223 case TEXI_MACROS_FILE_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
224 if (octave_optarg_wrapper ())
23711
5a97aafb12a9 don't call built-in interpreter functions from the application context
John W. Eaton <jwe@octave.org>
parents: 23696
diff changeset
225 m_texi_macros_file = octave_optarg_wrapper ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
226 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
227
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
228 case TRADITIONAL_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
229 m_traditional = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
230 m_persist = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
231 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
232
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
233 default:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
234 // getopt_long should print a message about unrecognized options and
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
235 // return '?', which is handled above. If we end up here, it is
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
236 // because there was an option but we forgot to handle it.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
237 // That should be fatal.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
238 panic_impossible ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
239 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
240 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
241 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
242
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
243 m_remaining_args = string_vector (argv+octave_optind_wrapper (),
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
244 argc-octave_optind_wrapper ());
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
245 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
246
29152
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
247 octave_value cmdline_options::as_octave_value (void) const
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
248 {
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
249 octave_scalar_map m;
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
250
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
251 m.assign ("sys_argc", sys_argc ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
252 m.assign ("sys_argv", string_vector (sys_argv ()));
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
253 m.assign ("debug_jit", debug_jit ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
254 m.assign ("echo_commands", echo_commands ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
255 m.assign ("forced_interactive", forced_interactive ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
256 m.assign ("forced_line_editing", forced_line_editing ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
257 m.assign ("gui", gui ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
258 m.assign ("inhibit_startup_message", inhibit_startup_message ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
259 m.assign ("jit_compiler", jit_compiler ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
260 m.assign ("line_editing", line_editing ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
261 m.assign ("no_window_system", no_window_system ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
262 m.assign ("persist", persist ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
263 m.assign ("read_history_file", read_history_file ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
264 m.assign ("read_init_files", read_init_files ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
265 m.assign ("read_site_files", read_site_files ());
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
266 m.assign ("server", server ());
29152
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
267 m.assign ("set_initial_path", set_initial_path ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
268 m.assign ("traditional", traditional ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
269 m.assign ("verbose_flag", verbose_flag ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
270 m.assign ("code_to_eval", code_to_eval ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
271 m.assign ("command_line_path", string_vector (command_line_path ()));
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
272 m.assign ("docstrings_file", docstrings_file ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
273 m.assign ("doc_cache_file", doc_cache_file ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
274 m.assign ("exec_path", exec_path ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
275 m.assign ("image_path", image_path ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
276 m.assign ("info_file", info_file ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
277 m.assign ("info_program", info_program ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
278 m.assign ("texi_macros_file", texi_macros_file ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
279 m.assign ("all_args", all_args ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
280 m.assign ("remaining_args", remaining_args ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
281
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
282 return m;
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
283 }
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
284
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23450
diff changeset
285 application *application::instance = nullptr;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
286
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
287 application::application (int argc, char **argv)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
288 : m_options (argc, argv)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
289 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
290 init ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
291 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
292
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
293 application::application (const cmdline_options& opts)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
294 : m_options (opts)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
295 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
296 init ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
297 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
298
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
299 // Note: Although the application destructor doesn't explicitly
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
300 // perform any actions, it can't be declared "default" in the header
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
301 // file if the octave::interpreter is an incomplete type. Providing
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
302 // an explicit definition of the destructor here is much simpler than
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
303 // including the full declaration of octave::interpreter in the
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
304 // octave.h header file.
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
305 application::~application (void) { }
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
306
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
307 void
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
308 application::set_program_names (const std::string& pname)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
309 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
310 m_program_invocation_name = pname;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
311
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29545
diff changeset
312 std::size_t pos = pname.find_last_of (sys::file_ops::dir_sep_chars ());
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
313
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
314 m_program_name = (pos != std::string::npos) ? pname.substr (pos+1) : pname;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
315 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
316
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
317 void
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
318 application::intern_argv (const string_vector& args)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
319 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
320 octave_idx_type nargs = args.numel ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
321
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
322 if (nargs > 0)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
323 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
324 // Skip first argument (program name).
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
325 nargs--;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
326
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
327 m_argv.resize (nargs);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
328
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
329 for (octave_idx_type i = 0; i < nargs; i++)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
330 m_argv[i] = args[i+1];
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
331 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
332 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
333
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
334 bool application::forced_interactive (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
335 {
23111
252975fdc444 more refactoring of interpreter and application classes
John W. Eaton <jwe@octave.org>
parents: 23102
diff changeset
336 return instance ? instance->m_options.forced_interactive () : false;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
337 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
338
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
339 // Provided for convenience. Will be removed once we eliminate the
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
340 // old terminal widget.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
341 bool application::experimental_terminal_widget (void) const
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
342 {
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
343 return (instance
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
344 ? instance->m_options.experimental_terminal_widget () : false);
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
345 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
346
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
347 bool application::interpreter_initialized (void)
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
348 {
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
349 return m_interpreter ? m_interpreter->initialized () : false;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
350 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
351
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
352 interpreter& application::create_interpreter (void)
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
353 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
354 if (! m_interpreter)
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
355 m_interpreter = std::unique_ptr<interpreter> (new interpreter (this));
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
356
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
357 return *m_interpreter;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
358 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
359
23819
5d8ef9b859f8 defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
360 void application::initialize_interpreter (void)
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
361 {
23819
5d8ef9b859f8 defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
362 if (m_interpreter)
5d8ef9b859f8 defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
363 m_interpreter->initialize ();
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
364 }
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
365
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
366 int application::execute_interpreter (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
367 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
368 return m_interpreter ? m_interpreter->execute () : -1;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
369 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
370
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
371 void application::delete_interpreter (void)
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
372 {
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
373 m_interpreter.reset ();
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
374 }
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
375
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
376 void application::init (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
377 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
378 if (instance)
23511
232c8d69d934 manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents: 23460
diff changeset
379 throw std::runtime_error
232c8d69d934 manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents: 23460
diff changeset
380 ("only one Octave application object may be active");
232c8d69d934 manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents: 23460
diff changeset
381
232c8d69d934 manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents: 23460
diff changeset
382 instance = this;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
383
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
384 string_vector all_args = m_options.all_args ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
385
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
386 set_program_names (all_args[0]);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
387
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
388 string_vector remaining_args = m_options.remaining_args ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
389
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
390 std::string code_to_eval = m_options.code_to_eval ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
391
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
392 m_have_script_file = ! remaining_args.empty ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
393
23102
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
394 m_have_eval_option_code = ! code_to_eval.empty ();
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
395
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
396 if (m_have_eval_option_code && m_have_script_file)
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
397 {
24344
cac0f8a1c696 Stop segfault when starting Octave with conflicting options (bug #52567).
Rik <rik@octave.org>
parents: 23857
diff changeset
398 std::cerr << R"(error: --eval "CODE" and script file are mutually exclusive options)" << std::endl;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
399
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
400 octave_print_terse_usage_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
401 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
402
24874
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
403 if (m_options.gui ())
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
404 {
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
405 if (m_options.no_window_system ())
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
406 {
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
407 std::cerr << "error: --gui and --no-window-system are mutually exclusive options" << std::endl;
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
408 octave_print_terse_usage_and_exit ();
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
409 }
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
410 if (! m_options.line_editing ())
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
411 {
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
412 std::cerr << "error: --gui and --no-line-editing are mutually exclusive options" << std::endl;
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
413 octave_print_terse_usage_and_exit ();
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
414 }
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
415 if (m_options.server ())
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
416 {
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
417 std::cerr << "error: --gui and --server are mutually exclusive options" << std::endl;
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
418 octave_print_terse_usage_and_exit ();
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
419 }
24874
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
420 }
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
421
23102
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
422 m_is_octave_program = ((m_have_script_file || m_have_eval_option_code)
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
423 && ! m_options.persist ()
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
424 && ! m_options.traditional ());
23460
b605146ed2ed do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
425
b605146ed2ed do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
426 // This should probably happen early.
b605146ed2ed do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
427 sysdep_init ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
428 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
429
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
430 int cli_application::execute (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
431 {
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
432 interpreter& interp = create_interpreter ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
433
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
434 int status = interp.execute ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
435
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
436 return status;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
437 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
438 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
439
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
440 DEFUN (isguirunning, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
441 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
442 @deftypefn {} {} isguirunning ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
443 Return true if Octave is running in GUI mode and false otherwise.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
444 @seealso{have_window_system}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
445 @end deftypefn */)
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
446 {
20849
994c0859ab8b maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20756
diff changeset
447 if (args.length () != 0)
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
448 print_usage ();
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
449
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
450 // FIXME: This isn't quite right, it just says that we intended to
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
451 // start the GUI, not that it is actually running.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
452
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
453 return ovl (octave::application::is_gui_running ());
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
454 }
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
455
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
456 /*
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
457 %!assert (islogical (isguirunning ()))
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
458 %!error isguirunning (1)
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
459 */
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
460
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
461 DEFUN (argv, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
462 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
463 @deftypefn {} {} argv ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
464 Return the command line arguments passed to Octave.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
465
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
466 For example, if you invoked Octave using the command
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
467
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
468 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
469 octave --no-line-editing --silent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
470 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
471
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
472 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
473 @code{argv} would return a cell array of strings with the elements
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
474 @option{--no-line-editing} and @option{--silent}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
475
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
476 If you write an executable Octave script, @code{argv} will return the list
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
477 of arguments passed to the script. @xref{Executable Octave Programs}, for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
478 an example of how to create an executable Octave script.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
479 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
480 {
20849
994c0859ab8b maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20756
diff changeset
481 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
482 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
483
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
484 return ovl (Cell (octave::application::argv ()));
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
485 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
486
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
487 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
488 %!assert (iscellstr (argv ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
489 %!error argv (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
490 */
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
491
29152
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
492 DEFUN (cmdline_options, args, ,
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
493 doc: /* -*- texinfo -*-
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
494 @deftypefn {} {} argv ()
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
495 Return a structure containing info about the command line arguments
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
496 passed to Octave.
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
497 @end deftypefn */)
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
498 {
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
499 if (args.length () != 0)
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
500 print_usage ();
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
501
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
502 octave::application *app = octave::application::app ();
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
503
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
504 if (! app)
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
505 error ("invalid application context!");
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
506
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
507 octave::cmdline_options opts = app->options ();
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
508
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
509 return ovl (opts.as_octave_value ());
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
510 }
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
511
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
512 DEFUN (program_invocation_name, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
513 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
514 @deftypefn {} {} program_invocation_name ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
515 Return the name that was typed at the shell prompt to run Octave.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
516
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
517 If executing a script from the command line (e.g., @code{octave foo.m})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
518 or using an executable Octave script, the program name is set to the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
519 name of the script. @xref{Executable Octave Programs}, for an example of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
520 how to create an executable Octave script.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
521 @seealso{program_name}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
522 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
523 {
20849
994c0859ab8b maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20756
diff changeset
524 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
525 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
526
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
527 return ovl (octave::application::program_invocation_name ());
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
528 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
529
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
530 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
531 %!assert (ischar (program_invocation_name ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
532 %!error program_invocation_name (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
533 */
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
534
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
535 DEFUN (program_name, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
536 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
537 @deftypefn {} {} program_name ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
538 Return the last component of the value returned by
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
539 @code{program_invocation_name}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
540 @seealso{program_invocation_name}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
541 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
542 {
20849
994c0859ab8b maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20756
diff changeset
543 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
544 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
545
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
546 return ovl (octave::application::program_name ());
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
547 }
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
548
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
549 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
550 %!assert (ischar (program_name ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
551 %!error program_name (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
552 */