Mercurial > hg > octave-avbm
annotate src/toplev.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | 4ced6b90fffb |
rev | line source |
---|---|
1683 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1995-2011 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 | |
1683 | 38 #include <sys/types.h> |
39 #include <unistd.h> | |
40 | |
2926 | 41 #include "cmd-edit.h" |
42 #include "file-ops.h" | |
1683 | 43 #include "lo-error.h" |
2370 | 44 #include "lo-mappers.h" |
3020 | 45 #include "oct-env.h" |
4153 | 46 #include "quit.h" |
1755 | 47 #include "str-vec.h" |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
8347
diff
changeset
|
48 #include "oct-locbuf.h" |
1683 | 49 |
2492 | 50 #include <defaults.h> |
1683 | 51 #include "defun.h" |
52 #include "error.h" | |
53 #include "file-io.h" | |
54 #include "input.h" | |
55 #include "lex.h" | |
2492 | 56 #include <oct-conf.h> |
1742 | 57 #include "oct-hist.h" |
2162 | 58 #include "oct-map.h" |
2862 | 59 #include "oct-obj.h" |
1683 | 60 #include "pager.h" |
61 #include "parse.h" | |
62 #include "pathsearch.h" | |
63 #include "procstream.h" | |
2370 | 64 #include "ov.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8581
diff
changeset
|
65 #include "pt-eval.h" |
2985 | 66 #include "pt-jump.h" |
2982 | 67 #include "pt-stmt.h" |
1683 | 68 #include "sighandlers.h" |
69 #include "sysdep.h" | |
2693 | 70 #include "syswait.h" |
1750 | 71 #include "toplev.h" |
1683 | 72 #include "unwind-prot.h" |
73 #include "utils.h" | |
74 #include "variables.h" | |
2492 | 75 #include <version.h> |
1683 | 76 |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
77 void (*octave_exit) (int) = ::exit; |
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
78 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
79 // 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
|
80 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
|
81 |
3020 | 82 // TRUE means we are exiting via the builtin exit or quit functions. |
9383 | 83 bool quitting_gracefully = false; |
84 // This stores the exit status. | |
85 int exit_status = 0; | |
1683 | 86 |
4217 | 87 // TRUE means we are ready to interpret commands, but not everything |
88 // is ready for interactive use. | |
89 bool octave_interpreter_ready = false; | |
90 | |
4172 | 91 // TRUE means we've processed all the init code and we are good to go. |
92 bool octave_initialized = false; | |
93 | |
1683 | 94 // Current command to execute. |
95 tree_statement_list *global_command = 0; | |
96 | |
5743 | 97 octave_call_stack *octave_call_stack::instance = 0; |
98 | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
99 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
100 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
|
101 { |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
102 tree_statement *stmt = do_current_statement (); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
103 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
104 return stmt ? stmt->line () : -1; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
105 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
106 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
107 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
108 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
|
109 { |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9483
diff
changeset
|
110 tree_statement *stmt = do_current_statement (); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
111 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
112 return stmt ? stmt->column () : -1; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
113 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
114 |
7877 | 115 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
|
116 octave_call_stack::do_caller_user_code_line (void) const |
7877 | 117 { |
118 int retval = -1; | |
119 | |
7890 | 120 const_iterator p = cs.end (); |
121 | |
122 while (p != cs.begin ()) | |
7877 | 123 { |
7890 | 124 const call_stack_elt& elt = *(--p); |
7877 | 125 |
126 octave_function *f = elt.fcn; | |
127 | |
128 if (f && f->is_user_code ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
129 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
130 tree_statement *stmt = elt.stmt; |
7877 | 131 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
132 if (stmt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
133 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
134 retval = stmt->line (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
135 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
136 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
137 } |
7877 | 138 } |
139 | |
140 return retval; | |
141 } | |
142 | |
143 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
|
144 octave_call_stack::do_caller_user_code_column (void) const |
7877 | 145 { |
146 int retval = -1; | |
147 | |
7890 | 148 const_iterator p = cs.end (); |
149 | |
150 while (p != cs.begin ()) | |
7877 | 151 { |
7890 | 152 const call_stack_elt& elt = *(--p); |
7877 | 153 |
154 octave_function *f = elt.fcn; | |
155 | |
156 if (f && f->is_user_code ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
157 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
158 tree_statement *stmt = elt.stmt; |
7877 | 159 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
160 if (stmt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
161 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
162 retval = stmt->column (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
163 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
164 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
165 } |
7877 | 166 } |
167 | |
168 return retval; | |
169 } | |
170 | |
7901 | 171 size_t |
172 octave_call_stack::do_num_user_code_frames (octave_idx_type& curr_user_frame) const | |
173 { | |
174 size_t retval = 0; | |
175 | |
176 curr_user_frame = 0; | |
177 | |
178 // Look for the caller of dbstack. | |
179 size_t frame = cs[curr_frame].prev; | |
180 | |
181 bool found = false; | |
182 | |
183 size_t k = cs.size (); | |
184 | |
185 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) | |
186 { | |
187 octave_function *f = (*p).fcn; | |
188 | |
189 if (--k == frame) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
190 found = true; |
7901 | 191 |
192 if (f && f->is_user_code ()) | |
10315
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 if (! found) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
195 curr_user_frame++; |
7901 | 196 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
197 retval++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
198 } |
7901 | 199 } |
200 | |
201 // We counted how many user frames were not the one, in reverse. | |
202 // Now set curr_user_frame to be the index in the other direction. | |
203 curr_user_frame = retval - curr_user_frame - 1; | |
204 | |
205 return retval; | |
206 } | |
207 | |
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
|
208 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
|
209 octave_call_stack::do_caller_user_code (size_t nskip) const |
5744 | 210 { |
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
|
211 octave_user_code *retval = 0; |
5744 | 212 |
7890 | 213 const_iterator p = cs.end (); |
214 | |
215 while (p != cs.begin ()) | |
5744 | 216 { |
7890 | 217 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
|
218 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
219 octave_function *f = elt.fcn; |
5744 | 220 |
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
|
221 if (f && f->is_user_code ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
222 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
223 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
224 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
225 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
226 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
227 retval = dynamic_cast<octave_user_code *> (f); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
228 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
229 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
230 } |
5744 | 231 } |
232 | |
233 return retval; | |
234 } | |
235 | |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
236 // 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
|
237 // 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
|
238 static const char *bt_fieldnames[] = { "file", "name", "line", |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
239 "column", "scope", "context", 0 }; |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
240 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
|
241 |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
242 octave_map |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
243 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
|
244 { |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
245 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
|
246 } |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
247 |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
248 octave_map |
7901 | 249 octave_call_stack::do_backtrace (size_t nskip, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
250 octave_idx_type& curr_user_frame) const |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
251 { |
7901 | 252 size_t user_code_frames = do_num_user_code_frames (curr_user_frame); |
253 | |
254 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
|
255 |
7901 | 256 // Our list is reversed. |
257 curr_user_frame = nframes - curr_user_frame - 1; | |
258 | |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
259 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
|
260 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10411
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 |
7901 | 268 if (nframes > 0) |
269 { | |
270 int k = 0; | |
271 | |
272 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
|
273 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
274 const call_stack_elt& elt = *p; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
275 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
276 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
|
277 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
278 if (f && f->is_user_code ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
279 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
280 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
281 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
282 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
283 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
284 scope(k) = elt.scope; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
285 context(k) = elt.context; |
7901 | 286 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
287 file(k) = f->fcn_file_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
288 std::string parent_fcn_name = f->parent_fcn_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
289 if (parent_fcn_name == std::string ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
290 name(k) = f->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
291 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
292 name(k) = f->parent_fcn_name () + Vfilemarker + f->name (); |
7901 | 293 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
294 tree_statement *stmt = elt.stmt; |
7901 | 295 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
296 if (stmt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
297 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
298 line(k) = stmt->line (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
299 column(k) = stmt->column (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
300 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
301 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
302 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
303 line(k) = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
304 column(k) = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
305 } |
7901 | 306 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
307 k++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
308 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
309 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
310 } |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
311 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
312 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
313 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
|
314 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
315 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
316 bool |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
317 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
|
318 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
319 bool retval = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
320 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
321 if (n < cs.size ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
322 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
323 retval = true; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
324 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
325 curr_frame = n; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
326 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
327 const call_stack_elt& elt = cs[n]; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
328 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
329 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
|
330 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
331 if (verbose) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
332 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
333 octave_function *f = elt.fcn; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
334 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
|
335 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
336 tree_statement *s = elt.stmt; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
337 int l = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
338 int c = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
339 if (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
340 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
341 l = s->line (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
342 c = s->column (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
343 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
344 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
345 octave_stdout << "stopped in " << nm |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
346 << " at line " << l << " column " << c |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
347 << " (" << elt.scope << "[" << elt.context << "])" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
348 << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
349 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
350 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
351 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
352 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
353 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
354 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
355 bool |
7901 | 356 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
|
357 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
358 bool retval = false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
359 |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
360 int incr = 0; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
361 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
362 if (nskip < 0) |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
363 incr = -1; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
364 else if (nskip > 0) |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
365 incr = 1; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
366 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
367 // 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
|
368 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
|
369 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
370 while (true) |
7890 | 371 { |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
372 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
|
373 break; |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
374 |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
375 frame += incr; |
7901 | 376 |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
377 const call_stack_elt& elt = cs[frame]; |
7901 | 378 |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
379 octave_function *f = elt.fcn; |
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
380 |
9990
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
381 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
|
382 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
383 if (nskip > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
384 nskip--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
385 else if (nskip < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
386 nskip++; |
7901 | 387 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
388 if (nskip == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
389 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
390 curr_frame = frame; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
391 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
|
392 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
393 symbol_table::set_scope_and_context (elt.scope, elt.context); |
7901 | 394 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
395 if (verbose) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
396 { |
9990
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
397 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
|
398 |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
399 if (f) |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
400 { |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
401 tree_statement *s = elt.stmt; |
7901 | 402 |
9990
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
403 int l = s ? s->line () : -1; |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
404 |
10839 | 405 buf << "stopped in " << f->name () |
406 << " at line " << l << 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
|
407 } |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
408 else |
2b008f1d3794
octave_call_stack::do_goto_frame_relative: stop searching at top frame
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
409 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
|
410 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
411 octave_stdout << buf.str (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
412 } |
9483
25c2e92ee03c
correctly skip frame assigned to keyboard function
John W. Eaton <jwe@octave.org>
parents:
9452
diff
changeset
|
413 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
414 retval = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
415 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
416 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
417 } |
7901 | 418 |
419 // 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
|
420 // 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
|
421 // jump to the new "prev" frame set above. |
7890 | 422 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
423 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
424 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
425 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
426 |
5744 | 427 void |
7901 | 428 octave_call_stack::do_goto_caller_frame (void) |
429 { | |
430 size_t frame = curr_frame; | |
431 | |
432 bool skipped = false; | |
433 | |
434 while (frame != 0) | |
435 { | |
436 frame = cs[frame].prev; | |
437 | |
438 const call_stack_elt& elt = cs[frame]; | |
439 | |
440 octave_function *f = elt.fcn; | |
441 | |
8581
6adcafc70c32
toplev.cc (octave_call_stack::do_goto_caller_frame): allow caller frame to be base frame
John W. Eaton <jwe@octave.org>
parents:
8574
diff
changeset
|
442 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
|
443 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
444 if (! skipped) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
445 // 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
|
446 skipped = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
447 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
448 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
449 // We found the caller user code frame. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
450 call_stack_elt tmp (elt); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
451 tmp.prev = curr_frame; |
7901 | 452 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
453 curr_frame = cs.size (); |
7901 | 454 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
455 cs.push_back (tmp); |
7901 | 456 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
457 symbol_table::set_scope_and_context (tmp.scope, tmp.context); |
7901 | 458 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
459 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
460 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
461 } |
7901 | 462 } |
463 } | |
464 | |
465 void | |
466 octave_call_stack::do_goto_base_frame (void) | |
467 { | |
468 call_stack_elt tmp (cs[0]); | |
469 tmp.prev = curr_frame; | |
470 | |
471 curr_frame = cs.size (); | |
472 | |
473 cs.push_back (tmp); | |
474 | |
475 symbol_table::set_scope_and_context (tmp.scope, tmp.context); | |
476 } | |
477 | |
478 void | |
8013
b3e667f1ab4c
call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
479 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
|
480 { |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
481 if (error_state > 0) |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
482 { |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
483 error_state = -1; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
484 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
485 error ("called from:"); |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
486 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
487 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
488 if (! cs.empty ()) |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
489 { |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
490 const call_stack_elt& elt = cs.back (); |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
491 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
492 octave_function *fcn = elt.fcn; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
493 tree_statement *stmt = elt.stmt; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
494 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
495 std::string fcn_name = "?unknown?"; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
496 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
497 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
498 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
499 fcn_name = fcn->fcn_file_name (); |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
500 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
501 if (fcn_name.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
502 fcn_name = fcn->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
503 } |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
504 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
505 int line = stmt ? stmt->line () : -1; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
506 int column = stmt ? stmt->column () : -1; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
507 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
508 error (" %s at line %d, column %d", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
509 fcn_name.c_str (), line, column); |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
510 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
511 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
512 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
513 void |
4180 | 514 recover_from_exception (void) |
515 { | |
516 can_interrupt = true; | |
4182 | 517 octave_interrupt_immediately = 0; |
4180 | 518 octave_interrupt_state = 0; |
5142 | 519 octave_signal_caught = 0; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
520 octave_exception_state = octave_no_exception; |
4180 | 521 octave_restore_signal_mask (); |
522 octave_catch_interrupts (); | |
523 } | |
524 | |
1907 | 525 int |
5189 | 526 main_loop (void) |
1907 | 527 { |
2016 | 528 octave_save_signal_mask (); |
529 | |
3020 | 530 can_interrupt = true; |
1907 | 531 |
5142 | 532 octave_signal_hook = octave_signal_handler; |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
533 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
534 octave_bad_alloc_hook = 0; |
4429 | 535 |
2554 | 536 octave_catch_interrupts (); |
1907 | 537 |
4172 | 538 octave_initialized = true; |
539 | |
1907 | 540 // The big loop. |
541 | |
4153 | 542 int retval = 0; |
1907 | 543 do |
544 { | |
4180 | 545 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
546 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
547 unwind_protect frame; |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9255
diff
changeset
|
548 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
549 reset_error_handler (); |
4318 | 550 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
551 reset_parser (); |
2620 | 552 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
553 if (symbol_table::at_top_level ()) |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
554 tree_evaluator::reset_debug_state (); |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
555 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
556 // Do this with an unwind-protect cleanup function so that |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
557 // the forced variables will be unmarked in the event of an |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
558 // interrupt. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
559 symbol_table::scope_id scope = symbol_table::top_scope (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
560 frame.add_fcn (symbol_table::unmark_forced_variables, scope); |
9260
9c2349a51218
properly unmark forced variables
John W. Eaton <jwe@octave.org>
parents:
9255
diff
changeset
|
561 |
11258
795c97ace02c
eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents:
11123
diff
changeset
|
562 frame.protect_var (global_command); |
795c97ace02c
eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents:
11123
diff
changeset
|
563 |
795c97ace02c
eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents:
11123
diff
changeset
|
564 global_command = 0; |
795c97ace02c
eliminate some possible memory leaks
John W. Eaton <jwe@octave.org>
parents:
11123
diff
changeset
|
565 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
566 // This is the same as yyparse in parse.y. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
567 retval = octave_parse (); |
2620 | 568 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
569 if (retval == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
570 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
571 if (global_command) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
572 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
573 global_command->accept (*current_evaluator); |
3883 | 574 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
575 delete global_command; |
3883 | 576 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
577 global_command = 0; |
3883 | 578 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
579 octave_quit (); |
4171 | 580 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
581 if (! (interactive || forced_interactive)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
582 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
583 bool quit = (tree_return_command::returning |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
584 || tree_break_command::breaking); |
4153 | 585 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
586 if (tree_return_command::returning) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
587 tree_return_command::returning = 0; |
4153 | 588 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
589 if (tree_break_command::breaking) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
590 tree_break_command::breaking--; |
4153 | 591 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
592 if (quit) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
593 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
594 } |
4153 | 595 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
596 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
597 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
598 if (! (interactive || forced_interactive)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
599 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
600 // We should exit with a non-zero status. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
601 retval = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
602 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
603 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
604 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
605 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
606 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
607 if (octave_completion_matches_called) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
608 octave_completion_matches_called = false; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
609 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
610 command_editor::increment_current_command_number (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
611 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
612 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
613 else if (parser_end_of_input) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
614 break; |
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 } |
4182 | 617 catch (octave_interrupt_exception) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
618 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
619 recover_from_exception (); |
9383 | 620 octave_stdout << "\n"; |
621 if (quitting_gracefully) | |
622 { | |
623 clean_up_and_exit (exit_status); | |
624 break; // If user has overriden the exit func. | |
625 } | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
626 } |
8704
236ff50db90f
load-path.cc: catch execution exception in getcwd
John W. Eaton <jwe@octave.org>
parents:
8669
diff
changeset
|
627 catch (octave_execution_exception) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
628 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
629 recover_from_exception (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
630 std::cerr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
631 << "error: unhandled execution exception -- trying to return to prompt" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
632 << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
633 } |
4181 | 634 catch (std::bad_alloc) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
635 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
636 recover_from_exception (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
637 std::cerr |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
638 << "error: memory exhausted or requested size too large for range of Octave's index type -- trying to return to prompt" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
639 << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
640 } |
1907 | 641 } |
642 while (retval == 0); | |
643 | |
644 return retval; | |
645 } | |
646 | |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
647 // Call a function with exceptions handled to avoid problems with |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
648 // errors while shutting down. |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
649 |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
650 #define IGNORE_EXCEPTION(E) \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
651 catch (E) \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
652 { \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
653 std::cerr << "error: ignoring " #E " while preparing to exit" << std::endl; \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
654 recover_from_exception (); \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
655 } |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
656 |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
657 #define SAFE_CALL(F, ARGS) \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
658 try \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
659 { \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
660 F ARGS; \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
661 } \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
662 IGNORE_EXCEPTION (octave_interrupt_exception) \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
663 IGNORE_EXCEPTION (octave_execution_exception) \ |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
664 IGNORE_EXCEPTION (std::bad_alloc) |
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
665 |
1683 | 666 // Fix up things before exiting. |
667 | |
668 void | |
3162 | 669 clean_up_and_exit (int retval) |
670 { | |
3216 | 671 do_octave_atexit (); |
1683 | 672 |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
673 // Clean up symbol table. |
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
674 SAFE_CALL (symbol_table::cleanup, ()); |
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9794
diff
changeset
|
675 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
676 SAFE_CALL (sysdep_cleanup, ()) |
5451 | 677 |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
678 if (octave_exit) |
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9187
diff
changeset
|
679 (*octave_exit) (retval == EOF ? 0 : retval); |
1683 | 680 } |
681 | |
11023
cb62c7401ea2
toplev.cc (Fquit): allow any number of output paramters
John W. Eaton <jwe@octave.org>
parents:
10890
diff
changeset
|
682 DEFUN (quit, args, , |
3332 | 683 "-*- texinfo -*-\n\ |
10840 | 684 @deftypefn {Built-in Function} {} exit (@var{status})\n\ |
3332 | 685 @deftypefnx {Built-in Function} {} quit (@var{status})\n\ |
686 Exit the current Octave session. If the optional integer value\n\ | |
687 @var{status} is supplied, pass that value to the operating system as the\n\ | |
6615 | 688 Octave's exit status. The default value is zero.\n\ |
3333 | 689 @end deftypefn") |
1683 | 690 { |
2086 | 691 octave_value_list retval; |
2068 | 692 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
693 if (! quit_allowed) |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
694 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
|
695 else |
2068 | 696 { |
3180 | 697 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
698 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
699 int tmp = args(0).nint_value (); |
1683 | 700 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
701 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
702 exit_status = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
703 } |
3180 | 704 |
9383 | 705 if (! error_state) |
706 { | |
707 quitting_gracefully = true; | |
708 | |
709 // Simulate interrupt. | |
710 | |
711 octave_interrupt_state = -1; | |
712 | |
713 octave_throw_interrupt_exception (); | |
714 } | |
2068 | 715 } |
716 | |
1683 | 717 return retval; |
718 } | |
719 | |
720 DEFALIAS (exit, quit); | |
721 | |
1957 | 722 DEFUN (warranty, , , |
3446 | 723 "-*- texinfo -*-\n\ |
724 @deftypefn {Built-in Function} {} warranty ()\n\ | |
725 Describe the conditions for copying and distributing Octave.\n\ | |
726 @end deftypefn") | |
1683 | 727 { |
2086 | 728 octave_value_list retval; |
1683 | 729 |
3922 | 730 octave_stdout << "\n" \ |
731 OCTAVE_NAME_VERSION_AND_COPYRIGHT "\n\ | |
732 \n\ | |
11104 | 733 GNU Octave free software; you can redistribute it and/or modify\n\ |
1683 | 734 it under the terms of the GNU General Public License as published by\n\ |
7016 | 735 the Free Software Foundation; either version 3 of the License, or\n\ |
1683 | 736 (at your option) any later version.\n\ |
737 \n\ | |
11104 | 738 GNU Octave is distributed in the hope that it will be useful,\n\ |
1683 | 739 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
740 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ | |
741 GNU General Public License for more details.\n\ | |
742 \n\ | |
743 You should have received a copy of the GNU General Public License\n\ | |
7016 | 744 along with this program. If not, see <http://www.gnu.org/licenses/>.\n\ |
1683 | 745 \n"; |
746 | |
747 return retval; | |
748 } | |
749 | |
750 // Execute a shell command. | |
751 | |
6316 | 752 static int |
753 wait_for_input (int fid) | |
754 { | |
755 int retval = -1; | |
756 | |
757 #if defined (HAVE_SELECT) | |
758 if (fid >= 0) | |
759 { | |
760 fd_set set; | |
761 | |
762 FD_ZERO (&set); | |
763 FD_SET (fid, &set); | |
764 | |
10411 | 765 retval = gnulib::select (FD_SETSIZE, &set, 0, 0, 0); |
6316 | 766 } |
767 #else | |
768 retval = 1; | |
769 #endif | |
770 | |
771 return retval; | |
772 } | |
773 | |
2086 | 774 static octave_value_list |
3523 | 775 run_command_and_return_output (const std::string& cmd_str) |
2083 | 776 { |
2086 | 777 octave_value_list retval; |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
778 unwind_protect frame; |
2083 | 779 |
780 iprocstream *cmd = new iprocstream (cmd_str.c_str ()); | |
781 | |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
782 frame.add_delete (cmd); |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
783 frame.add_fcn (octave_child_list::remove, cmd->pid ()); |
3060 | 784 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
785 if (*cmd) |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
786 { |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
787 int fid = cmd->file_number (); |
2095 | 788 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
789 std::ostringstream output_buf; |
4494 | 790 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
791 char ch; |
3147 | 792 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
793 for (;;) |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
794 { |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
795 if (cmd->get (ch)) |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
796 output_buf.put (ch); |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
797 else |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
798 { |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
799 if (! cmd->eof () && errno == EAGAIN) |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
800 { |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
801 cmd->clear (); |
3147 | 802 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
803 if (wait_for_input (fid) != 1) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
804 break; |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
805 } |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
806 else |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
807 break; |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
808 } |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
809 } |
3147 | 810 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
811 int cmd_status = cmd->close (); |
2083 | 812 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
813 if (WIFEXITED (cmd_status)) |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
814 cmd_status = WEXITSTATUS (cmd_status); |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
815 else |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
816 cmd_status = 127; |
2083 | 817 |
10212
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
818 retval(0) = cmd_status; |
56f7734f5448
fix process creation failure handling in system()
Jaroslav Hajek <highegg@gmail.com>
parents:
10186
diff
changeset
|
819 retval(1) = output_buf.str (); |
2083 | 820 } |
821 else | |
822 error ("unable to start subprocess for `%s'", cmd_str.c_str ()); | |
823 | |
824 return retval; | |
825 } | |
826 | |
5285 | 827 enum system_exec_type { et_sync, et_async }; |
828 | |
1957 | 829 DEFUN (system, args, nargout, |
3301 | 830 "-*- texinfo -*-\n\ |
11432
da51bc237526
Add additional calling form "shell_cmd" to system() documentation.
Rik <octave@nomad.inbox5.com>
parents:
11258
diff
changeset
|
831 @deftypefn {Built-in Function} {[@var{status}, @var{output}]} system (@var{string}, @var{return_output}, @var{type})\n\ |
da51bc237526
Add additional calling form "shell_cmd" to system() documentation.
Rik <octave@nomad.inbox5.com>
parents:
11258
diff
changeset
|
832 @deftypefnx {Built-in Function} {[@var{status}, @var{output}]} shell_cmd (@var{string}, @var{return_output}, @var{type})\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
|
833 Execute a shell command specified by @var{string}.\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
|
834 If the optional argument @var{type} is @code{\"async\"}, the process\n\ |
3301 | 835 is started in the background and the process id of the child process\n\ |
836 is returned immediately. Otherwise, the process is started, and\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8013
diff
changeset
|
837 Octave waits until it exits. If the @var{type} argument is omitted, a\n\ |
3301 | 838 value of @code{\"sync\"} is assumed.\n\ |
2083 | 839 \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
|
840 If the optional argument @var{return_output} is true and the subprocess\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
|
841 is started synchronously, or if @var{system} is called with one input\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
|
842 argument and one or more output arguments, the output from the command\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
|
843 is returned. Otherwise, if the subprocess is executed synchronously, its\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
|
844 output is sent to the standard output. To send the output of a command\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
|
845 executed with @code{system} through the pager, use a command like\n\ |
2321 | 846 \n\ |
3301 | 847 @example\n\ |
848 disp (system (cmd, 1));\n\ | |
849 @end example\n\ | |
2321 | 850 \n\ |
3301 | 851 @noindent\n\ |
2321 | 852 or\n\ |
853 \n\ | |
3301 | 854 @example\n\ |
9079
4d610aba7347
Cleanup documentation for system.texi, package.texi
Rik <rdrider0-list@yahoo.com>
parents:
9035
diff
changeset
|
855 printf (\"%s\\n\", system (cmd, 1));\n\ |
3301 | 856 @end example\n\ |
857 \n\ | |
5659 | 858 The @code{system} function can return two values. The first is the\n\ |
859 exit status of the command and the second is any output from the\n\ | |
860 command that was written to the standard output stream. For example,\n\ | |
3301 | 861 \n\ |
862 @example\n\ | |
5717 | 863 [status, output] = system (\"echo foo; exit 2\");\n\ |
3301 | 864 @end example\n\ |
865 \n\ | |
866 @noindent\n\ | |
867 will set the variable @code{output} to the string @samp{foo}, and the\n\ | |
868 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
|
869 \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
|
870 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
|
871 command shell that is started to run the command.\n\ |
3301 | 872 @end deftypefn") |
1683 | 873 { |
2086 | 874 octave_value_list retval; |
1683 | 875 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9990
diff
changeset
|
876 unwind_protect frame; |
3834 | 877 |
1683 | 878 int nargin = args.length (); |
879 | |
2083 | 880 if (nargin > 0 && nargin < 4) |
1683 | 881 { |
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
|
882 bool return_output = (nargin == 1 && nargout > 1); |
2083 | 883 |
5285 | 884 system_exec_type type = et_sync; |
2083 | 885 |
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
|
886 if (nargin == 3) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
887 { |
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
|
888 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
|
889 |
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
|
890 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
891 { |
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
|
892 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
|
893 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
|
894 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
|
895 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
|
896 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
897 { |
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
|
898 error ("system: third arg must be \"sync\" or \"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
|
899 return retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
900 } |
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
|
901 } |
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
|
902 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
|
903 { |
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
|
904 error ("system: third argument must be a character string"); |
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
|
905 return retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
906 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
907 } |
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
|
908 |
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
|
909 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
|
910 { |
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
|
911 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
|
912 |
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
|
913 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
|
914 { |
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
|
915 error ("system: expecting second argument to be true or false"); |
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
|
916 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
|
917 } |
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
|
918 } |
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
|
919 |
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
|
920 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
|
921 { |
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
|
922 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
|
923 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
|
924 } |
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
|
925 |
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
|
926 std::string cmd_str = args(0).string_value (); |
1683 | 927 |
2083 | 928 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
929 { |
7104 | 930 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
931 // Work around weird double-quote handling on Windows systems. |
7104 | 932 if (type == et_sync) |
933 cmd_str = "\"" + cmd_str + "\""; | |
934 #endif | |
935 | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
936 if (type == et_async) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
937 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
938 // FIXME -- maybe this should go in sysdep.cc? |
4086 | 939 #ifdef HAVE_FORK |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
940 pid_t pid = fork (); |
2083 | 941 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
942 if (pid < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
943 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
|
944 else if (pid == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
945 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
946 // FIXME -- should probably replace this |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
947 // call with something portable. |
3273 | 948 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
949 execl ("/bin/sh", "sh", "-c", cmd_str.c_str (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
950 static_cast<void *> (0)); |
3273 | 951 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
952 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
953 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
954 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
955 retval(0) = pid; |
6222 | 956 #elif defined (__WIN32__) |
957 STARTUPINFO si; | |
958 PROCESS_INFORMATION pi; | |
959 ZeroMemory (&si, sizeof (si)); | |
960 ZeroMemory (&pi, sizeof (pi)); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
961 OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length()+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
962 strcpy (xcmd_str, cmd_str.c_str ()); |
6222 | 963 |
964 if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi)) | |
965 error ("system: CreateProcess failed -- can't create child process"); | |
966 else | |
967 { | |
968 retval(0) = pi.dwProcessId; | |
969 CloseHandle (pi.hProcess); | |
970 CloseHandle (pi.hThread); | |
971 } | |
4086 | 972 #else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
973 error ("asynchronous system calls are not supported"); |
4086 | 974 #endif |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
975 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
976 else if (return_output) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
977 retval = run_command_and_return_output (cmd_str); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
978 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
979 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
980 int status = system (cmd_str.c_str ()); |
2321 | 981 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
982 // 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
|
983 // the process exited normally, extract the actual exit |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
984 // 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
|
985 // failure code. |
2321 | 986 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
987 if (WIFEXITED (status)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
988 status = WEXITSTATUS (status); |
2321 | 989 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
990 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
991 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
992 } |
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
|
993 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
|
994 error ("system: expecting std::string as first argument"); |
1683 | 995 } |
996 else | |
5823 | 997 print_usage (); |
1683 | 998 |
999 return retval; | |
1000 } | |
1001 | |
1002 DEFALIAS (shell_cmd, system); | |
1003 | |
5775 | 1004 // FIXME -- this should really be static, but that causes |
2614 | 1005 // problems on some systems. |
6680 | 1006 std::list<std::string> octave_atexit_functions; |
2077 | 1007 |
1008 void | |
1009 do_octave_atexit (void) | |
1010 { | |
3216 | 1011 static bool deja_vu = false; |
1012 | |
2077 | 1013 while (! octave_atexit_functions.empty ()) |
1014 { | |
6680 | 1015 std::string fcn = octave_atexit_functions.front (); |
4214 | 1016 |
6680 | 1017 octave_atexit_functions.pop_front (); |
2077 | 1018 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1019 SAFE_CALL (reset_error_handler, ()) |
5237 | 1020 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1021 SAFE_CALL (feval, (fcn, octave_value_list (), 0)) |
3215 | 1022 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1023 SAFE_CALL (flush_octave_stdout, ()) |
2077 | 1024 } |
3216 | 1025 |
1026 if (! deja_vu) | |
1027 { | |
1028 deja_vu = true; | |
1029 | |
6068 | 1030 // Do this explicitly so that destructors for mex file objects |
1031 // are called, so that functions registered with mexAtExit are | |
1032 // called. | |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1033 SAFE_CALL (clear_mex_functions, ()) |
6068 | 1034 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1035 SAFE_CALL (command_editor::restore_terminal_state, ()) |
3216 | 1036 |
5775 | 1037 // FIXME -- is this needed? Can it cause any trouble? |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1038 SAFE_CALL (raw_mode, (0)) |
3216 | 1039 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1040 SAFE_CALL (octave_history_write_timestamp, ()) |
5305 | 1041 |
8735
afbfd7f4fd93
toplev.cc (do_octave_atexit): only save history if Vsaving_history is true
John W. Eaton <jwe@octave.org>
parents:
8719
diff
changeset
|
1042 if (Vsaving_history) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1043 SAFE_CALL (command_history::clean_up_and_save, ()) |
3216 | 1044 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1045 SAFE_CALL (close_files, ()) |
3216 | 1046 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1047 SAFE_CALL (cleanup_tmp_files, ()) |
3216 | 1048 |
9452
deb668d53e60
toplev.cc: handle exceptions while preparing to exit
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
1049 SAFE_CALL (flush_octave_stdout, ()) |
3216 | 1050 |
5305 | 1051 if (! quitting_gracefully && (interactive || forced_interactive)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1052 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1053 octave_stdout << "\n"; |
5629 | 1054 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1055 // Yes, we want this to be separate from the call to |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1056 // flush_octave_stdout above. |
5629 | 1057 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1058 SAFE_CALL (flush_octave_stdout, ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1059 } |
3216 | 1060 } |
2077 | 1061 } |
1062 | |
7409 | 1063 void |
1064 octave_add_atexit_function (const std::string& fname) | |
1065 { | |
1066 octave_atexit_functions.push_front (fname); | |
1067 } | |
1068 | |
1069 bool | |
1070 octave_remove_atexit_function (const std::string& fname) | |
1071 { | |
1072 bool found = false; | |
1073 | |
1074 for (std::list<std::string>::iterator p = octave_atexit_functions.begin (); | |
1075 p != octave_atexit_functions.end (); p++) | |
1076 { | |
1077 if (*p == fname) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1078 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1079 octave_atexit_functions.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1080 found = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1081 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1082 } |
7409 | 1083 } |
1084 | |
1085 return found; | |
1086 } | |
1087 | |
1088 | |
6680 | 1089 DEFUN (atexit, args, nargout, |
3332 | 1090 "-*- texinfo -*-\n\ |
10840 | 1091 @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
|
1092 @deftypefnx {Built-in Function} {} atexit (@var{fcn}, @var{flag})\n\ |
3332 | 1093 Register a function to be called when Octave exits. For example,\n\ |
2077 | 1094 \n\ |
3332 | 1095 @example\n\ |
1096 @group\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1097 function last_words ()\n\ |
6620 | 1098 disp (\"Bye bye\");\n\ |
3332 | 1099 endfunction\n\ |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1100 atexit (\"last_words\");\n\ |
3332 | 1101 @end group\n\ |
1102 @end example\n\ | |
1103 \n\ | |
1104 @noindent\n\ | |
6620 | 1105 will print the message \"Bye bye\" when Octave exits.\n\ |
6680 | 1106 \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
|
1107 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
|
1108 @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
|
1109 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
|
1110 @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
|
1111 after registering the function @code{last_words} above,\n\ |
6680 | 1112 \n\ |
1113 @example\n\ | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1114 atexit (\"last_words\", false);\n\ |
6680 | 1115 @end example\n\ |
1116 \n\ | |
1117 @noindent\n\ | |
1118 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
|
1119 @code{last_words} when it exits.\n\ |
6680 | 1120 \n\ |
7001 | 1121 Note that @code{atexit} only removes the first occurrence of a function\n\ |
6680 | 1122 from the list, so if a function was placed in the list multiple\n\ |
1123 times with @code{atexit}, it must also be removed from the list\n\ | |
1124 multiple times.\n\ | |
3333 | 1125 @end deftypefn") |
2077 | 1126 { |
2086 | 1127 octave_value_list retval; |
2077 | 1128 |
1129 int nargin = args.length (); | |
1130 | |
6680 | 1131 if (nargin == 1 || nargin == 2) |
2077 | 1132 { |
3523 | 1133 std::string arg = args(0).string_value (); |
2077 | 1134 |
1135 if (! error_state) | |
6680 | 1136 { |
1137 bool add_mode = true; | |
1138 | |
1139 if (nargin == 2) | |
1140 { | |
1141 add_mode = args(1).bool_value (); | |
1142 | |
1143 if (error_state) | |
1144 error ("atexit: second argument must be a logical value"); | |
1145 } | |
1146 | |
1147 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1148 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1149 if (add_mode) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1150 octave_add_atexit_function (arg); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1151 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1152 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1153 bool found = octave_remove_atexit_function (arg); |
6680 | 1154 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1155 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1156 retval(0) = found; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1157 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1158 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1159 } |
2077 | 1160 else |
6680 | 1161 error ("atexit: argument must be a string"); |
2077 | 1162 } |
1163 else | |
5823 | 1164 print_usage (); |
2077 | 1165 |
1166 return retval; | |
1167 } | |
1168 | |
2689 | 1169 DEFUN (octave_config_info, args, , |
3301 | 1170 "-*- texinfo -*-\n\ |
1171 @deftypefn {Built-in Function} {} octave_config_info (@var{option})\n\ | |
1172 Return a structure containing configuration and installation\n\ | |
1173 information for Octave.\n\ | |
2689 | 1174 \n\ |
3301 | 1175 if @var{option} is a string, return the configuration information for the\n\ |
2689 | 1176 specified option.\n\ |
1177 \n\ | |
3301 | 1178 @end deftypefn") |
2162 | 1179 { |
2689 | 1180 octave_value retval; |
1181 | |
4128 | 1182 #if defined (ENABLE_DYNAMIC_LINKING) |
2689 | 1183 bool octave_supports_dynamic_linking = true; |
1184 #else | |
1185 bool octave_supports_dynamic_linking = false; | |
1186 #endif | |
1187 | |
4357 | 1188 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
|
1189 static octave_scalar_map m; |
2162 | 1190 |
6274 | 1191 struct conf_info_struct |
1192 { | |
1193 bool subst_home; | |
1194 const char *key; | |
1195 const char *val; | |
1196 }; | |
1197 | |
1198 static const conf_info_struct conf_info[] = | |
4357 | 1199 { |
6274 | 1200 { false, "ALL_CFLAGS", OCTAVE_CONF_ALL_CFLAGS }, |
1201 { false, "ALL_CXXFLAGS", OCTAVE_CONF_ALL_CXXFLAGS }, | |
1202 { false, "ALL_FFLAGS", OCTAVE_CONF_ALL_FFLAGS }, | |
1203 { false, "ALL_LDFLAGS", OCTAVE_CONF_ALL_LDFLAGS }, | |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1204 { false, "AMD_CPPFLAGS", OCTAVE_CONF_AMD_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1205 { false, "AMD_LDFLAGS", OCTAVE_CONF_AMD_LDFLAGS }, |
9514 | 1206 { false, "AMD_LIBS", OCTAVE_CONF_AMD_LIBS }, |
6274 | 1207 { false, "AR", OCTAVE_CONF_AR }, |
1208 { false, "ARFLAGS", OCTAVE_CONF_ARFLAGS }, | |
9568
d3fccc4c4b9e
use OCTAVE_CHECK_LIBRARY to check for ARPACK
John W. Eaton <jwe@octave.org>
parents:
9542
diff
changeset
|
1209 { false, "ARPACK_CPPFLAGS", OCTAVE_CONF_ARPACK_CPPFLAGS }, |
d3fccc4c4b9e
use OCTAVE_CHECK_LIBRARY to check for ARPACK
John W. Eaton <jwe@octave.org>
parents:
9542
diff
changeset
|
1210 { false, "ARPACK_LDFLAGS", OCTAVE_CONF_ARPACK_LDFLAGS }, |
9514 | 1211 { false, "ARPACK_LIBS", OCTAVE_CONF_ARPACK_LIBS }, |
6274 | 1212 { false, "BLAS_LIBS", OCTAVE_CONF_BLAS_LIBS }, |
8772
aeedc045cfe3
toplev.cc (Foctave_config_info): add CARBON_LIBS, X11_INCFLAGS, and X11_LIBS to the struct
John W. Eaton <jwe@octave.org>
parents:
8735
diff
changeset
|
1213 { false, "CARBON_LIBS", OCTAVE_CONF_CARBON_LIBS }, |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1214 { false, "CAMD_CPPFLAGS", OCTAVE_CONF_CAMD_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1215 { false, "CAMD_LDFLAGS", OCTAVE_CONF_CAMD_LDFLAGS }, |
9514 | 1216 { false, "CAMD_LIBS", OCTAVE_CONF_CAMD_LIBS }, |
6274 | 1217 { false, "CC", OCTAVE_CONF_CC }, |
1218 { false, "CC_VERSION", OCTAVE_CONF_CC_VERSION }, | |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1219 { false, "CCOLAMD_CPPFLAGS", OCTAVE_CONF_CCOLAMD_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1220 { false, "CCOLAMD_LDFLAGS", OCTAVE_CONF_CCOLAMD_LDFLAGS }, |
9514 | 1221 { false, "CCOLAMD_LIBS", OCTAVE_CONF_CCOLAMD_LIBS }, |
6274 | 1222 { false, "CFLAGS", OCTAVE_CONF_CFLAGS }, |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1223 { false, "CHOLMOD_CPPFLAGS", OCTAVE_CONF_CHOLMOD_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1224 { false, "CHOLMOD_LDFLAGS", OCTAVE_CONF_CHOLMOD_LDFLAGS }, |
9514 | 1225 { false, "CHOLMOD_LIBS", OCTAVE_CONF_CHOLMOD_LIBS }, |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1226 { false, "COLAMD_CPPFLAGS", OCTAVE_CONF_COLAMD_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1227 { false, "COLAMD_LDFLAGS", OCTAVE_CONF_COLAMD_LDFLAGS }, |
9514 | 1228 { false, "COLAMD_LIBS", OCTAVE_CONF_COLAMD_LIBS }, |
6274 | 1229 { false, "CPICFLAG", OCTAVE_CONF_CPICFLAG }, |
1230 { false, "CPPFLAGS", OCTAVE_CONF_CPPFLAGS }, | |
9519
ee99f9f37505
improve configure checks for qhull and curl libs
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
1231 { false, "CURL_CPPFLAGS", OCTAVE_CONF_CURL_CPPFLAGS }, |
ee99f9f37505
improve configure checks for qhull and curl libs
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
1232 { false, "CURL_LDFLAGS", OCTAVE_CONF_CURL_LDFLAGS }, |
6274 | 1233 { false, "CURL_LIBS", OCTAVE_CONF_CURL_LIBS }, |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1234 { false, "CXSPARSE_CPPFLAGS", OCTAVE_CONF_CXSPARSE_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1235 { false, "CXSPARSE_LDFLAGS", OCTAVE_CONF_CXSPARSE_LDFLAGS }, |
9514 | 1236 { false, "CXSPARSE_LIBS", OCTAVE_CONF_CXSPARSE_LIBS }, |
6274 | 1237 { false, "CXX", OCTAVE_CONF_CXX }, |
1238 { false, "CXXCPP", OCTAVE_CONF_CXXCPP }, | |
1239 { false, "CXXFLAGS", OCTAVE_CONF_CXXFLAGS }, | |
1240 { false, "CXXPICFLAG", OCTAVE_CONF_CXXPICFLAG }, | |
1241 { false, "CXX_VERSION", OCTAVE_CONF_CXX_VERSION }, | |
1242 { false, "DEFAULT_PAGER", OCTAVE_DEFAULT_PAGER }, | |
1243 { false, "DEFS", OCTAVE_CONF_DEFS }, | |
1244 { false, "DL_LD", OCTAVE_CONF_DL_LD }, | |
1245 { false, "DL_LDFLAGS", OCTAVE_CONF_DL_LDFLAGS }, | |
9515 | 1246 { false, "DL_LIBS", OCTAVE_CONF_DL_LIBS }, |
6274 | 1247 { false, "ENABLE_DYNAMIC_LINKING", OCTAVE_CONF_ENABLE_DYNAMIC_LINKING }, |
1248 { false, "EXEEXT", OCTAVE_CONF_EXEEXT }, | |
1249 { false, "F77", OCTAVE_CONF_F77 }, | |
1250 { false, "F77_FLOAT_STORE_FLAG", OCTAVE_CONF_F77_FLOAT_STORE_FLAG }, | |
10331
6a50aa2cdf00
never compile ranlib with 8-byte integers
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1251 { false, "F77_INTEGER_8_FLAG", OCTAVE_CONF_F77_INTEGER_8_FLAG }, |
6274 | 1252 { false, "FC", OCTAVE_CONF_FC }, |
1253 { false, "FFLAGS", OCTAVE_CONF_FFLAGS }, | |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1254 { false, "FFTW3_CPPFLAGS", OCTAVE_CONF_FFTW3_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1255 { false, "FFTW3_LDFLAGS", OCTAVE_CONF_FFTW3_LDFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1256 { false, "FFTW3_LIBS", OCTAVE_CONF_FFTW3_LIBS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1257 { false, "FFTW3F_CPPFLAGS", OCTAVE_CONF_FFTW3F_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1258 { false, "FFTW3F_LDFLAGS", OCTAVE_CONF_FFTW3F_LDFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1259 { false, "FFTW3F_LIBS", OCTAVE_CONF_FFTW3F_LIBS }, |
6274 | 1260 { false, "FLIBS", OCTAVE_CONF_FLIBS }, |
1261 { false, "FPICFLAG", OCTAVE_CONF_FPICFLAG }, | |
9514 | 1262 { false, "FT2_LIBS", OCTAVE_CONF_FT2_LIBS }, |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1263 { false, "GLPK_CPPFLAGS", OCTAVE_CONF_GLPK_CPPFLAGS }, |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9519
diff
changeset
|
1264 { false, "GLPK_LDFLAGS", OCTAVE_CONF_GLPK_LDFLAGS }, |
6274 | 1265 { false, "GLPK_LIBS", OCTAVE_CONF_GLPK_LIBS }, |
7361 | 1266 { false, "GNUPLOT", OCTAVE_CONF_GNUPLOT }, |
9514 | 1267 { false, "GRAPHICS_LIBS", OCTAVE_CONF_GRAPHICS_LIBS }, |
9542
f5ec5dc66824
use OCTAVE_CHECK_LIBRARY to check for HDF5
John W. Eaton <jwe@octave.org>
parents:
9538
diff
changeset
|
1268 { false, "HDF5_CPPFLAGS", OCTAVE_CONF_HDF5_CPPFLAGS }, |
f5ec5dc66824
use OCTAVE_CHECK_LIBRARY to check for HDF5
John W. Eaton <jwe@octave.org>
parents:
9538
diff
changeset
|
1269 { false, "HDF5_LDFLAGS", OCTAVE_CONF_HDF5_LDFLAGS }, |
9514 | 1270 { false, "HDF5_LIBS", OCTAVE_CONF_HDF5_LIBS }, |
6274 | 1271 { false, "INCFLAGS", OCTAVE_CONF_INCFLAGS }, |
9794
0d4613a736e9
convert build system to use automake and libtool
John W. Eaton <jwe@octave.org>
parents:
9575
diff
changeset
|
1272 { false, "LAPACK_LIBS", OCTAVE_CONF_LAPACK_LIBS }, |
6274 | 1273 { false, "LDFLAGS", OCTAVE_CONF_LDFLAGS }, |
1274 { false, "LD_CXX", OCTAVE_CONF_LD_CXX }, | |
1275 { false, "LD_STATIC_FLAG", OCTAVE_CONF_LD_STATIC_FLAG }, | |
1276 { false, "LEX", OCTAVE_CONF_LEX }, | |
1277 { false, "LEXLIB", OCTAVE_CONF_LEXLIB }, | |
1278 { false, "LFLAGS", OCTAVE_CONF_LFLAGS }, | |
1279 { false, "LIBCRUFT", OCTAVE_CONF_LIBCRUFT }, | |
1280 { false, "LIBEXT", OCTAVE_CONF_LIBEXT }, | |
1281 { false, "LIBFLAGS", OCTAVE_CONF_LIBFLAGS }, | |
1282 { false, "LIBOCTAVE", OCTAVE_CONF_LIBOCTAVE }, | |
1283 { false, "LIBOCTINTERP", OCTAVE_CONF_LIBOCTINTERP }, | |
1284 { false, "LIBS", OCTAVE_CONF_LIBS }, | |
1285 { false, "LN_S", OCTAVE_CONF_LN_S }, | |
9575
55ecaefb7d0f
Use pkg-config to configure GraphicsMagick++.
David Grundberg <individ@acc.umu.se>
parents:
9572
diff
changeset
|
1286 { false, "MAGICK_CPPFLAGS", OCTAVE_CONF_MAGICK_CPPFLAGS }, |
55ecaefb7d0f
Use pkg-config to configure GraphicsMagick++.
David Grundberg <individ@acc.umu.se>
parents:
9572
diff
changeset
|
1287 { false, "MAGICK_LDFLAGS", OCTAVE_CONF_MAGICK_LDFLAGS }, |
7926
d74f996e005d
__magick_read__.cc: configuration and style fixes
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
1288 { false, "MAGICK_LIBS", OCTAVE_CONF_MAGICK_LIBS }, |
6274 | 1289 { false, "MKOCTFILE_DL_LDFLAGS", OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS }, |
9514 | 1290 { false, "OPENGL_LIBS", OCTAVE_CONF_OPENGL_LIBS }, |
1291 { false, "PTHREAD_CFLAGS", OCTAVE_CONF_PTHREAD_CFLAGS }, | |
1292 { false, "PTHREAD_LIBS", OCTAVE_CONF_PTHREAD_LIBS }, | |
9519
ee99f9f37505
improve configure checks for qhull and curl libs
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
1293 { false, "QHULL_CPPFLAGS", OCTAVE_CONF_QHULL_CPPFLAGS }, |
ee99f9f37505
improve configure checks for qhull and curl libs
John W. Eaton <jwe@octave.org>
parents:
9515
diff
changeset
|
1294 { false, "QHULL_LDFLAGS", OCTAVE_CONF_QHULL_LDFLAGS }, |
9514 | 1295 { false, "QHULL_LIBS", OCTAVE_CONF_QHULL_LIBS }, |
9570
1ab56c73ec7c
use OCTAVE_CHECK_LIBRARY to check for qrupdate library
John W. Eaton <jwe@octave.org>
parents:
9568
diff
changeset
|
1296 { false, "QRUPDATE_CPPFLAGS", OCTAVE_CONF_QRUPDATE_CPPFLAGS }, |
1ab56c73ec7c
use OCTAVE_CHECK_LIBRARY to check for qrupdate library
John W. Eaton <jwe@octave.org>
parents:
9568
diff
changeset
|
1297 { false, "QRUPDATE_LDFLAGS", OCTAVE_CONF_QRUPDATE_LDFLAGS }, |
9514 | 1298 { false, "QRUPDATE_LIBS", OCTAVE_CONF_QRUPDATE_LIBS }, |
6274 | 1299 { false, "RANLIB", OCTAVE_CONF_RANLIB }, |
1300 { false, "RDYNAMIC_FLAG", OCTAVE_CONF_RDYNAMIC_FLAG }, | |
9515 | 1301 { false, "READLINE_LIBS", OCTAVE_CONF_READLINE_LIBS }, |
9514 | 1302 { false, "REGEX_LIBS", OCTAVE_CONF_REGEX_LIBS }, |
6274 | 1303 { false, "RLD_FLAG", OCTAVE_CONF_RLD_FLAG }, |
1304 { false, "SED", OCTAVE_CONF_SED }, | |
1305 { false, "SHARED_LIBS", OCTAVE_CONF_SHARED_LIBS }, | |
1306 { false, "SHLEXT", OCTAVE_CONF_SHLEXT }, | |
1307 { false, "SHLEXT_VER", OCTAVE_CONF_SHLEXT_VER }, | |
1308 { false, "SH_LD", OCTAVE_CONF_SH_LD }, | |
1309 { false, "SH_LDFLAGS", OCTAVE_CONF_SH_LDFLAGS }, | |
1310 { false, "SONAME_FLAGS", OCTAVE_CONF_SONAME_FLAGS }, | |
1311 { false, "STATIC_LIBS", OCTAVE_CONF_STATIC_LIBS }, | |
9515 | 1312 { false, "TERM_LIBS", OCTAVE_CONF_TERM_LIBS }, |
6274 | 1313 { false, "UGLY_DEFS", OCTAVE_CONF_UGLY_DEFS }, |
9572
ab8a163f2052
use OCTAVE_CHECK_LIB to check for UMFPACK
John W. Eaton <jwe@octave.org>
parents:
9570
diff
changeset
|
1314 { false, "UMFPACK_CPPFLAGS", OCTAVE_CONF_UMFPACK_CPPFLAGS }, |
ab8a163f2052
use OCTAVE_CHECK_LIB to check for UMFPACK
John W. Eaton <jwe@octave.org>
parents:
9570
diff
changeset
|
1315 { false, "UMFPACK_LDFLAGS", OCTAVE_CONF_UMFPACK_LDFLAGS }, |
9514 | 1316 { false, "UMFPACK_LIBS", OCTAVE_CONF_UMFPACK_LIBS }, |
6274 | 1317 { false, "USE_64_BIT_IDX_T", OCTAVE_CONF_USE_64_BIT_IDX_T }, |
8772
aeedc045cfe3
toplev.cc (Foctave_config_info): add CARBON_LIBS, X11_INCFLAGS, and X11_LIBS to the struct
John W. Eaton <jwe@octave.org>
parents:
8735
diff
changeset
|
1318 { false, "X11_INCFLAGS", OCTAVE_CONF_X11_INCFLAGS }, |
aeedc045cfe3
toplev.cc (Foctave_config_info): add CARBON_LIBS, X11_INCFLAGS, and X11_LIBS to the struct
John W. Eaton <jwe@octave.org>
parents:
8735
diff
changeset
|
1319 { false, "X11_LIBS", OCTAVE_CONF_X11_LIBS }, |
6274 | 1320 { false, "XTRA_CFLAGS", OCTAVE_CONF_XTRA_CFLAGS }, |
1321 { false, "XTRA_CXXFLAGS", OCTAVE_CONF_XTRA_CXXFLAGS }, | |
1322 { false, "YACC", OCTAVE_CONF_YACC }, | |
1323 { false, "YFLAGS", OCTAVE_CONF_YFLAGS }, | |
9538
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9523
diff
changeset
|
1324 { false, "Z_CPPFLAGS", OCTAVE_CONF_Z_CPPFLAGS }, |
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9523
diff
changeset
|
1325 { false, "Z_LDFLAGS", OCTAVE_CONF_Z_LDFLAGS }, |
d0239bddf621
use OCTAVE_CHECK_LIB to check for zlib
John W. Eaton <jwe@octave.org>
parents:
9523
diff
changeset
|
1326 { false, "Z_LIBS", OCTAVE_CONF_Z_LIBS }, |
6274 | 1327 { false, "api_version", OCTAVE_API_VERSION }, |
1328 { true, "archlibdir", OCTAVE_ARCHLIBDIR }, | |
1329 { true, "bindir", OCTAVE_BINDIR }, | |
1330 { false, "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE }, | |
1331 { false, "config_opts", OCTAVE_CONF_config_opts }, | |
1332 { true, "datadir", OCTAVE_DATADIR }, | |
1333 { true, "datarootdir", OCTAVE_DATAROOTDIR }, | |
6276 | 1334 { true, "exec_prefix", OCTAVE_EXEC_PREFIX }, |
6274 | 1335 { true, "fcnfiledir", OCTAVE_FCNFILEDIR }, |
1336 { true, "imagedir", OCTAVE_IMAGEDIR }, | |
1337 { true, "includedir", OCTAVE_INCLUDEDIR }, | |
1338 { true, "infodir", OCTAVE_INFODIR }, | |
6276 | 1339 { true, "infofile", OCTAVE_INFOFILE }, |
6274 | 1340 { true, "libdir", OCTAVE_LIBDIR }, |
1341 { true, "libexecdir", OCTAVE_LIBEXECDIR }, | |
6311 | 1342 { true, "localapiarchlibdir", OCTAVE_LOCALAPIARCHLIBDIR }, |
6274 | 1343 { true, "localapifcnfiledir", OCTAVE_LOCALAPIFCNFILEDIR }, |
1344 { true, "localapioctfiledir", OCTAVE_LOCALAPIOCTFILEDIR }, | |
1345 { true, "localarchlibdir", OCTAVE_LOCALARCHLIBDIR }, | |
1346 { true, "localfcnfiledir", OCTAVE_LOCALFCNFILEDIR }, | |
1347 { true, "localoctfiledir", OCTAVE_LOCALOCTFILEDIR }, | |
1348 { true, "localstartupfiledir", OCTAVE_LOCALSTARTUPFILEDIR }, | |
1349 { true, "localverarchlibdir", OCTAVE_LOCALVERARCHLIBDIR }, | |
1350 { true, "localverfcnfiledir", OCTAVE_LOCALVERFCNFILEDIR }, | |
1351 { true, "localveroctfiledir", OCTAVE_LOCALVEROCTFILEDIR }, | |
1352 { true, "man1dir", OCTAVE_MAN1DIR }, | |
1353 { false, "man1ext", OCTAVE_MAN1EXT }, | |
1354 { true, "mandir", OCTAVE_MANDIR }, | |
1355 { true, "octfiledir", OCTAVE_OCTFILEDIR }, | |
8719
679c270b7584
install DOC and NEWS in $octetcdir
John W. Eaton <jwe@octave.org>
parents:
8704
diff
changeset
|
1356 { true, "octetcdir", OCTAVE_OCTETCDIR }, |
6274 | 1357 { true, "octincludedir", OCTAVE_OCTINCLUDEDIR }, |
1358 { true, "octlibdir", OCTAVE_OCTLIBDIR }, | |
6276 | 1359 { true, "prefix", OCTAVE_PREFIX }, |
6274 | 1360 { true, "startupfiledir", OCTAVE_STARTUPFILEDIR }, |
1361 { false, "version", OCTAVE_VERSION }, | |
1362 { false, 0, 0 } | |
4357 | 1363 }; |
1364 | |
1365 if (! initialized) | |
1366 { | |
4675 | 1367 m.assign ("dld", octave_value (octave_supports_dynamic_linking)); |
4357 | 1368 |
4697 | 1369 oct_mach_info::float_format ff = oct_mach_info::native_float_format (); |
1370 m.assign ("float_format", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1371 octave_value (oct_mach_info::float_format_as_string (ff))); |
4697 | 1372 |
1373 m.assign ("words_big_endian", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1374 octave_value (oct_mach_info::words_big_endian ())); |
4697 | 1375 |
1376 m.assign ("words_little_endian", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1377 octave_value (oct_mach_info::words_little_endian ())); |
4697 | 1378 |
4357 | 1379 int i = 0; |
4440 | 1380 |
1381 while (true) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1382 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1383 const conf_info_struct& elt = conf_info[i++]; |
6274 | 1384 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1385 const char *key = elt.key; |
4357 | 1386 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1387 if (key) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1388 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1389 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
|
1390 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
|
1391 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
|
1392 m.assign (key, elt.val); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1393 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1394 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1395 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1396 } |
4357 | 1397 |
4691 | 1398 bool unix_system = true; |
7013 | 1399 bool mac_system = false; |
4691 | 1400 bool windows_system = false; |
1401 | |
1402 #if defined (WIN32) | |
1403 windows_system = true; | |
1404 #if !defined (__CYGWIN__) | |
1405 unix_system = false; | |
1406 #endif | |
1407 #endif | |
1408 | |
8574
83b8c739d626
toplev.cc: check OCTAVE_USE_OS_X_API instead of __APPLE__ && __MACH__
John W. Eaton <jwe@octave.org>
parents:
8377
diff
changeset
|
1409 #if defined (OCTAVE_USE_OS_X_API) |
7010 | 1410 mac_system = true; |
1411 #endif | |
1412 | |
4691 | 1413 m.assign ("unix", octave_value (unix_system)); |
7010 | 1414 m.assign ("mac", octave_value (mac_system)); |
4691 | 1415 m.assign ("windows", octave_value (windows_system)); |
1416 | |
4357 | 1417 initialized = true; |
1418 } | |
2162 | 1419 |
2689 | 1420 int nargin = args.length (); |
1421 | |
1422 if (nargin == 1) | |
1423 { | |
3523 | 1424 std::string arg = args(0).string_value (); |
2689 | 1425 |
1426 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1427 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1428 Cell c = m.contents (arg.c_str ()); |
5199 | 1429 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1430 if (c.is_empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1431 error ("octave_config_info: no info for `%s'", arg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1432 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1433 retval = c(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10212
diff
changeset
|
1434 } |
2689 | 1435 } |
1436 else if (nargin == 0) | |
4233 | 1437 retval = m; |
2689 | 1438 else |
5823 | 1439 print_usage (); |
2689 | 1440 |
1441 return retval; | |
2162 | 1442 } |
1443 | |
1683 | 1444 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE) |
2806 | 1445 |
1683 | 1446 int debug_new_delete = 0; |
1447 | |
1448 typedef void (*vfp)(void); | |
1449 extern vfp __new_handler; | |
1450 | |
1451 void * | |
1452 __builtin_new (size_t sz) | |
1453 { | |
1454 void *p; | |
1455 | |
1456 /* malloc (0) is unpredictable; avoid it. */ | |
1457 if (sz == 0) | |
1458 sz = 1; | |
2800 | 1459 p = malloc (sz); |
1683 | 1460 while (p == 0) |
1461 { | |
1462 (*__new_handler) (); | |
2800 | 1463 p = malloc (sz); |
1683 | 1464 } |
1465 | |
1466 if (debug_new_delete) | |
5629 | 1467 std::cerr << "__builtin_new: " << p << std::endl; |
1683 | 1468 |
1469 return p; | |
1470 } | |
1471 | |
1472 void | |
1473 __builtin_delete (void *ptr) | |
1474 { | |
1475 if (debug_new_delete) | |
5629 | 1476 std::cerr << "__builtin_delete: " << ptr << std::endl; |
1683 | 1477 |
1478 if (ptr) | |
1479 free (ptr); | |
1480 } | |
2806 | 1481 |
1683 | 1482 #endif |