Mercurial > hg > octave-nkf
annotate src/octave.cc @ 13281:834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
thread. Add uicontrol and uipanel implementation.
* oct-mutex.h (octave_base_mutex::try_lock): New method.
(octave_mutex::try_lock): Likewise.
(octave_auto_lock::octave_auto_lock): New argument for
blocking/non-blocking locks.
(octave_auto_lock::ok): New method to test locking state.
(octave_auto_lock::operator bool): Likewise.
(octave_thread): New utility class.
* oct-mutex.cc (octave_base_mutex::try_lock): New method.
(octave_w32_mutex::try_lock): Implement it for Win32.
(octave_pthread_mutex::try_lock): Implement it for pthread.
(octave_thread): Implement new utility class.
* octave.cc (octave_main): Initialize octave_thread.
* genprops.awk (emit_get_string_array): New function.
(emit_declarations): Use it for string_array_property.
* graphics.h.in (base_property::set): New argument to control toolkit
notifying.
(property::set): Likewise.
(string_array_property::string_vector_value): New method.
(radio_property::do_set): Add warning about abbreviated radio values.
(base_graphics_toolkit::initialize): Returns bool.
(graphics_toolkit::initialize): Likewise.
(base_graphics_object::toolkit_flag): New member.
(base_graphics_object::base_graphics_object): Initialize it.
(base_graphics_object::valid_toolkit_object): New method.
(base_graphics_object::initialize, base_graphics_object::finalize,
base_graphics_object::update): Likewise.
(graphics_object::initialize, graphics_object::finalize,
graphics_object::update): Likewise.
(figure::properties::set_toolkit): Move implementation to source file.
(base_properties::get_boundingbox): Add parent size argument for optimization.
(figure::properties::get_boundingbox): Likewise.
(axes::properties::get_boundingbox): Likewise.
(figure::properties::map_from_boundingbox): New utility method.
(figure::properties::map_to_boundingbox): Likewise.
(axes::properties::get_fontsize_points): New utility method.
(text::properties::get_fontsize_points): Likewise.
(axes::properties::xlabel, axes::properties::ylabel, axes::properties::zlabel,
axes::properties::title): Don't notify toolkit on initialization.
(axes::initialize): New method override.
(uicontrol): New class.
(uipanel): Likewise.
(graphics_event::create_callback_event): New static method overload.
(graphics_event::create_set_event): New argument to prevent circular
behavior when property change is triggered from the toolkit.
(gh_manager::post_set): Likewise.
(gh_manager::do_post_set): Likewise.
(gh_manager::make_graphics_handle): New argument controlling toolkit notify.
(gh_manager::make_figure_handle): Likewise.
(gh_manager::do_make_graphics_handle): Likewise.
(gh_manager::do_make_figure_handle): Likewise.
(gh_manager::try_lock): New static method.
(gh_manager::execute_listener): Likewise.
(gh_manager::enable_event_processing): Likewise.
(gh_manager::do_try_lock): New method.
(gh_manager::do_execute_listener): Likewise.
(gh_manager::do_enable_event_processing): Likewise.
(gh_manager::event_processing): New member.
(gh_manager::execute_callback): Protect graphics_object access.
(gh_manager::auto_lock): Inherits from octave_autolock. Renamed from autolock.
(gh_manager::auto_lock::auto_lock): New blocking/non-blocking argument.
* graphics.cc (default_control_position, default_control_sliderstep,
default_panel_position): New utility functions.
(convert_font_size): New utility function.
(convert_position): Support 2D-only positions.
(lookup_object_name): Support uicontrol and uipanel.
(make_graphics_object_from_type): Likewise.
(root_figure::init_factory_properties): Likewise.
(property_list::set, property_list::lookup): Likewise.
(base_property::set): New argument controlling toolkit notifying.
(base_property::run_listeners): Call gh_manager::execute_listener, allowing
to set a property from another thread and run listeners synchronously with
octave.
(color_property::do_set): Add warning about abbreviated radio value.
(double_radio_property::do_set): Likewise.
(finalize_r, initialize_r, xinitialize): New utility functions.
(gh_manager::do_free): Calls graphics_object::finalize.
(base_graphics_toolkit::initialize): Returns bool.
(gnuplot_toolkit::initialize): Likewise.
(figure::properties::set_toolkit): Move implementation from header.
(figure::properties::get_boundingbox): New argument for parent size.
(axes::properties::get_boundingbox): Likewise.
(figure::properties::map_from_boundingbox): New utility method.
(figure::properties::map_to_boundingbox): Likewise.
(axes::properties::update_fontunits): Use convert_font_size.
(axes::properties::get_fontsize_points): New utility method.
(text::properties::get_fontsize_points): Likewise.
(axes::initialize): New method override to trigger initialization of
labels and title.
(uicontrol): New class.
(uipanel): Likewise.
(gh_manager::gh_manager): Initialize new event_processing member.
(gh_manager::do_make_graphics_handle): New argument controlling toolkit
notifying.
(gh_manager::do_make_figure_handle): Likewise.
(callback_event::callback): New member.
(callback_event::callback_event): Initialize it.
(callback_event::execute): Use it.
(set_event::notify_toolkit): New member.
(set_event::set_event): Initialize it.
(set_event::execute): Use it. Also allow to set read-only properties.
(graphics_event::create_callback_event): New static method overload.
(graphics_event::create_set_event): New argument controlling toolkit notifying.
(gh_manager::do_restore_gcbo): Rename autolock to auto_lock.
(gh_manager::do_post_callback, gh_manager::do_post_function): Likewise.
(Fishandle, Fset, Fget, F__get__): Likewise.
(F__go_figure__, F__calc_dimensions__, GO_BODY): Likewise.
(F__go_delete__, F__go_axes_init__, F__go_handles__, F__go_figure_handles__,
Favailable_graphics_toolkits, Faddlistener, Fdellistener, Faddproperty):
Likewise.
(get_property_from_handle, set_property_in_handle): Likewise.
(gh_manager::do_post_set): Likewise. New argument controlling toolkit
notifying.
(gh_manager::do_execute_listener): New method.
(gh_manager::do_enable_event_processing): Likewise.
(gh_manager::do_execute_callback): Check callback argument validity.
Rename autolock to auto_lock.
(gh_manager::do_process_events): Execute drawnow at the end of event
processing loop, avoiding recursivity. Maintain the input event hook
if gh_manager::event_processing is non zero.
(make_graphics_object): Postpone object's toolkit initialization at
the end of the object creation.
(F__go_figure__): Likewise.
(F__go_uicontrol__, F__go_uipanel__): New functions.
* __init_fltk__.cc (fltk_graphics_toolkit::initialise): New method.
* gl-render.h (opengl_renderer::draw): New argument to identify top-level
calls.
(opengl_renderer::draw_uipanel): New method.
(opengl_renderer::init_gl_context): Likewise.
* gl-render.cc (opengl_renderer::draw): New argument to identify top-level
calls. Skip uicontrol objects. Handle uipanel objects when top-level.
(opengl_renderer::init_gl_context): New method.
(opengl_renderer::draw_figure): Use it.
(opengl_renderer::draw_uipanel): New method.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 06 Oct 2011 16:44:18 +0100 |
parents | 3109c8b0cff4 |
children | f90c3facfac3 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1993-2011 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
23 // Born February 20, 1992. | |
24 | |
240 | 25 #ifdef HAVE_CONFIG_H |
1192 | 26 #include <config.h> |
1 | 27 #endif |
28 | |
1355 | 29 #include <cassert> |
30 #include <cstdlib> | |
31 #include <cstring> | |
32 #include <ctime> | |
33 | |
3503 | 34 #include <iostream> |
1355 | 35 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
36 #include <getopt.h> |
12335
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
37 #include <sys/types.h> |
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
38 #include <unistd.h> |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
39 |
2926 | 40 #include "cmd-edit.h" |
3690 | 41 #include "f77-fcn.h" |
4097 | 42 #include "file-ops.h" |
2926 | 43 #include "file-stat.h" |
240 | 44 #include "lo-error.h" |
2926 | 45 #include "oct-env.h" |
3019 | 46 #include "pathsearch.h" |
1907 | 47 #include "str-vec.h" |
223 | 48 |
2492 | 49 #include <defaults.h> |
3933 | 50 #include "Cell.h" |
1355 | 51 #include "defun.h" |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
52 #include "display.h" |
1355 | 53 #include "error.h" |
54 #include "file-io.h" | |
1 | 55 #include "input.h" |
56 #include "lex.h" | |
5832 | 57 #include "load-path.h" |
4113 | 58 #include "octave.h" |
1742 | 59 #include "oct-hist.h" |
5654 | 60 #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
|
61 #include "oct-mutex.h" |
3195 | 62 #include "oct-obj.h" |
2375 | 63 #include "ops.h" |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
64 #include "ov.h" |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
65 #include "ov-range.h" |
1670 | 66 #include "toplev.h" |
1 | 67 #include "parse.h" |
562 | 68 #include "procstream.h" |
1355 | 69 #include "sighandlers.h" |
70 #include "sysdep.h" | |
1 | 71 #include "unwind-prot.h" |
1355 | 72 #include "utils.h" |
73 #include "variables.h" | |
2492 | 74 #include <version.h> |
1 | 75 |
4159 | 76 // Kluge. |
5990 | 77 extern "C" F77_RET_T |
11518 | 78 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL, |
79 const octave_idx_type& | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
80 F77_CHAR_ARG_LEN_DECL); |
4159 | 81 |
2910 | 82 extern void install_builtins (void); |
83 | |
1907 | 84 // The command-line options. |
85 static string_vector octave_argv; | |
1 | 86 |
5780 | 87 // The name used to invoke Octave. |
88 static std::string | |
89 octave_program_invocation_name; | |
90 | |
91 // The last component of octave_program_invocation_name. | |
92 static std::string octave_program_name; | |
93 | |
2239 | 94 // TRUE means we read ~/.octaverc and ./.octaverc. |
95 // (--norc; --no-init-file; -f) | |
96 static bool read_init_files = true; | |
97 | |
98 // TRUE means we read the site-wide octaverc files. | |
99 // (--norc; --no-site-file; -f) | |
2240 | 100 static bool read_site_files = true; |
1 | 101 |
6365 | 102 // 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
|
103 // (--no-init-path) |
6365 | 104 static bool set_initial_path = true; |
105 | |
3019 | 106 // TRUE means we don't print the usual startup message. |
616 | 107 // (--quiet; --silent; -q) |
2239 | 108 static bool inhibit_startup_message = false; |
1 | 109 |
3019 | 110 // TRUE means we turn on compatibility options. |
1410 | 111 // (--traditional) |
2239 | 112 static bool traditional = false; |
1410 | 113 |
3019 | 114 // If TRUE, print verbose info in some cases. |
1825 | 115 // (--verbose; -V) |
2239 | 116 static bool verbose_flag = false; |
1825 | 117 |
1 | 118 // Usage message |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
119 static const char *usage_string = |
11140 | 120 "octave [-HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ |
5814 | 121 [--exec-path path] [--help] [--image-path path] [--info-file file]\n\ |
9336
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
122 [--info-program prog] [--interactive] [--line-editing]\n\ |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
123 [--no-history] [--no-init-file] [--no-init-path] [--no-line-editing]\n\ |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
124 [--no-site-file] [--no-window-system] [-p path] [--path path]\n\ |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
125 [--silent] [--traditional] [--verbose] [--version] [file]"; |
1 | 126 |
1358 | 127 // This is here so that it's more likely that the usage message and |
1410 | 128 // the real set of options will agree. Note: the `+' must come first |
129 // to prevent getopt from permuting arguments! | |
11140 | 130 static const char *short_opts = "+HVdfhip:qvx"; |
139 | 131 |
5189 | 132 // The code to evaluate at startup (--eval CODE) |
133 static std::string code_to_eval; | |
134 | |
135 // If TRUE, don't exit after evaluating code given by --eval option. | |
136 static bool persist = false; | |
4356 | 137 |
1103 | 138 // Long options. See the comments in getopt.h for the meanings of the |
139 // fields in this structure. | |
8861 | 140 #define DOC_CACHE_FILE_OPTION 1 |
141 #define EVAL_OPTION 2 | |
142 #define EXEC_PATH_OPTION 3 | |
143 #define IMAGE_PATH_OPTION 4 | |
144 #define INFO_FILE_OPTION 5 | |
145 #define INFO_PROG_OPTION 6 | |
9336
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
146 #define LINE_EDITING_OPTION 7 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
147 #define NO_INIT_FILE_OPTION 8 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
148 #define NO_INIT_PATH_OPTION 9 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
149 #define NO_LINE_EDITING_OPTION 10 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
150 #define NO_SITE_FILE_OPTION 11 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
151 #define NO_WINDOW_SYSTEM_OPTION 12 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
152 #define PERSIST_OPTION 13 |
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
153 #define TRADITIONAL_OPTION 14 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
154 struct option long_opts[] = |
139 | 155 { |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
156 { "braindead", no_argument, 0, TRADITIONAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
157 { "debug", no_argument, 0, 'd' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
158 { "doc-cache-file", required_argument, 0, DOC_CACHE_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
159 { "echo-commands", no_argument, 0, 'x' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
160 { "eval", required_argument, 0, EVAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
161 { "exec-path", required_argument, 0, EXEC_PATH_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
162 { "help", no_argument, 0, 'h' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
163 { "image-path", required_argument, 0, IMAGE_PATH_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
164 { "info-file", required_argument, 0, INFO_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
165 { "info-program", required_argument, 0, INFO_PROG_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
166 { "interactive", no_argument, 0, 'i' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
167 { "line-editing", no_argument, 0, LINE_EDITING_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
168 { "no-history", no_argument, 0, 'H' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
169 { "no-init-file", no_argument, 0, NO_INIT_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
170 { "no-init-path", no_argument, 0, NO_INIT_PATH_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
171 { "no-line-editing", no_argument, 0, NO_LINE_EDITING_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
172 { "no-site-file", no_argument, 0, NO_SITE_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
173 { "no-window-system", no_argument, 0, NO_WINDOW_SYSTEM_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
174 { "norc", no_argument, 0, 'f' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
175 { "path", required_argument, 0, 'p' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
176 { "persist", no_argument, 0, PERSIST_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
177 { "quiet", no_argument, 0, 'q' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
178 { "silent", no_argument, 0, 'q' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
179 { "traditional", no_argument, 0, TRADITIONAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
180 { "verbose", no_argument, 0, 'V' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
181 { "version", no_argument, 0, 'v' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
182 { 0, 0, 0, 0 } |
139 | 183 }; |
1 | 184 |
1355 | 185 // Store the command-line options for later use. |
186 | |
187 static void | |
188 intern_argv (int argc, char **argv) | |
189 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
190 assert (symbol_table::at_top_level ()); |
4892 | 191 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
192 symbol_table::varref (".nargin.") = argc - 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
193 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
194 symbol_table::mark_hidden (".nargin."); |
3195 | 195 |
10485
b4e14e628fc9
Truncate argv() for scripts used without command line parameters. Bug #29423
Judd Storrs <jstorrs@gmail.com>
parents:
10370
diff
changeset
|
196 if (argc > 0) |
1355 | 197 { |
7336 | 198 octave_argv.resize (argc - 1); |
3933 | 199 |
2495 | 200 // Skip program name in argv. |
3933 | 201 int i = argc; |
202 while (--i > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
203 octave_argv[i-1] = *(argv+i); |
1355 | 204 } |
205 } | |
206 | |
1792 | 207 static void |
208 initialize_pathsearch (void) | |
209 { | |
210 // This may seem odd, but doing it this way means that we don't have | |
211 // to modify the kpathsea library... | |
212 | |
3523 | 213 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141 | 214 |
215 // For backward compatibility. | |
1792 | 216 |
2926 | 217 if (odb.empty ()) |
3141 | 218 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792 | 219 |
3141 | 220 if (odb.empty ()) |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
221 odb = Vdata_dir + file_ops::dir_sep_str () + "octave:" |
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
222 + Vlibexec_dir + file_ops::dir_sep_str () + "octave"; |
1792 | 223 } |
224 | |
5654 | 225 DEFUN (__version_info__, args, , |
226 "-*- texinfo -*-\n\ | |
6678 | 227 @deftypefn {Built-in Function} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\ |
6945 | 228 Undocumented internal function.\n\ |
5654 | 229 @end deftypefn") |
230 { | |
231 octave_value retval; | |
232 | |
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
|
233 static octave_map vinfo; |
5654 | 234 |
235 int nargin = args.length (); | |
236 | |
5658 | 237 if (nargin == 4) |
5654 | 238 { |
6639 | 239 if (vinfo.nfields () == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
240 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
241 vinfo.assign ("Name", args (0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
242 vinfo.assign ("Version", args (1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
243 vinfo.assign ("Release", args (2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
244 vinfo.assign ("Date", args (3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
245 } |
5781 | 246 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
247 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
248 octave_idx_type n = vinfo.numel () + 1; |
5654 | 249 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
250 vinfo.resize (dim_vector (n, 1)); |
5781 | 251 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
252 octave_value idx (n); |
5781 | 253 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
254 vinfo.assign (idx, "Name", Cell (octave_value (args (0)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
255 vinfo.assign (idx, "Version", Cell (octave_value (args (1)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
256 vinfo.assign (idx, "Release", Cell (octave_value (args (2)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
257 vinfo.assign (idx, "Date", Cell (octave_value (args (3)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
258 } |
5654 | 259 } |
260 else if (nargin == 0) | |
261 retval = vinfo; | |
262 else | |
5823 | 263 print_usage (); |
5654 | 264 |
265 return retval; | |
266 } | |
267 | |
268 static void | |
269 initialize_version_info (void) | |
270 { | |
271 octave_value_list args; | |
272 | |
5658 | 273 args(3) = OCTAVE_RELEASE_DATE; |
274 args(2) = OCTAVE_RELEASE; | |
5654 | 275 args(1) = OCTAVE_VERSION; |
276 args(0) = "GNU Octave"; | |
277 | |
278 F__version_info__ (args, 0); | |
279 } | |
280 | |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
281 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
282 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
|
283 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
284 std::cerr << "error: " << msg << "\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
285 << "error: execution of " << file << " failed\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
286 << "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
|
287 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
288 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
289 |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
290 // Execute commands from a file and catch potential exceptions in a |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
291 // consistent way. This function should be called anywhere we might |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
292 // parse and execute commands from a file before before we have entered |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
293 // the main loop in toplev.cc. |
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 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
296 safe_source_file (const std::string& file_name, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
297 const std::string& context = std::string (), |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
298 bool verbose = false, bool require_file = true, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
299 const std::string& warn_for = std::string ()) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
300 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
301 try |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
302 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
303 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
|
304 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
305 catch (octave_interrupt_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
306 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
307 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
308 octave_stdout << "\n"; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
309 if (quitting_gracefully) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
310 clean_up_and_exit (exit_status); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
311 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
312 catch (octave_execution_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
313 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
314 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
315 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
|
316 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
317 catch (std::bad_alloc) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
318 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
319 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
320 gripe_safe_source_exception |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
321 (file_name, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
322 "memory exhausted or requested size too large for range of Octave's index type"); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
323 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
324 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
325 |
581 | 326 // Initialize by reading startup files. |
327 | |
1 | 328 static void |
329 execute_startup_files (void) | |
330 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
331 unwind_protect frame; |
315 | 332 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
333 frame.protect_var (input_from_startup_file); |
1651 | 334 |
3019 | 335 input_from_startup_file = true; |
315 | 336 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
337 std::string context; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
338 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
339 bool verbose = (verbose_flag && ! inhibit_startup_message); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
340 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
341 bool require_file = false; |
578 | 342 |
2239 | 343 if (read_site_files) |
1 | 344 { |
2239 | 345 // Execute commands from the site-wide configuration file. |
346 // First from the file $(prefix)/lib/octave/site/m/octaverc | |
347 // (if it exists), then from the file | |
3597 | 348 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755 | 349 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
350 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
|
351 require_file); |
1755 | 352 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
353 safe_source_file (Vsite_defaults_file, context, verbose, require_file); |
1 | 354 } |
355 | |
2239 | 356 if (read_init_files) |
357 { | |
2512 | 358 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
359 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc | |
360 // is assumed. | |
2239 | 361 |
4804 | 362 bool home_rc_already_executed = false; |
2512 | 363 |
3523 | 364 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512 | 365 |
2926 | 366 if (initfile.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
367 initfile = ".octaverc"; |
2512 | 368 |
3523 | 369 std::string home_dir = octave_env::get_home_directory (); |
2926 | 370 |
4804 | 371 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
372 | |
373 std::string local_rc; | |
2239 | 374 |
5781 | 375 if (! home_rc.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
376 { |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
377 safe_source_file (home_rc, context, verbose, require_file); |
2239 | 378 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
379 // Names alone are not enough. |
2239 | 380 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
381 file_stat fs_home_rc (home_rc); |
2239 | 382 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
383 if (fs_home_rc) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
384 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
385 // 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
|
386 // because doing that may change the working directory. |
4804 | 387 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
388 local_rc = octave_env::make_absolute (initfile); |
4804 | 389 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
390 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
|
391 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
392 } |
2239 | 393 |
394 if (! home_rc_already_executed) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
395 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
396 if (local_rc.empty ()) |
10250 | 397 local_rc = octave_env::make_absolute (initfile); |
4804 | 398 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
399 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
|
400 } |
2239 | 401 } |
1 | 402 } |
403 | |
5189 | 404 static int |
405 execute_eval_option_code (const std::string& code) | |
406 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
407 unwind_protect frame; |
5189 | 408 |
7202 | 409 octave_save_signal_mask (); |
410 | |
411 can_interrupt = true; | |
412 | |
413 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
414 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
415 octave_bad_alloc_hook = 0; |
7202 | 416 |
417 octave_catch_interrupts (); | |
418 | |
419 octave_initialized = true; | |
420 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
421 frame.protect_var (interactive); |
5189 | 422 |
423 interactive = false; | |
424 | |
425 int parse_status = 0; | |
426 | |
6487 | 427 try |
428 { | |
429 eval_string (code, false, parse_status, 0); | |
430 } | |
7202 | 431 catch (octave_interrupt_exception) |
432 { | |
433 recover_from_exception (); | |
434 octave_stdout << "\n"; | |
9383 | 435 if (quitting_gracefully) |
436 clean_up_and_exit (exit_status); | |
7202 | 437 } |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
438 catch (octave_execution_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
439 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
440 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
441 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
|
442 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
443 } |
6487 | 444 catch (std::bad_alloc) |
445 { | |
6680 | 446 std::cerr << "error: memory exhausted or requested size too large for range of Octave's index type -- eval failed" |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
447 << std::endl; |
6487 | 448 } |
5189 | 449 |
450 return parse_status; | |
451 } | |
452 | |
453 static void | |
454 execute_command_line_file (const std::string& fname) | |
455 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
456 unwind_protect frame; |
5189 | 457 |
7202 | 458 octave_save_signal_mask (); |
459 | |
460 can_interrupt = true; | |
461 | |
462 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
463 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
464 octave_bad_alloc_hook = 0; |
7202 | 465 |
466 octave_catch_interrupts (); | |
467 | |
468 octave_initialized = true; | |
469 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
470 frame.protect_var (interactive); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
471 frame.protect_var (reading_script_file); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
472 frame.protect_var (input_from_command_line_file); |
5189 | 473 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
474 frame.protect_var (curr_fcn_file_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
475 frame.protect_var (curr_fcn_file_full_name); |
5189 | 476 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
477 frame.protect_var (octave_program_invocation_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
478 frame.protect_var (octave_program_name); |
5189 | 479 |
480 interactive = false; | |
481 reading_script_file = true; | |
482 input_from_command_line_file = true; | |
483 | |
484 curr_fcn_file_name = fname; | |
485 curr_fcn_file_full_name = curr_fcn_file_name; | |
486 | |
5780 | 487 octave_program_invocation_name = curr_fcn_file_name; |
5189 | 488 |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
489 size_t pos = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
490 |
8021 | 491 std::string tmp = (pos != std::string::npos) |
5189 | 492 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
493 | |
5780 | 494 octave_program_name = tmp; |
5189 | 495 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
496 std::string context; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
497 bool verbose = false; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
498 bool require_file = true; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
499 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
500 safe_source_file (fname, context, verbose, require_file, "octave"); |
5189 | 501 } |
502 | |
581 | 503 // Usage message with extra help. |
504 | |
1 | 505 static void |
506 verbose_usage (void) | |
507 { | |
3922 | 508 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613 | 509 \n\ |
10731
f5dbac015606
Add [FILE] to octave usage string (bug #30258).
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
510 Usage: octave [options] [FILE]\n\ |
1613 | 511 \n\ |
512 Options:\n\ | |
1119 | 513 \n\ |
3180 | 514 --debug, -d Enter parser debugging mode.\n\ |
8923
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
515 --doc-cache-file FILE Use doc cache file FILE.\n\ |
3180 | 516 --echo-commands, -x Echo commands as they are executed.\n\ |
5191 | 517 --eval CODE Evaluate CODE. Exit when done unless --persist.\n\ |
1613 | 518 --exec-path PATH Set path for executing subprograms.\n\ |
11140 | 519 --help, -h, Print short help message and exit.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
520 --image-path PATH Add PATH to head of image search path.\n\ |
1613 | 521 --info-file FILE Use top-level info file FILE.\n\ |
522 --info-program PROGRAM Use PROGRAM for reading info files.\n\ | |
3180 | 523 --interactive, -i Force interactive behavior.\n\ |
6938 | 524 --line-editing Force readline use for command-line editing.\n\ |
3180 | 525 --no-history, -H Don't save commands to the history list\n\ |
2470 | 526 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
527 --no-init-path Don't initialize function search path.\n\ |
2212 | 528 --no-line-editing Don't use readline for command-line editing.\n\ |
2470 | 529 --no-site-file Don't read the site-wide octaverc file.\n\ |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
530 --no-window-system Disable window system, including graphics.\n\ |
3238 | 531 --norc, -f Don't read any initialization files.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
532 --path PATH, -p PATH Add PATH to head of function search path.\n\ |
5189 | 533 --persist Go interactive after --eval or reading from FILE.\n\ |
3180 | 534 --silent, -q Don't print message at startup.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
535 --traditional Set variables for closer MATLAB compatibility.\n\ |
3180 | 536 --verbose, -V Enable verbose output in some cases.\n\ |
537 --version, -v Print version number and exit.\n\ | |
1119 | 538 \n\ |
5190 | 539 FILE Execute commands from FILE. Exit when done\n\ |
5191 | 540 unless --persist is also specified.\n\ |
4829 | 541 \n" |
542 OCTAVE_WWW_STATEMENT "\n\ | |
4356 | 543 \n" |
544 OCTAVE_CONTRIB_STATEMENT "\n\ | |
545 \n" | |
546 OCTAVE_BUGS_STATEMENT "\n"; | |
285 | 547 |
613 | 548 exit (0); |
1 | 549 } |
550 | |
581 | 551 // Terse usage messsage. |
552 | |
1 | 553 static void |
554 usage (void) | |
555 { | |
11140 | 556 std::cerr << "\nusage: " << usage_string << "\n\n"; |
1 | 557 exit (1); |
558 } | |
559 | |
560 static void | |
561 print_version_and_exit (void) | |
562 { | |
3922 | 563 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1 | 564 exit (0); |
565 } | |
566 | |
721 | 567 static void |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
568 lo_error_handler (const char *fmt, ...) |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
569 { |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
570 va_list args; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
571 va_start (args, fmt); |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9724
diff
changeset
|
572 verror_with_cfn (fmt, args); |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
573 va_end (args); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
574 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
575 octave_throw_execution_exception (); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
576 } |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
577 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
578 static void |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
579 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
|
580 { |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
581 va_list args; |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
582 va_start (args, fmt); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
583 verror_with_id_cfn (id, fmt, args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
584 va_end (args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
585 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
586 octave_throw_execution_exception (); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
587 } |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
588 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
589 static void |
721 | 590 initialize_error_handlers () |
591 { | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
592 set_liboctave_error_handler (lo_error_handler); |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
593 set_liboctave_error_with_id_handler (lo_error_with_id_handler); |
3325 | 594 set_liboctave_warning_handler (warning); |
5781 | 595 set_liboctave_warning_with_id_handler (warning_with_id); |
721 | 596 } |
597 | |
1410 | 598 // What happens on --traditional. |
599 | |
600 static void | |
601 maximum_braindamage (void) | |
602 { | |
5189 | 603 persist = true; |
604 | |
5794 | 605 bind_internal_variable ("PS1", ">> "); |
606 bind_internal_variable ("PS2", ""); | |
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
|
607 bind_internal_variable ("allow_noninteger_range_as_index", true); |
5794 | 608 bind_internal_variable ("beep_on_error", true); |
8473
4dd0213bb883
octave.cc (maximum_braindamage): set confirm_recursive_rmdir to false
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
609 bind_internal_variable ("confirm_recursive_rmdir", false); |
5794 | 610 bind_internal_variable ("crash_dumps_octave_core", false); |
611 bind_internal_variable ("default_save_options", "-mat-binary"); | |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
612 bind_internal_variable ("do_braindead_shortcircuit_evaluation", true); |
5794 | 613 bind_internal_variable ("fixed_point_format", true); |
614 bind_internal_variable ("history_timestamp_format_string", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
615 "%%-- %D %I:%M %p --%%"); |
5794 | 616 bind_internal_variable ("page_screen_output", false); |
617 bind_internal_variable ("print_empty_dimensions", false); | |
5904 | 618 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9383
diff
changeset
|
619 disable_warning ("Octave:abbreviated-property-match"); |
6159 | 620 disable_warning ("Octave:fopen-file-in-path"); |
5904 | 621 disable_warning ("Octave:function-name-clash"); |
6159 | 622 disable_warning ("Octave:load-file-in-path"); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
623 disable_warning ("Octave:possible-matlab-short-circuit-operator"); |
1410 | 624 } |
625 | |
581 | 626 // You guessed it. |
627 | |
1 | 628 int |
4368 | 629 octave_main (int argc, char **argv, int embedded) |
1 | 630 { |
3019 | 631 octave_env::set_program_name (argv[0]); |
632 | |
5780 | 633 octave_program_invocation_name = octave_env::get_program_invocation_name (); |
634 octave_program_name = octave_env::get_program_name (); | |
635 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
636 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
|
637 |
2205 | 638 // The order of these calls is important. The call to |
2926 | 639 // install_defaults must come before install_builtins because |
3019 | 640 // default variable values must be available for the variables to be |
2205 | 641 // installed, and the call to install_builtins must come before the |
642 // options are processed because some command line options override | |
5794 | 643 // defaults by calling bind_internal_variable. |
721 | 644 |
5844 | 645 init_signals (); |
646 | |
1 | 647 sysdep_init (); |
648 | |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
649 octave_ieee_init (); |
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
650 |
4159 | 651 // The idea here is to force xerbla to be referenced so that we will |
652 // link to our own version instead of the one provided by the BLAS | |
653 // library. But octave_NaN should never be -1, so we should never | |
654 // actually call xerbla. | |
655 | |
656 if (octave_NaN == -1) | |
11157
c75130f19440
octave.cc: fix call to xerbla
John W. Eaton <jwe@octave.org>
parents:
11140
diff
changeset
|
657 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6)); |
4159 | 658 |
721 | 659 initialize_error_handlers (); |
223 | 660 |
5794 | 661 initialize_default_warning_state (); |
662 | |
2926 | 663 install_defaults (); |
1 | 664 |
1792 | 665 initialize_pathsearch (); |
1744 | 666 |
4368 | 667 if (! embedded) |
668 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
|
669 else |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
670 quit_allowed = false; |
2205 | 671 |
672 initialize_file_io (); | |
673 | |
2375 | 674 install_types (); |
675 | |
676 install_ops (); | |
2205 | 677 |
678 install_builtins (); | |
679 | |
6938 | 680 bool forced_line_editing = false; |
681 | |
8273
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
8099
diff
changeset
|
682 bool read_history_file = true; |
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
8099
diff
changeset
|
683 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
684 while (true) |
1 | 685 { |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
686 int long_idx; |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
687 |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
688 int optc = getopt_long (argc, argv, short_opts, long_opts, &long_idx); |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
689 |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
690 if (optc < 0) |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
691 break; |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
692 |
139 | 693 switch (optc) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
694 { |
11140 | 695 case '?': |
696 // Unrecognized option. getopt_long already printed a | |
697 // message about that, so we will just print the usage string | |
698 // and exit. | |
699 usage (); | |
700 break; | |
701 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
702 case 'H': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
703 read_history_file = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
704 bind_internal_variable ("saving_history", false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
705 break; |
3180 | 706 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
707 case 'V': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
708 verbose_flag = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
709 break; |
793 | 710 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
711 case 'd': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
712 // This is the same as yydebug in parse.y. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
713 octave_debug++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
714 break; |
777 | 715 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
716 case 'f': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
717 read_init_files = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
718 read_site_files = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
719 break; |
777 | 720 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
721 case 'h': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
722 verbose_usage (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
723 break; |
777 | 724 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
725 case 'i': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
726 forced_interactive = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
727 break; |
777 | 728 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
729 case 'p': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
730 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
731 load_path::set_command_line_path (optarg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
732 break; |
777 | 733 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
734 case 'q': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
735 inhibit_startup_message = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
736 break; |
777 | 737 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
738 case 'x': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
739 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
740 double tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
741 bind_internal_variable ("echo_executing_commands", tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
742 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
743 break; |
777 | 744 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
745 case 'v': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
746 print_version_and_exit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
747 break; |
777 | 748 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
749 case DOC_CACHE_FILE_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
750 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
751 bind_internal_variable ("doc_cache_file", optarg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
752 break; |
8861 | 753 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
754 case EVAL_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
755 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
756 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
757 if (code_to_eval.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
758 code_to_eval = optarg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
759 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
760 code_to_eval += std::string (" ") + optarg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
761 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
762 break; |
5189 | 763 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
764 case EXEC_PATH_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
765 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
766 set_exec_path (optarg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
767 break; |
5814 | 768 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
769 case IMAGE_PATH_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
770 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
771 set_image_path (optarg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
772 break; |
1613 | 773 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
774 case INFO_FILE_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
775 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
776 bind_internal_variable ("info_file", optarg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
777 break; |
777 | 778 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
779 case INFO_PROG_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
780 if (optarg) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
781 bind_internal_variable ("info_program", optarg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
782 break; |
1613 | 783 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
784 case LINE_EDITING_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
785 forced_line_editing = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
786 break; |
6938 | 787 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
788 case NO_INIT_FILE_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
789 read_init_files = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
790 break; |
2239 | 791 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
792 case NO_INIT_PATH_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
793 set_initial_path = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
794 break; |
9336
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
795 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
796 case NO_LINE_EDITING_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
797 line_editing = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
798 break; |
2239 | 799 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
800 case NO_SITE_FILE_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
801 read_site_files = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
802 break; |
1821 | 803 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
804 case NO_WINDOW_SYSTEM_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
805 display_info::no_window_system (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
806 break; |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
807 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
808 case PERSIST_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
809 persist = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
810 break; |
9336
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
811 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
812 case TRADITIONAL_OPTION: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
813 traditional = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
814 break; |
1410 | 815 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
816 default: |
11140 | 817 // getopt_long should print a message about unrecognized |
818 // options and return '?', which is handled above. So if we | |
819 // end up here, it is because there was an option but we | |
820 // forgot to handle it. That should be fatal. | |
821 panic_impossible (); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
822 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
823 } |
1 | 824 } |
825 | |
2077 | 826 // Make sure we clean up when we exit. Also allow users to register |
827 // functions. If we don't have atexit or on_exit, we're going to | |
828 // leave some junk files around if we exit abnormally. | |
829 | |
830 atexit (do_octave_atexit); | |
1 | 831 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
832 // Is input coming from a terminal? If so, we are probably |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
833 // interactive. |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
834 |
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
|
835 // 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
|
836 // a redirected file. |
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
|
837 stdin_is_tty = isatty (fileno (stdin)); |
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
|
838 |
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
|
839 interactive = (! embedded && stdin_is_tty && isatty (fileno (stdout))); |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
840 |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
841 if (! interactive && ! forced_line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
842 line_editing = false; |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
843 |
9321
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
844 // 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
|
845 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
|
846 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
|
847 |
1358 | 848 // These can come after command line args since none of them set any |
849 // defaults that might be changed by command line options. | |
581 | 850 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
851 if (line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
852 initialize_command_input (); |
315 | 853 |
578 | 854 if (! inhibit_startup_message) |
3538 | 855 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
578 | 856 |
1410 | 857 if (traditional) |
858 maximum_braindamage (); | |
859 | |
4217 | 860 octave_interpreter_ready = true; |
861 | |
5654 | 862 initialize_version_info (); |
863 | |
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
|
864 // 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
|
865 // 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
|
866 |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
867 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
|
868 |
6365 | 869 load_path::initialize (set_initial_path); |
4217 | 870 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
871 initialize_history (read_history_file); |
1651 | 872 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
873 execute_startup_files (); |
1 | 874 |
578 | 875 if (! inhibit_startup_message && reading_startup_message_printed) |
3538 | 876 std::cout << std::endl; |
578 | 877 |
1358 | 878 // If there is an extra argument, see if it names a file to read. |
879 // Additional arguments are taken as command line options for the | |
880 // script. | |
1 | 881 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
882 int last_arg_idx = optind; |
3019 | 883 |
1817 | 884 int remaining_args = argc - last_arg_idx; |
3019 | 885 |
5189 | 886 if (! code_to_eval.empty ()) |
149 | 887 { |
5189 | 888 int parse_status = execute_eval_option_code (code_to_eval); |
889 | |
5242 | 890 if (! (persist || remaining_args > 0)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
891 clean_up_and_exit (parse_status || error_state ? 1 : 0); |
1 | 892 } |
893 | |
5189 | 894 if (remaining_args > 0) |
895 { | |
896 // If we are running an executable script (#! /bin/octave) then | |
897 // we should only see the args passed to the script. | |
898 | |
899 intern_argv (remaining_args, argv+last_arg_idx); | |
900 | |
901 execute_command_line_file (argv[last_arg_idx]); | |
902 | |
903 if (! persist) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
904 clean_up_and_exit (error_state ? 1 : 0); |
5189 | 905 } |
906 | |
907 // Avoid counting commands executed from startup files. | |
908 | |
909 command_editor::reset_current_command_number (1); | |
910 | |
911 // Now argv should have the full set of args. | |
912 intern_argv (argc, argv); | |
913 | |
914 if (! embedded) | |
915 switch_to_buffer (create_buffer (get_input_from_stdin ())); | |
916 | |
1358 | 917 // Force input to be echoed if not really interactive, but the user |
918 // has forced interactive behavior. | |
1 | 919 |
1907 | 920 if (! interactive && forced_interactive) |
287 | 921 { |
2926 | 922 command_editor::blink_matching_paren (false); |
1588 | 923 |
5775 | 924 // FIXME -- is this the right thing to do? |
1588 | 925 |
5794 | 926 bind_internal_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287 | 927 } |
1 | 928 |
4368 | 929 if (embedded) |
5502 | 930 { |
5775 | 931 // FIXME -- do we need to do any cleanup here before |
5502 | 932 // returning? If we don't, what will happen to Octave functions |
933 // that have been registered to execute with atexit, for example? | |
934 | |
935 return 1; | |
936 } | |
4368 | 937 |
5189 | 938 int retval = main_loop (); |
1 | 939 |
1005 | 940 if (retval == 1 && ! error_state) |
941 retval = 0; | |
942 | |
1 | 943 clean_up_and_exit (retval); |
4247 | 944 |
945 return 0; | |
1 | 946 } |
947 | |
5780 | 948 DEFUN (argv, args, , |
949 "-*- texinfo -*-\n\ | |
950 @deftypefn {Built-in Function} {} argv ()\n\ | |
951 Return the command line arguments passed to Octave. For example,\n\ | |
952 if you invoked Octave using the command\n\ | |
953 \n\ | |
954 @example\n\ | |
955 octave --no-line-editing --silent\n\ | |
956 @end example\n\ | |
957 \n\ | |
958 @noindent\n\ | |
959 @code{argv} would return a cell array of strings with the elements\n\ | |
10840 | 960 @option{--no-line-editing} and @option{--silent}.\n\ |
5780 | 961 \n\ |
962 If you write an executable Octave script, @code{argv} will return the\n\ | |
963 list of arguments passed to the script. @xref{Executable Octave Programs},\n\ | |
964 for an example of how to create an executable Octave script.\n\ | |
965 @end deftypefn") | |
966 { | |
967 octave_value retval; | |
968 | |
969 if (args.length () == 0) | |
970 retval = Cell (octave_argv); | |
971 else | |
5823 | 972 print_usage (); |
5780 | 973 |
974 return retval; | |
975 } | |
976 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
977 /* |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
978 %!error argv (1); |
12855
8f5bd903ba68
codesprint: Correct typos in previous check-ins to get tests running.
Rik <octave@nomad.inbox5.com>
parents:
12848
diff
changeset
|
979 %!assert (iscellstr (argv ())); |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
980 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
981 |
5780 | 982 DEFUN (program_invocation_name, args, , |
983 "-*- texinfo -*-\n\ | |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9584
diff
changeset
|
984 @deftypefn {Built-in Function} {} program_invocation_name ()\n\ |
5780 | 985 Return the name that was typed at the shell prompt to run Octave.\n\ |
986 \n\ | |
987 If executing a script from the command line (e.g., @code{octave foo.m})\n\ | |
988 or using an executable Octave script, the program name is set to the\n\ | |
989 name of the script. @xref{Executable Octave Programs}, for an example of\n\ | |
990 how to create an executable Octave script.\n\ | |
991 @seealso{program_name}\n\ | |
992 @end deftypefn") | |
993 { | |
994 octave_value retval; | |
995 | |
996 if (args.length () == 0) | |
997 retval = octave_program_invocation_name; | |
998 else | |
5823 | 999 print_usage (); |
5780 | 1000 |
1001 return retval; | |
1002 } | |
1003 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1004 /* |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1005 %!error program_invocation_name (1); |
12855
8f5bd903ba68
codesprint: Correct typos in previous check-ins to get tests running.
Rik <octave@nomad.inbox5.com>
parents:
12848
diff
changeset
|
1006 %!assert (ischar (program_invocation_name ())); |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1007 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1008 |
5780 | 1009 DEFUN (program_name, args, , |
1010 "-*- texinfo -*-\n\ | |
1011 @deftypefn {Built-in Function} {} program_name ()\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8273
diff
changeset
|
1012 Return the last component of the value returned by\n\ |
5780 | 1013 @code{program_invocation_name}.\n\ |
1014 @seealso{program_invocation_name}\n\ | |
1015 @end deftypefn") | |
1016 { | |
1017 octave_value retval; | |
1018 | |
1019 if (args.length () == 0) | |
1020 retval = octave_program_name; | |
1021 else | |
5823 | 1022 print_usage (); |
5780 | 1023 |
1024 return retval; | |
1025 } | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1026 |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1027 /* |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1028 %!error program_name (1); |
12855
8f5bd903ba68
codesprint: Correct typos in previous check-ins to get tests running.
Rik <octave@nomad.inbox5.com>
parents:
12848
diff
changeset
|
1029 %!assert (ischar (program_name ())); |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1030 */ |