annotate libinterp/octave.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 9c4e8c3bf41d
children 83f9f8bda883
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30160
diff changeset
3 // Copyright (C) 1993-2022 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"
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
51 #include "options.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"
29898
dffd1c943f1a main.cc: Use getopt to parse command line arguments (bug #60886).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29654
diff changeset
55 #include "usage.h"
1410
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
56
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
57 OCTAVE_NAMESPACE_BEGIN
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
58
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
59 cmdline_options::cmdline_options (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
60 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
61 m_all_args.resize (1);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
62 m_all_args[0] = "";
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
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
65 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
66 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
67 // Save raw program arguments.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
68 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
69
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
70 while (true)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
71 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
72 int long_idx;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
73
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
74 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
75 long_opts, &long_idx);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
76
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
77 if (optc < 0)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
78 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
79
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
80 switch (optc)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
81 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
82 case '?':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
83 // 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
84 // 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
85 octave_print_terse_usage_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
86 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
87
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
88 case 'H':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
89 m_read_history_file = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
90 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
91
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
92 case 'W':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
93 m_no_window_system = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
94 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
95
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
96 case 'V':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
97 m_verbose_flag = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
98 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
99
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
100 case 'd':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
101 // 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
102 octave_debug++;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
103 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
104
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
105 case 'f':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
106 m_read_init_files = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
107 m_read_site_files = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
108 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
109
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
110 case 'h':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
111 octave_print_verbose_usage_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
112 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
113
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
114 case 'i':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
115 m_forced_interactive = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
116 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
117
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
118 case 'p':
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
119 if (octave_optarg_wrapper ())
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
120 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
121 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
122
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
123 case 'q':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
124 m_inhibit_startup_message = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
125 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
126
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
127 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
128 m_echo_commands = true;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
129 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
130
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
131 case 'v':
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
132 octave_print_version_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
133 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
134
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
135 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
136 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
137 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
138 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
139
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
140 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
141 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
142 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
143 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
144
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
145 case EVAL_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
146 if (octave_optarg_wrapper ())
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
147 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
148 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
149 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
150 else
23857
4d4ba038d103 Restore processing multiple '--eval' lines when launching Octave (bug #51708).
Rik <rik@octave.org>
parents: 23819
diff changeset
151 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
152 + octave_optarg_wrapper ());
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
153 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
154 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
155
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
156 case EXEC_PATH_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
157 if (octave_optarg_wrapper ())
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
158 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
159 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
160
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
161 case EXPERIMENTAL_TERMINAL_WIDGET_OPTION:
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
162 m_experimental_terminal_widget = true;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
163 break;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
164
27823
83dd2bc500f0 Remove deprecated FORCE_GUI_OPTION from getopts parsing.
Rik <rik@octave.org>
parents: 27301
diff changeset
165 case GUI_OPTION:
24874
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
166 m_gui = true;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
167 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
168
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
169 case IMAGE_PATH_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
170 if (octave_optarg_wrapper ())
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
171 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
172 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
173
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
174 case INFO_FILE_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
175 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
176 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
177 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
178
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
179 case INFO_PROG_OPTION:
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
180 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
181 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
182 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
183
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
184 case LINE_EDITING_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
185 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
186 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
187
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
188 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
189 m_gui = false;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
190 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
191
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
192 case NO_INIT_FILE_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
193 m_read_init_files = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
194 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
195
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
196 case NO_INIT_PATH_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
197 m_set_initial_path = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
198 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
199
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
200 case NO_LINE_EDITING_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
201 m_line_editing = false;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
202 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
203
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
204 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
205 m_read_site_files = false;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
206 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
207
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
208 case PERSIST_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
209 m_persist = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
210 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
211
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
212 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
213 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
214 break;
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
215
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
216 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
217 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
218 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
219 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
220
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
221 case TRADITIONAL_OPTION:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
222 m_traditional = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
223 m_persist = true;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
224 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
225
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
226 default:
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
227 // 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
228 // 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
229 // 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
230 // That should be fatal.
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
231 panic_impossible ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
232 break;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
233 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
234 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
235
22090
66db9a493c84 avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents: 22089
diff changeset
236 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
237 argc-octave_optind_wrapper ());
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
238 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
239
29152
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
240 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
241 {
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
242 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
243
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
273 return m;
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
274 }
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
275
30160
9c4e8c3bf41d maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents: 29961
diff changeset
276 application *application::s_instance = nullptr;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
277
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
278 application::application (int argc, char **argv)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
279 : m_options (argc, argv)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
280 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
281 init ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
282 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
283
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
284 application::application (const cmdline_options& opts)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
285 : m_options (opts)
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 init ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
288 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
289
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
290 // 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
291 // perform any actions, it can't be declared "default" in the header
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
292 // file if the interpreter is an incomplete type. Providing
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
293 // an explicit definition of the destructor here is much simpler than
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
294 // including the full declaration of interpreter in the
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
295 // 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
296 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
297
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
298 void
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
299 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
300 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
301 m_program_invocation_name = pname;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
302
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
303 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
304
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
305 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
306 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
307
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
308 void
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
309 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
310 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
311 octave_idx_type nargs = args.numel ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
312
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
313 if (nargs > 0)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
314 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
315 // Skip first argument (program name).
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
316 nargs--;
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
317
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
318 m_argv.resize (nargs);
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 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
321 m_argv[i] = args[i+1];
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
322 }
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
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
325 bool application::forced_interactive (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
326 {
30160
9c4e8c3bf41d maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents: 29961
diff changeset
327 return s_instance ? s_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
328 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
329
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
330 // 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
331 // old terminal widget.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
332 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
333 {
30160
9c4e8c3bf41d maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents: 29961
diff changeset
334 return (s_instance
9c4e8c3bf41d maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents: 29961
diff changeset
335 ? s_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
336 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
337
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
338 bool application::interpreter_initialized (void)
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
339 {
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
340 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
341 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
342
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
343 interpreter& application::create_interpreter (void)
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
344 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
345 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
346 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
347
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
348 return *m_interpreter;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
349 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
350
23819
5d8ef9b859f8 defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
351 void application::initialize_interpreter (void)
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
352 {
23819
5d8ef9b859f8 defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
353 if (m_interpreter)
5d8ef9b859f8 defer execution of user code to interpreter::execute (bug #51631)
John W. Eaton <jwe@octave.org>
parents: 23807
diff changeset
354 m_interpreter->initialize ();
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
355 }
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
356
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
357 int application::execute_interpreter (void)
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 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
360 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
361
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
362 void application::delete_interpreter (void)
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
363 {
29547
60af3f38f4b1 use std::unique_ptr to manage interpreter object in application object
John W. Eaton <jwe@octave.org>
parents: 29546
diff changeset
364 m_interpreter.reset ();
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
365 }
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
366
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
367 void application::init (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
368 {
30160
9c4e8c3bf41d maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents: 29961
diff changeset
369 if (s_instance)
23511
232c8d69d934 manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents: 23460
diff changeset
370 throw std::runtime_error
232c8d69d934 manage interpreter instance in interpreter object
John W. Eaton <jwe@octave.org>
parents: 23460
diff changeset
371 ("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
372
30160
9c4e8c3bf41d maint: use "s_" prefix for static member variables in class application.
Rik <rik@octave.org>
parents: 29961
diff changeset
373 s_instance = this;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
374
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
375 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
376
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
377 set_program_names (all_args[0]);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
378
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
379 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
380
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
381 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
382
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
383 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
384
23102
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
385 m_have_eval_option_code = ! code_to_eval.empty ();
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
386
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
387 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
388 {
24344
cac0f8a1c696 Stop segfault when starting Octave with conflicting options (bug #52567).
Rik <rik@octave.org>
parents: 23857
diff changeset
389 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
390
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
391 octave_print_terse_usage_and_exit ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
392 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
393
24874
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
394 if (m_options.gui ())
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
395 {
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
396 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
397 {
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
398 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
399 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
400 }
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
401 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
402 {
a4dc2ef8741c Don't start GUI by default, require new '--gui' option
Carnë Draug <carandraug@octave.org>
parents: 24534
diff changeset
403 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
404 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
405 }
29254
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
406 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
407 {
11343ca3c125 allow Octave to operate as a server, executing commands from a queue
John W. Eaton <jwe@octave.org>
parents: 29152
diff changeset
408 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
409 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
410 }
24874
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
23102
373771419d51 refactor interpreter::execute
John W. Eaton <jwe@octave.org>
parents: 23087
diff changeset
413 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
414 && ! m_options.persist ()
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
415 && ! 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
416
b605146ed2ed do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
417 // 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
418 sysdep_init ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
419 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
420
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
421 int cli_application::execute (void)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
422 {
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
423 interpreter& interp = create_interpreter ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
424
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
425 int status = interp.execute ();
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
426
23117
17a3567a7b01 separate final interpreter initialization from execution
John W. Eaton <jwe@octave.org>
parents: 23111
diff changeset
427 return status;
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
428 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29949
diff changeset
429
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
430 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
431 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
432 @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
433 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
434 @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
435 @end deftypefn */)
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
436 {
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
437 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
438 print_usage ();
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
439
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22081
diff changeset
440 // 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
441 // 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
442
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
443 return ovl (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
444 }
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
445
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
446 /*
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
447 %!assert (islogical (isguirunning ()))
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
448 %!error isguirunning (1)
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
449 */
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
450
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
451 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
452 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
453 @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
454 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
455
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
456 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
457
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
458 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
459 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
460 @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
461
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
462 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
463 @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
464 @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
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 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
467 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
468 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
469 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
470 {
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
471 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
472 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
473
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
474 return ovl (Cell (application::argv ()));
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
475 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
476
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
477 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
478 %!assert (iscellstr (argv ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
479 %!error argv (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
480 */
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
481
29152
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
482 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
483 doc: /* -*- texinfo -*-
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
484 @deftypefn {} {} argv ()
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
485 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
486 passed to Octave.
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
487 @end deftypefn */)
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
488 {
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
489 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
490 print_usage ();
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
491
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
492 application *app = application::app ();
29152
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
493
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
494 if (! app)
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
495 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
496
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
497 cmdline_options opts = app->options ();
29152
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 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
500 }
556f20454064 make all command line option info available in scripting language
John W. Eaton <jwe@octave.org>
parents: 28349
diff changeset
501
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
502 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
503 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
504 @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
505 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
506
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21938
diff changeset
507 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
508 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
509 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
510 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
511 @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
512 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
513 {
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
514 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
515 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
516
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
517 return ovl (application::program_invocation_name ());
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
518 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
519
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
520 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
521 %!assert (ischar (program_invocation_name ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
522 %!error program_invocation_name (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
523 */
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
524
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
525 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
526 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
527 @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
528 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
529 @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
530 @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
531 @end deftypefn */)
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
532 {
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
533 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
534 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
535
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
536 return ovl (application::program_name ());
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
537 }
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
538
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
539 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
540 %!assert (ischar (program_name ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
541 %!error program_name (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
542 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29949
diff changeset
543
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29949
diff changeset
544 OCTAVE_NAMESPACE_END