Mercurial > octave
annotate libinterp/corefcn/toplev.cc @ 21157:94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
* debug.cc (parse_dbfunction_params): Accept "in", "at" and "if" tokens.
Only breakpoints are returned; "dbstop if error" etc. are processed in
the parser.
* debug.cc (dbstop_process_map_ags, Fdbstop): set breakpoints etc. based on the
output of A=dbstatus. The structure of A is not Matlab compatible.
* debug.cc (do_add_breakpoint_1, do_get_breakpoint_list): Store file
(not subfunction) names in bp_set, to avoid crash in "dbclear all".
* debug.cc (dbclear_all_signals, condition_valid,
stop_on_err_warn_status): New function
* debug.cc (do_add_breakpoint): take "condition" parameter.
* debug.cc (do_get_breakpoint_list): Make invariant copy of bp_set (bug #44195)
* debug.cc (do_add_breakpoint, do_remove_breakpoint,
do_remove_all_breakpoints_in_file): More informative error messages.
* debug.cc (Fdbclear): clear break on signals (error, warning etc.)
* debug.cc (Fdbstatus): Return all breakpoints when debugging, so that
"s = dbstatus; ...; dbstop (s)" works.
(Related to bug #41338, bug #41556)
* debug.cc (Fdbstatus): Return structure with conditions, and "if error" etc.
* debug.h (debug_on_err, debug_on_caught, debug_on_warn): New functions
* debug.h: Rename "fname_line_map" to "fname_bp_map", as it has conditions
* error.cc (verror): Allow dbstop on selected errors, or errors in try/catch
* error.h New globals: Vdebug_on_caught, in_try_catch.
* toplev.cc: Experimental code for Matlab's "dbstop if naninf".
* symtab.cc (load_class_constructor): Add class constructors to list of
methods so they can be breakpointed
* pt-pb.{cc,h} (take_action): Add "condition" to set_breakpoint call,
track bp_cond_list.
* pt-eval.cc visit_.*_command: Ask if breakpoint condition is satisfied.
* pt-eval.cc (visit_try_catch_command): Count the number of levels of
try/catch we are in to allow "dbstop if caught error".
* pt-stmt.cc (set_breakpoint): Pass condition
* pt-stmt.cc (is_breakpoint): If new argument is true, only return true
if the condition is set.
* pt-stmt.cc (bp_cond, preakpoints_and_conds): new function
* pt-stmt.h: new declarations
* pt.{cc,h} (meets_bp_condition, bp_cond): New function
* octave-link.h (update_breakpoint): Accept condition
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Sun, 24 Jan 2016 11:02:30 +1100 |
parents | e06e600f396a |
children | a65b906e25bc |
rev | line source |
---|---|
1683 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
3 Copyright (C) 1995-2015 John W. Eaton |
1683 | 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. | |
1683 | 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/>. | |
1683 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cassert> | |
4489 | 28 #include <cerrno> |
1683 | 29 #include <cstdlib> |
30 #include <cstring> | |
4221 | 31 #include <new> |
1683 | 32 |
3503 | 33 #include <fstream> |
34 #include <iostream> | |
5765 | 35 #include <sstream> |
1728 | 36 #include <string> |
37 | |
16317
ce5231908ea2
* toplev.cc: Include sys/select.h.
John W. Eaton <jwe@octave.org>
parents:
16292
diff
changeset
|
38 #include <sys/select.h> |
1683 | 39 #include <sys/types.h> |
40 #include <unistd.h> | |
41 | |
2926 | 42 #include "cmd-edit.h" |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12846
diff
changeset
|
43 #include "cmd-hist.h" |
2926 | 44 #include "file-ops.h" |
1683 | 45 #include "lo-error.h" |
2370 | 46 #include "lo-mappers.h" |
3020 | 47 #include "oct-env.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
48 #include "oct-locbuf.h" |
4153 | 49 #include "quit.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
50 #include "singleton-cleanup.h" |
1755 | 51 #include "str-vec.h" |
1683 | 52 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
53 #include "defaults.h" |
1683 | 54 #include "defun.h" |
55 #include "error.h" | |
56 #include "file-io.h" | |
14014
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
57 #include "graphics.h" |
1683 | 58 #include "input.h" |
59 #include "lex.h" | |
17755
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
60 #include "load-save.h" |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
61 #include "octave-link.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
62 #include "oct-conf.h" |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
63 #include "oct-conf-features.h" |
1742 | 64 #include "oct-hist.h" |
2162 | 65 #include "oct-map.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
66 #include "ovl.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
67 #include "ov.h" |
1683 | 68 #include "pager.h" |
69 #include "parse.h" | |
70 #include "pathsearch.h" | |
71 #include "procstream.h" | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8581
diff
changeset
|
72 #include "pt-eval.h" |
2985 | 73 #include "pt-jump.h" |
2982 | 74 #include "pt-stmt.h" |
1683 | 75 #include "sighandlers.h" |
76 #include "sysdep.h" | |
2693 | 77 #include "syswait.h" |
1750 | 78 #include "toplev.h" |
1683 | 79 #include "unwind-prot.h" |
80 #include "utils.h" | |
81 #include "variables.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
82 #include "version.h" |
1683 | 83 |
15756
ea1a1fb00744
Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents:
15596
diff
changeset
|
84 #ifndef SHELL_PATH |
ea1a1fb00744
Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents:
15596
diff
changeset
|
85 #define SHELL_PATH "/bin/sh" |
ea1a1fb00744
Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents:
15596
diff
changeset
|
86 #endif |
ea1a1fb00744
Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents:
15596
diff
changeset
|
87 |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
88 void (*octave_exit) (int) = ::exit; |
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
89 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
90 // TRUE means the quit() call is allowed. |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
91 bool quit_allowed = true; |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
92 |
3020 | 93 // TRUE means we are exiting via the builtin exit or quit functions. |
9383 | 94 bool quitting_gracefully = false; |
95 // This stores the exit status. | |
96 int exit_status = 0; | |
1683 | 97 |
4217 | 98 // TRUE means we are ready to interpret commands, but not everything |
99 // is ready for interactive use. | |
100 bool octave_interpreter_ready = false; | |
101 | |
4172 | 102 // TRUE means we've processed all the init code and we are good to go. |
103 bool octave_initialized = false; | |
104 | |
5743 | 105 octave_call_stack *octave_call_stack::instance = 0; |
106 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
107 std::string |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
108 octave_call_stack::stack_frame::fcn_file_name (void) const |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
109 { |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20962
diff
changeset
|
110 return m_fcn ? m_fcn->fcn_file_name () : ""; |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
111 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
112 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
113 std::string |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
114 octave_call_stack::stack_frame::fcn_name (bool print_subfn) const |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
115 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
116 std::string retval; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
117 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
118 if (m_fcn) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
119 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
120 std::string parent_fcn_name = m_fcn->parent_fcn_name (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
121 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
122 if (print_subfn && ! parent_fcn_name.empty ()) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
123 retval = parent_fcn_name + Vfilemarker; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
124 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
125 retval += m_fcn->name (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
126 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
127 else |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
128 retval = "<unknown>"; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
129 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
130 return retval; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
131 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
132 |
20511
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
133 bool |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
134 octave_call_stack::stack_frame::operator== (const octave_call_stack::stack_frame &rhs) const |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
135 { |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
136 if (this->line () != rhs.line ()) |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
137 return false; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
138 else if (this->column () != rhs.column ()) |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
139 return false; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
140 else if (this->fcn_file_name () != rhs.fcn_file_name ()) |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
141 return false; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
142 else if (this->fcn_name () != rhs.fcn_name ()) |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
143 return false; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
144 else |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
145 return true; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
146 } |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
147 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
148 void |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
149 octave_call_stack::create_instance (void) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
150 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
151 instance = new octave_call_stack (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
152 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
153 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
154 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
155 instance->do_push (0, symbol_table::top_scope (), 0); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
156 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
157 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
158 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
159 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
160 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
161 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
162 octave_call_stack::do_current_line (void) const |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
163 { |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
164 int retval = -1; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
165 |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
166 if (! cs.empty ()) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
167 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
168 const stack_frame& elt = cs[curr_frame]; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
169 retval = elt.m_line; |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
170 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
171 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
172 return retval; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
173 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
174 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
175 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
176 octave_call_stack::do_current_column (void) const |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
177 { |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
178 int retval = -1; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
179 |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
180 if (! cs.empty ()) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
181 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
182 const stack_frame& elt = cs[curr_frame]; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
183 retval = elt.m_column; |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
184 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
185 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
186 return retval; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
187 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
188 |
7877 | 189 int |
7923
c3d21b9b94b6
eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents:
7913
diff
changeset
|
190 octave_call_stack::do_caller_user_code_line (void) const |
7877 | 191 { |
192 int retval = -1; | |
193 | |
7890 | 194 const_iterator p = cs.end (); |
195 | |
196 while (p != cs.begin ()) | |
7877 | 197 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
198 const stack_frame& elt = *(--p); |
7877 | 199 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
200 octave_function *f = elt.m_fcn; |
7877 | 201 |
202 if (f && f->is_user_code ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
203 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
204 if (elt.m_line > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
205 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
206 retval = elt.m_line; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
207 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
208 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
209 } |
7877 | 210 } |
211 | |
212 return retval; | |
213 } | |
214 | |
215 int | |
7923
c3d21b9b94b6
eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents:
7913
diff
changeset
|
216 octave_call_stack::do_caller_user_code_column (void) const |
7877 | 217 { |
218 int retval = -1; | |
219 | |
7890 | 220 const_iterator p = cs.end (); |
221 | |
222 while (p != cs.begin ()) | |
7877 | 223 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
224 const stack_frame& elt = *(--p); |
7877 | 225 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
226 octave_function *f = elt.m_fcn; |
7877 | 227 |
228 if (f && f->is_user_code ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
229 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
230 if (elt.m_column) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
231 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
232 retval = elt.m_column; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
233 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
234 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
235 } |
7877 | 236 } |
237 | |
238 return retval; | |
239 } | |
240 | |
7901 | 241 size_t |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
242 octave_call_stack::do_num_user_code_frames |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
243 (octave_idx_type& curr_user_frame) const |
7901 | 244 { |
245 size_t retval = 0; | |
246 | |
247 curr_user_frame = 0; | |
248 | |
249 // Look for the caller of dbstack. | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
250 size_t xframe = cs[curr_frame].m_prev; |
7901 | 251 |
252 bool found = false; | |
253 | |
254 size_t k = cs.size (); | |
255 | |
256 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) | |
257 { | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
258 octave_function *f = (*p).m_fcn; |
7901 | 259 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
260 if (--k == xframe) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
261 found = true; |
7901 | 262 |
263 if (f && f->is_user_code ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
264 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
265 if (! found) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
266 curr_user_frame++; |
7901 | 267 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
268 retval++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
269 } |
7901 | 270 } |
271 | |
272 // We counted how many user frames were not the one, in reverse. | |
273 // Now set curr_user_frame to be the index in the other direction. | |
274 curr_user_frame = retval - curr_user_frame - 1; | |
275 | |
276 return retval; | |
277 } | |
278 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
279 octave_user_code * |
7923
c3d21b9b94b6
eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents:
7913
diff
changeset
|
280 octave_call_stack::do_caller_user_code (size_t nskip) const |
5744 | 281 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
282 octave_user_code *retval = 0; |
5744 | 283 |
7890 | 284 const_iterator p = cs.end (); |
285 | |
286 while (p != cs.begin ()) | |
5744 | 287 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
288 const stack_frame& elt = *(--p); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
289 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
290 octave_function *f = elt.m_fcn; |
5744 | 291 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
292 if (f && f->is_user_code ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
293 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
294 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
295 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
296 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
297 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
298 retval = dynamic_cast<octave_user_code *> (f); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
299 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
300 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
301 } |
5744 | 302 } |
303 | |
304 return retval; | |
305 } | |
306 | |
18267
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
307 bool |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
308 octave_call_stack::do_all_scripts (void) const |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
309 { |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
310 bool retval = true; |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
311 |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
312 const_iterator p = cs.end (); |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
313 |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
314 while (p != cs.begin ()) |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
315 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
316 const stack_frame& elt = *(--p); |
18267
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
317 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
318 octave_function *f = elt.m_fcn; |
18267
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
319 |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
320 if (f && ! f->is_user_script ()) |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
321 { |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
322 retval = false; |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
323 break; |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
324 } |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
325 } |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
326 |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
327 return retval; |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
328 } |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
18104
diff
changeset
|
329 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
330 // Use static fields for the best efficiency. |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
331 // NOTE: C++0x will allow these two to be merged into one. |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
332 static const char *bt_fieldnames[] = { "file", "name", "line", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
333 "column", "scope", "context", 0 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
334 }; |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
335 static const octave_fields bt_fields (bt_fieldnames); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
336 |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
337 octave_map |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
338 octave_call_stack::empty_backtrace (void) |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
339 { |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
340 return octave_map (dim_vector (0, 1), bt_fields); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
341 } |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
342 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
343 std::list<octave_call_stack::stack_frame> |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
344 octave_call_stack::do_backtrace_frames (size_t nskip, |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
345 octave_idx_type& curr_user_frame) const |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
346 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
347 std::list<octave_call_stack::stack_frame> retval; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
348 |
7901 | 349 size_t user_code_frames = do_num_user_code_frames (curr_user_frame); |
350 | |
351 size_t nframes = nskip <= user_code_frames ? user_code_frames - nskip : 0; | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
352 |
7901 | 353 // Our list is reversed. |
354 curr_user_frame = nframes - curr_user_frame - 1; | |
355 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
356 if (nframes > 0) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
357 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
358 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
359 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
360 const stack_frame& elt = *p; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
361 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
362 octave_function *f = elt.m_fcn; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
363 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
364 if (f && f->is_user_code ()) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
365 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
366 if (nskip > 0) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
367 nskip--; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
368 else |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
369 retval.push_back (elt); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
370 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
371 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
372 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
373 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
374 return retval; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
375 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
376 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
377 octave_map |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
378 octave_call_stack::do_backtrace (size_t nskip, |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
379 octave_idx_type& curr_user_frame, |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
380 bool print_subfn) const |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
381 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
382 std::list<octave_call_stack::stack_frame> frames |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
383 = do_backtrace_frames (nskip, curr_user_frame); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
384 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
385 size_t nframes = frames.size (); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
386 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
387 octave_map retval (dim_vector (nframes, 1), bt_fields); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
388 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
389 Cell& file = retval.contents (0); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
390 Cell& name = retval.contents (1); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
391 Cell& line = retval.contents (2); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
392 Cell& column = retval.contents (3); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
393 Cell& scope = retval.contents (4); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
394 Cell& context = retval.contents (5); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
395 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
396 octave_idx_type k = 0; |
7901 | 397 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
398 for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
399 p != frames.end (); p++) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
400 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
401 const stack_frame& elt = *p; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
402 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
403 scope(k) = elt.m_scope; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
404 context(k) = elt.m_context; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
405 file(k) = elt.fcn_file_name (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
406 name(k) = elt.fcn_name (print_subfn); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
407 line(k) = elt.m_line; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
408 column(k) = elt.m_column; |
7901 | 409 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
410 k++; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
411 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
412 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
413 return retval; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
414 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
415 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
416 bool |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
417 octave_call_stack::do_goto_frame (size_t n, bool verbose) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
418 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
419 bool retval = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
420 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
421 if (n < cs.size ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
422 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
423 retval = true; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
424 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
425 curr_frame = n; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
426 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
427 const stack_frame& elt = cs[n]; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
428 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
429 symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
430 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
431 if (verbose) |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
432 octave_stdout << "stopped in " << elt.fcn_name () |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
433 << " at line " << elt.m_line |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
434 << " column " << elt.m_column |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
435 << " (" << elt.m_scope << "[" << elt.m_context << "])" |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
436 << std::endl; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
437 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
438 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
439 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
440 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
441 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
442 bool |
7901 | 443 octave_call_stack::do_goto_frame_relative (int nskip, bool verbose) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
444 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
445 bool retval = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
446 |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
447 int incr = 0; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
448 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
449 if (nskip < 0) |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
450 incr = -1; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
451 else if (nskip > 0) |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
452 incr = 1; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
453 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
454 // Start looking with the caller of dbup/dbdown/keyboard. |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
455 size_t xframe = cs[curr_frame].m_prev; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
456 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
457 while (true) |
7890 | 458 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
459 if ((incr < 0 && xframe == 0) || (incr > 0 && xframe == cs.size () - 1)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
460 break; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
461 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
462 xframe += incr; |
7901 | 463 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
464 const stack_frame& elt = cs[xframe]; |
7901 | 465 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
466 octave_function *f = elt.m_fcn; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
467 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
468 if (xframe == 0 || (f && f->is_user_code ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
469 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
470 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
471 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
472 else if (nskip < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
473 nskip++; |
7901 | 474 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
475 if (nskip == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
476 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
477 curr_frame = xframe; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
478 cs[cs.size () - 1].m_prev = curr_frame; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
479 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
480 symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); |
7901 | 481 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
482 if (verbose) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
483 { |
9990
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
484 std::ostringstream buf; |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
485 |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
486 if (f) |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
487 buf << "stopped in " << f->name () |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
488 << " at line " << elt.m_line << std::endl; |
9990
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
489 else |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
490 buf << "at top level" << std::endl; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
491 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
492 octave_stdout << buf.str (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
493 } |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
494 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
495 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
496 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
497 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
498 } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
499 else if (incr == 0) // Break out of infinite loop by choosing an incr. |
18755
fc43c8017e9b
Fix infinite loop when using builtin ("keyboard") (bug #33296).
Rik <rik@octave.org>
parents:
18638
diff
changeset
|
500 incr = -1; |
7901 | 501 |
502 // There is no need to set scope and context here. That will | |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
503 // happen when the dbup/dbdown/keyboard frame is popped and we |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
504 // jump to the new "prev" frame set above. |
7890 | 505 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
506 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
507 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
508 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
509 |
5744 | 510 void |
7901 | 511 octave_call_stack::do_goto_caller_frame (void) |
512 { | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
513 size_t xframe = curr_frame; |
7901 | 514 |
515 bool skipped = false; | |
516 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
517 while (xframe != 0) |
7901 | 518 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
519 xframe = cs[xframe].m_prev; |
7901 | 520 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
521 const stack_frame& elt = cs[xframe]; |
7901 | 522 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
523 octave_function *f = elt.m_fcn; |
7901 | 524 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
525 if (elt.m_scope == cs[0].m_scope || (f && f->is_user_code ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
526 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
527 if (! skipped) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
528 // We found the current user code frame, so skip it. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
529 skipped = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
530 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
531 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
532 // We found the caller user code frame. |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
533 stack_frame tmp (elt); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
534 tmp.m_prev = curr_frame; |
7901 | 535 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
536 curr_frame = cs.size (); |
7901 | 537 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
538 cs.push_back (tmp); |
7901 | 539 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
540 symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); |
7901 | 541 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
542 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
543 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
544 } |
7901 | 545 } |
546 } | |
547 | |
548 void | |
549 octave_call_stack::do_goto_base_frame (void) | |
550 { | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
551 stack_frame tmp (cs[0]); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
552 tmp.m_prev = curr_frame; |
7901 | 553 |
554 curr_frame = cs.size (); | |
555 | |
556 cs.push_back (tmp); | |
557 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
558 symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
559 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
560 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
561 void |
4180 | 562 recover_from_exception (void) |
563 { | |
564 can_interrupt = true; | |
4182 | 565 octave_interrupt_immediately = 0; |
4180 | 566 octave_interrupt_state = 0; |
5142 | 567 octave_signal_caught = 0; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
568 octave_exception_state = octave_no_exception; |
4180 | 569 octave_restore_signal_mask (); |
570 octave_catch_interrupts (); | |
571 } | |
572 | |
1907 | 573 int |
5189 | 574 main_loop (void) |
1907 | 575 { |
2016 | 576 octave_save_signal_mask (); |
577 | |
3020 | 578 can_interrupt = true; |
1907 | 579 |
5142 | 580 octave_signal_hook = octave_signal_handler; |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
581 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
582 octave_bad_alloc_hook = 0; |
4429 | 583 |
2554 | 584 octave_catch_interrupts (); |
1907 | 585 |
4172 | 586 octave_initialized = true; |
587 | |
1907 | 588 // The big loop. |
589 | |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19734
diff
changeset
|
590 octave_lexer *lxr = (interactive |
16335
bef822a80ffb
if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents:
16317
diff
changeset
|
591 ? new octave_lexer () |
bef822a80ffb
if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents:
16317
diff
changeset
|
592 : new octave_lexer (stdin)); |
bef822a80ffb
if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents:
16317
diff
changeset
|
593 |
bef822a80ffb
if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents:
16317
diff
changeset
|
594 octave_parser parser (*lxr); |
16151 | 595 |
4153 | 596 int retval = 0; |
1907 | 597 do |
598 { | |
4180 | 599 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
600 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
601 reset_error_handler (); |
4318 | 602 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
603 parser.reset (); |
2620 | 604 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
605 if (symbol_table::at_top_level ()) |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
606 tree_evaluator::reset_debug_state (); |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
607 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
608 retval = parser.run (); |
2620 | 609 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
610 if (retval == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
611 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
612 if (parser.stmt_list) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
613 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
614 parser.stmt_list->accept (*current_evaluator); |
3883 | 615 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
616 octave_quit (); |
4171 | 617 |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19734
diff
changeset
|
618 if (! interactive) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
619 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
620 bool quit = (tree_return_command::returning |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
621 || tree_break_command::breaking); |
4153 | 622 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
623 if (tree_return_command::returning) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
624 tree_return_command::returning = 0; |
4153 | 625 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
626 if (tree_break_command::breaking) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
627 tree_break_command::breaking--; |
4153 | 628 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
629 if (quit) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
630 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
631 } |
4153 | 632 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
633 if (octave_completion_matches_called) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
634 octave_completion_matches_called = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
635 else |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
636 command_editor::increment_current_command_number (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
637 } |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
638 else if (parser.lexer.end_of_input) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
639 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
640 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
641 } |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20511
diff
changeset
|
642 catch (const octave_interrupt_exception&) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
643 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
644 recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
645 |
9383 | 646 octave_stdout << "\n"; |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
647 |
9383 | 648 if (quitting_gracefully) |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
649 return exit_status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
650 } |
20651
c1d94e5cd5ea
catch index_exception by const reference where possible
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
651 catch (const index_exception& e) |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
652 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
653 recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
654 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
655 std::cerr << "error: unhandled index exception: " |
20652
7a8096f8df5d
more cleanup of indexing exceptions
John W. Eaton <jwe@octave.org>
parents:
20651
diff
changeset
|
656 << e.message () << " -- trying to return to prompt" |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
657 << std::endl; |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
658 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
659 catch (const octave_execution_exception& e) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
660 { |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
661 std::string stack_trace = e.info (); |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
662 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
663 if (! stack_trace.empty ()) |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
664 std::cerr << stack_trace; |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
665 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
666 if (interactive) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
667 recover_from_exception (); |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
668 else |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
669 { |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
670 // We should exit with a nonzero status. |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
671 retval = 1; |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
672 break; |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
673 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
674 } |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20511
diff
changeset
|
675 catch (const std::bad_alloc&) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
676 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
677 recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
678 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
679 std::cerr << "error: out of memory -- trying to return to prompt" |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
680 << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
681 } |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
682 |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
683 #ifdef DBSTOP_NANINF |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
684 if (Vdebug_on_naninf) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
685 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
686 if (setjump (naninf_jump) != 0) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
687 debug_or_throw_exception (true); // true = stack trace |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
688 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
689 #endif |
1907 | 690 } |
691 while (retval == 0); | |
692 | |
18638
4ccd2b473f84
Print newline after closing interpreter with EOF (bug #41513).
Vaibhav Gupta <vaibhav.gupta@students.iiit.ac.in>
parents:
18515
diff
changeset
|
693 octave_stdout << "\n"; |
4ccd2b473f84
Print newline after closing interpreter with EOF (bug #41513).
Vaibhav Gupta <vaibhav.gupta@students.iiit.ac.in>
parents:
18515
diff
changeset
|
694 |
16987
aabe12e5fdc1
Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents:
16892
diff
changeset
|
695 if (retval == EOF) |
aabe12e5fdc1
Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents:
16892
diff
changeset
|
696 retval = 0; |
aabe12e5fdc1
Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents:
16892
diff
changeset
|
697 |
1907 | 698 return retval; |
699 } | |
700 | |
1683 | 701 // Fix up things before exiting. |
702 | |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
703 static std::list<std::string> octave_atexit_functions; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
704 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
705 static void |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
706 do_octave_atexit (void) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
707 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
708 static bool deja_vu = false; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
709 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
710 OCTAVE_SAFE_CALL (remove_input_event_hook_functions, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
711 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
712 while (! octave_atexit_functions.empty ()) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
713 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
714 std::string fcn = octave_atexit_functions.front (); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
715 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
716 octave_atexit_functions.pop_front (); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
717 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
718 OCTAVE_SAFE_CALL (reset_error_handler, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
719 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
720 OCTAVE_SAFE_CALL (feval, (fcn, octave_value_list (), 0)); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
721 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
722 OCTAVE_SAFE_CALL (flush_octave_stdout, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
723 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
724 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
725 if (! deja_vu) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
726 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
727 deja_vu = true; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
728 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
729 // Process pending events and disasble octave_link event |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
730 // processing with this call. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
731 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
732 octave_link::process_events (true); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
733 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
734 // Do this explicitly so that destructors for mex file objects |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
735 // are called, so that functions registered with mexAtExit are |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
736 // called. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
737 OCTAVE_SAFE_CALL (clear_mex_functions, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
738 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
739 OCTAVE_SAFE_CALL (command_editor::restore_terminal_state, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
740 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
741 // FIXME: is this needed? Can it cause any trouble? |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
742 OCTAVE_SAFE_CALL (raw_mode, (0)); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
743 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
744 OCTAVE_SAFE_CALL (octave_history_write_timestamp, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
745 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
746 if (! command_history::ignoring_entries ()) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
747 OCTAVE_SAFE_CALL (command_history::clean_up_and_save, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
748 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
749 OCTAVE_SAFE_CALL (gh_manager::close_all_figures, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
750 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
751 OCTAVE_SAFE_CALL (gtk_manager::unload_all_toolkits, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
752 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
753 OCTAVE_SAFE_CALL (close_files, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
754 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
755 OCTAVE_SAFE_CALL (cleanup_tmp_files, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
756 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
757 OCTAVE_SAFE_CALL (symbol_table::cleanup, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
758 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
759 OCTAVE_SAFE_CALL (sysdep_cleanup, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
760 |
17755
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
761 OCTAVE_SAFE_CALL (octave_finalize_hdf5, ()); |
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
762 |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
763 OCTAVE_SAFE_CALL (flush_octave_stdout, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
764 |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19734
diff
changeset
|
765 if (! quitting_gracefully && interactive) |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
766 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
767 octave_stdout << "\n"; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
768 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
769 // Yes, we want this to be separate from the call to |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
770 // flush_octave_stdout above. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
771 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
772 OCTAVE_SAFE_CALL (flush_octave_stdout, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
773 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
774 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
775 // Don't call singleton_cleanup_list::cleanup until we have the |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
776 // problems with registering/unregistering types worked out. For |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
777 // example, uncomment the following line, then use the make_int |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
778 // function from the examples directory to create an integer |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
779 // object and then exit Octave. Octave should crash with a |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
780 // segfault when cleaning up the typinfo singleton. We need some |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
781 // way to force new octave_value_X types that are created in |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
782 // .oct files to be unregistered when the .oct file shared library |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
783 // is unloaded. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
784 // |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
785 // OCTAVE_SAFE_CALL (singleton_cleanup_list::cleanup, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
786 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
787 OCTAVE_SAFE_CALL (octave_chunk_buffer::clear, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
788 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
789 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
790 |
1683 | 791 void |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
792 clean_up_and_exit (int status, bool safe_to_return) |
3162 | 793 { |
3216 | 794 do_octave_atexit (); |
1683 | 795 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
796 if (octave_link::exit (status)) |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
797 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
798 if (safe_to_return) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
799 return; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
800 else |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
801 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
802 // What should we do here? We might be called from some |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
803 // location other than the end of octave_execute_interpreter, |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
804 // so it might not be safe to return. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
805 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
806 // We have nothing else to do at this point, and the |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
807 // octave_link::exit function is supposed to take care of |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
808 // exiting for us. Assume that job won't take more than a |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
809 // day... |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
810 |
20923
58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20878
diff
changeset
|
811 octave_sleep (86400); // FIXME: really needed? |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
812 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
813 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
814 else |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
815 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
816 if (octave_exit) |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
817 (*octave_exit) (status); |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
818 } |
1683 | 819 } |
820 | |
11023
cb62c7401ea2
toplev.cc (Fquit): allow any number of output paramters
John W. Eaton <jwe@octave.org>
parents:
10890
diff
changeset
|
821 DEFUN (quit, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
822 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
823 @deftypefn {} {} exit\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
824 @deftypefnx {} {} exit (@var{status})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
825 @deftypefnx {} {} quit\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
826 @deftypefnx {} {} quit (@var{status})\n\ |
19273
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
827 Exit the current Octave session.\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
828 \n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
829 If the optional integer value @var{status} is supplied, pass that value to\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
830 the operating system as Octave's exit status. The default value is zero.\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
831 \n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
832 When exiting, Octave will attempt to run the m-file @file{finish.m} if it\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
833 exists. User commands to save the workspace or clean up temporary files\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
834 may be placed in that file. Alternatively, another m-file may be scheduled\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
835 to run using @code{atexit}.\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
836 @seealso{atexit}\n\ |
3333 | 837 @end deftypefn") |
1683 | 838 { |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
839 // Confirm OK to shutdown. Note: A dynamic function installation similar |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
840 // to overriding polymorphism for which the GUI can install its own "quit" |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
841 // yet call this base "quit" could be nice. No link would be needed here. |
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
842 if (! octave_link::confirm_shutdown ()) |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
843 return ovl (); |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
844 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
845 if (! quit_allowed) |
11590
4ced6b90fffb
style fixes for warning and error messages in source files
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
846 error ("quit: not supported in embedded mode"); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
847 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
848 if (args.length () > 0) |
2068 | 849 { |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
850 int tmp = args(0).nint_value (); |
1683 | 851 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
852 exit_status = tmp; |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
853 } |
3180 | 854 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
855 // Instead of simply calling exit, we simulate an interrupt |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
856 // with a request to exit cleanly so that no matter where the |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
857 // call to quit occurs, we will run the unwind_protect stack, |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
858 // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
859 // exiting. |
9383 | 860 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
861 quitting_gracefully = true; |
9383 | 862 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
863 octave_interrupt_state = -1; |
9383 | 864 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
865 octave_throw_interrupt_exception (); |
2068 | 866 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
867 return ovl (); |
1683 | 868 } |
869 | |
870 DEFALIAS (exit, quit); | |
871 | |
1957 | 872 DEFUN (warranty, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
873 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
874 @deftypefn {} {} warranty ()\n\ |
3446 | 875 Describe the conditions for copying and distributing Octave.\n\ |
876 @end deftypefn") | |
1683 | 877 { |
17510
7542f4496974
eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
878 octave_stdout << "\n" << octave_name_version_and_copyright () << "\n\ |
3922 | 879 \n\ |
19604
7005044f3080
Correct missing word in output of warranty().
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17821
diff
changeset
|
880 GNU Octave is free software; you can redistribute it and/or modify\n\ |
1683 | 881 it under the terms of the GNU General Public License as published by\n\ |
7016 | 882 the Free Software Foundation; either version 3 of the License, or\n\ |
1683 | 883 (at your option) any later version.\n\ |
884 \n\ | |
11104 | 885 GNU Octave is distributed in the hope that it will be useful,\n\ |
1683 | 886 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
887 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ | |
888 GNU General Public License for more details.\n\ | |
889 \n\ | |
890 You should have received a copy of the GNU General Public License\n\ | |
7016 | 891 along with this program. If not, see <http://www.gnu.org/licenses/>.\n\ |
1683 | 892 \n"; |
893 | |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
894 return ovl (); |
1683 | 895 } |
896 | |
897 // Execute a shell command. | |
898 | |
6316 | 899 static int |
900 wait_for_input (int fid) | |
901 { | |
902 int retval = -1; | |
903 | |
904 #if defined (HAVE_SELECT) | |
905 if (fid >= 0) | |
906 { | |
907 fd_set set; | |
908 | |
909 FD_ZERO (&set); | |
910 FD_SET (fid, &set); | |
911 | |
10411 | 912 retval = gnulib::select (FD_SETSIZE, &set, 0, 0, 0); |
6316 | 913 } |
914 #else | |
915 retval = 1; | |
916 #endif | |
917 | |
918 return retval; | |
919 } | |
920 | |
2086 | 921 static octave_value_list |
3523 | 922 run_command_and_return_output (const std::string& cmd_str) |
2083 | 923 { |
2086 | 924 octave_value_list retval; |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
925 unwind_protect frame; |
2083 | 926 |
927 iprocstream *cmd = new iprocstream (cmd_str.c_str ()); | |
928 | |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
929 frame.add_delete (cmd); |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
930 frame.add_fcn (octave_child_list::remove, cmd->pid ()); |
3060 | 931 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
932 if (! *cmd) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
933 error ("system: unable to start subprocess for '%s'", cmd_str.c_str ()); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
934 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
935 int fid = cmd->file_number (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
936 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
937 std::ostringstream output_buf; |
2095 | 938 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
939 char ch; |
4494 | 940 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
941 for (;;) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
942 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
943 if (cmd->get (ch)) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
944 output_buf.put (ch); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
945 else |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
946 { |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
947 if (! cmd->eof () && errno == EAGAIN) |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
948 { |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
949 cmd->clear (); |
3147 | 950 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
951 if (wait_for_input (fid) != 1) |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
952 break; |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
953 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
954 else |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
955 break; |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
956 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
957 } |
3147 | 958 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
959 int cmd_status = cmd->close (); |
2083 | 960 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
961 if (octave_wait::ifexited (cmd_status)) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
962 cmd_status = octave_wait::exitstatus (cmd_status); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
963 else |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
964 cmd_status = 127; |
2083 | 965 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
966 retval = ovl (cmd_status, output_buf.str ()); |
2083 | 967 |
968 return retval; | |
969 } | |
970 | |
5285 | 971 enum system_exec_type { et_sync, et_async }; |
972 | |
1957 | 973 DEFUN (system, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
974 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
975 @deftypefn {} {} system (\"@var{string}\")\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
976 @deftypefnx {} {} system (\"@var{string}\", @var{return_output})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
977 @deftypefnx {} {} system (\"@var{string}\", @var{return_output}, @var{type})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
978 @deftypefnx {} {[@var{status}, @var{output}] =} system (@dots{})\n\ |
11123
fbec4b3be59f
toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
979 Execute a shell command specified by @var{string}.\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
980 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
981 If the optional argument @var{type} is @qcode{\"async\"}, the process is\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
982 started in the background and the process ID of the child process is\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
983 returned immediately. Otherwise, the child process is started and Octave\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
984 waits until it exits. If the @var{type} argument is omitted, it defaults to\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
985 the value @qcode{\"sync\"}.\n\ |
2083 | 986 \n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
987 If @var{system} is called with one or more output arguments, or if the\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
988 optional argument @var{return_output} is true and the subprocess is started\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
989 synchronously, then the output from the command is returned as a variable.\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
990 Otherwise, if the subprocess is executed synchronously, its output is sent\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
991 to the standard output. To send the output of a command executed with\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
992 @code{system} through the pager, use a command like\n\ |
2321 | 993 \n\ |
3301 | 994 @example\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
995 @group\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
996 [output, text] = system (\"cmd\");\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
997 disp (text);\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
998 @end group\n\ |
3301 | 999 @end example\n\ |
2321 | 1000 \n\ |
3301 | 1001 @noindent\n\ |
2321 | 1002 or\n\ |
1003 \n\ | |
3301 | 1004 @example\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1005 printf (\"%s\\n\", nthargout (2, \"system\", \"cmd\"));\n\ |
3301 | 1006 @end example\n\ |
1007 \n\ | |
5659 | 1008 The @code{system} function can return two values. The first is the\n\ |
1009 exit status of the command and the second is any output from the\n\ | |
1010 command that was written to the standard output stream. For example,\n\ | |
3301 | 1011 \n\ |
1012 @example\n\ | |
5717 | 1013 [status, output] = system (\"echo foo; exit 2\");\n\ |
3301 | 1014 @end example\n\ |
1015 \n\ | |
1016 @noindent\n\ | |
1017 will set the variable @code{output} to the string @samp{foo}, and the\n\ | |
1018 variable @code{status} to the integer @samp{2}.\n\ | |
11123
fbec4b3be59f
toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
1019 \n\ |
fbec4b3be59f
toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
1020 For commands run asynchronously, @var{status} is the process id of the\n\ |
fbec4b3be59f
toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
1021 command shell that is started to run the command.\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1022 @seealso{unix, dos}\n\ |
3301 | 1023 @end deftypefn") |
1683 | 1024 { |
1025 int nargin = args.length (); | |
1026 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1027 if (nargin == 0 || nargin > 3) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1028 print_usage (); |
2083 | 1029 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1030 system_exec_type type = et_sync; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1031 if (nargin == 3) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1032 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1033 std::string type_str = args(2).xstring_value ("system: TYPE must be a string"); |
11123
fbec4b3be59f
toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
1034 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1035 if (type_str == "sync") |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1036 type = et_sync; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1037 else if (type_str == "async") |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1038 type = et_async; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1039 else |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
1040 error ("system: TYPE must be \"sync\" or \"async\""); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1041 } |
11123
fbec4b3be59f
toplev.cc (Fsystem): allow optional return_output and type arguments to be specified independently
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
1042 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1043 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1044 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1045 // FIXME: Is this unwind_protect frame needed anymore (12/16/15)? |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1046 unwind_protect frame; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1047 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1048 bool return_output = (nargin == 1 && nargout > 1); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1049 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1050 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1051 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1052 try |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1053 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1054 return_output = args(1).is_true (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1055 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1056 catch (octave_execution_exception& e) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1057 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1058 error (e, "system: RETURN_OUTPUT must be boolean value true or false"); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1059 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1060 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1061 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1062 if (return_output && type == et_async) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
1063 error ("system: can't return output from commands run asynchronously"); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1064 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1065 std::string cmd_str = args(0).xstring_value ("system: first argument must be a string"); |
1683 | 1066 |
7104 | 1067 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1068 // Work around weird double-quote handling on Windows systems. |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1069 if (type == et_sync) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1070 cmd_str = "\"" + cmd_str + "\""; |
7104 | 1071 #endif |
1072 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1073 if (type == et_async) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1074 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1075 // FIXME: maybe this should go in sysdep.cc? |
4086 | 1076 #ifdef HAVE_FORK |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1077 pid_t pid = fork (); |
2083 | 1078 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1079 if (pid < 0) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1080 error ("system: fork failed -- can't create child process"); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1081 else if (pid == 0) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1082 { |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1083 // FIXME: should probably replace this call with something portable. |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1084 execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (), |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1085 static_cast<void *> (0)); |
3273 | 1086 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1087 panic_impossible (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1088 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1089 else |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1090 retval(0) = pid; |
6222 | 1091 #elif defined (__WIN32__) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1092 STARTUPINFO si; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1093 PROCESS_INFORMATION pi; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1094 ZeroMemory (&si, sizeof (si)); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1095 ZeroMemory (&pi, sizeof (pi)); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1096 OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1097 strcpy (xcmd_str, cmd_str.c_str ()); |
6222 | 1098 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1099 if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi)) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1100 error ("system: CreateProcess failed -- can't create child process"); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1101 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1102 retval(0) = pi.dwProcessId; |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1103 CloseHandle (pi.hProcess); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1104 CloseHandle (pi.hThread); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1105 #else |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
1106 err_disabled_feature ("system", "asynchronous system calls"); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1107 #endif |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1108 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1109 else if (return_output) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1110 retval = run_command_and_return_output (cmd_str); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1111 else |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1112 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1113 int status = system (cmd_str.c_str ()); |
2321 | 1114 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1115 // The value in status is as returned by waitpid. If |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1116 // the process exited normally, extract the actual exit |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1117 // status of the command. Otherwise, return 127 as a |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1118 // failure code. |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
1119 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1120 if (octave_wait::ifexited (status)) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1121 status = octave_wait::exitstatus (status); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1122 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1123 retval(0) = status; |
1683 | 1124 } |
1125 | |
1126 return retval; | |
1127 } | |
1128 | |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1129 /* |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1130 %!test |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1131 %! cmd = ls_command (); |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1132 %! [status, output] = system (cmd); |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1133 %! assert (status, 0); |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1134 %! assert (ischar (output)); |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1135 %! assert (! isempty (output)); |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1136 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1137 %!error system () |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1138 %!error system (1, 2, 3) |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1139 */ |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1140 |
7409 | 1141 void |
1142 octave_add_atexit_function (const std::string& fname) | |
1143 { | |
1144 octave_atexit_functions.push_front (fname); | |
1145 } | |
1146 | |
1147 bool | |
1148 octave_remove_atexit_function (const std::string& fname) | |
1149 { | |
1150 bool found = false; | |
1151 | |
1152 for (std::list<std::string>::iterator p = octave_atexit_functions.begin (); | |
1153 p != octave_atexit_functions.end (); p++) | |
1154 { | |
1155 if (*p == fname) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1156 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1157 octave_atexit_functions.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1158 found = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1159 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1160 } |
7409 | 1161 } |
1162 | |
1163 return found; | |
1164 } | |
1165 | |
1166 | |
6680 | 1167 DEFUN (atexit, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1168 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1169 @deftypefn {} {} atexit (@var{fcn})\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1170 @deftypefnx {} {} atexit (@var{fcn}, @var{flag})\n\ |
19273
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
1171 Register a function to be called when Octave exits.\n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
1172 \n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
1173 For example,\n\ |
2077 | 1174 \n\ |
3332 | 1175 @example\n\ |
1176 @group\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1177 function last_words ()\n\ |
6620 | 1178 disp (\"Bye bye\");\n\ |
3332 | 1179 endfunction\n\ |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1180 atexit (\"last_words\");\n\ |
3332 | 1181 @end group\n\ |
1182 @end example\n\ | |
1183 \n\ | |
1184 @noindent\n\ | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16987
diff
changeset
|
1185 will print the message @qcode{\"Bye bye\"} when Octave exits.\n\ |
6680 | 1186 \n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1187 The additional argument @var{flag} will register or unregister @var{fcn}\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1188 from the list of functions to be called when Octave exits. If @var{flag} is\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1189 true, the function is registered, and if @var{flag} is false, it is\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1190 unregistered. For example, after registering the function @code{last_words}\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1191 above,\n\ |
6680 | 1192 \n\ |
1193 @example\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1194 atexit (\"last_words\", false);\n\ |
6680 | 1195 @end example\n\ |
1196 \n\ | |
1197 @noindent\n\ | |
1198 will remove the function from the list and Octave will not call\n\ | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9079
diff
changeset
|
1199 @code{last_words} when it exits.\n\ |
6680 | 1200 \n\ |
7001 | 1201 Note that @code{atexit} only removes the first occurrence of a function\n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1202 from the list, so if a function was placed in the list multiple times with\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1203 @code{atexit}, it must also be removed from the list multiple times.\n\ |
19273
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
1204 @seealso{quit}\n\ |
3333 | 1205 @end deftypefn") |
2077 | 1206 { |
1207 int nargin = args.length (); | |
1208 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1209 if (nargin < 1 || nargin > 2) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1210 print_usage (); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
1211 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1212 std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string"); |
2077 | 1213 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1214 bool add_mode = (nargin == 2) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1215 ? args(1).xbool_value ("atexit: FLAG argument must be a logical value") |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1216 : true; |
6680 | 1217 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1218 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1219 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1220 if (add_mode) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1221 octave_add_atexit_function (arg); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1222 else |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1223 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1224 bool found = octave_remove_atexit_function (arg); |
6680 | 1225 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1226 if (nargout > 0) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1227 retval = ovl (found); |
2077 | 1228 } |
1229 | |
1230 return retval; | |
1231 } | |
1232 | |
2689 | 1233 DEFUN (octave_config_info, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1234 "-*- texinfo -*-\n\ |
20853
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1235 @deftypefn {} {} octave_config_info ()\n\ |
1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
1236 @deftypefnx {} {} octave_config_info (@var{option})\n\ |
19192
8a8a7bc2a09d
Improve docstrings and mark documentation m-files as tested in miscellaneous/ dir.
Rik <rik@octave.org>
parents:
19032
diff
changeset
|
1237 Return a structure containing configuration and installation information for\n\ |
8a8a7bc2a09d
Improve docstrings and mark documentation m-files as tested in miscellaneous/ dir.
Rik <rik@octave.org>
parents:
19032
diff
changeset
|
1238 Octave.\n\ |
2689 | 1239 \n\ |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12195
diff
changeset
|
1240 If @var{option} is a string, return the configuration information for the\n\ |
2689 | 1241 specified option.\n\ |
1242 \n\ | |
19274
66ca15a97988
doc: Remove deprecated dump_prefs function from the manual.
Rik <rik@octave.org>
parents:
19273
diff
changeset
|
1243 @seealso{computer}\n\ |
3301 | 1244 @end deftypefn") |
2162 | 1245 { |
4128 | 1246 #if defined (ENABLE_DYNAMIC_LINKING) |
2689 | 1247 bool octave_supports_dynamic_linking = true; |
1248 #else | |
1249 bool octave_supports_dynamic_linking = false; | |
1250 #endif | |
1251 | |
4357 | 1252 static bool initialized = false; |
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:
11023
diff
changeset
|
1253 static octave_scalar_map m; |
2162 | 1254 |
6274 | 1255 struct conf_info_struct |
1256 { | |
1257 bool subst_home; | |
1258 const char *key; | |
1259 const char *val; | |
1260 }; | |
1261 | |
1262 static const conf_info_struct conf_info[] = | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1263 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1264 { false, "ALL_CFLAGS", OCTAVE_CONF_ALL_CFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1265 { false, "ALL_CXXFLAGS", OCTAVE_CONF_ALL_CXXFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1266 { false, "ALL_FFLAGS", OCTAVE_CONF_ALL_FFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1267 { false, "ALL_LDFLAGS", OCTAVE_CONF_ALL_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1268 { false, "AMD_CPPFLAGS", OCTAVE_CONF_AMD_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1269 { false, "AMD_LDFLAGS", OCTAVE_CONF_AMD_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1270 { false, "AMD_LIBS", OCTAVE_CONF_AMD_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1271 { false, "AR", OCTAVE_CONF_AR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1272 { false, "ARFLAGS", OCTAVE_CONF_ARFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1273 { false, "ARPACK_CPPFLAGS", OCTAVE_CONF_ARPACK_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1274 { false, "ARPACK_LDFLAGS", OCTAVE_CONF_ARPACK_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1275 { false, "ARPACK_LIBS", OCTAVE_CONF_ARPACK_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1276 { false, "BLAS_LIBS", OCTAVE_CONF_BLAS_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1277 { false, "CAMD_CPPFLAGS", OCTAVE_CONF_CAMD_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1278 { false, "CAMD_LDFLAGS", OCTAVE_CONF_CAMD_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1279 { false, "CAMD_LIBS", OCTAVE_CONF_CAMD_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1280 { false, "CARBON_LIBS", OCTAVE_CONF_CARBON_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1281 { false, "CC", OCTAVE_CONF_CC }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1282 { false, "CCOLAMD_CPPFLAGS", OCTAVE_CONF_CCOLAMD_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1283 { false, "CCOLAMD_LDFLAGS", OCTAVE_CONF_CCOLAMD_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1284 { false, "CCOLAMD_LIBS", OCTAVE_CONF_CCOLAMD_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1285 { false, "CFLAGS", OCTAVE_CONF_CFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1286 { false, "CHOLMOD_CPPFLAGS", OCTAVE_CONF_CHOLMOD_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1287 { false, "CHOLMOD_LDFLAGS", OCTAVE_CONF_CHOLMOD_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1288 { false, "CHOLMOD_LIBS", OCTAVE_CONF_CHOLMOD_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1289 { false, "COLAMD_CPPFLAGS", OCTAVE_CONF_COLAMD_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1290 { false, "COLAMD_LDFLAGS", OCTAVE_CONF_COLAMD_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1291 { false, "COLAMD_LIBS", OCTAVE_CONF_COLAMD_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1292 { false, "CPICFLAG", OCTAVE_CONF_CPICFLAG }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1293 { false, "CPPFLAGS", OCTAVE_CONF_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1294 { false, "CURL_CPPFLAGS", OCTAVE_CONF_CURL_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1295 { false, "CURL_LDFLAGS", OCTAVE_CONF_CURL_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1296 { false, "CURL_LIBS", OCTAVE_CONF_CURL_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1297 { false, "CXSPARSE_CPPFLAGS", OCTAVE_CONF_CXSPARSE_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1298 { false, "CXSPARSE_LDFLAGS", OCTAVE_CONF_CXSPARSE_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1299 { false, "CXSPARSE_LIBS", OCTAVE_CONF_CXSPARSE_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1300 { false, "CXX", OCTAVE_CONF_CXX }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1301 { false, "CXXCPP", OCTAVE_CONF_CXXCPP }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1302 { false, "CXXFLAGS", OCTAVE_CONF_CXXFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1303 { false, "CXXPICFLAG", OCTAVE_CONF_CXXPICFLAG }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1304 { false, "DEFAULT_PAGER", OCTAVE_DEFAULT_PAGER }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1305 { false, "DEFS", OCTAVE_CONF_DEFS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1306 { false, "DL_LD", OCTAVE_CONF_DL_LD }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1307 { false, "DL_LDFLAGS", OCTAVE_CONF_DL_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1308 { false, "DL_LIBS", OCTAVE_CONF_DL_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1309 { false, "GCC_VERSION", OCTAVE_CONF_GCC_VERSION }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1310 { false, "GXX_VERSION", OCTAVE_CONF_GXX_VERSION }, |
21131
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
1311 { false, "ENABLE_64", OCTAVE_CONF_ENABLE_64 }, |
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
1312 { false, "ENABLE_BOUNDS_CHECK", OCTAVE_CONF_ENABLE_BOUNDS_CHECK }, |
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
1313 { false, "ENABLE_DOCS", OCTAVE_CONF_ENABLE_DOCS }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1314 { false, "ENABLE_DYNAMIC_LINKING", OCTAVE_CONF_ENABLE_DYNAMIC_LINKING }, |
21131
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
1315 { false, "ENABLE_FLOAT_TRUNCATE", OCTAVE_CONF_ENABLE_FLOAT_TRUNCATE }, |
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
1316 { false, "ENABLE_JIT", OCTAVE_CONF_ENABLE_JIT }, |
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21109
diff
changeset
|
1317 { false, "ENABLE_OPENMP", OCTAVE_CONF_ENABLE_OPENMP }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1318 { false, "EXEEXT", OCTAVE_CONF_EXEEXT }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1319 { false, "F77", OCTAVE_CONF_F77 }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1320 { false, "F77_FLOAT_STORE_FLAG", OCTAVE_CONF_F77_FLOAT_STORE_FLAG }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1321 { false, "F77_INTEGER_8_FLAG", OCTAVE_CONF_F77_INTEGER_8_FLAG }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1322 { false, "FFLAGS", OCTAVE_CONF_FFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1323 { false, "FFTW3_CPPFLAGS", OCTAVE_CONF_FFTW3_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1324 { false, "FFTW3_LDFLAGS", OCTAVE_CONF_FFTW3_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1325 { false, "FFTW3_LIBS", OCTAVE_CONF_FFTW3_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1326 { false, "FFTW3F_CPPFLAGS", OCTAVE_CONF_FFTW3F_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1327 { false, "FFTW3F_LDFLAGS", OCTAVE_CONF_FFTW3F_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1328 { false, "FFTW3F_LIBS", OCTAVE_CONF_FFTW3F_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1329 { false, "FLIBS", OCTAVE_CONF_FLIBS }, |
19733
08033d583435
more consistently use _CPPFLAGS and _LDFLAGS variables
John W. Eaton <jwe@octave.org>
parents:
19732
diff
changeset
|
1330 { false, "FLTK_CPPFLAGS", OCTAVE_CONF_FLTK_CPPFLAGS }, |
08033d583435
more consistently use _CPPFLAGS and _LDFLAGS variables
John W. Eaton <jwe@octave.org>
parents:
19732
diff
changeset
|
1331 { false, "FLTK_LDFLAGS", OCTAVE_CONF_FLTK_LDFLAGS }, |
19732
bf25e9f7c22a
use FLTK_CFLAGS and FLTK_LIBS instead of GRAPHICS_CFLAGS and GRAPHICS_LIBS
John W. Eaton <jwe@octave.org>
parents:
19714
diff
changeset
|
1332 { false, "FLTK_LIBS", OCTAVE_CONF_FLTK_LIBS }, |
19733
08033d583435
more consistently use _CPPFLAGS and _LDFLAGS variables
John W. Eaton <jwe@octave.org>
parents:
19732
diff
changeset
|
1333 { false, "FONTCONFIG_CPPFLAGS", OCTAVE_CONF_FONTCONFIG_CPPFLAGS }, |
08033d583435
more consistently use _CPPFLAGS and _LDFLAGS variables
John W. Eaton <jwe@octave.org>
parents:
19732
diff
changeset
|
1334 { false, "FONTCONFIG_LIBS", OCTAVE_CONF_FONTCONFIG_LIBS }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1335 { false, "FPICFLAG", OCTAVE_CONF_FPICFLAG }, |
19733
08033d583435
more consistently use _CPPFLAGS and _LDFLAGS variables
John W. Eaton <jwe@octave.org>
parents:
19732
diff
changeset
|
1336 { false, "FT2_CPPFLAGS", OCTAVE_CONF_FT2_CPPFLAGS }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1337 { false, "FT2_LIBS", OCTAVE_CONF_FT2_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1338 { false, "GLPK_CPPFLAGS", OCTAVE_CONF_GLPK_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1339 { false, "GLPK_LDFLAGS", OCTAVE_CONF_GLPK_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1340 { false, "GLPK_LIBS", OCTAVE_CONF_GLPK_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1341 { false, "GNUPLOT", OCTAVE_CONF_GNUPLOT }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1342 { false, "HDF5_CPPFLAGS", OCTAVE_CONF_HDF5_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1343 { false, "HDF5_LDFLAGS", OCTAVE_CONF_HDF5_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1344 { false, "HDF5_LIBS", OCTAVE_CONF_HDF5_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1345 { false, "LAPACK_LIBS", OCTAVE_CONF_LAPACK_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1346 { false, "LDFLAGS", OCTAVE_CONF_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1347 { false, "LD_CXX", OCTAVE_CONF_LD_CXX }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1348 { false, "LD_STATIC_FLAG", OCTAVE_CONF_LD_STATIC_FLAG }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1349 { false, "LEX", OCTAVE_CONF_LEX }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1350 { false, "LEXLIB", OCTAVE_CONF_LEXLIB }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1351 { false, "LFLAGS", OCTAVE_CONF_LFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1352 { false, "LIBEXT", OCTAVE_CONF_LIBEXT }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1353 { false, "LIBFLAGS", OCTAVE_CONF_LIBFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1354 { false, "LIBOCTAVE", OCTAVE_CONF_LIBOCTAVE }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1355 { false, "LIBOCTINTERP", OCTAVE_CONF_LIBOCTINTERP }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1356 { false, "LIBS", OCTAVE_CONF_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1357 { false, "LLVM_CPPFLAGS", OCTAVE_CONF_LLVM_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1358 { false, "LLVM_LDFLAGS", OCTAVE_CONF_LLVM_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1359 { false, "LLVM_LIBS", OCTAVE_CONF_LLVM_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1360 { false, "LN_S", OCTAVE_CONF_LN_S }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1361 { false, "MAGICK_CPPFLAGS", OCTAVE_CONF_MAGICK_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1362 { false, "MAGICK_LDFLAGS", OCTAVE_CONF_MAGICK_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1363 { false, "MAGICK_LIBS", OCTAVE_CONF_MAGICK_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1364 { false, "MKOCTFILE_DL_LDFLAGS", OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1365 { false, "OCTAVE_LINK_DEPS", OCTAVE_CONF_OCTAVE_LINK_DEPS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1366 { false, "OCTAVE_LINK_OPTS", OCTAVE_CONF_OCTAVE_LINK_OPTS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1367 { false, "OCT_LINK_DEPS", OCTAVE_CONF_OCT_LINK_DEPS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1368 { false, "OCT_LINK_OPTS", OCTAVE_CONF_OCT_LINK_OPTS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1369 { false, "OPENGL_LIBS", OCTAVE_CONF_OPENGL_LIBS }, |
19734
9f6ee9cb749c
put OSMESA compiler flag variables in config_options struct
John W. Eaton <jwe@octave.org>
parents:
19733
diff
changeset
|
1370 { false, "OSMESA_CPPFLAGS", OCTAVE_CONF_OSMESA_CPPFLAGS }, |
9f6ee9cb749c
put OSMESA compiler flag variables in config_options struct
John W. Eaton <jwe@octave.org>
parents:
19733
diff
changeset
|
1371 { false, "OSMESA_LDFLAGS", OCTAVE_CONF_OSMESA_LDFLAGS }, |
9f6ee9cb749c
put OSMESA compiler flag variables in config_options struct
John W. Eaton <jwe@octave.org>
parents:
19733
diff
changeset
|
1372 { false, "OSMESA_LIBS", OCTAVE_CONF_OSMESA_LIBS }, |
17821
82c94987abc6
build: Remove REGEX_CPPFLAGS from XTRA_CXXFLAGS.
Rik <rik@octave.org>
parents:
17816
diff
changeset
|
1373 { false, "PCRE_CPPFLAGS", OCTAVE_CONF_PCRE_CPPFLAGS }, |
82c94987abc6
build: Remove REGEX_CPPFLAGS from XTRA_CXXFLAGS.
Rik <rik@octave.org>
parents:
17816
diff
changeset
|
1374 { false, "PCRE_LIBS", OCTAVE_CONF_PCRE_LIBS }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1375 { false, "PTHREAD_CFLAGS", OCTAVE_CONF_PTHREAD_CFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1376 { false, "PTHREAD_LIBS", OCTAVE_CONF_PTHREAD_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1377 { false, "QHULL_CPPFLAGS", OCTAVE_CONF_QHULL_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1378 { false, "QHULL_LDFLAGS", OCTAVE_CONF_QHULL_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1379 { false, "QHULL_LIBS", OCTAVE_CONF_QHULL_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1380 { false, "QRUPDATE_CPPFLAGS", OCTAVE_CONF_QRUPDATE_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1381 { false, "QRUPDATE_LDFLAGS", OCTAVE_CONF_QRUPDATE_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1382 { false, "QRUPDATE_LIBS", OCTAVE_CONF_QRUPDATE_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1383 { false, "QT_CPPFLAGS", OCTAVE_CONF_QT_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1384 { false, "QT_LDFLAGS", OCTAVE_CONF_QT_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1385 { false, "QT_LIBS", OCTAVE_CONF_QT_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1386 { false, "RANLIB", OCTAVE_CONF_RANLIB }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1387 { false, "RDYNAMIC_FLAG", OCTAVE_CONF_RDYNAMIC_FLAG }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1388 { false, "READLINE_LIBS", OCTAVE_CONF_READLINE_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1389 { false, "SED", OCTAVE_CONF_SED }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1390 { false, "SHARED_LIBS", OCTAVE_CONF_SHARED_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1391 { false, "SHLEXT", OCTAVE_CONF_SHLEXT }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1392 { false, "SHLEXT_VER", OCTAVE_CONF_SHLEXT_VER }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1393 { false, "SH_LD", OCTAVE_CONF_SH_LD }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1394 { false, "SH_LDFLAGS", OCTAVE_CONF_SH_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1395 { false, "SONAME_FLAGS", OCTAVE_CONF_SONAME_FLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1396 { false, "STATIC_LIBS", OCTAVE_CONF_STATIC_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1397 { false, "TERM_LIBS", OCTAVE_CONF_TERM_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1398 { false, "UMFPACK_CPPFLAGS", OCTAVE_CONF_UMFPACK_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1399 { false, "UMFPACK_LDFLAGS", OCTAVE_CONF_UMFPACK_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1400 { false, "UMFPACK_LIBS", OCTAVE_CONF_UMFPACK_LIBS }, |
21140
e06e600f396a
eliminate use of USE_64_BIT_IDX_T
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
1401 { false, "USE_64_BIT_IDX_T", OCTAVE_CONF_ENABLE_64 }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1402 { false, "WARN_CFLAGS", OCTAVE_CONF_WARN_CFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1403 { false, "WARN_CXXFLAGS", OCTAVE_CONF_WARN_CXXFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1404 { false, "X11_INCFLAGS", OCTAVE_CONF_X11_INCFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1405 { false, "X11_LIBS", OCTAVE_CONF_X11_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1406 { false, "XTRA_CFLAGS", OCTAVE_CONF_XTRA_CFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1407 { false, "XTRA_CXXFLAGS", OCTAVE_CONF_XTRA_CXXFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1408 { false, "YACC", OCTAVE_CONF_YACC }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1409 { false, "YFLAGS", OCTAVE_CONF_YFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1410 { false, "Z_CPPFLAGS", OCTAVE_CONF_Z_CPPFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1411 { false, "Z_LDFLAGS", OCTAVE_CONF_Z_LDFLAGS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1412 { false, "Z_LIBS", OCTAVE_CONF_Z_LIBS }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1413 { false, "api_version", OCTAVE_API_VERSION }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1414 { true, "archlibdir", OCTAVE_ARCHLIBDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1415 { true, "bindir", OCTAVE_BINDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1416 { false, "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1417 { false, "config_opts", OCTAVE_CONF_config_opts }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1418 { true, "datadir", OCTAVE_DATADIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1419 { true, "datarootdir", OCTAVE_DATAROOTDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1420 { true, "exec_prefix", OCTAVE_EXEC_PREFIX }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1421 { true, "fcnfiledir", OCTAVE_FCNFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1422 { true, "imagedir", OCTAVE_IMAGEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1423 { true, "includedir", OCTAVE_INCLUDEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1424 { true, "infodir", OCTAVE_INFODIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1425 { true, "infofile", OCTAVE_INFOFILE }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1426 { true, "libdir", OCTAVE_LIBDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1427 { true, "libexecdir", OCTAVE_LIBEXECDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1428 { true, "localapiarchlibdir", OCTAVE_LOCALAPIARCHLIBDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1429 { true, "localapifcnfiledir", OCTAVE_LOCALAPIFCNFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1430 { true, "localapioctfiledir", OCTAVE_LOCALAPIOCTFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1431 { true, "localarchlibdir", OCTAVE_LOCALARCHLIBDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1432 { true, "localfcnfiledir", OCTAVE_LOCALFCNFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1433 { true, "localoctfiledir", OCTAVE_LOCALOCTFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1434 { true, "localstartupfiledir", OCTAVE_LOCALSTARTUPFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1435 { true, "localverarchlibdir", OCTAVE_LOCALVERARCHLIBDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1436 { true, "localverfcnfiledir", OCTAVE_LOCALVERFCNFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1437 { true, "localveroctfiledir", OCTAVE_LOCALVEROCTFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1438 { true, "man1dir", OCTAVE_MAN1DIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1439 { false, "man1ext", OCTAVE_MAN1EXT }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1440 { true, "mandir", OCTAVE_MANDIR }, |
19032
d902542221c8
new data directory for storing data files we distribute
John W. Eaton <jwe@octave.org>
parents:
18812
diff
changeset
|
1441 { true, "octdatadir", OCTAVE_OCTDATADIR }, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1442 { true, "octfiledir", OCTAVE_OCTFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1443 { true, "octetcdir", OCTAVE_OCTETCDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1444 { true, "octincludedir", OCTAVE_OCTINCLUDEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1445 { true, "octlibdir", OCTAVE_OCTLIBDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1446 { true, "octtestsdir", OCTAVE_OCTTESTSDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1447 { true, "prefix", OCTAVE_PREFIX }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1448 { true, "startupfiledir", OCTAVE_STARTUPFILEDIR }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1449 { false, "version", OCTAVE_VERSION }, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1450 { false, 0, 0 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1451 }; |
4357 | 1452 |
1453 if (! initialized) | |
1454 { | |
4675 | 1455 m.assign ("dld", octave_value (octave_supports_dynamic_linking)); |
4357 | 1456 |
4697 | 1457 oct_mach_info::float_format ff = oct_mach_info::native_float_format (); |
1458 m.assign ("float_format", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1459 octave_value (oct_mach_info::float_format_as_string (ff))); |
4697 | 1460 |
1461 m.assign ("words_big_endian", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1462 octave_value (oct_mach_info::words_big_endian ())); |
4697 | 1463 |
1464 m.assign ("words_little_endian", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1465 octave_value (oct_mach_info::words_little_endian ())); |
4697 | 1466 |
16170
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1467 m.assign ("features", octave_value (octave_config_features ())); |
2a4f83826024
new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
1468 |
4357 | 1469 int i = 0; |
4440 | 1470 |
1471 while (true) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1472 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1473 const conf_info_struct& elt = conf_info[i++]; |
6274 | 1474 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1475 const char *key = elt.key; |
4357 | 1476 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1477 if (key) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1478 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1479 if (elt.subst_home) |
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:
11023
diff
changeset
|
1480 m.assign (key, subst_octave_home (elt.val)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1481 else |
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:
11023
diff
changeset
|
1482 m.assign (key, elt.val); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1483 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1484 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1485 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1486 } |
4357 | 1487 |
4691 | 1488 bool unix_system = true; |
7013 | 1489 bool mac_system = false; |
4691 | 1490 bool windows_system = false; |
1491 | |
1492 #if defined (WIN32) | |
1493 windows_system = true; | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20785
diff
changeset
|
1494 #if ! defined (__CYGWIN__) |
4691 | 1495 unix_system = false; |
1496 #endif | |
1497 #endif | |
1498 | |
8574
83b8c739d626
toplev.cc: check OCTAVE_USE_OS_X_API instead of __APPLE__ && __MACH__
John W. Eaton <jwe@octave.org>
parents:
8377
diff
changeset
|
1499 #if defined (OCTAVE_USE_OS_X_API) |
7010 | 1500 mac_system = true; |
1501 #endif | |
1502 | |
4691 | 1503 m.assign ("unix", octave_value (unix_system)); |
7010 | 1504 m.assign ("mac", octave_value (mac_system)); |
4691 | 1505 m.assign ("windows", octave_value (windows_system)); |
1506 | |
4357 | 1507 initialized = true; |
1508 } | |
2162 | 1509 |
2689 | 1510 int nargin = args.length (); |
1511 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1512 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1513 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1514 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1515 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1516 |
2689 | 1517 if (nargin == 1) |
1518 { | |
3523 | 1519 std::string arg = args(0).string_value (); |
2689 | 1520 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1521 if (! m.isfield (arg)) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1522 error ("octave_config_info: invalid parameter '%s'", arg.c_str ()); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1523 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1524 Cell c = m.contents (arg); |
5199 | 1525 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1526 if (c.is_empty ()) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1527 error ("octave_config_info: no info for '%s'", arg.c_str ()); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1528 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1529 retval = ovl (c(0)); |
2689 | 1530 } |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1531 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1532 retval = ovl (m); |
2689 | 1533 |
1534 return retval; | |
2162 | 1535 } |
1536 | |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1537 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14156
diff
changeset
|
1538 %!assert (ischar (octave_config_info ("version"))) |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1539 %!test |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1540 %! x = octave_config_info (); |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1541 %! assert (isstruct (x)); |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1542 %! assert (! isempty (x)); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14156
diff
changeset
|
1543 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14156
diff
changeset
|
1544 %!error octave_config_info (1, 2) |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1545 */ |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1546 |
1683 | 1547 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE) |
2806 | 1548 |
1683 | 1549 int debug_new_delete = 0; |
1550 | |
1551 typedef void (*vfp)(void); | |
1552 extern vfp __new_handler; | |
1553 | |
1554 void * | |
1555 __builtin_new (size_t sz) | |
1556 { | |
1557 void *p; | |
1558 | |
20946 | 1559 // malloc (0) is unpredictable; avoid it. |
1683 | 1560 if (sz == 0) |
1561 sz = 1; | |
15451
219479b461b8
build: Add missing tests and gnulib modules suggested by autoscan.
Rik <rik@octave.org>
parents:
15424
diff
changeset
|
1562 p = gnulib::malloc (sz); |
1683 | 1563 while (p == 0) |
1564 { | |
1565 (*__new_handler) (); | |
15451
219479b461b8
build: Add missing tests and gnulib modules suggested by autoscan.
Rik <rik@octave.org>
parents:
15424
diff
changeset
|
1566 p = gnulib::malloc (sz); |
1683 | 1567 } |
1568 | |
1569 if (debug_new_delete) | |
5629 | 1570 std::cerr << "__builtin_new: " << p << std::endl; |
1683 | 1571 |
1572 return p; | |
1573 } | |
1574 | |
1575 void | |
1576 __builtin_delete (void *ptr) | |
1577 { | |
1578 if (debug_new_delete) | |
5629 | 1579 std::cerr << "__builtin_delete: " << ptr << std::endl; |
1683 | 1580 |
1581 if (ptr) | |
1582 free (ptr); | |
1583 } | |
2806 | 1584 |
1683 | 1585 #endif |