annotate libinterp/octave.cc @ 21220:d78e45987d6a

rename octave::build_env namespace from octave::config * build-env-features.sh: Rename from ocgt-conf-features.sh. Update for new names. * build-env.h: Rename from oct-conf.h. Also declare features function. * build-env.in.cc: Rename from oct-conf.in.cc. * oct-conf-features.h: Delete. * libinterp/module.mk: Update. * toplev.cc, __init_gnuplot__.cc, octave.cc: Update for new names.
author John W. Eaton <jwe@octave.org>
date Sun, 07 Feb 2016 14:56:17 -0500
parents fcac5dbbf9ed
children 40de9f8f23a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19602
diff changeset
3 Copyright (C) 1993-2015 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6945
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23 // Born February 20, 1992.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
24
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 223
diff changeset
25 #ifdef HAVE_CONFIG_H
21200
fcac5dbbf9ed maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents: 21186
diff changeset
26 # include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
29 #include <cassert>
17811
ef4fc092c86b set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents: 17792
diff changeset
30 #include <clocale>
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
31 #include <cstdlib>
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
32 #include <cstring>
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
33 #include <ctime>
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
34
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3481
diff changeset
35 #include <iostream>
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
36
17570
1c7d768c3847 don't fork if there is no controlling tty
John W. Eaton <jwe@octave.org>
parents: 17568
diff changeset
37 #include <fcntl.h>
10195
b49d47b637b7 use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents: 10191
diff changeset
38 #include <getopt.h>
12335
6e9f100c0d61 include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
39 #include <sys/types.h>
6e9f100c0d61 include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
40 #include <unistd.h>
10195
b49d47b637b7 use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents: 10191
diff changeset
41
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
42 #include "cmd-edit.h"
3690
55e59236c5e5 [project @ 2000-06-30 20:55:36 by jwe]
jwe
parents: 3597
diff changeset
43 #include "f77-fcn.h"
4097
596f88296519 [project @ 2002-10-09 20:26:27 by jwe]
jwe
parents: 4051
diff changeset
44 #include "file-ops.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
45 #include "file-stat.h"
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 223
diff changeset
46 #include "lo-error.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
47 #include "oct-env.h"
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
48 #include "str-vec.h"
223
82c050e70f7a [project @ 1993-11-14 10:58:11 by jwe]
jwe
parents: 206
diff changeset
49
21220
d78e45987d6a rename octave::build_env namespace from octave::config
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
50 #include "build-env.h"
15475
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
51 #include "builtins.h"
15262
ad1a980b0cb5 install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents: 15244
diff changeset
52 #include "defaults.h"
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3922
diff changeset
53 #include "Cell.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
54 #include "defun.h"
9335
f2d354df53ee new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents: 9321
diff changeset
55 #include "display.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
56 #include "error.h"
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
57 #include "file-io.h"
15473
457a2ff2a71b set Vinfo_file and Vinfo_program variables directly from command line options
John W. Eaton <jwe@octave.org>
parents: 15472
diff changeset
58 #include "help.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
59 #include "input.h"
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
60 #include "lex.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
61 #include "load-path.h"
17755
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
62 #include "load-save.h"
4113
f4bf4833e6c7 [project @ 2002-10-17 19:58:42 by jwe]
jwe
parents: 4101
diff changeset
63 #include "octave.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1711
diff changeset
64 #include "oct-hist.h"
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
65 #include "oct-map.h"
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13239
diff changeset
66 #include "oct-mutex.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
67 #include "ovl.h"
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2277
diff changeset
68 #include "ops.h"
17777
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
69 #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
70 #include "ov.h"
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents: 14619
diff changeset
71 #include "ov-classdef.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
72 #include "ov-range.h"
1670
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1669
diff changeset
73 #include "toplev.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
74 #include "parse.h"
562
50bf8d1b024e [project @ 1994-07-25 23:19:11 by jwe]
jwe
parents: 560
diff changeset
75 #include "procstream.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
76 #include "sighandlers.h"
21186
7f35125714b4 don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents: 21040
diff changeset
77 #include "siglist.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
78 #include "sysdep.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
79 #include "unwind-prot.h"
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
80 #include "utils.h"
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
81 #include "variables.h"
2492
06595bc7f2d0 [project @ 1996-11-09 00:13:50 by jwe]
jwe
parents: 2470
diff changeset
82 #include <version.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
83
4159
e9e2055ad0af [project @ 2002-11-08 03:27:35 by jwe]
jwe
parents: 4157
diff changeset
84 // Kluge.
5990
d90d089a9d32 [project @ 2006-09-15 14:34:57 by jwe]
jwe
parents: 5904
diff changeset
85 extern "C" F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11368
diff changeset
86 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11368
diff changeset
87 const octave_idx_type&
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
88 F77_CHAR_ARG_LEN_DECL);
4159
e9e2055ad0af [project @ 2002-11-08 03:27:35 by jwe]
jwe
parents: 4157
diff changeset
89
2910
1da1af95082e [project @ 1997-04-30 06:42:17 by jwe]
jwe
parents: 2897
diff changeset
90 extern void install_builtins (void);
1da1af95082e [project @ 1997-04-30 06:42:17 by jwe]
jwe
parents: 2897
diff changeset
91
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
92 int octave_cmdline_argc;
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
93 char **octave_cmdline_argv;
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
94 int octave_embedded;
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
95
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
96 // The command-line options.
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
97 static string_vector octave_argv;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
98
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
99 // The name used to invoke Octave.
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
100 static std::string octave_program_invocation_name;
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
101
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
102 // The last component of octave_program_invocation_name.
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
103 static std::string octave_program_name;
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
104
16210
78365c56a762 make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
105 // TRUE means we are using readline.
78365c56a762 make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
106 // (--no-line-editing)
78365c56a762 make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
107 static bool line_editing = true;
78365c56a762 make global line_editing variable static in octave.cc
John W. Eaton <jwe@octave.org>
parents: 16208
diff changeset
108
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
109 // TRUE means we read ~/.octaverc and ./.octaverc.
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
110 // (--norc; --no-init-file; -f)
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
111 static bool read_init_files = true;
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
112
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
113 // TRUE means we read the site-wide octaverc files.
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
114 // (--norc; --no-site-file; -f)
2240
e759180dd7db [project @ 1996-05-22 02:42:17 by jwe]
jwe
parents: 2239
diff changeset
115 static bool read_site_files = true;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
116
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6159
diff changeset
117 // TRUE means we set the initial path to configured defaults.
9132
eb1747dbd360 Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents: 9009
diff changeset
118 // (--no-init-path)
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6159
diff changeset
119 static bool set_initial_path = true;
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6159
diff changeset
120
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3014
diff changeset
121 // TRUE means we don't print the usual startup message.
616
9ced66fce8a3 [project @ 1994-08-15 04:16:37 by jwe]
jwe
parents: 614
diff changeset
122 // (--quiet; --silent; -q)
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
123 static bool inhibit_startup_message = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
124
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3014
diff changeset
125 // If TRUE, print verbose info in some cases.
1825
8219d9b7cb73 [project @ 1996-02-02 01:00:57 by jwe]
jwe
parents: 1821
diff changeset
126 // (--verbose; -V)
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
127 static bool verbose_flag = false;
1825
8219d9b7cb73 [project @ 1996-02-02 01:00:57 by jwe]
jwe
parents: 1821
diff changeset
128
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
129 // If TRUE, force the GUI to start.
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
130 // (--force-gui)
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
131 static bool force_gui_option = false;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
132
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
133 // If TRUE don't start the GUI.
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
134 // (--no-gui)
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
135 static bool no_gui_option = false;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
136
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
137 // If TRUE, force readline command line editing.
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
138 // (--line-editing)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
139 static bool forced_line_editing = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
140
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
141 // If TRUE, initialize history list from saved history file.
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
142 // (--no-history; -H)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
143 static bool read_history_file = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
144
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
145 // The value of "path" specified on the command line.
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
146 // (--path; -p)
15225
2d337a9869e9 correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents: 15224
diff changeset
147 static std::list<std::string> command_line_path;
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
148
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
149 // The value for "EXEC_PATH" specified on the command line.
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
150 // (--exec-path)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
151 static std::string exec_path;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
152
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
153 // The value for "IMAGE_PATH" specified on the command line.
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
154 // (--image-path)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
155 static std::string image_path;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
156
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
157 // If TRUE, ignore the window system even if it is available.
16774
8d188159ce5f Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents: 16753
diff changeset
158 // (--no-window-system, -W)
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
159 static bool no_window_system = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
160
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
161 // The code to evaluate at startup
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
162 // (--eval CODE)
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
163 static std::string code_to_eval;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
164
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
165 // If TRUE, don't exit after evaluating code given by --eval option.
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
166 // (--persist)
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
167 static bool persist = false;
4356
b6ad3db48255 [project @ 2003-02-22 02:57:33 by jwe]
jwe
parents: 4324
diff changeset
168
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
169 // If TRUE, the GUI should be started.
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
170 static bool start_gui = false;
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
171
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
172 // If TRUE use traditional (maximally MATLAB compatible) settings
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
173 // (--traditional)
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
174 static bool traditional = false;
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
175
19850
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
176 // TRUE if this is a program and no interpreter and interaction is
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
177 // needed. For example, an octave program with shebang line, or code
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
178 // from eval without persist.
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
179 static bool an_octave_program = false;
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
180
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
181 // Store the command-line options for later use.
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
182
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
183 static void
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
184 intern_argv (int argc, char **argv)
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
185 {
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
186 assert (symbol_table::at_top_level ());
4892
7e5370e5c7ee [project @ 2004-05-07 17:37:47 by jwe]
jwe
parents: 4829
diff changeset
187
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16210
diff changeset
188 symbol_table::assign (".nargin.", argc - 1);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
189
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
190 symbol_table::mark_hidden (".nargin.");
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3189
diff changeset
191
10485
b4e14e628fc9 Truncate argv() for scripts used without command line parameters. Bug #29423
Judd Storrs <jstorrs@gmail.com>
parents: 10370
diff changeset
192 if (argc > 0)
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
193 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7202
diff changeset
194 octave_argv.resize (argc - 1);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3922
diff changeset
195
2495
29cd3862a9dc [project @ 1996-11-11 02:39:49 by jwe]
jwe
parents: 2492
diff changeset
196 // Skip program name in argv.
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3922
diff changeset
197 int i = argc;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3922
diff changeset
198 while (--i > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
199 octave_argv[i-1] = *(argv+i);
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
200 }
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
201 }
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
202
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
203 DEFUN (__version_info__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
204 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20849
diff changeset
205 @deftypefn {} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
206 Undocumented internal function.\n\
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
207 @end deftypefn")
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
208 {
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
209 static octave_map vinfo;
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
210
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
211 int nargin = args.length ();
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
212
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
213 if (nargin != 0 && nargin != 4)
994c0859ab8b maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20756
diff changeset
214 print_usage ();
994c0859ab8b maint: Refactor C++ calls to print_usage to resemble m-files (2015 code sprint)
Mike Miller <mtmiller@octave.org>
parents: 20756
diff changeset
215
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
216 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
217
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
218 if (nargin == 0)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
219 retval = vinfo;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
220 else if (nargin == 4)
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
221 {
6639
ed74670db09b [project @ 2007-05-21 19:47:22 by jwe]
jwe
parents: 6615
diff changeset
222 if (vinfo.nfields () == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
223 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
224 vinfo.assign ("Name", args(0));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
225 vinfo.assign ("Version", args(1));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
226 vinfo.assign ("Release", args(2));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
227 vinfo.assign ("Date", args(3));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
228 }
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5780
diff changeset
229 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
230 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
231 octave_idx_type n = vinfo.numel () + 1;
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
232
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
233 vinfo.resize (dim_vector (n, 1));
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5780
diff changeset
234
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
235 octave_value idx (n);
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5780
diff changeset
236
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
237 vinfo.assign (idx, "Name", Cell (octave_value (args(0))));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
238 vinfo.assign (idx, "Version", Cell (octave_value (args(1))));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
239 vinfo.assign (idx, "Release", Cell (octave_value (args(2))));
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
240 vinfo.assign (idx, "Date", Cell (octave_value (args(3))));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
241 }
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
242 }
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
243
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
244 return retval;
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
245 }
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
246
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
247 static void
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
248 initialize_version_info (void)
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
249 {
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
250 octave_value_list args;
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
251
5658
7b45fda21557 [project @ 2006-03-10 03:57:23 by jwe]
jwe
parents: 5654
diff changeset
252 args(3) = OCTAVE_RELEASE_DATE;
7b45fda21557 [project @ 2006-03-10 03:57:23 by jwe]
jwe
parents: 5654
diff changeset
253 args(2) = OCTAVE_RELEASE;
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
254 args(1) = OCTAVE_VERSION;
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
255 args(0) = "GNU Octave";
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
256
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
257 F__version_info__ (args, 0);
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
258 }
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
259
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
260 static void
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
261 gripe_safe_source_exception (const std::string& file, const std::string& msg)
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
262 {
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
263 std::cerr << "error: " << msg << "\n"
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
264 << "error: execution of " << file << " failed\n"
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
265 << "error: trying to make my way to a command prompt"
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
266 << std::endl;
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
267 }
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
268
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
269 // Execute commands from a file and catch potential exceptions in a consistent
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
270 // way. This function should be called anywhere we might parse and execute
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
271 // commands from a file before before we have entered the main loop in
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
272 // toplev.cc.
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
273
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
274 static void
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
275 safe_source_file (const std::string& file_name,
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 20957
diff changeset
276 const std::string& context = "",
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
277 bool verbose = false, bool require_file = true,
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 20957
diff changeset
278 const std::string& warn_for = "")
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
279 {
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
280 try
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
281 {
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
282 source_file (file_name, context, verbose, require_file, warn_for);
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
283 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20487
diff changeset
284 catch (const octave_interrupt_exception&)
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
285 {
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
286 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
287
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
288 octave_stdout << "\n";
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
289
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
290 if (quitting_gracefully)
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
291 clean_up_and_exit (exit_status);
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
292 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20487
diff changeset
293 catch (const octave_execution_exception&)
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
294 {
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
295 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
296
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
297 gripe_safe_source_exception (file_name, "unhandled execution exception");
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
298 }
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
299 }
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
300
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 578
diff changeset
301 // Initialize by reading startup files.
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 578
diff changeset
302
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
303 static void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
304 execute_startup_files (void)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
305 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
306 unwind_protect frame;
315
260863721a51 [project @ 1994-01-28 04:22:45 by jwe]
jwe
parents: 290
diff changeset
307
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
308 std::string context;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
309
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
310 bool verbose = (verbose_flag && ! inhibit_startup_message);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
311
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
312 bool require_file = false;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 565
diff changeset
313
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
314 if (read_site_files)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
315 {
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
316 // Execute commands from the site-wide configuration file.
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
317 // First from the file $(prefix)/lib/octave/site/m/octaverc
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
318 // (if it exists), then from the file
3597
26662775f4e9 [project @ 2000-02-12 02:24:41 by jwe]
jwe
parents: 3566
diff changeset
319 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists).
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1744
diff changeset
320
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
321 safe_source_file (Vlocal_site_defaults_file, context, verbose,
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
322 require_file);
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1744
diff changeset
323
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
324 safe_source_file (Vsite_defaults_file, context, verbose, require_file);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
325 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
326
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
327 if (read_init_files)
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
328 {
2512
fda09c1e787e [project @ 1996-11-14 08:39:41 by jwe]
jwe
parents: 2495
diff changeset
329 // Try to execute commands from $HOME/$OCTAVE_INITFILE and
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19529
diff changeset
330 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set,
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
331 // .octaverc is assumed.
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
332
4804
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
333 bool home_rc_already_executed = false;
2512
fda09c1e787e [project @ 1996-11-14 08:39:41 by jwe]
jwe
parents: 2495
diff changeset
334
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
335 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE");
2512
fda09c1e787e [project @ 1996-11-14 08:39:41 by jwe]
jwe
parents: 2495
diff changeset
336
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
337 if (initfile.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
338 initfile = ".octaverc";
2512
fda09c1e787e [project @ 1996-11-14 08:39:41 by jwe]
jwe
parents: 2495
diff changeset
339
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
340 std::string home_dir = octave_env::get_home_directory ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
341
4804
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
342 std::string home_rc = octave_env::make_absolute (initfile, home_dir);
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
343
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
344 std::string local_rc;
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
345
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5780
diff changeset
346 if (! home_rc.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
347 {
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
348 safe_source_file (home_rc, context, verbose, require_file);
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
349
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
350 // Names alone are not enough.
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
351
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
352 file_stat fs_home_rc (home_rc);
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
353
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
354 if (fs_home_rc)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
356 // We want to check for curr_dir after executing home_rc
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
357 // because doing that may change the working directory.
4804
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
358
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
359 local_rc = octave_env::make_absolute (initfile);
4804
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
360
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
361 home_rc_already_executed = same_file (home_rc, local_rc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
362 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
363 }
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
364
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
365 if (! home_rc_already_executed)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
366 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
367 if (local_rc.empty ())
10250
2d47356a7a1a use gnulib getcwd module
John W. Eaton <jwe@octave.org>
parents: 10244
diff changeset
368 local_rc = octave_env::make_absolute (initfile);
4804
6202d9b75f83 [project @ 2004-02-27 16:40:59 by jwe]
jwe
parents: 4753
diff changeset
369
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
370 safe_source_file (local_rc, context, verbose, require_file);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10250
diff changeset
371 }
2239
4d12b52750cb [project @ 1996-05-22 02:38:16 by jwe]
jwe
parents: 2212
diff changeset
372 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
373 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
374
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
375 static int
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
376 execute_eval_option_code (const std::string& code)
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
377 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
378 unwind_protect frame;
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
379
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
380 octave_save_signal_mask ();
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
381
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
382 can_interrupt = true;
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
383
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
384 octave_signal_hook = octave_signal_handler;
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
385 octave_interrupt_hook = 0;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
386 octave_bad_alloc_hook = 0;
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
387
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
388 octave_catch_interrupts ();
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
389
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
390 octave_initialized = true;
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
391
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
392 frame.protect_var (interactive);
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
393
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
394 interactive = false;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
395
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
396 int parse_status = 0;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
397
6487
ef5113474882 [project @ 2007-04-04 15:31:37 by jwe]
jwe
parents: 6365
diff changeset
398 try
ef5113474882 [project @ 2007-04-04 15:31:37 by jwe]
jwe
parents: 6365
diff changeset
399 {
ef5113474882 [project @ 2007-04-04 15:31:37 by jwe]
jwe
parents: 6365
diff changeset
400 eval_string (code, false, parse_status, 0);
ef5113474882 [project @ 2007-04-04 15:31:37 by jwe]
jwe
parents: 6365
diff changeset
401 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20487
diff changeset
402 catch (const octave_interrupt_exception&)
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
403 {
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
404 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
405
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
406 octave_stdout << "\n";
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
407
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
408 if (quitting_gracefully)
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
409 clean_up_and_exit (exit_status);
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
410 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20487
diff changeset
411 catch (const octave_execution_exception&)
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
412 {
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
413 recover_from_exception ();
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
414
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
415 std::cerr << "error: unhandled execution exception -- eval failed"
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
416 << std::endl;
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
417 }
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
418
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
419 return parse_status;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
420 }
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
421
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
422 static void
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
423 execute_command_line_file (const std::string& fname)
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
424 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
425 unwind_protect frame;
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
426
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
427 octave_save_signal_mask ();
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
428
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
429 can_interrupt = true;
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
430
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
431 octave_signal_hook = octave_signal_handler;
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
432 octave_interrupt_hook = 0;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
433 octave_bad_alloc_hook = 0;
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
434
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
435 octave_catch_interrupts ();
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
436
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
437 octave_initialized = true;
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7017
diff changeset
438
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
439 frame.protect_var (interactive);
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
440
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
441 frame.protect_var (octave_program_invocation_name);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9999
diff changeset
442 frame.protect_var (octave_program_name);
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
443
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
444 interactive = false;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
445
16203
127cccb037bf move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents: 16199
diff changeset
446 octave_program_invocation_name = fname;
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
447
16203
127cccb037bf move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents: 16199
diff changeset
448 size_t pos = fname.find_last_of (file_ops::dir_sep_chars ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
449
16203
127cccb037bf move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents: 16199
diff changeset
450 octave_program_name
127cccb037bf move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents: 16199
diff changeset
451 = (pos != std::string::npos) ? fname.substr (pos+1) : fname;
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
452
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
453 std::string context;
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
454 bool verbose = false;
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
455 bool require_file = true;
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7481
diff changeset
456
11368
944b7e20fc5a improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents: 11234
diff changeset
457 safe_source_file (fname, context, verbose, require_file, "octave");
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
458 }
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
459
21040
3e7cfee5f786 maint: Rename attributes GCC_ATTR_XXX to OCTAVE_XXX.
Rik <rik@octave.org>
parents: 21037
diff changeset
460 OCTAVE_NORETURN static void
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
461 lo_error_handler (const char *fmt, ...)
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
462 {
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
463 va_list args;
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
464 va_start (args, fmt);
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9724
diff changeset
465 verror_with_cfn (fmt, args);
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
466 va_end (args);
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
467
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
468 octave_throw_execution_exception ();
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
469 }
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
470
21040
3e7cfee5f786 maint: Rename attributes GCC_ATTR_XXX to OCTAVE_XXX.
Rik <rik@octave.org>
parents: 21037
diff changeset
471 OCTAVE_NORETURN static void
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
472 lo_error_with_id_handler (const char *id, const char *fmt, ...)
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
473 {
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
474 va_list args;
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
475 va_start (args, fmt);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
476 verror_with_id_cfn (id, fmt, args);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
477 va_end (args);
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
478
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
479 octave_throw_execution_exception ();
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
480 }
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
481
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
482 static void
721
54a6858bc7e7 [project @ 1994-09-21 15:17:38 by jwe]
jwe
parents: 712
diff changeset
483 initialize_error_handlers ()
54a6858bc7e7 [project @ 1994-09-21 15:17:38 by jwe]
jwe
parents: 712
diff changeset
484 {
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
485 set_liboctave_error_handler (lo_error_handler);
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
486 set_liboctave_error_with_id_handler (lo_error_with_id_handler);
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3259
diff changeset
487 set_liboctave_warning_handler (warning);
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5780
diff changeset
488 set_liboctave_warning_with_id_handler (warning_with_id);
721
54a6858bc7e7 [project @ 1994-09-21 15:17:38 by jwe]
jwe
parents: 712
diff changeset
489 }
54a6858bc7e7 [project @ 1994-09-21 15:17:38 by jwe]
jwe
parents: 712
diff changeset
490
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
491 // What internal options get configured by --traditional.
1410
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
492
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
493 static void
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
494 maximum_braindamage (void)
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
495 {
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
496 persist = true;
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
497
15475
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
498 FPS1 (octave_value (">> "));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
499 FPS2 (octave_value (""));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
500 FPS4 (octave_value (""));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
501 Fbeep_on_error (octave_value (true));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
502 Fconfirm_recursive_rmdir (octave_value (false));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
503 Fcrash_dumps_octave_core (octave_value (false));
19391
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19030
diff changeset
504 Fdisable_diagonal_matrix (octave_value (true));
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19030
diff changeset
505 Fdisable_permutation_matrix (octave_value (true));
19394
b39cbe9f3bb0 allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents: 19391
diff changeset
506 Fdisable_range (octave_value (true));
15475
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
507 Ffixed_point_format (octave_value (true));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
508 Fhistory_timestamp_format_string (octave_value ("%%-- %D %I:%M %p --%%"));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
509 Fpage_screen_output (octave_value (false));
da6c37ed0b42 eliminate calls to bind_internal_variable when setting --traditional options
John W. Eaton <jwe@octave.org>
parents: 15474
diff changeset
510 Fprint_empty_dimensions (octave_value (false));
19391
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19030
diff changeset
511 Fsave_default_options (octave_value ("-mat-binary"));
18153
ab26db8da20a set struct levels to print to 0 for --traditional (bug #40955)
John W. Eaton <jwe@octave.org>
parents: 18130
diff changeset
512 Fstruct_levels_to_print (octave_value (0));
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5844
diff changeset
513
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9383
diff changeset
514 disable_warning ("Octave:abbreviated-property-match");
19030
9ef10e6a5987 make "file found in path" warnings consistent
John W. Eaton <jwe@octave.org>
parents: 18159
diff changeset
515 disable_warning ("Octave:data-file-in-path");
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5844
diff changeset
516 disable_warning ("Octave:function-name-clash");
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
517 disable_warning ("Octave:possible-matlab-short-circuit-operator");
1410
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
518 }
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
519
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
520 // EMBEDDED is declared int instead of bool because this function is
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
521 // declared extern "C".
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 578
diff changeset
522
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
523 int
4368
c45874c087c7 [project @ 2003-03-17 14:01:56 by jwe]
jwe
parents: 4356
diff changeset
524 octave_main (int argc, char **argv, int embedded)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
525 {
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
526 octave_process_command_line (argc, argv);
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
527
16540
63b144e6a3d0 partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
528 sysdep_init ();
63b144e6a3d0 partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
529
63b144e6a3d0 partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
530 install_defaults ();
63b144e6a3d0 partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
531
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
532 octave_initialize_interpreter (argc, argv, embedded);
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
533
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
534 return octave_execute_interpreter ();
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
535 }
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
536
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
537 void
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
538 octave_process_command_line (int argc, char **argv)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
539 {
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
540 octave_cmdline_argc = argc;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
541 octave_cmdline_argv = argv;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
542
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
543 while (true)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
544 {
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
545 int long_idx;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
546
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
547 int optc = getopt_long (argc, argv, short_opts, long_opts, &long_idx);
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
548
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
549 if (optc < 0)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
550 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
551
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
552 switch (optc)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
553 {
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
554 case '?':
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
555 // Unrecognized option. getopt_long already printed a message about
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
556 // it, so we will just print the usage string and exit.
17777
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
557 octave_print_terse_usage_and_exit ();
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
558 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
559
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
560 case 'H':
16876
9e0618443c2b Rename saving_history() to history_save().
Rik <rik@octave.org>
parents: 16875
diff changeset
561 Fhistory_save (octave_value (false));
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
562 read_history_file = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
563 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
564
16774
8d188159ce5f Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents: 16753
diff changeset
565 case 'W':
8d188159ce5f Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents: 16753
diff changeset
566 no_window_system = true;
8d188159ce5f Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents: 16753
diff changeset
567 break;
8d188159ce5f Add -W command line option to disable window system (bug #38937)
Rik <rik@octave.org>
parents: 16753
diff changeset
568
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
569 case 'V':
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
570 verbose_flag = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
571 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
572
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
573 case 'd':
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
574 // This is the same as yydebug in parse.y.
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
575 octave_debug++;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
576 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
577
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
578 case 'f':
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
579 read_init_files = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
580 read_site_files = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
581 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
582
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
583 case 'h':
17777
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
584 octave_print_verbose_usage_and_exit ();
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
585 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
586
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
587 case 'i':
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
588 forced_interactive = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
589 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
590
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
591 case 'p':
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
592 if (optarg)
15225
2d337a9869e9 correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents: 15224
diff changeset
593 command_line_path.push_back (optarg);
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
594 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
595
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
596 case 'q':
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
597 inhibit_startup_message = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
598 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
599
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
600 case 'x':
15477
8b5fc510c6d6 don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents: 15476
diff changeset
601 {
8b5fc510c6d6 don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents: 15476
diff changeset
602 int val = ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE;
8b5fc510c6d6 don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents: 15476
diff changeset
603 Fecho_executing_commands (octave_value (val));
8b5fc510c6d6 don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents: 15476
diff changeset
604 }
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
605 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
606
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
607 case 'v':
17777
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
608 octave_print_version_and_exit ();
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
609 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
610
15470
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
611 case BUILT_IN_DOCSTRINGS_FILE_OPTION:
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
612 if (optarg)
15480
c7d7d43f26bb call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents: 15479
diff changeset
613 Fbuilt_in_docstrings_file (octave_value (optarg));
15470
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
614 break;
bf0857c789f4 initialize docstrings for built-in functions from file
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
615
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
616 case DOC_CACHE_FILE_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
617 if (optarg)
15480
c7d7d43f26bb call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents: 15479
diff changeset
618 Fdoc_cache_file (octave_value (optarg));
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
619 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
620
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
621 case EVAL_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
622 if (optarg)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
623 {
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
624 if (code_to_eval.empty ())
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
625 code_to_eval = optarg;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
626 else
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
627 code_to_eval += std::string (" ") + optarg;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
628 }
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
629 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
630
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
631 case EXEC_PATH_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
632 if (optarg)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
633 exec_path = optarg;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
634 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
635
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
636 case FORCE_GUI_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
637 force_gui_option = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
638 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
639
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
640 case IMAGE_PATH_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
641 if (optarg)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
642 image_path = optarg;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
643 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
644
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
645 case INFO_FILE_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
646 if (optarg)
15480
c7d7d43f26bb call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents: 15479
diff changeset
647 Finfo_file (octave_value (optarg));
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
648 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
649
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
650 case INFO_PROG_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
651 if (optarg)
15480
c7d7d43f26bb call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents: 15479
diff changeset
652 Finfo_program (octave_value (optarg));
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
653 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
654
16877
5482cd26311a Rename enable_jit_compiler to jit_enable, enable_jit_debugging to debug_jit.
Rik <rik@octave.org>
parents: 16876
diff changeset
655 case DEBUG_JIT_OPTION:
5482cd26311a Rename enable_jit_compiler to jit_enable, enable_jit_debugging to debug_jit.
Rik <rik@octave.org>
parents: 16876
diff changeset
656 Fdebug_jit (octave_value (true));
15310
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
657 break;
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
658
17792
26e9312e6928 Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents: 17787
diff changeset
659 case JIT_COMPILER_OPTION:
26e9312e6928 Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents: 17787
diff changeset
660 Fjit_enable (octave_value (true));
26e9312e6928 Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents: 17787
diff changeset
661 break;
26e9312e6928 Build JIT compiler by default, but do not enable it by default.
Rik <rik@octave.org>
parents: 17787
diff changeset
662
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
663 case LINE_EDITING_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
664 forced_line_editing = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
665 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
666
15310
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
667 case NO_GUI_OPTION:
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
668 no_gui_option = true;
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
669 break;
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
670
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
671 case NO_INIT_FILE_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
672 read_init_files = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
673 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
674
15310
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
675 case NO_INIT_PATH_OPTION:
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15290
diff changeset
676 set_initial_path = false;
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
677 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
678
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
679 case NO_LINE_EDITING_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
680 line_editing = false;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
681 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
682
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
683 case NO_SITE_FILE_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
684 read_site_files = 0;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
685 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
686
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
687 case PERSIST_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
688 persist = true;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
689 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
690
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
691 case TEXI_MACROS_FILE_OPTION:
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
692 if (optarg)
15480
c7d7d43f26bb call Ffoo functions instead of setting Vfoo directly.
John W. Eaton <jwe@octave.org>
parents: 15479
diff changeset
693 Ftexi_macros_file (octave_value (optarg));
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
694 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
695
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
696 case TRADITIONAL_OPTION:
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
697 traditional = true;
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
698 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
699
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
700 default:
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
701 // getopt_long should print a message about unrecognized options and
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
702 // return '?', which is handled above. If we end up here, it is
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
703 // because there was an option but we forgot to handle it.
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
704 // That should be fatal.
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
705 panic_impossible ();
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
706 break;
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
707 }
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
708 }
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
709
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
710 // Check for various incompatible argument pairs
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
711 if (force_gui_option && no_gui_option)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
712 {
20957
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20940
diff changeset
713 warning ("only one of --force-gui and --no-gui may be used");
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
714
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
715 octave_print_terse_usage_and_exit ();
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
716 }
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
717
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
718 bool script_file = (argc - optind) > 0;
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
719 if (! code_to_eval.empty () && script_file)
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
720 {
20957
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20940
diff changeset
721 warning ("--eval \"CODE\" and script file are mutually exclusive options");
17777
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
722
ae8905fbf1f8 move usage and options strings and funtions to separate file
John W. Eaton <jwe@octave.org>
parents: 17755
diff changeset
723 octave_print_terse_usage_and_exit ();
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
724 }
20487
779c1d85cf90 Initialize interpreter correctly with script and --traditional (bug #45921)
Mike Miller <mtmiller@octave.org>
parents: 19950
diff changeset
725 an_octave_program = ((script_file || ! code_to_eval.empty ())
779c1d85cf90 Initialize interpreter correctly with script and --traditional (bug #45921)
Mike Miller <mtmiller@octave.org>
parents: 19950
diff changeset
726 && ! persist && ! traditional);
19850
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
727
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
728 }
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
729
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
730 // EMBEDDED is declared int instead of bool because this function is
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
731 // declared extern "C".
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
732
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
733 void
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
734 octave_initialize_interpreter (int argc, char **argv, int embedded)
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
735 {
17811
ef4fc092c86b set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents: 17792
diff changeset
736 // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting
ef4fc092c86b set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents: 17792
diff changeset
737 setlocale (LC_NUMERIC, "C");
17849
e432697a0621 octave.cc: Set LC_TIME to C locale so that dates always compute correctly.
Rik <rik@octave.org>
parents: 17828
diff changeset
738 setlocale (LC_TIME, "C");
19950
e75a0fe1eee2 Set LC_NUMERIC and LC_TIME environment variables to 'C' (bug 44469).
Rik <rik@octave.org>
parents: 19857
diff changeset
739 octave_env::putenv ("LC_NUMERIC", "C");
e75a0fe1eee2 Set LC_NUMERIC and LC_TIME environment variables to 'C' (bug 44469).
Rik <rik@octave.org>
parents: 19857
diff changeset
740 octave_env::putenv ("LC_TIME", "C");
17811
ef4fc092c86b set LC_NUMERIC local to "C" for CLI and GUI (bug #40422)
John W. Eaton <jwe@octave.org>
parents: 17792
diff changeset
741
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
742 octave_embedded = embedded;
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
743
3019
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3014
diff changeset
744 octave_env::set_program_name (argv[0]);
92aa3d651723 [project @ 1997-06-03 22:07:16 by jwe]
jwe
parents: 3014
diff changeset
745
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
746 octave_program_invocation_name = octave_env::get_program_invocation_name ();
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
747 octave_program_name = octave_env::get_program_name ();
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
748
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13239
diff changeset
749 octave_thread::init ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13239
diff changeset
750
16540
63b144e6a3d0 partially undo the changes in 9bc1f8278966
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
751 set_default_prompts ();
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
752
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
753 // Initialize default warning state before --traditional option
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
754 // that may reset them.
18125
60dee9205bb5 set default warning state before modifying for --traditional option
John W. Eaton <jwe@octave.org>
parents: 17849
diff changeset
755
60dee9205bb5 set default warning state before modifying for --traditional option
John W. Eaton <jwe@octave.org>
parents: 17849
diff changeset
756 initialize_default_warning_state ();
60dee9205bb5 set default warning state before modifying for --traditional option
John W. Eaton <jwe@octave.org>
parents: 17849
diff changeset
757
16528
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
758 if (traditional)
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
759 maximum_braindamage ();
9bc1f8278966 allow GUI to customize prompts at startup
John W. Eaton <jwe@octave.org>
parents: 16485
diff changeset
760
5844
034cdbd34c0a [project @ 2006-06-07 15:38:58 by jwe]
jwe
parents: 5832
diff changeset
761 init_signals ();
034cdbd34c0a [project @ 2006-06-07 15:38:58 by jwe]
jwe
parents: 5832
diff changeset
762
11234
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11157
diff changeset
763 octave_ieee_init ();
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11157
diff changeset
764
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
765 // The idea here is to force xerbla to be referenced so that we will link to
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
766 // our own version instead of the one provided by the BLAS library. But
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
767 // octave_NaN should never be -1, so we should never actually call xerbla.
4159
e9e2055ad0af [project @ 2002-11-08 03:27:35 by jwe]
jwe
parents: 4157
diff changeset
768
e9e2055ad0af [project @ 2002-11-08 03:27:35 by jwe]
jwe
parents: 4157
diff changeset
769 if (octave_NaN == -1)
11157
c75130f19440 octave.cc: fix call to xerbla
John W. Eaton <jwe@octave.org>
parents: 11140
diff changeset
770 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6));
4159
e9e2055ad0af [project @ 2002-11-08 03:27:35 by jwe]
jwe
parents: 4157
diff changeset
771
721
54a6858bc7e7 [project @ 1994-09-21 15:17:38 by jwe]
jwe
parents: 712
diff changeset
772 initialize_error_handlers ();
223
82c050e70f7a [project @ 1993-11-14 10:58:11 by jwe]
jwe
parents: 206
diff changeset
773
4368
c45874c087c7 [project @ 2003-03-17 14:01:56 by jwe]
jwe
parents: 4356
diff changeset
774 if (! embedded)
c45874c087c7 [project @ 2003-03-17 14:01:56 by jwe]
jwe
parents: 4356
diff changeset
775 install_signal_handlers ();
9255
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
776 else
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
777 quit_allowed = false;
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
778
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
779 initialize_file_io ();
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
780
2375
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2277
diff changeset
781 install_types ();
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2277
diff changeset
782
7ef24992e290 [project @ 1996-10-12 00:39:52 by jwe]
jwe
parents: 2277
diff changeset
783 install_ops ();
2205
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
784
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
785 install_builtins ();
bd389b53befa [project @ 1996-05-15 06:15:45 by jwe]
jwe
parents: 2095
diff changeset
786
15843
622f3f794162 Re-instate classdef bootstrapping.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15838
diff changeset
787 install_classdef ();
622f3f794162 Re-instate classdef bootstrapping.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15838
diff changeset
788
15225
2d337a9869e9 correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents: 15224
diff changeset
789 for (std::list<std::string>::const_iterator it = command_line_path.begin ();
2d337a9869e9 correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents: 15224
diff changeset
790 it != command_line_path.end (); it++)
2d337a9869e9 correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents: 15224
diff changeset
791 load_path::set_command_line_path (*it);
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 721
diff changeset
792
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
793 if (! exec_path.empty ())
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
794 set_exec_path (exec_path);
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
795
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
796 if (! image_path.empty ())
15327
cc18c566a7cd Fix --image-path option
Mike Miller <mtmiller@ieee.org>
parents: 15310
diff changeset
797 set_image_path (image_path);
777
a2f9d3fd720c [project @ 1994-10-07 14:01:53 by jwe]
jwe
parents: 721
diff changeset
798
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
799 if (no_window_system)
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
800 display_info::no_window_system ();
1410
5f2cd468a1c3 [project @ 1995-09-15 06:44:52 by jwe]
jwe
parents: 1363
diff changeset
801
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
802 // Is input coming from a terminal? If so, we are probably interactive.
9320
080dc45ea682 don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents: 9260
diff changeset
803
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9753
diff changeset
804 // If stdin is not a tty, then we are reading commands from a pipe or
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9753
diff changeset
805 // a redirected file.
16208
ed91ab4d4515 eliminate stdin_is_tty global variable
John W. Eaton <jwe@octave.org>
parents: 16203
diff changeset
806 bool stdin_is_tty = gnulib::isatty (fileno (stdin));
9999
653716f3d976 get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents: 9753
diff changeset
807
19850
f81a1da191e4 Script file or eval code are not interactive session so keep Octave quiet.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
808 interactive = (! embedded && ! an_octave_program && stdin_is_tty
14160
ebcb0f83698f use gnulib::isatty
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
809 && gnulib::isatty (fileno (stdout)));
9320
080dc45ea682 don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents: 9260
diff changeset
810
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
811 // Check if the user forced an interactive session. If he
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
812 // unnecessarily did so, reset forced_interactive to false.
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
813 if (forced_interactive)
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
814 {
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
815 if (interactive)
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
816 forced_interactive = false;
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
817 else
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
818 interactive = true;
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
819 }
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
820
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
821 if ((! interactive || forced_interactive) && ! forced_line_editing)
9320
080dc45ea682 don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents: 9260
diff changeset
822 line_editing = false;
080dc45ea682 don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents: 9260
diff changeset
823
19602
f3ac54ac2c6a also skip startup message if session is not interactive
John W. Eaton <jwe@octave.org>
parents: 19600
diff changeset
824 // Also skip start-up message unless session is interactive.
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
825 if (! interactive)
19602
f3ac54ac2c6a also skip startup message if session is not interactive
John W. Eaton <jwe@octave.org>
parents: 19600
diff changeset
826 inhibit_startup_message = true;
f3ac54ac2c6a also skip startup message if session is not interactive
John W. Eaton <jwe@octave.org>
parents: 19600
diff changeset
827
9321
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 9320
diff changeset
828 // Force default line editor if we don't want readline editing.
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 9320
diff changeset
829 if (! line_editing)
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 9320
diff changeset
830 command_editor::force_default_editor ();
9b87aeb24ea9 avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents: 9320
diff changeset
831
1358
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1355
diff changeset
832 // These can come after command line args since none of them set any
dc9c01f66a19 [project @ 1995-09-05 21:10:01 by jwe]
jwe
parents: 1355
diff changeset
833 // defaults that might be changed by command line options.
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 578
diff changeset
834
9320
080dc45ea682 don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents: 9260
diff changeset
835 if (line_editing)
080dc45ea682 don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents: 9260
diff changeset
836 initialize_command_input ();
315
260863721a51 [project @ 1994-01-28 04:22:45 by jwe]
jwe
parents: 290
diff changeset
837
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4159
diff changeset
838 octave_interpreter_ready = true;
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4159
diff changeset
839
5654
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
840 initialize_version_info ();
6aae52010e3b [project @ 2006-03-09 19:04:53 by jwe]
jwe
parents: 5502
diff changeset
841
8099
e0a6e54f5a19 octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents: 8021
diff changeset
842 // Make all command-line arguments available to startup files,
e0a6e54f5a19 octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents: 8021
diff changeset
843 // including PKG_ADD files.
e0a6e54f5a19 octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents: 8021
diff changeset
844
e0a6e54f5a19 octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents: 8021
diff changeset
845 intern_argv (argc, argv);
e0a6e54f5a19 octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents: 8021
diff changeset
846
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6159
diff changeset
847 load_path::initialize (set_initial_path);
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4159
diff changeset
848
13239
3109c8b0cff4 Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12855
diff changeset
849 initialize_history (read_history_file);
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
850 }
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
851
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
852 int
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
853 octave_execute_interpreter (void)
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
854 {
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
855 if (! inhibit_startup_message)
17510
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 16877
diff changeset
856 std::cout << octave_startup_message () << "\n" << std::endl;
1651
e846e361a265 [project @ 1995-12-20 06:59:12 by jwe]
jwe
parents: 1613
diff changeset
857
17755
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
858 octave_prepare_hdf5 ();
9c03b071fd7b avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
859
13239
3109c8b0cff4 Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 12855
diff changeset
860 execute_startup_files ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
861
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 565
diff changeset
862 if (! inhibit_startup_message && reading_startup_message_printed)
3538
0ff7323dab8b [project @ 2000-02-02 12:36:25 by jwe]
jwe
parents: 3531
diff changeset
863 std::cout << std::endl;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 565
diff changeset
864
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
865 // Execute any code specified with --eval 'CODE'
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
866 if (! code_to_eval.empty ())
149
471912bc76c4 [project @ 1993-10-05 19:11:06 by jwe]
jwe
parents: 143
diff changeset
867 {
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
868 int parse_status = 0;
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
869
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
870 try
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
871 {
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
872 parse_status = execute_eval_option_code (code_to_eval);
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
873 }
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
874 catch (const octave_execution_exception&)
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
875 {
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
876 recover_from_exception ();
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
877
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
878 parse_status = 1;
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
879 }
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
880
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
881 if (! persist)
16753
f8f35ddc49a2 exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents: 16540
diff changeset
882 {
f8f35ddc49a2 exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents: 16540
diff changeset
883 quitting_gracefully = true;
f8f35ddc49a2 exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents: 16540
diff changeset
884
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
885 clean_up_and_exit (parse_status);
16753
f8f35ddc49a2 exit gracefully after executing code from --eval
John W. Eaton <jwe@octave.org>
parents: 16540
diff changeset
886 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
887 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
888
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
889 // If there is an extra argument, see if it names a file to read.
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
890 // Additional arguments are taken as command line options for the script.
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
891
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
892 int last_arg_idx = optind;
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
893 int remaining_args = octave_cmdline_argc - last_arg_idx;
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
894
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
895 if (remaining_args > 0)
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
896 {
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
897 // If we are running an executable script (#! /bin/octave) then
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
898 // we should only see the args passed to the script.
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
899
20747
ee2743bd07a8 eliminate various compiler warnings
John W. Eaton <jwe@octave.org>
parents: 20743
diff changeset
900 exit_status = 0;
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
901
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
902 try
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
903 {
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
904 intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx);
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
905
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
906 execute_command_line_file (octave_cmdline_argv[last_arg_idx]);
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
907 }
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
908 catch (const octave_execution_exception&)
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
909 {
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
910 recover_from_exception ();
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20747
diff changeset
911
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
912 exit_status = 1;
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
913 }
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
914
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
915 if (! persist)
14074
f90c3facfac3 don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
916 {
f90c3facfac3 don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
917 quitting_gracefully = true;
f90c3facfac3 don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
918
20743
b6408331bfa2 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
919 clean_up_and_exit (exit_status);
14074
f90c3facfac3 don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
920 }
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
921 }
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
922
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
923 // Avoid counting commands executed from startup files.
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
924
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
925 command_editor::reset_current_command_number (1);
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
926
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
927 // Now argv should have the full set of args.
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
928 intern_argv (octave_cmdline_argc, octave_cmdline_argv);
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
929
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
930 // Force input to be echoed if not really interactive,
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
931 // but the user has forced interactive behavior.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
932
19849
1c9ed5b4c73d input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
933 if (forced_interactive)
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 285
diff changeset
934 {
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2910
diff changeset
935 command_editor::blink_matching_paren (false);
1588
27f5ac98fc4a [project @ 1995-10-31 06:04:47 by jwe]
jwe
parents: 1572
diff changeset
936
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
937 // FIXME: is this the right thing to do?
15477
8b5fc510c6d6 don't use bind_internal_variable when handling -x option
John W. Eaton <jwe@octave.org>
parents: 15476
diff changeset
938 Fecho_executing_commands (octave_value (ECHO_CMD_LINE));
287
6027a905fc06 [project @ 1994-01-13 01:41:00 by jwe]
jwe
parents: 285
diff changeset
939 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
940
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 14619
diff changeset
941 if (octave_embedded)
5502
dae5ba706ff2 [project @ 2005-10-20 06:37:30 by jwe]
jwe
parents: 5307
diff changeset
942 {
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
943 // FIXME: Do we need to do any cleanup here before returning?
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
944 // If we don't, what will happen to Octave functions that have been
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
945 // registered to execute with atexit, for example?
5502
dae5ba706ff2 [project @ 2005-10-20 06:37:30 by jwe]
jwe
parents: 5307
diff changeset
946
dae5ba706ff2 [project @ 2005-10-20 06:37:30 by jwe]
jwe
parents: 5307
diff changeset
947 return 1;
dae5ba706ff2 [project @ 2005-10-20 06:37:30 by jwe]
jwe
parents: 5307
diff changeset
948 }
4368
c45874c087c7 [project @ 2003-03-17 14:01:56 by jwe]
jwe
parents: 4356
diff changeset
949
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 5102
diff changeset
950 int retval = main_loop ();
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
951
14074
f90c3facfac3 don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
952 quitting_gracefully = true;
f90c3facfac3 don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
953
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
954 clean_up_and_exit (retval, true);
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4233
diff changeset
955
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
956 return retval;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
957 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
958
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
959 static bool
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
960 check_starting_gui (void)
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
961 {
17828
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
962 if (no_window_system)
15160
973296940c89 don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
963 return false;
973296940c89 don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
964
17828
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
965 std::string err_msg;
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
966 if (! display_info::display_available (err_msg))
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
967 {
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
968 if (! (inhibit_startup_message || err_msg.empty ()))
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
969 warning (err_msg.c_str ());
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
970
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
971 return false;
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
972 }
6b787e274eb1 make -q suppress no graphical display startup message (bug #38937)
John W. Eaton <jwe@octave.org>
parents: 17811
diff changeset
973
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
974 if (force_gui_option)
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
975 return true;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
976
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
977 if (no_gui_option)
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
978 return false;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
979
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
980 if (persist)
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
981 return true;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
982
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
983 // If stdin is not a tty, then assume we are reading commands from a pipe or
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
984 // a redirected file and the GUI should not start. If this is not the case
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
985 // (for example, starting from a desktop "launcher" with no terminal) and you
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
986 // want to start the GUI, you may use the --force-gui option to start the GUI.
15224
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
987
a44e4a08fc55 perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents: 15223
diff changeset
988 if (! gnulib::isatty (fileno (stdin)))
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
989 return false;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
990
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
991 // If we have code to eval or execute from a file, and we are going to exit
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
992 // immediately after executing it, don't start the gui.
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
993
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
994 int last_arg_idx = optind;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
995 int remaining_args = octave_cmdline_argc - last_arg_idx;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
996
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
997 if (! code_to_eval.empty () || remaining_args > 0)
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
998 return false;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
999
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
1000 return true;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
1001 }
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
1002
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1003 // Return int instead of bool because this function is declared extern "C".
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1004
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1005 int
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1006 octave_starting_gui (void)
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1007 {
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1008 start_gui = check_starting_gui ();
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1009 return start_gui;
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1010 }
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1011
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1012 DEFUN (isguirunning, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1013 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20849
diff changeset
1014 @deftypefn {} {} isguirunning ()\n\
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1015 Return true if Octave is running in GUI mode and false otherwise.\n\
19857
bf511802add7 doc: Add have_window_system() to documentation.
Rik <rik@octave.org>
parents: 19850
diff changeset
1016 @seealso{have_window_system}\n\
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1017 @end deftypefn")
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1018 {
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
1019 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
1020 print_usage ();
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1021
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1022 return ovl (start_gui);
15702
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1023 }
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1024
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1025 /*
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1026 %!assert (islogical (isguirunning ()))
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1027 %!error isguirunning (1)
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1028 */
534b6f7108b7 Add isguirunning function to query whether the GUI is running
Mike Miller <mtmiller@ieee.org>
parents: 15490
diff changeset
1029
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1030 DEFUN (argv, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1031 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20849
diff changeset
1032 @deftypefn {} {} argv ()\n\
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1033 Return the command line arguments passed to Octave.\n\
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1034 \n\
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1035 For example, if you invoked Octave using the command\n\
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1036 \n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1037 @example\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1038 octave --no-line-editing --silent\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1039 @end example\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1040 \n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1041 @noindent\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1042 @code{argv} would return a cell array of strings with the elements\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10731
diff changeset
1043 @option{--no-line-editing} and @option{--silent}.\n\
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1044 \n\
19525
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1045 If you write an executable Octave script, @code{argv} will return the list\n\
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1046 of arguments passed to the script. @xref{Executable Octave Programs}, for\n\
18377fc879d0 Make cmd-line options for --eval, script file, '< script' mutually exclusive (bug #35318).
Rik <rik@octave.org>
parents: 19394
diff changeset
1047 an example of how to create an executable Octave script.\n\
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1048 @end deftypefn")
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1049 {
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
1050 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
1051 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1052
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1053 return ovl (Cell (octave_argv));
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1054 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1055
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1056 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
1057 %!assert (iscellstr (argv ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
1058 %!error argv (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1059 */
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1060
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1061 DEFUN (program_invocation_name, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1062 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20849
diff changeset
1063 @deftypefn {} {} program_invocation_name ()\n\
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1064 Return the name that was typed at the shell prompt to run Octave.\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1065 \n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1066 If executing a script from the command line (e.g., @code{octave foo.m})\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1067 or using an executable Octave script, the program name is set to the\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1068 name of the script. @xref{Executable Octave Programs}, for an example of\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1069 how to create an executable Octave script.\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1070 @seealso{program_name}\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1071 @end deftypefn")
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1072 {
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
1073 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
1074 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1075
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1076 return ovl (octave_program_invocation_name);
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1077 }
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1078
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1079 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
1080 %!assert (ischar (program_invocation_name ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
1081 %!error program_invocation_name (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1082 */
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1083
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1084 DEFUN (program_name, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17778
diff changeset
1085 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20849
diff changeset
1086 @deftypefn {} {} program_name ()\n\
8347
fa78cb8d8a5c corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents: 8273
diff changeset
1087 Return the last component of the value returned by\n\
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1088 @code{program_invocation_name}.\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1089 @seealso{program_invocation_name}\n\
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1090 @end deftypefn")
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1091 {
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
1092 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5814
diff changeset
1093 print_usage ();
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1094
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
1095 return ovl (octave_program_name);
5780
cbf717bf8150 [project @ 2006-04-27 20:02:30 by jwe]
jwe
parents: 5775
diff changeset
1096 }
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1097
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1098 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
1099 %!assert (ischar (program_name ()))
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14160
diff changeset
1100 %!error program_name (1)
12848
e3323dda983b codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents: 12335
diff changeset
1101 */