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