Mercurial > octave
annotate libinterp/corefcn/toplev.cc @ 21899:7c053ad1c7ba
hide sys/select header
* liboctave/wrappers/wait-for-input.c,
liboctave/wrappers/wait-for-input.h: New files.
* liboctave/wrappers/module.mk: Update.
* toplev.cc: Use new octave_wait_for_input function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 14 Jun 2016 13:43:17 -0400 |
parents | bfc662ee0340 |
children | 98f5dd2ff29a |
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 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21618
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21253
diff
changeset
|
24 # include "config.h" |
1683 | 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 | |
2926 | 38 #include "cmd-edit.h" |
12989
00235a6446da
eliminate duplication of internal variables controlling command history
John W. Eaton <jwe@octave.org>
parents:
12846
diff
changeset
|
39 #include "cmd-hist.h" |
2926 | 40 #include "file-ops.h" |
1683 | 41 #include "lo-error.h" |
2370 | 42 #include "lo-mappers.h" |
3020 | 43 #include "oct-env.h" |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21598
diff
changeset
|
44 #include "oct-fftw.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
45 #include "oct-locbuf.h" |
4153 | 46 #include "quit.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
47 #include "singleton-cleanup.h" |
1755 | 48 #include "str-vec.h" |
21899 | 49 #include "wait-for-input.h" |
1683 | 50 |
21220
d78e45987d6a
rename octave::build_env namespace from octave::config
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
51 #include "build-env.h" |
21607
37f6ed8a6f1b
store liboctave and liboctinterp hg ids separately
John W. Eaton <jwe@octave.org>
parents:
21605
diff
changeset
|
52 #include "liboctinterp-build-info.h" |
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" |
1742 | 62 #include "oct-hist.h" |
2162 | 63 #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
|
64 #include "ovl.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
65 #include "ov.h" |
1683 | 66 #include "pager.h" |
67 #include "parse.h" | |
68 #include "pathsearch.h" | |
69 #include "procstream.h" | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8581
diff
changeset
|
70 #include "pt-eval.h" |
2985 | 71 #include "pt-jump.h" |
2982 | 72 #include "pt-stmt.h" |
1683 | 73 #include "sighandlers.h" |
74 #include "sysdep.h" | |
2693 | 75 #include "syswait.h" |
1750 | 76 #include "toplev.h" |
1683 | 77 #include "unwind-prot.h" |
78 #include "utils.h" | |
79 #include "variables.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
80 #include "version.h" |
1683 | 81 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21618
diff
changeset
|
82 #if ! defined (SHELL_PATH) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21182
diff
changeset
|
83 # define SHELL_PATH "/bin/sh" |
15756
ea1a1fb00744
Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents:
15596
diff
changeset
|
84 #endif |
ea1a1fb00744
Make the path to the shell interpreter configuable
Mike Miller <mtmiller@ieee.org>
parents:
15596
diff
changeset
|
85 |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
86 void (*octave_exit) (int) = ::exit; |
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
87 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
88 // 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
|
89 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
|
90 |
3020 | 91 // TRUE means we are exiting via the builtin exit or quit functions. |
9383 | 92 bool quitting_gracefully = false; |
93 // This stores the exit status. | |
94 int exit_status = 0; | |
1683 | 95 |
4217 | 96 // TRUE means we are ready to interpret commands, but not everything |
97 // is ready for interactive use. | |
98 bool octave_interpreter_ready = false; | |
99 | |
4172 | 100 // TRUE means we've processed all the init code and we are good to go. |
101 bool octave_initialized = false; | |
102 | |
5743 | 103 octave_call_stack *octave_call_stack::instance = 0; |
104 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
105 std::string |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
106 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
|
107 { |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20962
diff
changeset
|
108 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
|
109 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
110 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
111 std::string |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
112 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
|
113 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
114 std::string retval; |
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 if (m_fcn) |
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 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
|
119 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
120 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
|
121 retval = parent_fcn_name + Vfilemarker; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
122 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
123 retval += m_fcn->name (); |
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 else |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
126 retval = "<unknown>"; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
127 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
128 return retval; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
129 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
130 |
20511
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
131 bool |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
132 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
|
133 { |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
134 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
|
135 return false; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
136 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
|
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->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
|
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_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
|
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 |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
143 return true; |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
144 } |
9502e0142c19
Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents:
20172
diff
changeset
|
145 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
146 void |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
147 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
|
148 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
149 instance = new octave_call_stack (); |
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 if (instance) |
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 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
|
154 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
155 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
|
156 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
157 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13981
diff
changeset
|
158 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
159 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
160 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
|
161 { |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
162 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
|
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 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
|
165 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
166 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
|
167 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
|
168 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
169 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
170 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
|
171 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
172 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
173 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
174 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
|
175 { |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
176 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
|
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 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
|
179 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
180 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
|
181 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
|
182 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
183 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16347
diff
changeset
|
184 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
|
185 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
186 |
7901 | 187 size_t |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
188 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
|
189 (octave_idx_type& curr_user_frame) const |
7901 | 190 { |
191 size_t retval = 0; | |
192 | |
193 curr_user_frame = 0; | |
194 | |
195 // 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
|
196 size_t xframe = cs[curr_frame].m_prev; |
7901 | 197 |
198 bool found = false; | |
199 | |
200 size_t k = cs.size (); | |
201 | |
202 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) | |
203 { | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
204 octave_function *f = (*p).m_fcn; |
7901 | 205 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
206 if (--k == xframe) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
207 found = true; |
7901 | 208 |
209 if (f && f->is_user_code ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
210 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
211 if (! found) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
212 curr_user_frame++; |
7901 | 213 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
214 retval++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
215 } |
7901 | 216 } |
217 | |
218 // We counted how many user frames were not the one, in reverse. | |
219 // Now set curr_user_frame to be the index in the other direction. | |
220 curr_user_frame = retval - curr_user_frame - 1; | |
221 | |
222 return retval; | |
223 } | |
224 | |
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
|
225 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
|
226 octave_call_stack::do_caller_user_code (size_t nskip) const |
5744 | 227 { |
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
|
228 octave_user_code *retval = 0; |
5744 | 229 |
7890 | 230 const_iterator p = cs.end (); |
231 | |
232 while (p != cs.begin ()) | |
5744 | 233 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
234 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
|
235 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
236 octave_function *f = elt.m_fcn; |
5744 | 237 |
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
|
238 if (f && f->is_user_code ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
239 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
240 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
241 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
242 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
243 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
244 retval = dynamic_cast<octave_user_code *> (f); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
245 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
246 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
247 } |
5744 | 248 } |
249 | |
250 return retval; | |
251 } | |
252 | |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
253 int |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
254 octave_call_stack::do_caller_user_code_line (void) const |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
255 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
256 int retval = -1; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
257 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
258 const_iterator p = cs.end (); |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
259 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
260 while (p != cs.begin ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
261 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
262 const stack_frame& elt = *(--p); |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
263 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
264 octave_function *f = elt.m_fcn; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
265 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
266 if (f && f->is_user_code ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
267 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
268 if (elt.m_line > 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
269 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
270 retval = elt.m_line; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
271 break; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
272 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
273 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
274 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
275 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
276 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
277 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
278 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
279 int |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
280 octave_call_stack::do_caller_user_code_column (void) const |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
281 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
282 int retval = -1; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
283 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
284 const_iterator p = cs.end (); |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
285 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
286 while (p != cs.begin ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
287 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
288 const stack_frame& elt = *(--p); |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
289 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
290 octave_function *f = elt.m_fcn; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
291 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
292 if (f && f->is_user_code ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
293 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
294 if (elt.m_column) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
295 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
296 retval = elt.m_column; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
297 break; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
298 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
299 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
300 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
301 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
302 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
303 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
304 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
305 octave_user_code * |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
306 octave_call_stack::do_debug_user_code (void) const |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
307 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
308 octave_user_code *retval = 0; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
309 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
310 // This should never happen... |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
311 if (curr_frame == 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
312 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
313 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
314 // Start looking with the caller of the calling debug function. |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
315 size_t i = cs[curr_frame].m_prev; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
316 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
317 while (i != 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
318 { |
21618
d8d0020bf1e9
Fix hang when querying dbstack (bug #47605).
Rik <rik@octave.org>
parents:
21608
diff
changeset
|
319 const stack_frame& elt = cs[i--]; |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
320 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
321 octave_function *f = elt.m_fcn; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
322 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
323 if (f && f->is_user_code ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
324 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
325 retval = dynamic_cast<octave_user_code *> (f); |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
326 break; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
327 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
328 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
329 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
330 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
331 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
332 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
333 int |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
334 octave_call_stack::do_debug_user_code_line (void) const |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
335 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
336 int retval = -1; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
337 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
338 // This should never happen... |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
339 if (curr_frame == 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
340 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
341 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
342 // Start looking with the caller of the calling debug function. |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
343 size_t i = cs[curr_frame].m_prev; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
344 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
345 while (i != 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
346 { |
21618
d8d0020bf1e9
Fix hang when querying dbstack (bug #47605).
Rik <rik@octave.org>
parents:
21608
diff
changeset
|
347 const stack_frame& elt = cs[i--]; |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
348 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
349 octave_function *f = elt.m_fcn; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
350 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
351 if (f && f->is_user_code ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
352 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
353 if (elt.m_line) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
354 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
355 retval = elt.m_line; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
356 break; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
357 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
358 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
359 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
360 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
361 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
362 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
363 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
364 int |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
365 octave_call_stack::do_debug_user_code_column (void) const |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
366 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
367 int retval = -1; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
368 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
369 // This should never happen... |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
370 if (curr_frame == 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
371 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
372 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
373 // Start looking with the caller of the calling debug function. |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
374 size_t i = cs[curr_frame].m_prev; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
375 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
376 while (i != 0) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
377 { |
21618
d8d0020bf1e9
Fix hang when querying dbstack (bug #47605).
Rik <rik@octave.org>
parents:
21608
diff
changeset
|
378 const stack_frame& elt = cs[i--]; |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
379 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
380 octave_function *f = elt.m_fcn; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
381 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
382 if (f && f->is_user_code ()) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
383 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
384 if (elt.m_column) |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
385 { |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
386 retval = elt.m_column; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
387 break; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
388 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
389 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
390 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
391 |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
392 return retval; |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
393 } |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
394 |
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
|
395 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
|
396 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
|
397 { |
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
|
398 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
|
399 |
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
|
400 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
|
401 |
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
|
402 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
|
403 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
404 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
|
405 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
406 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
|
407 |
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
|
408 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
|
409 { |
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
|
410 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
|
411 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
|
412 } |
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
|
413 } |
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
|
414 |
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
|
415 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
|
416 } |
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
|
417 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
418 // 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
|
419 // 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
|
420 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
|
421 "column", "scope", "context", 0 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
422 }; |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
423 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
|
424 |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
425 octave_map |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
426 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
|
427 { |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
428 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
|
429 } |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
430 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
431 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
|
432 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
|
433 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
|
434 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
435 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
|
436 |
7901 | 437 size_t user_code_frames = do_num_user_code_frames (curr_user_frame); |
438 | |
439 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
|
440 |
7901 | 441 // Our list is reversed. |
442 curr_user_frame = nframes - curr_user_frame - 1; | |
443 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
444 if (nframes > 0) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
445 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
446 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
|
447 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
448 const stack_frame& elt = *p; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
449 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
450 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
|
451 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
452 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
|
453 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
454 if (nskip > 0) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
455 nskip--; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
456 else |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
457 retval.push_back (elt); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
458 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
459 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
460 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
461 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
462 return retval; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
463 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
464 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
465 octave_map |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
466 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
|
467 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
|
468 bool print_subfn) const |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
469 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
470 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
|
471 = 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
|
472 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
473 size_t nframes = frames.size (); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
474 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
475 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
|
476 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
477 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
|
478 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
|
479 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
|
480 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
|
481 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
|
482 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
|
483 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
484 octave_idx_type k = 0; |
7901 | 485 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
486 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
|
487 p != frames.end (); p++) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
488 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
489 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
|
490 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
491 scope(k) = elt.m_scope; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
492 context(k) = elt.m_context; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
493 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
|
494 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
|
495 line(k) = elt.m_line; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
496 column(k) = elt.m_column; |
7901 | 497 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
498 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
|
499 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
500 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
501 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
|
502 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
503 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
504 bool |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
505 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
|
506 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
507 bool retval = false; |
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 if (n < cs.size ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
510 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
511 retval = true; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
512 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
513 curr_frame = n; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
514 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
515 const stack_frame& elt = cs[n]; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
516 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
517 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
|
518 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
519 if (verbose) |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
520 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
|
521 << " at line " << elt.m_line |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
522 << " column " << elt.m_column |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
523 << " [" << elt.fcn_file_name () << "] " |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
524 << " (scope = " << elt.m_scope |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
525 << "[context = " << elt.m_context << "])" |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
526 << std::endl; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
527 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
528 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
529 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
530 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
531 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
532 bool |
7901 | 533 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
|
534 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
535 bool retval = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
536 |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
537 int incr = 0; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
538 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
539 if (nskip < 0) |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
540 incr = -1; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
541 else if (nskip > 0) |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
542 incr = 1; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
543 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
544 // 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
|
545 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
|
546 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
547 while (true) |
7890 | 548 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
549 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
|
550 break; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
551 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
552 xframe += incr; |
7901 | 553 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
554 const stack_frame& elt = cs[xframe]; |
7901 | 555 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
556 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
|
557 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
558 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
|
559 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
560 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
561 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
562 else if (nskip < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
563 nskip++; |
7901 | 564 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
565 if (nskip == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
566 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
567 curr_frame = xframe; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
568 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
|
569 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
570 symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); |
7901 | 571 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
572 if (verbose) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
573 { |
9990
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
574 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
|
575 |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
576 if (f) |
21322
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
577 buf << "stopped in " << elt.fcn_name () |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
578 << " at line " << elt.m_line |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
579 << " [" << elt.fcn_file_name () << "] " |
909129eb77c5
use correct stack frame when reporting debug location
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
580 << 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
|
581 else |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
582 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
|
583 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
584 octave_stdout << buf.str (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
585 } |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
586 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
587 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
588 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
589 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
590 } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
591 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
|
592 incr = -1; |
7901 | 593 |
594 // 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
|
595 // 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
|
596 // jump to the new "prev" frame set above. |
7890 | 597 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
598 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
599 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
600 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
601 |
5744 | 602 void |
7901 | 603 octave_call_stack::do_goto_caller_frame (void) |
604 { | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
605 size_t xframe = curr_frame; |
7901 | 606 |
607 bool skipped = false; | |
608 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
609 while (xframe != 0) |
7901 | 610 { |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
611 xframe = cs[xframe].m_prev; |
7901 | 612 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
613 const stack_frame& elt = cs[xframe]; |
7901 | 614 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
615 octave_function *f = elt.m_fcn; |
7901 | 616 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
617 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
|
618 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
619 if (! skipped) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
620 // 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
|
621 skipped = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
622 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
623 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
624 // 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
|
625 stack_frame tmp (elt); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
626 tmp.m_prev = curr_frame; |
7901 | 627 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
628 curr_frame = cs.size (); |
7901 | 629 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
630 cs.push_back (tmp); |
7901 | 631 |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
632 symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); |
7901 | 633 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
634 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
635 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
636 } |
7901 | 637 } |
638 } | |
639 | |
640 void | |
641 octave_call_stack::do_goto_base_frame (void) | |
642 { | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
643 stack_frame tmp (cs[0]); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
644 tmp.m_prev = curr_frame; |
7901 | 645 |
646 curr_frame = cs.size (); | |
647 | |
648 cs.push_back (tmp); | |
649 | |
19415
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
19403
diff
changeset
|
650 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
|
651 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
652 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
653 void |
4180 | 654 recover_from_exception (void) |
655 { | |
656 can_interrupt = true; | |
4182 | 657 octave_interrupt_immediately = 0; |
4180 | 658 octave_interrupt_state = 0; |
5142 | 659 octave_signal_caught = 0; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
660 octave_exception_state = octave_no_exception; |
4180 | 661 octave_restore_signal_mask (); |
662 octave_catch_interrupts (); | |
663 } | |
664 | |
1907 | 665 int |
5189 | 666 main_loop (void) |
1907 | 667 { |
2016 | 668 octave_save_signal_mask (); |
669 | |
3020 | 670 can_interrupt = true; |
1907 | 671 |
5142 | 672 octave_signal_hook = octave_signal_handler; |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
673 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
674 octave_bad_alloc_hook = 0; |
4429 | 675 |
2554 | 676 octave_catch_interrupts (); |
1907 | 677 |
4172 | 678 octave_initialized = true; |
679 | |
1907 | 680 // The big loop. |
681 | |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19734
diff
changeset
|
682 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
|
683 ? 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
|
684 : 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
|
685 |
bef822a80ffb
if not interactive, bypass readline and read stdin as a file (bug #38520)
John W. Eaton <jwe@octave.org>
parents:
16317
diff
changeset
|
686 octave_parser parser (*lxr); |
16151 | 687 |
4153 | 688 int retval = 0; |
1907 | 689 do |
690 { | |
4180 | 691 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
692 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
693 reset_error_handler (); |
4318 | 694 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
695 parser.reset (); |
2620 | 696 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
697 if (symbol_table::at_top_level ()) |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
698 tree_evaluator::reset_debug_state (); |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
699 |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
700 retval = parser.run (); |
2620 | 701 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
702 if (retval == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
703 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
704 if (parser.stmt_list) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
705 { |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
706 parser.stmt_list->accept (*current_evaluator); |
3883 | 707 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
708 octave_quit (); |
4171 | 709 |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19734
diff
changeset
|
710 if (! interactive) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
711 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
712 bool quit = (tree_return_command::returning |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
713 || tree_break_command::breaking); |
4153 | 714 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
715 if (tree_return_command::returning) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
716 tree_return_command::returning = 0; |
4153 | 717 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
718 if (tree_break_command::breaking) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
719 tree_break_command::breaking--; |
4153 | 720 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
721 if (quit) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
722 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
723 } |
4153 | 724 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
725 if (octave_completion_matches_called) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
726 octave_completion_matches_called = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
727 else |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
728 octave::command_editor::increment_current_command_number (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
729 } |
16288
fe3b9a51e625
rename curr_lexer, curr_parser, CURR_LEXER
John W. Eaton <jwe@octave.org>
parents:
16287
diff
changeset
|
730 else if (parser.lexer.end_of_input) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
731 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
732 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
733 } |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20511
diff
changeset
|
734 catch (const octave_interrupt_exception&) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
735 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
736 recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
737 |
9383 | 738 if (quitting_gracefully) |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
739 return exit_status; |
21359
8e94a86ca648
Do not print extra newlines to stdout on exit (bug #47258).
Carnë Draug <carandraug@octave.org>
parents:
21322
diff
changeset
|
740 |
8e94a86ca648
Do not print extra newlines to stdout on exit (bug #47258).
Carnë Draug <carandraug@octave.org>
parents:
21322
diff
changeset
|
741 // Required newline when the user does Ctrl+C at the prompt. |
21363
8cfd1b47d49f
Eliminate more extra newlines to stdout when not interactive (bug #47258)
Mike Miller <mtmiller@octave.org>
parents:
21359
diff
changeset
|
742 if (interactive) |
8cfd1b47d49f
Eliminate more extra newlines to stdout when not interactive (bug #47258)
Mike Miller <mtmiller@octave.org>
parents:
21359
diff
changeset
|
743 octave_stdout << "\n"; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
744 } |
20651
c1d94e5cd5ea
catch index_exception by const reference where possible
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
745 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
|
746 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
747 recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
748 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
749 std::cerr << "error: unhandled index exception: " |
20652
7a8096f8df5d
more cleanup of indexing exceptions
John W. Eaton <jwe@octave.org>
parents:
20651
diff
changeset
|
750 << 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
|
751 << std::endl; |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20535
diff
changeset
|
752 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
753 catch (const octave_execution_exception& e) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
754 { |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
755 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
|
756 |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
757 if (! stack_trace.empty ()) |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
758 std::cerr << stack_trace; |
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
759 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
760 if (interactive) |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
761 recover_from_exception (); |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
762 else |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
763 { |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
764 // We should exit with a nonzero status. |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
765 retval = 1; |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
766 break; |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
767 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
768 } |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20511
diff
changeset
|
769 catch (const std::bad_alloc&) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
770 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
771 recover_from_exception (); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
772 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
773 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
|
774 << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
775 } |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
776 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21618
diff
changeset
|
777 #if defined (DBSTOP_NANINF) |
21157
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
778 if (Vdebug_on_naninf) |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
779 { |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
780 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
|
781 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
|
782 } |
94fc5f13d51b
dbstop: conditional breakpoint, dbstop if caught error etc. (bug #46795)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21140
diff
changeset
|
783 #endif |
1907 | 784 } |
785 while (retval == 0); | |
786 | |
21363
8cfd1b47d49f
Eliminate more extra newlines to stdout when not interactive (bug #47258)
Mike Miller <mtmiller@octave.org>
parents:
21359
diff
changeset
|
787 if (interactive) |
8cfd1b47d49f
Eliminate more extra newlines to stdout when not interactive (bug #47258)
Mike Miller <mtmiller@octave.org>
parents:
21359
diff
changeset
|
788 octave_stdout << "\n"; |
18638
4ccd2b473f84
Print newline after closing interpreter with EOF (bug #41513).
Vaibhav Gupta <vaibhav.gupta@students.iiit.ac.in>
parents:
18515
diff
changeset
|
789 |
16987
aabe12e5fdc1
Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents:
16892
diff
changeset
|
790 if (retval == EOF) |
aabe12e5fdc1
Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents:
16892
diff
changeset
|
791 retval = 0; |
aabe12e5fdc1
Allow exit/quit to properly pass all possible exit status values
Mike Miller <mtmiller@ieee.org>
parents:
16892
diff
changeset
|
792 |
1907 | 793 return retval; |
794 } | |
795 | |
1683 | 796 // Fix up things before exiting. |
797 | |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
798 static std::list<std::string> octave_atexit_functions; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
799 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
800 static void |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
801 do_octave_atexit (void) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
802 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
803 static bool deja_vu = false; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
804 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
805 OCTAVE_SAFE_CALL (remove_input_event_hook_functions, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
806 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
807 while (! octave_atexit_functions.empty ()) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
808 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
809 std::string fcn = octave_atexit_functions.front (); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
810 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
811 octave_atexit_functions.pop_front (); |
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 OCTAVE_SAFE_CALL (reset_error_handler, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
814 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
815 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
|
816 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
817 OCTAVE_SAFE_CALL (flush_octave_stdout, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
818 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
819 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
820 if (! deja_vu) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
821 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
822 deja_vu = true; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
823 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
824 // Process pending events and disasble octave_link event |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
825 // processing with this call. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
826 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
827 octave_link::process_events (true); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
828 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
829 // 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
|
830 // 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
|
831 // called. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
832 OCTAVE_SAFE_CALL (clear_mex_functions, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
833 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
834 OCTAVE_SAFE_CALL (octave::command_editor::restore_terminal_state, ()); |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
835 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
836 // 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
|
837 OCTAVE_SAFE_CALL (raw_mode, (0)); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
838 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
839 OCTAVE_SAFE_CALL (octave_history_write_timestamp, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
840 |
21748
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
841 if (! octave::command_history::ignoring_entries ()) |
176536b15d68
use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
842 OCTAVE_SAFE_CALL (octave::command_history::clean_up_and_save, ()); |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
843 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
844 OCTAVE_SAFE_CALL (gh_manager::close_all_figures, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
845 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
846 OCTAVE_SAFE_CALL (gtk_manager::unload_all_toolkits, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
847 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
848 OCTAVE_SAFE_CALL (close_files, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
849 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
850 OCTAVE_SAFE_CALL (cleanup_tmp_files, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
851 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
852 OCTAVE_SAFE_CALL (symbol_table::cleanup, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
853 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
854 OCTAVE_SAFE_CALL (sysdep_cleanup, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
855 |
17755
9c03b071fd7b
avoid HDF5 error message at exit (bug #37713)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
856 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
|
857 |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
858 OCTAVE_SAFE_CALL (flush_octave_stdout, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
859 |
19849
1c9ed5b4c73d
input.h: change meaning of interactive and forced_interactive global variables.
Carnë Draug <carandraug@octave.org>
parents:
19734
diff
changeset
|
860 if (! quitting_gracefully && interactive) |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
861 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
862 octave_stdout << "\n"; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
863 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
864 // 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
|
865 // flush_octave_stdout above. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
866 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
867 OCTAVE_SAFE_CALL (flush_octave_stdout, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
868 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
869 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
870 // 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
|
871 // problems with registering/unregistering types worked out. For |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
872 // 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
|
873 // 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
|
874 // 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
|
875 // 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
|
876 // 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
|
877 // .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
|
878 // is unloaded. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
879 // |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
880 // OCTAVE_SAFE_CALL (singleton_cleanup_list::cleanup, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
881 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
882 OCTAVE_SAFE_CALL (octave_chunk_buffer::clear, ()); |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
883 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
884 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
885 |
1683 | 886 void |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
887 clean_up_and_exit (int status, bool safe_to_return) |
3162 | 888 { |
3216 | 889 do_octave_atexit (); |
1683 | 890 |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
891 if (octave_link::exit (status)) |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
892 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
893 if (safe_to_return) |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
894 return; |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
895 else |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
896 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
897 // 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
|
898 // 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
|
899 // so it might not be safe to return. |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
900 |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
901 // 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
|
902 // 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
|
903 // 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
|
904 // day... |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
905 |
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
|
906 octave_sleep (86400); // FIXME: really needed? |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
907 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
908 } |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
909 else |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
910 { |
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
911 if (octave_exit) |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
912 (*octave_exit) (status); |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
913 } |
1683 | 914 } |
915 | |
11023
cb62c7401ea2
toplev.cc (Fquit): allow any number of output paramters
John W. Eaton <jwe@octave.org>
parents:
10890
diff
changeset
|
916 DEFUN (quit, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
917 "-*- 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
|
918 @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
|
919 @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
|
920 @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
|
921 @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
|
922 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
|
923 \n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
924 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
|
925 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
|
926 \n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
927 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
|
928 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
|
929 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
|
930 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
|
931 @seealso{atexit}\n\ |
3333 | 932 @end deftypefn") |
1683 | 933 { |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
934 // 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
|
935 // 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
|
936 // 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
|
937 if (! octave_link::confirm_shutdown ()) |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
938 return ovl (); |
19714
21015ca26566
Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
19697
diff
changeset
|
939 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
940 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
|
941 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
|
942 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
943 if (args.length () > 0) |
2068 | 944 { |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
945 int tmp = args(0).nint_value (); |
1683 | 946 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
947 exit_status = tmp; |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
948 } |
3180 | 949 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
950 // 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
|
951 // 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
|
952 // 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
|
953 // 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
|
954 // exiting. |
9383 | 955 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
956 quitting_gracefully = true; |
9383 | 957 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
958 octave_interrupt_state = -1; |
9383 | 959 |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
960 octave_throw_interrupt_exception (); |
2068 | 961 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
962 return ovl (); |
1683 | 963 } |
964 | |
965 DEFALIAS (exit, quit); | |
966 | |
1957 | 967 DEFUN (warranty, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
968 "-*- 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
|
969 @deftypefn {} {} warranty ()\n\ |
3446 | 970 Describe the conditions for copying and distributing Octave.\n\ |
971 @end deftypefn") | |
1683 | 972 { |
17510
7542f4496974
eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
973 octave_stdout << "\n" << octave_name_version_and_copyright () << "\n\ |
3922 | 974 \n\ |
19604
7005044f3080
Correct missing word in output of warranty().
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
17821
diff
changeset
|
975 GNU Octave is free software; you can redistribute it and/or modify\n\ |
1683 | 976 it under the terms of the GNU General Public License as published by\n\ |
7016 | 977 the Free Software Foundation; either version 3 of the License, or\n\ |
1683 | 978 (at your option) any later version.\n\ |
979 \n\ | |
11104 | 980 GNU Octave is distributed in the hope that it will be useful,\n\ |
1683 | 981 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
982 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ | |
983 GNU General Public License for more details.\n\ | |
984 \n\ | |
985 You should have received a copy of the GNU General Public License\n\ | |
7016 | 986 along with this program. If not, see <http://www.gnu.org/licenses/>.\n\ |
1683 | 987 \n"; |
988 | |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
989 return ovl (); |
1683 | 990 } |
991 | |
992 // Execute a shell command. | |
993 | |
2086 | 994 static octave_value_list |
3523 | 995 run_command_and_return_output (const std::string& cmd_str) |
2083 | 996 { |
2086 | 997 octave_value_list retval; |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
998 octave::unwind_protect frame; |
2083 | 999 |
1000 iprocstream *cmd = new iprocstream (cmd_str.c_str ()); | |
1001 | |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1002 frame.add_delete (cmd); |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1003 frame.add_fcn (octave_child_list::remove, cmd->pid ()); |
3060 | 1004 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1005 if (! *cmd) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1006 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
|
1007 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1008 int fid = cmd->file_number (); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1009 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1010 std::ostringstream output_buf; |
2095 | 1011 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1012 char ch; |
4494 | 1013 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1014 for (;;) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1015 { |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1016 if (cmd->get (ch)) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1017 output_buf.put (ch); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1018 else |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1019 { |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1020 if (! cmd->eof () && errno == EAGAIN) |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1021 { |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1022 cmd->clear (); |
3147 | 1023 |
21899 | 1024 if (octave_wait_for_input (fid) != 1) |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1025 break; |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1026 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1027 else |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1028 break; |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
1029 } |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1030 } |
3147 | 1031 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1032 int cmd_status = cmd->close (); |
2083 | 1033 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1034 if (octave_wait::ifexited (cmd_status)) |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1035 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
|
1036 else |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1037 cmd_status = 127; |
2083 | 1038 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1039 retval = ovl (cmd_status, output_buf.str ()); |
2083 | 1040 |
1041 return retval; | |
1042 } | |
1043 | |
5285 | 1044 enum system_exec_type { et_sync, et_async }; |
1045 | |
1957 | 1046 DEFUN (system, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1047 "-*- 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
|
1048 @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
|
1049 @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
|
1050 @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
|
1051 @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
|
1052 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
|
1053 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1054 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
|
1055 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
|
1056 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
|
1057 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
|
1058 the value @qcode{\"sync\"}.\n\ |
2083 | 1059 \n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1060 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
|
1061 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
|
1062 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
|
1063 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
|
1064 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
|
1065 @code{system} through the pager, use a command like\n\ |
2321 | 1066 \n\ |
3301 | 1067 @example\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1068 @group\n\ |
21855 | 1069 [~, text] = system (\"cmd\");\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1070 disp (text);\n\ |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1071 @end group\n\ |
3301 | 1072 @end example\n\ |
2321 | 1073 \n\ |
3301 | 1074 @noindent\n\ |
2321 | 1075 or\n\ |
1076 \n\ | |
3301 | 1077 @example\n\ |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1078 printf (\"%s\\n\", nthargout (2, \"system\", \"cmd\"));\n\ |
3301 | 1079 @end example\n\ |
1080 \n\ | |
5659 | 1081 The @code{system} function can return two values. The first is the\n\ |
1082 exit status of the command and the second is any output from the\n\ | |
1083 command that was written to the standard output stream. For example,\n\ | |
3301 | 1084 \n\ |
1085 @example\n\ | |
5717 | 1086 [status, output] = system (\"echo foo; exit 2\");\n\ |
3301 | 1087 @end example\n\ |
1088 \n\ | |
1089 @noindent\n\ | |
1090 will set the variable @code{output} to the string @samp{foo}, and the\n\ | |
1091 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
|
1092 \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
|
1093 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
|
1094 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
|
1095 @seealso{unix, dos}\n\ |
3301 | 1096 @end deftypefn") |
1683 | 1097 { |
1098 int nargin = args.length (); | |
1099 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1100 if (nargin == 0 || nargin > 3) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1101 print_usage (); |
2083 | 1102 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1103 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
|
1104 if (nargin == 3) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1105 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1106 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
|
1107 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1108 if (type_str == "sync") |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1109 type = et_sync; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1110 else if (type_str == "async") |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1111 type = et_async; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1112 else |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20799
diff
changeset
|
1113 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
|
1114 } |
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
|
1115 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1116 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1117 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1118 // FIXME: Is this unwind_protect frame needed anymore (12/16/15)? |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
1119 octave::unwind_protect frame; |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1120 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1121 bool return_output = (nargin == 1 && nargout > 1); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1122 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1123 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1124 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1125 try |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1126 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1127 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
|
1128 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1129 catch (octave_execution_exception& e) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1130 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1131 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
|
1132 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1133 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1134 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1135 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
|
1136 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
|
1137 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1138 std::string cmd_str = args(0).xstring_value ("system: first argument must be a string"); |
1683 | 1139 |
7104 | 1140 #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
|
1141 // 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
|
1142 if (type == et_sync) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1143 cmd_str = "\"" + cmd_str + "\""; |
7104 | 1144 #endif |
1145 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1146 if (type == et_async) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1147 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1148 // FIXME: maybe this should go in sysdep.cc? |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21618
diff
changeset
|
1149 #if defined (HAVE_FORK) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1150 pid_t pid = fork (); |
2083 | 1151 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1152 if (pid < 0) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1153 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
|
1154 else if (pid == 0) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1155 { |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1156 // 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
|
1157 execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (), |
21534
be1c9f1e31ab
Cast NULL pointer to char, rather than void, when using execl.
Rik <rik@octave.org>
parents:
21434
diff
changeset
|
1158 static_cast<char *> (0)); |
3273 | 1159 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1160 panic_impossible (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1161 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1162 else |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1163 retval(0) = pid; |
6222 | 1164 #elif defined (__WIN32__) |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1165 STARTUPINFO si; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1166 PROCESS_INFORMATION pi; |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1167 ZeroMemory (&si, sizeof (si)); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1168 ZeroMemory (&pi, sizeof (pi)); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1169 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
|
1170 strcpy (xcmd_str, cmd_str.c_str ()); |
6222 | 1171 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1172 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
|
1173 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
|
1174 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1175 retval(0) = pi.dwProcessId; |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1176 CloseHandle (pi.hProcess); |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
21017
diff
changeset
|
1177 CloseHandle (pi.hThread); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1178 #else |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
1179 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
|
1180 #endif |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1181 } |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1182 else if (return_output) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1183 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
|
1184 else |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1185 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1186 int status = system (cmd_str.c_str ()); |
2321 | 1187 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1188 // 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
|
1189 // 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
|
1190 // 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
|
1191 // failure code. |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
1192 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1193 if (octave_wait::ifexited (status)) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1194 status = octave_wait::exitstatus (status); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1195 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1196 retval(0) = status; |
1683 | 1197 } |
1198 | |
1199 return retval; | |
1200 } | |
1201 | |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1202 /* |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1203 %!test |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1204 %! cmd = ls_command (); |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1205 %! [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
|
1206 %! assert (status, 0); |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1207 %! assert (ischar (output)); |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1208 %! assert (! isempty (output)); |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1209 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1210 %!error system () |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
14016
diff
changeset
|
1211 %!error system (1, 2, 3) |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1212 */ |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1213 |
7409 | 1214 void |
1215 octave_add_atexit_function (const std::string& fname) | |
1216 { | |
1217 octave_atexit_functions.push_front (fname); | |
1218 } | |
1219 | |
1220 bool | |
1221 octave_remove_atexit_function (const std::string& fname) | |
1222 { | |
1223 bool found = false; | |
1224 | |
1225 for (std::list<std::string>::iterator p = octave_atexit_functions.begin (); | |
1226 p != octave_atexit_functions.end (); p++) | |
1227 { | |
1228 if (*p == fname) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1229 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1230 octave_atexit_functions.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1231 found = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1232 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1233 } |
7409 | 1234 } |
1235 | |
1236 return found; | |
1237 } | |
1238 | |
1239 | |
6680 | 1240 DEFUN (atexit, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1241 "-*- 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
|
1242 @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
|
1243 @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
|
1244 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
|
1245 \n\ |
dc64f1c4a33e
doc: Add documentation about finish.m and shutdown procedure to manual.
Rik <rik@octave.org>
parents:
19192
diff
changeset
|
1246 For example,\n\ |
2077 | 1247 \n\ |
3332 | 1248 @example\n\ |
1249 @group\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1250 function last_words ()\n\ |
6620 | 1251 disp (\"Bye bye\");\n\ |
3332 | 1252 endfunction\n\ |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1253 atexit (\"last_words\");\n\ |
3332 | 1254 @end group\n\ |
1255 @end example\n\ | |
1256 \n\ | |
1257 @noindent\n\ | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16987
diff
changeset
|
1258 will print the message @qcode{\"Bye bye\"} when Octave exits.\n\ |
6680 | 1259 \n\ |
20172
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19849
diff
changeset
|
1260 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
|
1261 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
|
1262 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
|
1263 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
|
1264 above,\n\ |
6680 | 1265 \n\ |
1266 @example\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1267 atexit (\"last_words\", false);\n\ |
6680 | 1268 @end example\n\ |
1269 \n\ | |
1270 @noindent\n\ | |
1271 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
|
1272 @code{last_words} when it exits.\n\ |
6680 | 1273 \n\ |
7001 | 1274 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
|
1275 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
|
1276 @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
|
1277 @seealso{quit}\n\ |
3333 | 1278 @end deftypefn") |
2077 | 1279 { |
1280 int nargin = args.length (); | |
1281 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1282 if (nargin < 1 || nargin > 2) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1283 print_usage (); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
1284 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1285 std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string"); |
2077 | 1286 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1287 bool add_mode = (nargin == 2) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1288 ? 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
|
1289 : true; |
6680 | 1290 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1291 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1292 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1293 if (add_mode) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1294 octave_add_atexit_function (arg); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1295 else |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1296 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1297 bool found = octave_remove_atexit_function (arg); |
6680 | 1298 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1299 if (nargout > 0) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1300 retval = ovl (found); |
2077 | 1301 } |
1302 | |
1303 return retval; | |
1304 } | |
1305 | |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1306 static octave_value |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1307 find_config_info (const octave_scalar_map& m, const std::string& key) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1308 { |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1309 if (m.isfield (key)) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1310 { |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1311 Cell c = m.contents (key); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1312 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1313 if (! c.is_empty ()) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1314 return c(0); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1315 } |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1316 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1317 return octave_value (); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1318 } |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1319 |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1320 DEFUN (__octave_config_info__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1321 "-*- texinfo -*-\n\ |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1322 @deftypefn {} {} __octave_config_info__ ()\n\ |
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1323 @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
|
1324 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
|
1325 Octave.\n\ |
2689 | 1326 \n\ |
12208
9611014e7cf1
Add function compare_versions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12195
diff
changeset
|
1327 If @var{option} is a string, return the configuration information for the\n\ |
2689 | 1328 specified option.\n\ |
1329 \n\ | |
19274
66ca15a97988
doc: Remove deprecated dump_prefs function from the manual.
Rik <rik@octave.org>
parents:
19273
diff
changeset
|
1330 @seealso{computer}\n\ |
3301 | 1331 @end deftypefn") |
2162 | 1332 { |
4128 | 1333 #if defined (ENABLE_DYNAMIC_LINKING) |
2689 | 1334 bool octave_supports_dynamic_linking = true; |
1335 #else | |
1336 bool octave_supports_dynamic_linking = false; | |
1337 #endif | |
1338 | |
4357 | 1339 static bool initialized = false; |
2162 | 1340 |
6274 | 1341 struct conf_info_struct |
1342 { | |
1343 const char *key; | |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1344 octave_value val; |
6274 | 1345 }; |
1346 | |
1347 static const conf_info_struct conf_info[] = | |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1348 { |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1349 { "DEFAULT_PAGER", OCTAVE_DEFAULT_PAGER }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1350 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21226
diff
changeset
|
1351 #if defined (OCTAVE_ENABLE_64) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1352 { "ENABLE_64", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1353 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1354 { "ENABLE_64", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1355 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1356 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21226
diff
changeset
|
1357 #if defined (OCTAVE_ENABLE_ATOMIC_REFCOUNT) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1358 { "ENABLE_ATOMIC_REFCOUNT", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1359 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1360 { "ENABLE_ATOMIC_REFCOUNT", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1361 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1362 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21226
diff
changeset
|
1363 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1364 { "ENABLE_BOUNDS_CHECK", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1365 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1366 { "ENABLE_BOUNDS_CHECK", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1367 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1368 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1369 #if defined (ENABLE_DOCS) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1370 { "ENABLE_DOCS", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1371 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1372 { "ENABLE_DOCS", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1373 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1374 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1375 #if defined (ENABLE_DYNAMIC_LINKING) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1376 { "ENABLE_DYNAMIC_LINKING", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1377 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1378 { "ENABLE_DYNAMIC_LINKING", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1379 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1380 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21226
diff
changeset
|
1381 #if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1382 { "ENABLE_FLOAT_TRUNCATE", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1383 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1384 { "ENABLE_FLOAT_TRUNCATE", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1385 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1386 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1387 #if defined (ENABLE_JIT) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1388 { "ENABLE_JIT", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1389 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1390 { "ENABLE_JIT", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1391 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1392 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21226
diff
changeset
|
1393 #if defined (OCTAVE_ENABLE_OPENMP) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1394 { "ENABLE_OPENMP", true }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1395 #else |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1396 { "ENABLE_OPENMP", false }, |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1397 #endif |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1398 |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1399 { "api_version", OCTAVE_API_VERSION }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1400 { "archlibdir", subst_octave_home (OCTAVE_ARCHLIBDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1401 { "bindir", subst_octave_home (OCTAVE_BINDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1402 { "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1403 { "datadir", subst_octave_home (OCTAVE_DATADIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1404 { "datarootdir", subst_octave_home (OCTAVE_DATAROOTDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1405 { "exec_prefix", subst_octave_home (OCTAVE_EXEC_PREFIX) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1406 { "fcnfiledir", subst_octave_home (OCTAVE_FCNFILEDIR) }, |
21600
184b85b31e03
more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents:
21598
diff
changeset
|
1407 { "fftw_version", octave_fftw_version () }, |
21603
37cbdf7bffa9
Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
21600
diff
changeset
|
1408 { "fftwf_version", octave_fftwf_version () }, |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1409 { "imagedir", subst_octave_home (OCTAVE_IMAGEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1410 { "includedir", subst_octave_home (OCTAVE_INCLUDEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1411 { "infodir", subst_octave_home (OCTAVE_INFODIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1412 { "infofile", subst_octave_home (OCTAVE_INFOFILE) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1413 { "libdir", subst_octave_home (OCTAVE_LIBDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1414 { "libexecdir", subst_octave_home (OCTAVE_LIBEXECDIR) }, |
21608
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21607
diff
changeset
|
1415 // Each library and executable has its own definition of the hg |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21607
diff
changeset
|
1416 // id. We check for consistency when Octave starts so we just |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21607
diff
changeset
|
1417 // store and report one of them here. |
80258bb3a14b
store hg id info in libgui and main exe and check for consistency (bug #45659)
John W. Eaton <jwe@octave.org>
parents:
21607
diff
changeset
|
1418 { "hg_id", liboctinterp_hg_id () }, |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1419 { "localapiarchlibdir", subst_octave_home (OCTAVE_LOCALAPIARCHLIBDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1420 { "localapifcnfiledir", subst_octave_home (OCTAVE_LOCALAPIFCNFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1421 { "localapioctfiledir", subst_octave_home (OCTAVE_LOCALAPIOCTFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1422 { "localarchlibdir", subst_octave_home (OCTAVE_LOCALARCHLIBDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1423 { "localfcnfiledir", subst_octave_home (OCTAVE_LOCALFCNFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1424 { "localoctfiledir", subst_octave_home (OCTAVE_LOCALOCTFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1425 { "localstartupfiledir", subst_octave_home (OCTAVE_LOCALSTARTUPFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1426 { "localverarchlibdir", subst_octave_home (OCTAVE_LOCALVERARCHLIBDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1427 { "localverfcnfiledir", subst_octave_home (OCTAVE_LOCALVERFCNFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1428 { "localveroctfiledir", subst_octave_home (OCTAVE_LOCALVEROCTFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1429 { "man1dir", subst_octave_home (OCTAVE_MAN1DIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1430 { "man1ext", OCTAVE_MAN1EXT }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1431 { "mandir", subst_octave_home (OCTAVE_MANDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1432 { "octdatadir", subst_octave_home (OCTAVE_OCTDATADIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1433 { "octfiledir", subst_octave_home (OCTAVE_OCTFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1434 { "octetcdir", subst_octave_home (OCTAVE_OCTETCDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1435 { "octincludedir", subst_octave_home (OCTAVE_OCTINCLUDEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1436 { "octlibdir", subst_octave_home (OCTAVE_OCTLIBDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1437 { "octtestsdir", subst_octave_home (OCTAVE_OCTTESTSDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1438 { "prefix", subst_octave_home (OCTAVE_PREFIX) }, |
21598
cf552443c104
revise method of handling hg id for build info
John W. Eaton <jwe@octave.org>
parents:
21597
diff
changeset
|
1439 { "release_date", OCTAVE_RELEASE_DATE }, |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1440 { "startupfiledir", subst_octave_home (OCTAVE_STARTUPFILEDIR) }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1441 { "version", OCTAVE_VERSION }, |
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1442 { 0, octave_value () } |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1443 }; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1444 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1445 struct build_info_struct |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1446 { |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1447 const char *key; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1448 const char *val; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17755
diff
changeset
|
1449 }; |
4357 | 1450 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1451 static const build_info_struct build_info[] = |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1452 { |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1453 { "AMD_CPPFLAGS", octave::build_env::AMD_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1454 { "AMD_LDFLAGS", octave::build_env::AMD_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1455 { "AMD_LIBS", octave::build_env::AMD_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1456 { "AR", octave::build_env::AR }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1457 { "ARFLAGS", octave::build_env::ARFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1458 { "ARPACK_CPPFLAGS", octave::build_env::ARPACK_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1459 { "ARPACK_LDFLAGS", octave::build_env::ARPACK_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1460 { "ARPACK_LIBS", octave::build_env::ARPACK_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1461 { "BLAS_LIBS", octave::build_env::BLAS_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1462 { "CAMD_CPPFLAGS", octave::build_env::CAMD_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1463 { "CAMD_LDFLAGS", octave::build_env::CAMD_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1464 { "CAMD_LIBS", octave::build_env::CAMD_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1465 { "CARBON_LIBS", octave::build_env::CARBON_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1466 { "CC", octave::build_env::CC }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1467 { "CCOLAMD_CPPFLAGS", octave::build_env::CCOLAMD_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1468 { "CCOLAMD_LDFLAGS", octave::build_env::CCOLAMD_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1469 { "CCOLAMD_LIBS", octave::build_env::CCOLAMD_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1470 { "CFLAGS", octave::build_env::CFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1471 { "CHOLMOD_CPPFLAGS", octave::build_env::CHOLMOD_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1472 { "CHOLMOD_LDFLAGS", octave::build_env::CHOLMOD_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1473 { "CHOLMOD_LIBS", octave::build_env::CHOLMOD_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1474 { "COLAMD_CPPFLAGS", octave::build_env::COLAMD_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1475 { "COLAMD_LDFLAGS", octave::build_env::COLAMD_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1476 { "COLAMD_LIBS", octave::build_env::COLAMD_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1477 { "CPICFLAG", octave::build_env::CPICFLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1478 { "CPPFLAGS", octave::build_env::CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1479 { "CURL_CPPFLAGS", octave::build_env::CURL_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1480 { "CURL_LDFLAGS", octave::build_env::CURL_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1481 { "CURL_LIBS", octave::build_env::CURL_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1482 { "CXSPARSE_CPPFLAGS", octave::build_env::CXSPARSE_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1483 { "CXSPARSE_LDFLAGS", octave::build_env::CXSPARSE_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1484 { "CXSPARSE_LIBS", octave::build_env::CXSPARSE_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1485 { "CXX", octave::build_env::CXX }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1486 { "CXXCPP", octave::build_env::CXXCPP }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1487 { "CXXFLAGS", octave::build_env::CXXFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1488 { "CXXPICFLAG", octave::build_env::CXXPICFLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1489 { "DEFS", octave::build_env::DEFS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1490 { "DL_LD", octave::build_env::DL_LD }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1491 { "DL_LDFLAGS", octave::build_env::DL_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1492 { "DL_LIBS", octave::build_env::DL_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1493 { "GCC_VERSION", octave::build_env::GCC_VERSION }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1494 { "GXX_VERSION", octave::build_env::GXX_VERSION }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1495 { "EXEEXT", octave::build_env::EXEEXT }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1496 { "F77", octave::build_env::F77 }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1497 { "F77_FLOAT_STORE_FLAG", octave::build_env::F77_FLOAT_STORE_FLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1498 { "F77_INTEGER_8_FLAG", octave::build_env::F77_INTEGER_8_FLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1499 { "FFLAGS", octave::build_env::FFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1500 { "FFTW3_CPPFLAGS", octave::build_env::FFTW3_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1501 { "FFTW3_LDFLAGS", octave::build_env::FFTW3_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1502 { "FFTW3_LIBS", octave::build_env::FFTW3_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1503 { "FFTW3F_CPPFLAGS", octave::build_env::FFTW3F_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1504 { "FFTW3F_LDFLAGS", octave::build_env::FFTW3F_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1505 { "FFTW3F_LIBS", octave::build_env::FFTW3F_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1506 { "FLIBS", octave::build_env::FLIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1507 { "FLTK_CPPFLAGS", octave::build_env::FLTK_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1508 { "FLTK_LDFLAGS", octave::build_env::FLTK_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1509 { "FLTK_LIBS", octave::build_env::FLTK_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1510 { "FONTCONFIG_CPPFLAGS", octave::build_env::FONTCONFIG_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1511 { "FONTCONFIG_LIBS", octave::build_env::FONTCONFIG_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1512 { "FPICFLAG", octave::build_env::FPICFLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1513 { "FT2_CPPFLAGS", octave::build_env::FT2_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1514 { "FT2_LIBS", octave::build_env::FT2_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1515 { "GLPK_CPPFLAGS", octave::build_env::GLPK_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1516 { "GLPK_LDFLAGS", octave::build_env::GLPK_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1517 { "GLPK_LIBS", octave::build_env::GLPK_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1518 { "GNUPLOT", octave::build_env::GNUPLOT }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1519 { "HDF5_CPPFLAGS", octave::build_env::HDF5_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1520 { "HDF5_LDFLAGS", octave::build_env::HDF5_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1521 { "HDF5_LIBS", octave::build_env::HDF5_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1522 { "LAPACK_LIBS", octave::build_env::LAPACK_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1523 { "LDFLAGS", octave::build_env::LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1524 { "LD_CXX", octave::build_env::LD_CXX }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1525 { "LD_STATIC_FLAG", octave::build_env::LD_STATIC_FLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1526 { "LEX", octave::build_env::LEX }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1527 { "LEXLIB", octave::build_env::LEXLIB }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1528 { "LFLAGS", octave::build_env::LFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1529 { "LIBEXT", octave::build_env::LIBEXT }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1530 { "LIBOCTAVE", octave::build_env::LIBOCTAVE }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1531 { "LIBOCTINTERP", octave::build_env::LIBOCTINTERP }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1532 { "LIBS", octave::build_env::LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1533 { "LLVM_CPPFLAGS", octave::build_env::LLVM_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1534 { "LLVM_LDFLAGS", octave::build_env::LLVM_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1535 { "LLVM_LIBS", octave::build_env::LLVM_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1536 { "LN_S", octave::build_env::LN_S }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1537 { "MAGICK_CPPFLAGS", octave::build_env::MAGICK_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1538 { "MAGICK_LDFLAGS", octave::build_env::MAGICK_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1539 { "MAGICK_LIBS", octave::build_env::MAGICK_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1540 { "MKOCTFILE_DL_LDFLAGS", octave::build_env::MKOCTFILE_DL_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1541 { "OCTAVE_LINK_DEPS", octave::build_env::OCTAVE_LINK_DEPS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1542 { "OCTAVE_LINK_OPTS", octave::build_env::OCTAVE_LINK_OPTS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1543 { "OCT_LINK_DEPS", octave::build_env::OCT_LINK_DEPS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1544 { "OCT_LINK_OPTS", octave::build_env::OCT_LINK_OPTS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1545 { "OPENGL_LIBS", octave::build_env::OPENGL_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1546 { "OSMESA_CPPFLAGS", octave::build_env::OSMESA_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1547 { "OSMESA_LDFLAGS", octave::build_env::OSMESA_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1548 { "OSMESA_LIBS", octave::build_env::OSMESA_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1549 { "PCRE_CPPFLAGS", octave::build_env::PCRE_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1550 { "PCRE_LIBS", octave::build_env::PCRE_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1551 { "PTHREAD_CFLAGS", octave::build_env::PTHREAD_CFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1552 { "PTHREAD_LIBS", octave::build_env::PTHREAD_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1553 { "QHULL_CPPFLAGS", octave::build_env::QHULL_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1554 { "QHULL_LDFLAGS", octave::build_env::QHULL_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1555 { "QHULL_LIBS", octave::build_env::QHULL_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1556 { "QRUPDATE_CPPFLAGS", octave::build_env::QRUPDATE_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1557 { "QRUPDATE_LDFLAGS", octave::build_env::QRUPDATE_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1558 { "QRUPDATE_LIBS", octave::build_env::QRUPDATE_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1559 { "QT_CPPFLAGS", octave::build_env::QT_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1560 { "QT_LDFLAGS", octave::build_env::QT_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1561 { "QT_LIBS", octave::build_env::QT_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1562 { "RANLIB", octave::build_env::RANLIB }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1563 { "RDYNAMIC_FLAG", octave::build_env::RDYNAMIC_FLAG }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1564 { "READLINE_LIBS", octave::build_env::READLINE_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1565 { "SED", octave::build_env::SED }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1566 { "SHARED_LIBS", octave::build_env::SHARED_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1567 { "SHLEXT", octave::build_env::SHLEXT }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1568 { "SHLEXT_VER", octave::build_env::SHLEXT_VER }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1569 { "SH_LD", octave::build_env::SH_LD }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1570 { "SH_LDFLAGS", octave::build_env::SH_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1571 { "STATIC_LIBS", octave::build_env::STATIC_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1572 { "TERM_LIBS", octave::build_env::TERM_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1573 { "UMFPACK_CPPFLAGS", octave::build_env::UMFPACK_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1574 { "UMFPACK_LDFLAGS", octave::build_env::UMFPACK_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1575 { "UMFPACK_LIBS", octave::build_env::UMFPACK_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1576 { "WARN_CFLAGS", octave::build_env::WARN_CFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1577 { "WARN_CXXFLAGS", octave::build_env::WARN_CXXFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1578 { "X11_INCFLAGS", octave::build_env::X11_INCFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1579 { "X11_LIBS", octave::build_env::X11_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1580 { "XTRA_CFLAGS", octave::build_env::XTRA_CFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1581 { "XTRA_CXXFLAGS", octave::build_env::XTRA_CXXFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1582 { "YACC", octave::build_env::YACC }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1583 { "YFLAGS", octave::build_env::YFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1584 { "Z_CPPFLAGS", octave::build_env::Z_CPPFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1585 { "Z_LDFLAGS", octave::build_env::Z_LDFLAGS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1586 { "Z_LIBS", octave::build_env::Z_LIBS }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1587 { "config_opts", octave::build_env::config_opts }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1588 { 0, 0 }, |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1589 }; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1590 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1591 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1592 static octave_scalar_map config; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1593 static octave_scalar_map build_env; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1594 static octave_scalar_map build_features = octave::build_env::features (); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1595 |
4357 | 1596 if (! initialized) |
1597 { | |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1598 int i; |
4357 | 1599 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1600 i = 0; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1601 while (true) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1602 { |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1603 const build_info_struct& elt = build_info[i++]; |
4697 | 1604 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1605 const char *key = elt.key; |
4697 | 1606 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1607 if (key) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1608 build_env.assign (key, elt.val); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1609 else |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1610 break; |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1611 } |
4697 | 1612 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1613 i = 0; |
4440 | 1614 while (true) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1615 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1616 const conf_info_struct& elt = conf_info[i++]; |
6274 | 1617 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1618 const char *key = elt.key; |
4357 | 1619 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1620 if (key) |
21253
a66a737913b5
allow __have_feature__ to check for ENABLE_ options
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1621 config.assign (key, elt.val); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1622 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1623 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1624 } |
4357 | 1625 |
4691 | 1626 bool unix_system = true; |
7013 | 1627 bool mac_system = false; |
4691 | 1628 bool windows_system = false; |
1629 | |
1630 #if defined (WIN32) | |
1631 windows_system = true; | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20785
diff
changeset
|
1632 #if ! defined (__CYGWIN__) |
4691 | 1633 unix_system = false; |
1634 #endif | |
1635 #endif | |
1636 | |
8574
83b8c739d626
toplev.cc: check OCTAVE_USE_OS_X_API instead of __APPLE__ && __MACH__
John W. Eaton <jwe@octave.org>
parents:
8377
diff
changeset
|
1637 #if defined (OCTAVE_USE_OS_X_API) |
7010 | 1638 mac_system = true; |
1639 #endif | |
1640 | |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1641 config.assign ("unix", octave_value (unix_system)); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1642 config.assign ("mac", octave_value (mac_system)); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1643 config.assign ("windows", octave_value (windows_system)); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1644 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1645 config.assign ("dld", octave_value (octave_supports_dynamic_linking)); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1646 |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1647 octave::mach_info::float_format ff = octave::mach_info::native_float_format (); |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1648 config.assign ("float_format", |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1649 octave_value (octave::mach_info::float_format_as_string (ff))); |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1650 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1651 config.assign ("words_big_endian", |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1652 octave_value (octave::mach_info::words_big_endian ())); |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1653 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1654 config.assign ("words_little_endian", |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
1655 octave_value (octave::mach_info::words_little_endian ())); |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1656 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1657 config.assign ("build_environment", octave_value (build_env)); |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1658 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1659 config.assign ("build_features", octave_value (build_features)); |
4691 | 1660 |
4357 | 1661 initialized = true; |
1662 } | |
2162 | 1663 |
2689 | 1664 int nargin = args.length (); |
1665 | |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1666 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1667 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1668 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1669 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1670 |
2689 | 1671 if (nargin == 1) |
1672 { | |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1673 std::string arg = args(0).xstring_value ("__octave_config_info__: OPTION argument must be a string"); |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1674 |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1675 octave_value info = find_config_info (config, arg); |
2689 | 1676 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1677 if (info.is_undefined ()) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1678 info = find_config_info (build_env, arg); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1679 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1680 if (info.is_undefined ()) |
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1681 info = find_config_info (build_features, arg); |
5199 | 1682 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1683 if (info.is_undefined ()) |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1684 error ("__octave_config_info__: no info for '%s'", arg.c_str ()); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20923
diff
changeset
|
1685 |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1686 return info; |
2689 | 1687 } |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
1688 else |
21226
a55b8ece1ecd
reorganize octave_config_info again
John W. Eaton <jwe@octave.org>
parents:
21220
diff
changeset
|
1689 retval = ovl (config); |
2689 | 1690 |
1691 return retval; | |
2162 | 1692 } |
1693 | |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1694 /* |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1695 %!assert (ischar (__octave_config_info__ ("version"))) |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1696 %!test |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1697 %! x = __octave_config_info__ (); |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1698 %! assert (isstruct (x)); |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1699 %! assert (! isempty (x)); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14156
diff
changeset
|
1700 |
21603
37cbdf7bffa9
Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
21600
diff
changeset
|
1701 %!assert (__octave_config_info__ ("fftw_version"), __octave_config_info__ ("fftwf_version")) |
37cbdf7bffa9
Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents:
21600
diff
changeset
|
1702 |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21421
diff
changeset
|
1703 %!error __octave_config_info__ (1, 2) |
12846
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1704 */ |
9ce9e1e2d2c8
codesprint: new tests for toplev.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1705 |
1683 | 1706 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE) |
2806 | 1707 |
1683 | 1708 int debug_new_delete = 0; |
1709 | |
1710 typedef void (*vfp)(void); | |
1711 extern vfp __new_handler; | |
1712 | |
1713 void * | |
1714 __builtin_new (size_t sz) | |
1715 { | |
1716 void *p; | |
1717 | |
20946 | 1718 // malloc (0) is unpredictable; avoid it. |
1683 | 1719 if (sz == 0) |
1720 sz = 1; | |
15451
219479b461b8
build: Add missing tests and gnulib modules suggested by autoscan.
Rik <rik@octave.org>
parents:
15424
diff
changeset
|
1721 p = gnulib::malloc (sz); |
1683 | 1722 while (p == 0) |
1723 { | |
1724 (*__new_handler) (); | |
15451
219479b461b8
build: Add missing tests and gnulib modules suggested by autoscan.
Rik <rik@octave.org>
parents:
15424
diff
changeset
|
1725 p = gnulib::malloc (sz); |
1683 | 1726 } |
1727 | |
1728 if (debug_new_delete) | |
5629 | 1729 std::cerr << "__builtin_new: " << p << std::endl; |
1683 | 1730 |
1731 return p; | |
1732 } | |
1733 | |
1734 void | |
1735 __builtin_delete (void *ptr) | |
1736 { | |
1737 if (debug_new_delete) | |
5629 | 1738 std::cerr << "__builtin_delete: " << ptr << std::endl; |
1683 | 1739 |
1740 if (ptr) | |
1741 free (ptr); | |
1742 } | |
2806 | 1743 |
1683 | 1744 #endif |