Mercurial > hg > octave-lyh
annotate src/toplev.cc @ 8011:3100283874d7
improve backtrace error messages
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Aug 2008 23:09:32 -0400 |
parents | 0d607e8dbbfa |
children | b3e667f1ab4c |
rev | line source |
---|---|
1683 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
4 2004, 2005, 2006, 2007 John W. Eaton | |
1683 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1683 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1683 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include <cassert> | |
4489 | 29 #include <cerrno> |
1683 | 30 #include <cstdlib> |
31 #include <cstring> | |
4221 | 32 #include <new> |
1683 | 33 |
3503 | 34 #include <fstream> |
35 #include <iostream> | |
5765 | 36 #include <sstream> |
1728 | 37 #include <string> |
38 | |
1683 | 39 #ifdef HAVE_UNISTD_H |
2442 | 40 #ifdef HAVE_SYS_TYPES_H |
1683 | 41 #include <sys/types.h> |
2442 | 42 #endif |
1683 | 43 #include <unistd.h> |
44 #endif | |
45 | |
2926 | 46 #include "cmd-edit.h" |
47 #include "file-ops.h" | |
1683 | 48 #include "lo-error.h" |
2370 | 49 #include "lo-mappers.h" |
3020 | 50 #include "oct-env.h" |
4153 | 51 #include "quit.h" |
1755 | 52 #include "str-vec.h" |
1683 | 53 |
2492 | 54 #include <defaults.h> |
1683 | 55 #include "defun.h" |
56 #include "error.h" | |
57 #include "file-io.h" | |
58 #include "input.h" | |
59 #include "lex.h" | |
2492 | 60 #include <oct-conf.h> |
1742 | 61 #include "oct-hist.h" |
2162 | 62 #include "oct-map.h" |
2862 | 63 #include "oct-obj.h" |
1683 | 64 #include "pager.h" |
65 #include "parse.h" | |
66 #include "pathsearch.h" | |
67 #include "procstream.h" | |
2370 | 68 #include "ov.h" |
2985 | 69 #include "pt-jump.h" |
2982 | 70 #include "pt-stmt.h" |
1683 | 71 #include "sighandlers.h" |
72 #include "sysdep.h" | |
2693 | 73 #include "syswait.h" |
1750 | 74 #include "toplev.h" |
1683 | 75 #include "unwind-prot.h" |
76 #include "utils.h" | |
77 #include "variables.h" | |
2492 | 78 #include <version.h> |
1683 | 79 |
3020 | 80 // TRUE means we are exiting via the builtin exit or quit functions. |
81 static bool quitting_gracefully = false; | |
1683 | 82 |
4217 | 83 // TRUE means we are ready to interpret commands, but not everything |
84 // is ready for interactive use. | |
85 bool octave_interpreter_ready = false; | |
86 | |
4172 | 87 // TRUE means we've processed all the init code and we are good to go. |
88 bool octave_initialized = false; | |
89 | |
1683 | 90 // Current command to execute. |
91 tree_statement_list *global_command = 0; | |
92 | |
5743 | 93 octave_call_stack *octave_call_stack::instance = 0; |
94 | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
95 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
96 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
|
97 { |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
98 tree_statement *stmt = do_top_statement (); |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
99 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
100 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
|
101 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
102 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
103 int |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
104 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
|
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 tree_statement *stmt = do_top_statement (); |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
107 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
108 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
|
109 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
110 |
7877 | 111 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
|
112 octave_call_stack::do_caller_user_code_line (void) const |
7877 | 113 { |
114 int retval = -1; | |
115 | |
7890 | 116 const_iterator p = cs.end (); |
117 | |
118 while (p != cs.begin ()) | |
7877 | 119 { |
7890 | 120 const call_stack_elt& elt = *(--p); |
7877 | 121 |
122 octave_function *f = elt.fcn; | |
123 | |
124 if (f && f->is_user_code ()) | |
125 { | |
126 tree_statement *stmt = elt.stmt; | |
127 | |
128 if (stmt) | |
129 { | |
130 retval = stmt->line (); | |
131 break; | |
132 } | |
133 } | |
134 } | |
135 | |
136 return retval; | |
137 } | |
138 | |
139 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
|
140 octave_call_stack::do_caller_user_code_column (void) const |
7877 | 141 { |
142 int retval = -1; | |
143 | |
7890 | 144 const_iterator p = cs.end (); |
145 | |
146 while (p != cs.begin ()) | |
7877 | 147 { |
7890 | 148 const call_stack_elt& elt = *(--p); |
7877 | 149 |
150 octave_function *f = elt.fcn; | |
151 | |
152 if (f && f->is_user_code ()) | |
153 { | |
154 tree_statement *stmt = elt.stmt; | |
155 | |
156 if (stmt) | |
157 { | |
158 retval = stmt->column (); | |
159 break; | |
160 } | |
161 } | |
162 } | |
163 | |
164 return retval; | |
165 } | |
166 | |
7901 | 167 size_t |
168 octave_call_stack::do_num_user_code_frames (octave_idx_type& curr_user_frame) const | |
169 { | |
170 size_t retval = 0; | |
171 | |
172 curr_user_frame = 0; | |
173 | |
174 // Look for the caller of dbstack. | |
175 size_t frame = cs[curr_frame].prev; | |
176 | |
177 bool found = false; | |
178 | |
179 size_t k = cs.size (); | |
180 | |
181 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) | |
182 { | |
183 octave_function *f = (*p).fcn; | |
184 | |
185 if (--k == frame) | |
186 found = true; | |
187 | |
188 if (f && f->is_user_code ()) | |
189 { | |
190 if (! found) | |
191 curr_user_frame++; | |
192 | |
193 retval++; | |
194 } | |
195 } | |
196 | |
197 // We counted how many user frames were not the one, in reverse. | |
198 // Now set curr_user_frame to be the index in the other direction. | |
199 curr_user_frame = retval - curr_user_frame - 1; | |
200 | |
201 return retval; | |
202 } | |
203 | |
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
|
204 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
|
205 octave_call_stack::do_caller_user_code (size_t nskip) const |
5744 | 206 { |
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
|
207 octave_user_code *retval = 0; |
5744 | 208 |
7890 | 209 const_iterator p = cs.end (); |
210 | |
211 while (p != cs.begin ()) | |
5744 | 212 { |
7890 | 213 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
|
214 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
215 octave_function *f = elt.fcn; |
5744 | 216 |
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
|
217 if (f && f->is_user_code ()) |
5744 | 218 { |
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
|
219 if (nskip > 0) |
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
|
220 nskip--; |
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
|
221 else |
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
|
222 { |
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
|
223 retval = dynamic_cast<octave_user_code *> (f); |
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
|
224 break; |
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
|
225 } |
5744 | 226 } |
227 } | |
228 | |
229 return retval; | |
230 } | |
231 | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
232 Octave_map |
7901 | 233 octave_call_stack::do_backtrace (size_t nskip, |
234 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
|
235 { |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
236 Octave_map retval; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
237 |
7901 | 238 size_t user_code_frames = do_num_user_code_frames (curr_user_frame); |
239 | |
240 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
|
241 |
7901 | 242 // Our list is reversed. |
243 curr_user_frame = nframes - curr_user_frame - 1; | |
244 | |
245 Cell keys (6, 1); | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
246 |
7901 | 247 keys(0) = "file"; |
248 keys(1) = "name"; | |
249 keys(2) = "line"; | |
250 keys(3) = "column"; | |
251 keys(4) = "scope"; | |
252 keys(5) = "context"; | |
7890 | 253 |
7901 | 254 Cell file (nframes, 1); |
255 Cell name (nframes, 1); | |
256 Cell line (nframes, 1); | |
257 Cell column (nframes, 1); | |
258 Cell scope (nframes, 1); | |
259 Cell context (nframes, 1); | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
260 |
7901 | 261 if (nframes > 0) |
262 { | |
263 int k = 0; | |
264 | |
265 for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); 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
|
266 { |
7901 | 267 const call_stack_elt& elt = *p; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
268 |
7736 | 269 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
|
270 |
7901 | 271 if (f && f->is_user_code ()) |
7736 | 272 { |
7901 | 273 if (nskip > 0) |
274 nskip--; | |
7736 | 275 else |
276 { | |
7901 | 277 scope(k) = elt.scope; |
278 context(k) = elt.context; | |
279 | |
280 file(k) = f->fcn_file_name (); | |
281 std::string parent_fcn_name = f->parent_fcn_name (); | |
282 if (parent_fcn_name == std::string ()) | |
283 name(k) = f->name (); | |
284 else | |
285 name(k) = f->parent_fcn_name () + Vfilemarker + f->name (); | |
286 | |
287 tree_statement *stmt = elt.stmt; | |
288 | |
289 if (stmt) | |
290 { | |
291 line(k) = stmt->line (); | |
292 column(k) = stmt->column (); | |
293 } | |
294 else | |
295 { | |
296 line(k) = -1; | |
297 column(k) = -1; | |
298 } | |
299 | |
300 k++; | |
7736 | 301 } |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
302 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
303 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
304 |
7736 | 305 retval.assign ("file", file); |
306 retval.assign ("name", name); | |
307 retval.assign ("line", line); | |
308 retval.assign ("column", column); | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
309 retval.assign ("scope", scope); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
310 retval.assign ("context", context); |
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) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
332 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
333 octave_function *f = elt.fcn; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
334 std::string nm = f ? f->name () : std::string ("<unknown>"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
335 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
336 tree_statement *s = elt.stmt; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
337 int l = -1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
338 int c = -1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
339 if (s) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
340 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
341 l = s->line (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
342 c = s->column (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
343 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
344 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
345 octave_stdout << "stopped in " << nm |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
346 << " at line " << l << " column " << c |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
347 << " (" << elt.scope << "[" << elt.context << "])" |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
348 << std::endl; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
349 } |
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 |
7901 | 360 if (nskip == 0) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
361 retval = true; |
7890 | 362 else |
363 { | |
7901 | 364 int incr = nskip < 0 ? -1 : 1; |
365 | |
366 // Start looking with the caller of dbup/dbdown. | |
367 size_t frame = cs[curr_frame].prev; | |
368 | |
369 while (true) | |
370 { | |
371 if ((incr < 0 && frame == 0) || (incr > 0 && frame == cs.size () - 1)) | |
372 break; | |
373 | |
374 frame += incr; | |
375 | |
376 const call_stack_elt& elt = cs[frame]; | |
377 | |
378 octave_function *f = elt.fcn; | |
379 | |
380 if (f && f->is_user_code ()) | |
381 { | |
382 if (nskip > 0) | |
383 nskip--; | |
384 else if (nskip < 0) | |
385 nskip++; | |
386 | |
387 if (nskip == 0) | |
388 { | |
389 curr_frame = frame; | |
390 cs[cs.size () - 1].prev = curr_frame; | |
7890 | 391 |
7901 | 392 if (verbose) |
393 { | |
394 tree_statement *s = elt.stmt; | |
395 int l = -1; | |
396 int c = -1; | |
397 if (s) | |
398 { | |
399 l = s->line (); | |
400 c = s->column (); | |
401 } | |
402 | |
403 std::ostringstream buf; | |
404 buf << f->name () << ": " << " line " << l | |
405 << ", column " << c << std::endl; | |
406 | |
407 octave_stdout << buf.str (); | |
408 } | |
409 | |
410 retval = true; | |
411 break; | |
412 } | |
413 } | |
414 } | |
415 | |
416 // There is no need to set scope and context here. That will | |
417 // happen when the dbup/dbdown frame is popped and we jump to | |
418 // the new "prev" frame set above. | |
7890 | 419 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
420 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
421 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
422 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
423 |
5744 | 424 void |
7901 | 425 octave_call_stack::do_goto_caller_frame (void) |
426 { | |
427 size_t frame = curr_frame; | |
428 | |
429 bool skipped = false; | |
430 | |
431 while (frame != 0) | |
432 { | |
433 frame = cs[frame].prev; | |
434 | |
435 const call_stack_elt& elt = cs[frame]; | |
436 | |
437 octave_function *f = elt.fcn; | |
438 | |
439 if (f && f->is_user_code ()) | |
440 { | |
441 if (! skipped) | |
442 // We found the current user code frame, so skip it. | |
443 skipped = true; | |
444 else | |
445 { | |
446 // We found the caller user code frame. | |
447 call_stack_elt tmp (elt); | |
448 tmp.prev = curr_frame; | |
449 | |
450 curr_frame = cs.size (); | |
451 | |
452 cs.push_back (tmp); | |
453 | |
454 symbol_table::set_scope_and_context (tmp.scope, tmp.context); | |
455 | |
456 break; | |
457 } | |
458 } | |
459 } | |
460 } | |
461 | |
462 void | |
463 octave_call_stack::do_goto_base_frame (void) | |
464 { | |
465 call_stack_elt tmp (cs[0]); | |
466 tmp.prev = curr_frame; | |
467 | |
468 curr_frame = cs.size (); | |
469 | |
470 cs.push_back (tmp); | |
471 | |
472 symbol_table::set_scope_and_context (tmp.scope, tmp.context); | |
473 } | |
474 | |
475 void | |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
476 octave_call_stack::backtrace_error_message (void) const |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
477 { |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
478 if (error_state > 0) |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
479 { |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
480 error_state = -1; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
481 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
482 error ("called from:"); |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
483 } |
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 if (! cs.empty ()) |
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 const call_stack_elt& elt = cs.back (); |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
488 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
489 octave_function *fcn = elt.fcn; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
490 tree_statement *stmt = elt.stmt; |
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 std::string fcn_name = "?unknown?"; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
493 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
494 if (fcn) |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
495 { |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
496 fcn_name = fcn->fcn_file_name (); |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
497 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
498 if (fcn_name.empty ()) |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
499 fcn_name = fcn->name (); |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
500 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
501 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
502 int line = stmt ? stmt->line () : -1; |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
503 int column = stmt ? stmt->column () : -1; |
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 error (" %s at line %d, column %d", |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
506 fcn_name.c_str (), line, column); |
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 } |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
509 |
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
510 void |
4180 | 511 recover_from_exception (void) |
512 { | |
513 can_interrupt = true; | |
4182 | 514 octave_interrupt_immediately = 0; |
4180 | 515 octave_interrupt_state = 0; |
5142 | 516 octave_signal_caught = 0; |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7409
diff
changeset
|
517 octave_exception_state = octave_no_exception; |
4180 | 518 octave_restore_signal_mask (); |
519 octave_catch_interrupts (); | |
520 } | |
521 | |
1907 | 522 int |
5189 | 523 main_loop (void) |
1907 | 524 { |
2016 | 525 octave_save_signal_mask (); |
526 | |
3020 | 527 can_interrupt = true; |
1907 | 528 |
5142 | 529 octave_signal_hook = octave_signal_handler; |
4429 | 530 octave_interrupt_hook = unwind_protect::run_all; |
531 octave_bad_alloc_hook = unwind_protect::run_all; | |
532 | |
2554 | 533 octave_catch_interrupts (); |
1907 | 534 |
4172 | 535 octave_initialized = true; |
536 | |
1907 | 537 // The big loop. |
538 | |
4153 | 539 int retval = 0; |
1907 | 540 do |
541 { | |
4180 | 542 try |
1907 | 543 { |
7336 | 544 symbol_table::reset_scope (); |
2620 | 545 |
4318 | 546 reset_error_handler (); |
547 | |
4153 | 548 reset_parser (); |
2620 | 549 |
4753 | 550 // This is the same as yyparse in parse.y. |
551 retval = octave_parse (); | |
2620 | 552 |
4153 | 553 if (retval == 0) |
554 { | |
7913
f46e73bcb85b
toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
555 if (global_command) |
3804 | 556 { |
7913
f46e73bcb85b
toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
557 global_command->eval (); |
3883 | 558 |
7913
f46e73bcb85b
toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
559 delete global_command; |
3883 | 560 |
7913
f46e73bcb85b
toplev.cc (main_loop): undo previous change; input.cc (get_debug_input): don't delete global_command here
John W. Eaton <jwe@octave.org>
parents:
7903
diff
changeset
|
561 global_command = 0; |
3883 | 562 |
4171 | 563 OCTAVE_QUIT; |
564 | |
3883 | 565 if (! (interactive || forced_interactive)) |
566 { | |
4207 | 567 bool quit = (tree_return_command::returning |
568 || tree_break_command::breaking); | |
4153 | 569 |
4207 | 570 if (tree_return_command::returning) |
571 tree_return_command::returning = 0; | |
4153 | 572 |
4207 | 573 if (tree_break_command::breaking) |
574 tree_break_command::breaking--; | |
4153 | 575 |
576 if (quit) | |
577 break; | |
578 } | |
579 | |
580 if (error_state) | |
581 { | |
582 if (! (interactive || forced_interactive)) | |
583 { | |
584 // We should exit with a non-zero status. | |
585 retval = 1; | |
586 break; | |
587 } | |
588 } | |
589 else | |
590 { | |
591 if (octave_completion_matches_called) | |
592 octave_completion_matches_called = false; | |
593 else | |
594 command_editor::increment_current_command_number (); | |
3883 | 595 } |
596 } | |
4153 | 597 else if (parser_end_of_input) |
598 break; | |
2620 | 599 } |
4153 | 600 } |
4182 | 601 catch (octave_interrupt_exception) |
4153 | 602 { |
4180 | 603 recover_from_exception (); |
5629 | 604 octave_stdout << "\n"; |
4180 | 605 } |
4181 | 606 catch (std::bad_alloc) |
4180 | 607 { |
608 recover_from_exception (); | |
609 std::cerr | |
6680 | 610 << "error: memory exhausted or requested size too large for range of Octave's index type -- trying to return to prompt" |
611 << std::endl; | |
1907 | 612 } |
613 } | |
614 while (retval == 0); | |
615 | |
616 return retval; | |
617 } | |
618 | |
1683 | 619 // Fix up things before exiting. |
620 | |
621 void | |
3162 | 622 clean_up_and_exit (int retval) |
623 { | |
3216 | 624 do_octave_atexit (); |
1683 | 625 |
5451 | 626 sysdep_cleanup (); |
627 | |
3162 | 628 exit (retval == EOF ? 0 : retval); |
1683 | 629 } |
630 | |
3180 | 631 DEFUN (quit, args, nargout, |
3332 | 632 "-*- texinfo -*-\n\ |
633 @deftypefn {Built-in Function} {} exit (@var{status})\n\ | |
634 @deftypefnx {Built-in Function} {} quit (@var{status})\n\ | |
635 Exit the current Octave session. If the optional integer value\n\ | |
636 @var{status} is supplied, pass that value to the operating system as the\n\ | |
6615 | 637 Octave's exit status. The default value is zero.\n\ |
3333 | 638 @end deftypefn") |
1683 | 639 { |
2086 | 640 octave_value_list retval; |
2068 | 641 |
3180 | 642 if (nargout == 0) |
2068 | 643 { |
3180 | 644 int exit_status = 0; |
645 | |
646 quitting_gracefully = true; | |
1683 | 647 |
3180 | 648 if (args.length () > 0) |
649 { | |
3202 | 650 int tmp = args(0).nint_value (); |
1683 | 651 |
3202 | 652 if (! error_state) |
653 exit_status = tmp; | |
3180 | 654 } |
655 | |
656 clean_up_and_exit (exit_status); | |
2068 | 657 } |
3180 | 658 else |
659 error ("quit: invalid number of output arguments"); | |
2068 | 660 |
1683 | 661 return retval; |
662 } | |
663 | |
664 DEFALIAS (exit, quit); | |
665 | |
1957 | 666 DEFUN (warranty, , , |
3446 | 667 "-*- texinfo -*-\n\ |
668 @deftypefn {Built-in Function} {} warranty ()\n\ | |
669 Describe the conditions for copying and distributing Octave.\n\ | |
670 @end deftypefn") | |
1683 | 671 { |
2086 | 672 octave_value_list retval; |
1683 | 673 |
3922 | 674 octave_stdout << "\n" \ |
675 OCTAVE_NAME_VERSION_AND_COPYRIGHT "\n\ | |
676 \n\ | |
1683 | 677 This program is free software; you can redistribute it and/or modify\n\ |
678 it under the terms of the GNU General Public License as published by\n\ | |
7016 | 679 the Free Software Foundation; either version 3 of the License, or\n\ |
1683 | 680 (at your option) any later version.\n\ |
681 \n\ | |
682 This program is distributed in the hope that it will be useful,\n\ | |
683 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ | |
684 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ | |
685 GNU General Public License for more details.\n\ | |
686 \n\ | |
687 You should have received a copy of the GNU General Public License\n\ | |
7016 | 688 along with this program. If not, see <http://www.gnu.org/licenses/>.\n\ |
1683 | 689 \n"; |
690 | |
691 return retval; | |
692 } | |
693 | |
694 // Execute a shell command. | |
695 | |
1965 | 696 static void |
697 cleanup_iprocstream (void *p) | |
698 { | |
3060 | 699 iprocstream *cmd = static_cast<iprocstream *> (p); |
700 | |
701 octave_child_list::remove (cmd->pid ()); | |
702 | |
703 delete cmd; | |
1965 | 704 } |
705 | |
6316 | 706 static int |
707 wait_for_input (int fid) | |
708 { | |
709 int retval = -1; | |
710 | |
711 #if defined (HAVE_SELECT) | |
712 if (fid >= 0) | |
713 { | |
714 fd_set set; | |
715 | |
716 FD_ZERO (&set); | |
717 FD_SET (fid, &set); | |
718 | |
719 retval = select (FD_SETSIZE, &set, 0, 0, 0); | |
720 } | |
721 #else | |
722 retval = 1; | |
723 #endif | |
724 | |
725 return retval; | |
726 } | |
727 | |
2086 | 728 static octave_value_list |
3523 | 729 run_command_and_return_output (const std::string& cmd_str) |
2083 | 730 { |
2086 | 731 octave_value_list retval; |
2083 | 732 |
733 iprocstream *cmd = new iprocstream (cmd_str.c_str ()); | |
734 | |
3060 | 735 if (cmd) |
2083 | 736 { |
3060 | 737 unwind_protect::add (cleanup_iprocstream, cmd); |
738 | |
739 if (*cmd) | |
740 { | |
6316 | 741 int fid = cmd->file_number (); |
2095 | 742 |
6316 | 743 std::ostringstream output_buf; |
4494 | 744 |
3060 | 745 char ch; |
3147 | 746 |
4489 | 747 for (;;) |
3147 | 748 { |
4489 | 749 if (cmd->get (ch)) |
750 output_buf.put (ch); | |
751 else | |
752 { | |
753 if (! cmd->eof () && errno == EAGAIN) | |
754 { | |
755 cmd->clear (); | |
3147 | 756 |
6316 | 757 if (wait_for_input (fid) != 1) |
758 break; | |
4489 | 759 } |
760 else | |
761 break; | |
762 } | |
3147 | 763 } |
764 | |
3252 | 765 int cmd_status = cmd->close (); |
2083 | 766 |
3060 | 767 if (WIFEXITED (cmd_status)) |
768 cmd_status = WEXITSTATUS (cmd_status); | |
769 else | |
770 cmd_status = 127; | |
2083 | 771 |
5659 | 772 retval(0) = (double) cmd_status; |
5765 | 773 retval(1) = output_buf.str (); |
3060 | 774 } |
775 | |
776 unwind_protect::run (); | |
2083 | 777 } |
778 else | |
779 error ("unable to start subprocess for `%s'", cmd_str.c_str ()); | |
780 | |
781 return retval; | |
782 } | |
783 | |
5285 | 784 enum system_exec_type { et_sync, et_async }; |
785 | |
1957 | 786 DEFUN (system, args, nargout, |
3301 | 787 "-*- texinfo -*-\n\ |
788 @deftypefn {Built-in Function} {} system (@var{string}, @var{return_output}, @var{type})\n\ | |
789 Execute a shell command specified by @var{string}. The second\n\ | |
790 argument is optional. If @var{type} is @code{\"async\"}, the process\n\ | |
791 is started in the background and the process id of the child process\n\ | |
792 is returned immediately. Otherwise, the process is started, and\n\ | |
793 Octave waits until it exits. If @var{type} argument is omitted, a\n\ | |
794 value of @code{\"sync\"} is assumed.\n\ | |
2083 | 795 \n\ |
3301 | 796 If two input arguments are given (the actual value of\n\ |
797 @var{return_output} is irrelevant) and the subprocess is started\n\ | |
798 synchronously, or if @var{system} is called with one input argument and\n\ | |
799 one or more output arguments, the output from the command is returned.\n\ | |
5097 | 800 Otherwise, if the subprocess is executed synchronously, its output is\n\ |
2321 | 801 sent to the standard output. To send the output of a command executed\n\ |
3301 | 802 with @var{system} through the pager, use a command like\n\ |
2321 | 803 \n\ |
3301 | 804 @example\n\ |
805 disp (system (cmd, 1));\n\ | |
806 @end example\n\ | |
2321 | 807 \n\ |
3301 | 808 @noindent\n\ |
2321 | 809 or\n\ |
810 \n\ | |
3301 | 811 @example\n\ |
812 printf (\"%s\n\", system (cmd, 1));\n\ | |
813 @end example\n\ | |
814 \n\ | |
5659 | 815 The @code{system} function can return two values. The first is the\n\ |
816 exit status of the command and the second is any output from the\n\ | |
817 command that was written to the standard output stream. For example,\n\ | |
3301 | 818 \n\ |
819 @example\n\ | |
5717 | 820 [status, output] = system (\"echo foo; exit 2\");\n\ |
3301 | 821 @end example\n\ |
822 \n\ | |
823 @noindent\n\ | |
824 will set the variable @code{output} to the string @samp{foo}, and the\n\ | |
825 variable @code{status} to the integer @samp{2}.\n\ | |
826 @end deftypefn") | |
1683 | 827 { |
2086 | 828 octave_value_list retval; |
1683 | 829 |
3834 | 830 unwind_protect::begin_frame ("Fsystem"); |
831 | |
1683 | 832 int nargin = args.length (); |
833 | |
2083 | 834 if (nargin > 0 && nargin < 4) |
1683 | 835 { |
5672 | 836 bool return_output = (nargout > 1 || nargin > 1); |
2083 | 837 |
3523 | 838 std::string cmd_str = args(0).string_value (); |
2083 | 839 |
5285 | 840 system_exec_type type = et_sync; |
2083 | 841 |
842 if (! error_state) | |
843 { | |
844 if (nargin > 2) | |
845 { | |
3523 | 846 std::string type_str = args(2).string_value (); |
1683 | 847 |
2083 | 848 if (! error_state) |
849 { | |
850 if (type_str == "sync") | |
5285 | 851 type = et_sync; |
2083 | 852 else if (type_str == "async") |
5285 | 853 type = et_async; |
2083 | 854 else |
855 error ("system: third arg must be \"sync\" or \"async\""); | |
856 } | |
857 else | |
858 error ("system: third argument must be a string"); | |
859 } | |
860 } | |
861 else | |
3523 | 862 error ("system: expecting std::string as first argument"); |
1683 | 863 |
2083 | 864 if (! error_state) |
865 { | |
7104 | 866 #if defined (__WIN32__) && ! defined (__CYGWIN__) |
867 // Work around weird double-quote handling on Windows systems. | |
868 if (type == et_sync) | |
869 cmd_str = "\"" + cmd_str + "\""; | |
870 #endif | |
871 | |
5285 | 872 if (type == et_async) |
2083 | 873 { |
6222 | 874 // FIXME -- maybe this should go in sysdep.cc? |
4086 | 875 #ifdef HAVE_FORK |
2083 | 876 pid_t pid = fork (); |
877 | |
878 if (pid < 0) | |
879 error ("system: fork failed -- can't create child process"); | |
880 else if (pid == 0) | |
881 { | |
5775 | 882 // FIXME -- should probably replace this |
3273 | 883 // call with something portable. |
884 | |
5510 | 885 execl ("/bin/sh", "sh", "-c", cmd_str.c_str (), |
886 static_cast<void *> (0)); | |
3273 | 887 |
888 panic_impossible (); | |
2083 | 889 } |
890 else | |
4254 | 891 retval(0) = pid; |
6222 | 892 #elif defined (__WIN32__) |
893 STARTUPINFO si; | |
894 PROCESS_INFORMATION pi; | |
895 ZeroMemory (&si, sizeof (si)); | |
896 ZeroMemory (&pi, sizeof (pi)); | |
897 OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length()+1); | |
6676 | 898 strcpy (xcmd_str, cmd_str.c_str ()); |
6222 | 899 |
900 if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi)) | |
901 error ("system: CreateProcess failed -- can't create child process"); | |
902 else | |
903 { | |
904 retval(0) = pi.dwProcessId; | |
905 CloseHandle (pi.hProcess); | |
906 CloseHandle (pi.hThread); | |
907 } | |
4086 | 908 #else |
909 error ("asynchronous system calls are not supported"); | |
910 #endif | |
2083 | 911 } |
2321 | 912 else if (return_output) |
913 retval = run_command_and_return_output (cmd_str); | |
2083 | 914 else |
2321 | 915 { |
916 int status = system (cmd_str.c_str ()); | |
917 | |
918 // The value in status is as returned by waitpid. If | |
919 // the process exited normally, extract the actual exit | |
920 // status of the command. Otherwise, return 127 as a | |
921 // failure code. | |
922 | |
2693 | 923 if (WIFEXITED (status)) |
924 status = WEXITSTATUS (status); | |
2321 | 925 |
4233 | 926 retval(0) = status; |
2321 | 927 } |
2083 | 928 } |
1683 | 929 } |
930 else | |
5823 | 931 print_usage (); |
1683 | 932 |
3834 | 933 unwind_protect::run_frame ("Fsystem"); |
934 | |
1683 | 935 return retval; |
936 } | |
937 | |
938 DEFALIAS (shell_cmd, system); | |
939 | |
5775 | 940 // FIXME -- this should really be static, but that causes |
2614 | 941 // problems on some systems. |
6680 | 942 std::list<std::string> octave_atexit_functions; |
2077 | 943 |
944 void | |
945 do_octave_atexit (void) | |
946 { | |
3216 | 947 static bool deja_vu = false; |
948 | |
2077 | 949 while (! octave_atexit_functions.empty ()) |
950 { | |
6680 | 951 std::string fcn = octave_atexit_functions.front (); |
4214 | 952 |
6680 | 953 octave_atexit_functions.pop_front (); |
2077 | 954 |
5237 | 955 reset_error_handler (); |
956 | |
4233 | 957 feval (fcn, octave_value_list (), 0); |
3215 | 958 |
959 flush_octave_stdout (); | |
2077 | 960 } |
3216 | 961 |
962 if (! deja_vu) | |
963 { | |
964 deja_vu = true; | |
965 | |
6068 | 966 // Do this explicitly so that destructors for mex file objects |
967 // are called, so that functions registered with mexAtExit are | |
968 // called. | |
6072 | 969 clear_mex_functions (); |
6068 | 970 |
3216 | 971 command_editor::restore_terminal_state (); |
972 | |
5775 | 973 // FIXME -- is this needed? Can it cause any trouble? |
3216 | 974 raw_mode (0); |
975 | |
5305 | 976 octave_history_write_timestamp (); |
977 | |
3216 | 978 command_history::clean_up_and_save (); |
979 | |
980 close_files (); | |
981 | |
982 cleanup_tmp_files (); | |
983 | |
984 flush_octave_stdout (); | |
985 | |
5305 | 986 if (! quitting_gracefully && (interactive || forced_interactive)) |
5629 | 987 { |
988 octave_stdout << "\n"; | |
989 | |
990 // Yes, we want this to be separate from the call to | |
991 // flush_octave_stdout above. | |
992 | |
993 flush_octave_stdout (); | |
994 } | |
3216 | 995 } |
2077 | 996 } |
997 | |
7409 | 998 void |
999 octave_add_atexit_function (const std::string& fname) | |
1000 { | |
1001 octave_atexit_functions.push_front (fname); | |
1002 } | |
1003 | |
1004 bool | |
1005 octave_remove_atexit_function (const std::string& fname) | |
1006 { | |
1007 bool found = false; | |
1008 | |
1009 for (std::list<std::string>::iterator p = octave_atexit_functions.begin (); | |
1010 p != octave_atexit_functions.end (); p++) | |
1011 { | |
1012 if (*p == fname) | |
1013 { | |
1014 octave_atexit_functions.erase (p); | |
1015 found = true; | |
1016 break; | |
1017 } | |
1018 } | |
1019 | |
1020 return found; | |
1021 } | |
1022 | |
1023 | |
6680 | 1024 DEFUN (atexit, args, nargout, |
3332 | 1025 "-*- texinfo -*-\n\ |
1026 @deftypefn {Built-in Function} {} atexit (@var{fcn})\n\ | |
1027 Register a function to be called when Octave exits. For example,\n\ | |
2077 | 1028 \n\ |
3332 | 1029 @example\n\ |
1030 @group\n\ | |
6620 | 1031 function bye_bye ()\n\ |
1032 disp (\"Bye bye\");\n\ | |
3332 | 1033 endfunction\n\ |
6620 | 1034 atexit (\"bye_bye\");\n\ |
3332 | 1035 @end group\n\ |
1036 @end example\n\ | |
1037 \n\ | |
1038 @noindent\n\ | |
6620 | 1039 will print the message \"Bye bye\" when Octave exits.\n\ |
6680 | 1040 \n\ |
1041 @deftypefnx {Built-in Function} {} atexit (@var{fcn}, @var{flag})\n\ | |
1042 Register or unregister a function to be called when Octave exits,\n\ | |
1043 depending on @var{flag}. If @var{flag} is true, the function is\n\ | |
1044 registered, if @var{flag} is false, it is unregistered. For example,\n\ | |
1045 after registering the function @code{bye_bye} as above,\n\ | |
1046 \n\ | |
1047 @example\n\ | |
1048 atexit (\"bye_bye\", false);\n\ | |
1049 @end example\n\ | |
1050 \n\ | |
1051 @noindent\n\ | |
1052 will remove the function from the list and Octave will not call\n\ | |
1053 the function @code{bye_by} when it exits.\n\ | |
1054 \n\ | |
7001 | 1055 Note that @code{atexit} only removes the first occurrence of a function\n\ |
6680 | 1056 from the list, so if a function was placed in the list multiple\n\ |
1057 times with @code{atexit}, it must also be removed from the list\n\ | |
1058 multiple times.\n\ | |
3333 | 1059 @end deftypefn") |
2077 | 1060 { |
2086 | 1061 octave_value_list retval; |
2077 | 1062 |
1063 int nargin = args.length (); | |
1064 | |
6680 | 1065 if (nargin == 1 || nargin == 2) |
2077 | 1066 { |
3523 | 1067 std::string arg = args(0).string_value (); |
2077 | 1068 |
1069 if (! error_state) | |
6680 | 1070 { |
1071 bool add_mode = true; | |
1072 | |
1073 if (nargin == 2) | |
1074 { | |
1075 add_mode = args(1).bool_value (); | |
1076 | |
1077 if (error_state) | |
1078 error ("atexit: second argument must be a logical value"); | |
1079 } | |
1080 | |
1081 if (! error_state) | |
1082 { | |
1083 if (add_mode) | |
7409 | 1084 octave_add_atexit_function (arg); |
6680 | 1085 else |
1086 { | |
7409 | 1087 bool found = octave_remove_atexit_function (arg); |
6680 | 1088 |
1089 if (nargout > 0) | |
1090 retval(0) = found; | |
1091 } | |
1092 } | |
1093 } | |
2077 | 1094 else |
6680 | 1095 error ("atexit: argument must be a string"); |
2077 | 1096 } |
1097 else | |
5823 | 1098 print_usage (); |
2077 | 1099 |
1100 return retval; | |
1101 } | |
1102 | |
2689 | 1103 DEFUN (octave_config_info, args, , |
3301 | 1104 "-*- texinfo -*-\n\ |
1105 @deftypefn {Built-in Function} {} octave_config_info (@var{option})\n\ | |
1106 Return a structure containing configuration and installation\n\ | |
1107 information for Octave.\n\ | |
2689 | 1108 \n\ |
3301 | 1109 if @var{option} is a string, return the configuration information for the\n\ |
2689 | 1110 specified option.\n\ |
1111 \n\ | |
3301 | 1112 @end deftypefn") |
2162 | 1113 { |
2689 | 1114 octave_value retval; |
1115 | |
4128 | 1116 #if defined (ENABLE_DYNAMIC_LINKING) |
2689 | 1117 bool octave_supports_dynamic_linking = true; |
1118 #else | |
1119 bool octave_supports_dynamic_linking = false; | |
1120 #endif | |
1121 | |
4357 | 1122 static bool initialized = false; |
1123 static Octave_map m; | |
2162 | 1124 |
6274 | 1125 struct conf_info_struct |
1126 { | |
1127 bool subst_home; | |
1128 const char *key; | |
1129 const char *val; | |
1130 }; | |
1131 | |
1132 static const conf_info_struct conf_info[] = | |
4357 | 1133 { |
6274 | 1134 { false, "ALL_CFLAGS", OCTAVE_CONF_ALL_CFLAGS }, |
1135 { false, "ALL_CXXFLAGS", OCTAVE_CONF_ALL_CXXFLAGS }, | |
1136 { false, "ALL_FFLAGS", OCTAVE_CONF_ALL_FFLAGS }, | |
1137 { false, "ALL_LDFLAGS", OCTAVE_CONF_ALL_LDFLAGS }, | |
1138 { false, "AR", OCTAVE_CONF_AR }, | |
1139 { false, "ARFLAGS", OCTAVE_CONF_ARFLAGS }, | |
1140 { false, "BLAS_LIBS", OCTAVE_CONF_BLAS_LIBS }, | |
1141 { false, "CC", OCTAVE_CONF_CC }, | |
1142 { false, "CC_VERSION", OCTAVE_CONF_CC_VERSION }, | |
1143 { false, "CFLAGS", OCTAVE_CONF_CFLAGS }, | |
1144 { false, "CPICFLAG", OCTAVE_CONF_CPICFLAG }, | |
1145 { false, "CPPFLAGS", OCTAVE_CONF_CPPFLAGS }, | |
1146 { false, "CURL_LIBS", OCTAVE_CONF_CURL_LIBS }, | |
1147 { false, "CXX", OCTAVE_CONF_CXX }, | |
1148 { false, "CXXCPP", OCTAVE_CONF_CXXCPP }, | |
1149 { false, "CXXFLAGS", OCTAVE_CONF_CXXFLAGS }, | |
1150 { false, "CXXPICFLAG", OCTAVE_CONF_CXXPICFLAG }, | |
1151 { false, "CXX_VERSION", OCTAVE_CONF_CXX_VERSION }, | |
1152 { false, "DEFAULT_PAGER", OCTAVE_DEFAULT_PAGER }, | |
1153 { false, "DEFS", OCTAVE_CONF_DEFS }, | |
1154 { false, "DL_LD", OCTAVE_CONF_DL_LD }, | |
1155 { false, "DL_LDFLAGS", OCTAVE_CONF_DL_LDFLAGS }, | |
1156 { false, "ENABLE_DYNAMIC_LINKING", OCTAVE_CONF_ENABLE_DYNAMIC_LINKING }, | |
1157 { false, "EXEEXT", OCTAVE_CONF_EXEEXT }, | |
1158 { false, "F2C", OCTAVE_CONF_F2C }, | |
1159 { false, "F2CFLAGS", OCTAVE_CONF_F2CFLAGS }, | |
1160 { false, "F77", OCTAVE_CONF_F77 }, | |
1161 { false, "F77_FLOAT_STORE_FLAG", OCTAVE_CONF_F77_FLOAT_STORE_FLAG }, | |
1162 { false, "FC", OCTAVE_CONF_FC }, | |
1163 { false, "FFLAGS", OCTAVE_CONF_FFLAGS }, | |
1164 { false, "FFTW_LIBS", OCTAVE_CONF_FFTW_LIBS }, | |
1165 { false, "FLIBS", OCTAVE_CONF_FLIBS }, | |
1166 { false, "FPICFLAG", OCTAVE_CONF_FPICFLAG }, | |
1167 { false, "GLPK_LIBS", OCTAVE_CONF_GLPK_LIBS }, | |
7361 | 1168 { false, "GNUPLOT", OCTAVE_CONF_GNUPLOT }, |
6274 | 1169 { false, "INCFLAGS", OCTAVE_CONF_INCFLAGS }, |
1170 { false, "LDFLAGS", OCTAVE_CONF_LDFLAGS }, | |
1171 { false, "LD_CXX", OCTAVE_CONF_LD_CXX }, | |
1172 { false, "LD_STATIC_FLAG", OCTAVE_CONF_LD_STATIC_FLAG }, | |
1173 { false, "LEX", OCTAVE_CONF_LEX }, | |
1174 { false, "LEXLIB", OCTAVE_CONF_LEXLIB }, | |
1175 { false, "LFLAGS", OCTAVE_CONF_LFLAGS }, | |
1176 { false, "LIBCRUFT", OCTAVE_CONF_LIBCRUFT }, | |
1177 { false, "LIBEXT", OCTAVE_CONF_LIBEXT }, | |
1178 { false, "LIBFLAGS", OCTAVE_CONF_LIBFLAGS }, | |
1179 { false, "LIBOCTAVE", OCTAVE_CONF_LIBOCTAVE }, | |
1180 { false, "LIBOCTINTERP", OCTAVE_CONF_LIBOCTINTERP }, | |
1181 { false, "LIBREADLINE", OCTAVE_CONF_LIBREADLINE }, | |
1182 { false, "LIBS", OCTAVE_CONF_LIBS }, | |
1183 { false, "LN_S", OCTAVE_CONF_LN_S }, | |
7926
d74f996e005d
__magick_read__.cc: configuration and style fixes
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
1184 { false, "MAGICK_INCFLAGS", OCTAVE_CONF_MAGICK_INCFLAGS }, |
d74f996e005d
__magick_read__.cc: configuration and style fixes
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
1185 { false, "MAGICK_LIBS", OCTAVE_CONF_MAGICK_LIBS }, |
6274 | 1186 { false, "MKOCTFILE_DL_LDFLAGS", OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS }, |
1187 { false, "RANLIB", OCTAVE_CONF_RANLIB }, | |
1188 { false, "RDYNAMIC_FLAG", OCTAVE_CONF_RDYNAMIC_FLAG }, | |
1189 { false, "RLD_FLAG", OCTAVE_CONF_RLD_FLAG }, | |
1190 { false, "SED", OCTAVE_CONF_SED }, | |
1191 { false, "SHARED_LIBS", OCTAVE_CONF_SHARED_LIBS }, | |
1192 { false, "SHLEXT", OCTAVE_CONF_SHLEXT }, | |
1193 { false, "SHLEXT_VER", OCTAVE_CONF_SHLEXT_VER }, | |
1194 { false, "SH_LD", OCTAVE_CONF_SH_LD }, | |
1195 { false, "SH_LDFLAGS", OCTAVE_CONF_SH_LDFLAGS }, | |
1196 { false, "SONAME_FLAGS", OCTAVE_CONF_SONAME_FLAGS }, | |
1197 { false, "STATIC_LIBS", OCTAVE_CONF_STATIC_LIBS }, | |
1198 { false, "UGLY_DEFS", OCTAVE_CONF_UGLY_DEFS }, | |
1199 { false, "USE_64_BIT_IDX_T", OCTAVE_CONF_USE_64_BIT_IDX_T }, | |
1200 { false, "XTRA_CFLAGS", OCTAVE_CONF_XTRA_CFLAGS }, | |
1201 { false, "XTRA_CXXFLAGS", OCTAVE_CONF_XTRA_CXXFLAGS }, | |
1202 { false, "YACC", OCTAVE_CONF_YACC }, | |
1203 { false, "YFLAGS", OCTAVE_CONF_YFLAGS }, | |
1204 { false, "api_version", OCTAVE_API_VERSION }, | |
1205 { true, "archlibdir", OCTAVE_ARCHLIBDIR }, | |
1206 { true, "bindir", OCTAVE_BINDIR }, | |
1207 { false, "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE }, | |
1208 { false, "config_opts", OCTAVE_CONF_config_opts }, | |
1209 { true, "datadir", OCTAVE_DATADIR }, | |
1210 { true, "datarootdir", OCTAVE_DATAROOTDIR }, | |
6276 | 1211 { true, "exec_prefix", OCTAVE_EXEC_PREFIX }, |
6274 | 1212 { true, "fcnfiledir", OCTAVE_FCNFILEDIR }, |
1213 { true, "imagedir", OCTAVE_IMAGEDIR }, | |
1214 { true, "includedir", OCTAVE_INCLUDEDIR }, | |
1215 { true, "infodir", OCTAVE_INFODIR }, | |
6276 | 1216 { true, "infofile", OCTAVE_INFOFILE }, |
6274 | 1217 { true, "libdir", OCTAVE_LIBDIR }, |
1218 { true, "libexecdir", OCTAVE_LIBEXECDIR }, | |
6311 | 1219 { true, "localapiarchlibdir", OCTAVE_LOCALAPIARCHLIBDIR }, |
6274 | 1220 { true, "localapifcnfiledir", OCTAVE_LOCALAPIFCNFILEDIR }, |
1221 { true, "localapioctfiledir", OCTAVE_LOCALAPIOCTFILEDIR }, | |
1222 { true, "localarchlibdir", OCTAVE_LOCALARCHLIBDIR }, | |
1223 { true, "localfcnfiledir", OCTAVE_LOCALFCNFILEDIR }, | |
1224 { true, "localoctfiledir", OCTAVE_LOCALOCTFILEDIR }, | |
1225 { true, "localstartupfiledir", OCTAVE_LOCALSTARTUPFILEDIR }, | |
1226 { true, "localverarchlibdir", OCTAVE_LOCALVERARCHLIBDIR }, | |
1227 { true, "localverfcnfiledir", OCTAVE_LOCALVERFCNFILEDIR }, | |
1228 { true, "localveroctfiledir", OCTAVE_LOCALVEROCTFILEDIR }, | |
1229 { true, "man1dir", OCTAVE_MAN1DIR }, | |
1230 { false, "man1ext", OCTAVE_MAN1EXT }, | |
1231 { true, "mandir", OCTAVE_MANDIR }, | |
1232 { true, "octfiledir", OCTAVE_OCTFILEDIR }, | |
1233 { true, "octincludedir", OCTAVE_OCTINCLUDEDIR }, | |
1234 { true, "octlibdir", OCTAVE_OCTLIBDIR }, | |
6276 | 1235 { true, "prefix", OCTAVE_PREFIX }, |
6274 | 1236 { true, "startupfiledir", OCTAVE_STARTUPFILEDIR }, |
1237 { false, "version", OCTAVE_VERSION }, | |
1238 { false, 0, 0 } | |
4357 | 1239 }; |
1240 | |
1241 if (! initialized) | |
1242 { | |
4675 | 1243 m.assign ("dld", octave_value (octave_supports_dynamic_linking)); |
4357 | 1244 |
4697 | 1245 oct_mach_info::float_format ff = oct_mach_info::native_float_format (); |
1246 m.assign ("float_format", | |
1247 octave_value (oct_mach_info::float_format_as_string (ff))); | |
1248 | |
1249 m.assign ("words_big_endian", | |
1250 octave_value (oct_mach_info::words_big_endian ())); | |
1251 | |
1252 m.assign ("words_little_endian", | |
1253 octave_value (oct_mach_info::words_little_endian ())); | |
1254 | |
4357 | 1255 int i = 0; |
4440 | 1256 |
1257 while (true) | |
4357 | 1258 { |
6274 | 1259 const conf_info_struct& elt = conf_info[i++]; |
1260 | |
1261 const char *key = elt.key; | |
4357 | 1262 |
1263 if (key) | |
6274 | 1264 { |
1265 if (elt.subst_home) | |
1266 m.assign (key, octave_value (subst_octave_home (elt.val))); | |
1267 else | |
1268 m.assign (key, octave_value (elt.val)); | |
1269 } | |
4357 | 1270 else |
1271 break; | |
1272 } | |
1273 | |
4691 | 1274 bool unix_system = true; |
7013 | 1275 bool mac_system = false; |
4691 | 1276 bool windows_system = false; |
1277 | |
1278 #if defined (WIN32) | |
1279 windows_system = true; | |
1280 #if !defined (__CYGWIN__) | |
1281 unix_system = false; | |
1282 #endif | |
1283 #endif | |
1284 | |
7010 | 1285 #if defined (__APPLE__) && defined (__MACH__) |
1286 mac_system = true; | |
1287 #endif | |
1288 | |
4691 | 1289 m.assign ("unix", octave_value (unix_system)); |
7010 | 1290 m.assign ("mac", octave_value (mac_system)); |
4691 | 1291 m.assign ("windows", octave_value (windows_system)); |
1292 | |
4357 | 1293 initialized = true; |
1294 } | |
2162 | 1295 |
2689 | 1296 int nargin = args.length (); |
1297 | |
1298 if (nargin == 1) | |
1299 { | |
3523 | 1300 std::string arg = args(0).string_value (); |
2689 | 1301 |
1302 if (! error_state) | |
4675 | 1303 { |
1304 Cell c = m.contents (arg.c_str ()); | |
5199 | 1305 |
1306 if (c.is_empty ()) | |
1307 error ("octave_config_info: no info for `%s'", arg.c_str ()); | |
1308 else | |
1309 retval = c(0); | |
4675 | 1310 } |
2689 | 1311 } |
1312 else if (nargin == 0) | |
4233 | 1313 retval = m; |
2689 | 1314 else |
5823 | 1315 print_usage (); |
2689 | 1316 |
1317 return retval; | |
2162 | 1318 } |
1319 | |
1683 | 1320 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE) |
2806 | 1321 |
1683 | 1322 int debug_new_delete = 0; |
1323 | |
1324 typedef void (*vfp)(void); | |
1325 extern vfp __new_handler; | |
1326 | |
1327 void * | |
1328 __builtin_new (size_t sz) | |
1329 { | |
1330 void *p; | |
1331 | |
1332 /* malloc (0) is unpredictable; avoid it. */ | |
1333 if (sz == 0) | |
1334 sz = 1; | |
2800 | 1335 p = malloc (sz); |
1683 | 1336 while (p == 0) |
1337 { | |
1338 (*__new_handler) (); | |
2800 | 1339 p = malloc (sz); |
1683 | 1340 } |
1341 | |
1342 if (debug_new_delete) | |
5629 | 1343 std::cerr << "__builtin_new: " << p << std::endl; |
1683 | 1344 |
1345 return p; | |
1346 } | |
1347 | |
1348 void | |
1349 __builtin_delete (void *ptr) | |
1350 { | |
1351 if (debug_new_delete) | |
5629 | 1352 std::cerr << "__builtin_delete: " << ptr << std::endl; |
1683 | 1353 |
1354 if (ptr) | |
1355 free (ptr); | |
1356 } | |
2806 | 1357 |
1683 | 1358 #endif |
1359 | |
1360 /* | |
1361 ;;; Local Variables: *** | |
1362 ;;; mode: C++ *** | |
1363 ;;; End: *** | |
1364 */ |