1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
1343
|
28 #include <cstdarg> |
1633
|
29 #include <cstring> |
1343
|
30 |
5765
|
31 #include <sstream> |
1728
|
32 #include <string> |
|
33 |
1352
|
34 #include "defun.h" |
1
|
35 #include "error.h" |
3707
|
36 #include "input.h" |
1742
|
37 #include "pager.h" |
1352
|
38 #include "oct-obj.h" |
5567
|
39 #include "oct-map.h" |
1352
|
40 #include "utils.h" |
2370
|
41 #include "ov.h" |
3707
|
42 #include "ov-usr-fcn.h" |
|
43 #include "pt-pr-code.h" |
|
44 #include "pt-stmt.h" |
|
45 #include "toplev.h" |
|
46 #include "unwind-prot.h" |
2370
|
47 #include "variables.h" |
1
|
48 |
2174
|
49 // TRUE means that Octave will try to beep obnoxiously before printing |
|
50 // error messages. |
5794
|
51 static bool Vbeep_on_error = false; |
2174
|
52 |
3707
|
53 // TRUE means that Octave will try to enter the debugger when an error |
|
54 // is encountered. This will also inhibit printing of the normal |
|
55 // traceback message (you will only see the top-level error message). |
5794
|
56 static bool Vdebug_on_error = false; |
3707
|
57 |
|
58 // TRUE means that Octave will try to enter the debugger when a warning |
|
59 // is encountered. |
5794
|
60 static bool Vdebug_on_warning = false; |
3707
|
61 |
5567
|
62 // TRUE means that Octave will try to display a stack trace when a |
|
63 // warning is encountered. |
|
64 static bool Vbacktrace_on_warning = false; |
|
65 |
|
66 // TRUE means that Octave will print a verbose warning. Currently unused. |
|
67 static bool Vverbose_warning; |
|
68 |
5582
|
69 // TRUE means that Octave will print no warnings, but lastwarn will be |
|
70 //updated |
|
71 static bool Vquiet_warning = false; |
|
72 |
5567
|
73 // A structure containing (most of) the current state of warnings. |
|
74 static Octave_map warning_options; |
|
75 |
3935
|
76 // The text of the last error message. |
|
77 static std::string Vlast_error_message; |
|
78 |
3934
|
79 // The text of the last warning message. |
|
80 static std::string Vlast_warning_message; |
|
81 |
5567
|
82 // The last warning message id. |
|
83 static std::string Vlast_warning_id; |
3934
|
84 |
5567
|
85 // The last error message id. |
|
86 static std::string Vlast_error_id; |
3934
|
87 |
143
|
88 // Current error state. |
3935
|
89 // |
|
90 // Valid values: |
|
91 // |
|
92 // -2: an error has occurred, but don't print any messages. |
|
93 // -1: an error has occurred, we are printing a traceback |
|
94 // 0: no error |
|
95 // 1: an error has occurred |
|
96 // |
672
|
97 int error_state = 0; |
|
98 |
3489
|
99 // Current warning state. |
3935
|
100 // |
|
101 // Valid values: |
|
102 // |
|
103 // 0: no warning |
|
104 // 1: a warning has occurred |
|
105 // |
3489
|
106 int warning_state = 0; |
|
107 |
1489
|
108 // Tell the error handler whether to print messages, or just store |
|
109 // them for later. Used for handling errors in eval() and |
|
110 // the `unwind_protect' statement. |
4699
|
111 int buffer_error_messages = 0; |
1489
|
112 |
3815
|
113 // TRUE means error messages are turned off. |
|
114 bool discard_error_messages = false; |
|
115 |
4452
|
116 // TRUE means warning messages are turned off. |
|
117 bool discard_warning_messages = false; |
|
118 |
3811
|
119 // The message buffer. |
5765
|
120 static std::ostringstream *error_message_buffer = 0; |
143
|
121 |
4318
|
122 void |
|
123 reset_error_handler (void) |
|
124 { |
|
125 error_state = 0; |
|
126 warning_state = 0; |
4699
|
127 buffer_error_messages = 0; |
4318
|
128 discard_error_messages = false; |
|
129 } |
|
130 |
5567
|
131 static void |
5794
|
132 initialize_warning_options (const std::string& state) |
5567
|
133 { |
|
134 warning_options.clear (); |
|
135 |
|
136 warning_options.assign ("identifier", "all"); |
|
137 warning_options.assign ("state", state); |
|
138 } |
|
139 |
3491
|
140 // Warning messages are never buffered. |
|
141 |
|
142 static void |
5567
|
143 vwarning (const char *name, const char *id, const char *fmt, va_list args) |
3491
|
144 { |
4452
|
145 if (discard_warning_messages) |
|
146 return; |
|
147 |
3491
|
148 flush_octave_stdout (); |
|
149 |
5765
|
150 std::ostringstream output_buf; |
3491
|
151 |
|
152 if (name) |
3761
|
153 output_buf << name << ": "; |
|
154 |
|
155 octave_vformat (output_buf, fmt, args); |
|
156 |
5765
|
157 output_buf << std::endl; |
3491
|
158 |
5775
|
159 // FIXME -- we really want to capture the message before it |
3935
|
160 // has all the formatting goop attached to it. We probably also |
|
161 // want just the message, not the traceback information. |
|
162 |
5765
|
163 std::string msg_string = output_buf.str (); |
3934
|
164 |
3935
|
165 if (! warning_state) |
|
166 { |
|
167 // This is the first warning in a possible series. |
5567
|
168 |
|
169 Vlast_warning_id = id; |
3935
|
170 Vlast_warning_message = msg_string; |
|
171 } |
3934
|
172 |
5582
|
173 if (! Vquiet_warning) |
|
174 { |
|
175 octave_diary << msg_string; |
3935
|
176 |
5582
|
177 std::cerr << msg_string; |
|
178 } |
3491
|
179 } |
|
180 |
1
|
181 static void |
4732
|
182 verror (bool save_last_error, std::ostream& os, |
5567
|
183 const char *name, const char *id, const char *fmt, va_list args) |
1
|
184 { |
3815
|
185 if (discard_error_messages) |
|
186 return; |
|
187 |
3585
|
188 if (! buffer_error_messages) |
|
189 flush_octave_stdout (); |
914
|
190 |
2174
|
191 bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state; |
1423
|
192 |
5765
|
193 std::ostringstream output_buf; |
1
|
194 |
2174
|
195 if (to_beep_or_not_to_beep_p) |
1423
|
196 output_buf << "\a"; |
3620
|
197 |
599
|
198 if (name) |
|
199 output_buf << name << ": "; |
3620
|
200 |
|
201 octave_vformat (output_buf, fmt, args); |
|
202 |
5765
|
203 output_buf << std::endl; |
581
|
204 |
5775
|
205 // FIXME -- we really want to capture the message before it |
3935
|
206 // has all the formatting goop attached to it. We probably also |
|
207 // want just the message, not the traceback information. |
|
208 |
5765
|
209 std::string msg_string = output_buf.str (); |
3935
|
210 |
4731
|
211 if (! error_state && save_last_error) |
3935
|
212 { |
|
213 // This is the first error in a possible series. |
5567
|
214 |
|
215 Vlast_error_id = id; |
3935
|
216 Vlast_error_message = msg_string; |
|
217 } |
|
218 |
1489
|
219 if (buffer_error_messages) |
|
220 { |
3941
|
221 std::string tmp = msg_string; |
1489
|
222 |
|
223 if (! error_message_buffer) |
|
224 { |
5765
|
225 error_message_buffer = new std::ostringstream (); |
1489
|
226 |
5775
|
227 // FIXME -- this is ugly, but it prevents |
1489
|
228 // |
4699
|
229 // eval ("error (\"msg\")", "error (lasterr ())"); |
1489
|
230 // |
|
231 // from printing `error: ' twice. Assumes that the NAME we |
|
232 // have been given doesn't contain `:'. |
|
233 |
3935
|
234 size_t pos = msg_string.find (':'); |
3162
|
235 |
3935
|
236 if (pos != NPOS && pos < Vlast_error_message.length () - 2) |
|
237 tmp = msg_string.substr (pos+2); |
1489
|
238 } |
|
239 |
3935
|
240 *error_message_buffer << tmp; |
1489
|
241 } |
|
242 else |
|
243 { |
3935
|
244 octave_diary << msg_string; |
4732
|
245 os << msg_string; |
1489
|
246 } |
1
|
247 } |
|
248 |
1266
|
249 // Note that we don't actually print any message if the error string |
|
250 // is just "" or "\n". This allows error ("") and error ("\n") to |
|
251 // just set the error state. |
|
252 |
1005
|
253 static void |
5567
|
254 error_1 (std::ostream& os, const char *name, const char *id, |
|
255 const char *fmt, va_list args) |
1005
|
256 { |
|
257 if (error_state != -2) |
|
258 { |
1489
|
259 if (fmt) |
1005
|
260 { |
1489
|
261 if (*fmt) |
1005
|
262 { |
1489
|
263 int len = strlen (fmt); |
|
264 if (fmt[len - 1] == '\n') |
1266
|
265 { |
1489
|
266 if (len > 1) |
1266
|
267 { |
1489
|
268 char *tmp_fmt = strsave (fmt); |
|
269 tmp_fmt[len - 1] = '\0'; |
5567
|
270 verror (true, os, name, id, tmp_fmt, args); |
1489
|
271 delete [] tmp_fmt; |
|
272 } |
1423
|
273 |
1489
|
274 error_state = -2; |
1266
|
275 } |
1489
|
276 else |
5567
|
277 verror (true, os, name, id, fmt, args); |
1005
|
278 } |
|
279 } |
1489
|
280 else |
|
281 panic ("error_1: invalid format"); |
1423
|
282 |
|
283 if (! error_state) |
|
284 error_state = 1; |
1005
|
285 } |
|
286 } |
|
287 |
1
|
288 void |
6338
|
289 vmessage (const char *name, const char *fmt, va_list args) |
|
290 { |
|
291 verror (false, std::cerr, name, "", fmt, args); |
|
292 } |
|
293 |
|
294 void |
1
|
295 message (const char *name, const char *fmt, ...) |
|
296 { |
|
297 va_list args; |
|
298 va_start (args, fmt); |
6338
|
299 vmessage (name, fmt, args); |
1
|
300 va_end (args); |
|
301 } |
|
302 |
|
303 void |
6338
|
304 vmessage_with_id (const char *name, const char *id, const char *fmt, |
|
305 va_list args) |
|
306 { |
|
307 verror (false, std::cerr, name, id, fmt, args); |
|
308 } |
|
309 |
|
310 void |
5567
|
311 message_with_id (const char *name, const char *id, const char *fmt, ...) |
|
312 { |
|
313 va_list args; |
|
314 va_start (args, fmt); |
6338
|
315 vmessage_with_id (name, id, fmt, args); |
5567
|
316 va_end (args); |
|
317 } |
|
318 |
|
319 void |
|
320 usage_1 (const char *id, const char *fmt, va_list args) |
|
321 { |
|
322 verror (true, std::cerr, "usage", id, fmt, args); |
|
323 error_state = -1; |
|
324 } |
|
325 |
|
326 void |
6338
|
327 vusage (const char *fmt, va_list args) |
|
328 { |
|
329 usage_1 ("", fmt, args); |
|
330 } |
|
331 |
|
332 void |
1
|
333 usage (const char *fmt, ...) |
|
334 { |
|
335 va_list args; |
|
336 va_start (args, fmt); |
6338
|
337 vusage (fmt, args); |
5567
|
338 va_end (args); |
|
339 } |
|
340 |
|
341 void |
6338
|
342 vusage_with_id (const char *id, const char *fmt, va_list args) |
|
343 { |
|
344 usage_1 (id, fmt, args); |
|
345 } |
|
346 |
|
347 void |
5567
|
348 usage_with_id (const char *id, const char *fmt, ...) |
|
349 { |
|
350 va_list args; |
|
351 va_start (args, fmt); |
6338
|
352 vusage_with_id (id, fmt, args); |
1
|
353 va_end (args); |
|
354 } |
|
355 |
3707
|
356 static void |
3719
|
357 pr_where_2 (const char *fmt, va_list args) |
|
358 { |
|
359 if (fmt) |
|
360 { |
|
361 if (*fmt) |
|
362 { |
|
363 int len = strlen (fmt); |
|
364 if (fmt[len - 1] == '\n') |
|
365 { |
|
366 if (len > 1) |
|
367 { |
|
368 char *tmp_fmt = strsave (fmt); |
|
369 tmp_fmt[len - 1] = '\0'; |
5567
|
370 verror (false, std::cerr, 0, "", tmp_fmt, args); |
3719
|
371 delete [] tmp_fmt; |
|
372 } |
|
373 } |
|
374 else |
5567
|
375 verror (false, std::cerr, 0, "", fmt, args); |
3719
|
376 } |
|
377 } |
|
378 else |
|
379 panic ("pr_where_2: invalid format"); |
|
380 } |
|
381 |
|
382 static void |
3707
|
383 pr_where_1 (const char *fmt, ...) |
|
384 { |
|
385 va_list args; |
|
386 va_start (args, fmt); |
3719
|
387 pr_where_2 (fmt, args); |
3707
|
388 va_end (args); |
|
389 } |
|
390 |
|
391 static void |
4719
|
392 pr_where (const char *name, bool print_code = true) |
3707
|
393 { |
|
394 if (curr_statement) |
|
395 { |
4976
|
396 std::string nm; |
3707
|
397 |
4976
|
398 int l = -1; |
|
399 int c = -1; |
|
400 |
5744
|
401 octave_function *fcn |
|
402 = octave_call_stack::caller_user_script_or_function (); |
4976
|
403 |
|
404 if (fcn) |
3708
|
405 { |
5743
|
406 nm = fcn->fcn_file_name (); |
4976
|
407 |
5743
|
408 if (nm.empty ()) |
|
409 nm = fcn->name (); |
3708
|
410 |
5743
|
411 if (curr_statement) |
|
412 { |
|
413 l = curr_statement->line (); |
|
414 c = curr_statement->column (); |
4976
|
415 } |
3708
|
416 } |
3707
|
417 |
4976
|
418 if (nm.empty ()) |
|
419 { |
|
420 if (l > 0 && c > 0) |
|
421 pr_where_1 ("%s: near line %d, column %d:", name, l, c); |
|
422 } |
3708
|
423 else |
4976
|
424 { |
|
425 if (l > 0 && c > 0) |
|
426 pr_where_1 ("%s: in %s near line %d, column %d:", |
|
427 name, nm.c_str (), l, c); |
|
428 else |
|
429 pr_where_1 ("%s: in %s", name, nm.c_str ()); |
|
430 } |
3707
|
431 |
4719
|
432 if (print_code) |
|
433 { |
5775
|
434 // FIXME -- Note that the column number is probably |
4719
|
435 // not going to mean much here since the code is being |
|
436 // reproduced from the parse tree, and we are only showing |
|
437 // one statement even if there were multiple statements on |
|
438 // the original source line. |
3707
|
439 |
5765
|
440 std::ostringstream output_buf; |
3708
|
441 |
4719
|
442 output_buf << std::endl; |
3707
|
443 |
4719
|
444 tree_print_code tpc (output_buf, ">>> "); |
|
445 |
|
446 curr_statement->accept (tpc); |
3707
|
447 |
5765
|
448 output_buf << std::endl; |
3707
|
449 |
5765
|
450 std::string msg = output_buf.str (); |
3707
|
451 |
5765
|
452 pr_where_1 ("%s", msg.c_str ()); |
4719
|
453 } |
3707
|
454 } |
|
455 } |
|
456 |
6000
|
457 static void |
|
458 error_2 (const char *id, const char *fmt, va_list args) |
|
459 { |
|
460 int init_state = error_state; |
|
461 |
|
462 error_1 (std::cerr, "error", id, fmt, args); |
|
463 |
|
464 if ((interactive || forced_interactive) |
|
465 && Vdebug_on_error && init_state == 0 |
|
466 && octave_call_stack::caller_user_script_or_function ()) |
|
467 { |
|
468 unwind_protect_bool (Vdebug_on_error); |
|
469 Vdebug_on_error = false; |
|
470 |
|
471 pr_where ("error"); |
|
472 |
|
473 error_state = 0; |
|
474 |
|
475 do_keyboard (octave_value_list ()); |
|
476 |
|
477 unwind_protect::run (); |
|
478 } |
|
479 } |
|
480 |
|
481 void |
6338
|
482 verror (const char *fmt, va_list args) |
|
483 { |
|
484 error_2 ("", fmt, args); |
|
485 } |
|
486 |
|
487 void |
6000
|
488 error (const char *fmt, ...) |
|
489 { |
|
490 va_list args; |
|
491 va_start (args, fmt); |
6338
|
492 verror (fmt, args); |
6000
|
493 va_end (args); |
|
494 } |
|
495 |
|
496 void |
6338
|
497 verror_with_id (const char *id, const char *fmt, va_list args) |
|
498 { |
|
499 error_2 (id, fmt, args); |
|
500 } |
|
501 |
|
502 void |
6000
|
503 error_with_id (const char *id, const char *fmt, ...) |
|
504 { |
|
505 va_list args; |
|
506 va_start (args, fmt); |
6338
|
507 verror_with_id (id, fmt, args); |
6000
|
508 va_end (args); |
|
509 } |
|
510 |
5567
|
511 static int |
|
512 check_state (const std::string& state) |
|
513 { |
|
514 // -1: not found |
|
515 // 0: found, "off" |
|
516 // 1: found, "on" |
|
517 // 2: found, "error" |
|
518 |
|
519 if (state == "off") |
|
520 return 0; |
|
521 else if (state == "on") |
|
522 return 1; |
|
523 else if (state == "error") |
|
524 return 2; |
|
525 else |
|
526 return -1; |
|
527 } |
|
528 |
|
529 // For given warning ID, return 0 if warnings are disabled, 1 if |
|
530 // enabled, and 2 if this ID should be an error instead of a warning. |
|
531 |
5781
|
532 int |
5567
|
533 warning_enabled (const std::string& id) |
1
|
534 { |
5567
|
535 int retval = 0; |
|
536 |
|
537 int all_state = -1; |
|
538 int id_state = -1; |
|
539 |
|
540 octave_idx_type nel = warning_options.numel (); |
|
541 |
|
542 if (nel > 0) |
|
543 { |
|
544 Cell identifier = warning_options.contents ("identifier"); |
|
545 Cell state = warning_options.contents ("state"); |
|
546 |
|
547 bool all_found = false; |
|
548 bool id_found = false; |
|
549 |
|
550 for (octave_idx_type i = 0; i < nel; i++) |
|
551 { |
|
552 octave_value ov = identifier(i); |
|
553 std::string ovs = ov.string_value (); |
|
554 |
|
555 if (! all_found && ovs == "all") |
|
556 { |
|
557 all_state = check_state (state(i).string_value ()); |
|
558 |
|
559 if (all_state >= 0) |
|
560 all_found = true; |
|
561 } |
|
562 |
|
563 if (! id_found && ovs == id) |
|
564 { |
|
565 id_state = check_state (state(i).string_value ()); |
|
566 |
|
567 if (id_state >= 0) |
|
568 id_found = true; |
|
569 } |
|
570 |
|
571 if (all_found && id_found) |
|
572 break; |
|
573 } |
|
574 } |
|
575 |
|
576 if (all_state == -1) |
|
577 panic_impossible (); |
|
578 |
|
579 if (all_state == 0) |
|
580 { |
|
581 if (id_state >= 0) |
|
582 retval = id_state; |
|
583 } |
|
584 else if (all_state == 1) |
|
585 { |
|
586 if (id_state == 0 || id_state == 2) |
|
587 retval = id_state; |
|
588 else |
|
589 retval = all_state; |
|
590 } |
|
591 else if (all_state == 2) |
|
592 retval = 2; |
|
593 |
|
594 return retval; |
|
595 } |
|
596 |
|
597 static void |
|
598 warning_1 (const char *id, const char *fmt, va_list args) |
|
599 { |
|
600 int warn_opt = warning_enabled (id); |
|
601 |
|
602 if (warn_opt == 2) |
|
603 { |
|
604 // Handle this warning as an error. |
|
605 |
5998
|
606 error_2 (id, fmt, args); |
5567
|
607 } |
|
608 else if (warn_opt == 1) |
3934
|
609 { |
4014
|
610 if (curr_sym_tab != top_level_sym_tab |
5567
|
611 && Vbacktrace_on_warning |
4452
|
612 && ! warning_state |
|
613 && ! discard_warning_messages) |
4719
|
614 pr_where ("warning", false); |
3986
|
615 |
5567
|
616 vwarning ("warning", id, fmt, args); |
3707
|
617 |
3935
|
618 warning_state = 1; |
|
619 |
3934
|
620 if ((interactive || forced_interactive) |
5743
|
621 && Vdebug_on_warning |
5744
|
622 && octave_call_stack::caller_user_script_or_function ()) |
3934
|
623 { |
|
624 unwind_protect_bool (Vdebug_on_warning); |
|
625 Vdebug_on_warning = false; |
3707
|
626 |
3934
|
627 do_keyboard (octave_value_list ()); |
3707
|
628 |
3934
|
629 unwind_protect::run (); |
|
630 } |
3707
|
631 } |
1
|
632 } |
|
633 |
|
634 void |
6338
|
635 vwarning (const char *fmt, va_list args) |
|
636 { |
|
637 warning_1 ("", fmt, args); |
|
638 } |
|
639 |
|
640 void |
5567
|
641 warning (const char *fmt, ...) |
|
642 { |
|
643 va_list args; |
|
644 va_start (args, fmt); |
6338
|
645 vwarning (fmt, args); |
5567
|
646 va_end (args); |
|
647 } |
|
648 |
|
649 void |
6338
|
650 vwarning_with_id (const char *id, const char *fmt, va_list args) |
|
651 { |
|
652 warning_1 (id, fmt, args); |
|
653 } |
|
654 |
|
655 void |
5567
|
656 warning_with_id (const char *id, const char *fmt, ...) |
|
657 { |
|
658 va_list args; |
|
659 va_start (args, fmt); |
6338
|
660 vwarning_with_id (id, fmt, args); |
5567
|
661 va_end (args); |
|
662 } |
|
663 |
|
664 void |
6338
|
665 vparse_error (const char *fmt, va_list args) |
|
666 { |
|
667 error_1 (std::cerr, 0, "", fmt, args); |
|
668 } |
|
669 |
|
670 void |
1005
|
671 parse_error (const char *fmt, ...) |
|
672 { |
|
673 va_list args; |
|
674 va_start (args, fmt); |
6338
|
675 vparse_error (fmt, args); |
5567
|
676 va_end (args); |
|
677 } |
|
678 |
|
679 void |
6338
|
680 vparse_error_with_id (const char *id, const char *fmt, va_list args) |
|
681 { |
|
682 error_1 (std::cerr, 0, id, fmt, args); |
|
683 } |
|
684 |
|
685 void |
5567
|
686 parse_error_with_id (const char *id, const char *fmt, ...) |
|
687 { |
|
688 va_list args; |
|
689 va_start (args, fmt); |
6338
|
690 vparse_error_with_id (id, fmt, args); |
1
|
691 va_end (args); |
|
692 } |
|
693 |
189
|
694 void |
1
|
695 panic (const char *fmt, ...) |
|
696 { |
|
697 va_list args; |
|
698 va_start (args, fmt); |
4699
|
699 buffer_error_messages = 0; |
3815
|
700 discard_error_messages = false; |
5567
|
701 verror (false, std::cerr, "panic", "", fmt, args); |
1
|
702 va_end (args); |
|
703 abort (); |
|
704 } |
|
705 |
4732
|
706 static void |
|
707 defun_usage_message_1 (const char *fmt, ...) |
|
708 { |
|
709 va_list args; |
|
710 va_start (args, fmt); |
5567
|
711 error_1 (octave_stdout, 0, "", fmt, args); |
4732
|
712 va_end (args); |
|
713 } |
|
714 |
|
715 void |
|
716 defun_usage_message (const std::string& msg) |
|
717 { |
|
718 defun_usage_message_1 ("%s", msg.c_str ()); |
|
719 } |
|
720 |
5567
|
721 typedef void (*error_fun)(const char *, const char *, ...); |
1489
|
722 |
2086
|
723 extern octave_value_list Fsprintf (const octave_value_list&, int); |
1489
|
724 |
3934
|
725 static std::string |
5567
|
726 handle_message (error_fun f, const char *id, const char *msg, |
|
727 const octave_value_list& args) |
528
|
728 { |
3934
|
729 std::string retval; |
528
|
730 |
3523
|
731 std::string tstr; |
1728
|
732 |
528
|
733 int nargin = args.length (); |
|
734 |
2745
|
735 if (nargin > 0) |
528
|
736 { |
3066
|
737 octave_value arg; |
|
738 |
|
739 if (nargin > 1) |
|
740 { |
|
741 octave_value_list tmp = Fsprintf (args, 1); |
|
742 arg = tmp(0); |
|
743 } |
|
744 else |
|
745 arg = args(0); |
2745
|
746 |
|
747 if (arg.is_defined ()) |
528
|
748 { |
2745
|
749 if (arg.is_string ()) |
|
750 { |
|
751 tstr = arg.string_value (); |
|
752 msg = tstr.c_str (); |
|
753 |
|
754 if (! msg) |
|
755 return retval; |
|
756 } |
|
757 else if (arg.is_empty ()) |
528
|
758 return retval; |
|
759 } |
|
760 } |
|
761 |
1489
|
762 // Ugh. |
|
763 |
|
764 int len = strlen (msg); |
|
765 if (msg[len - 1] == '\n') |
|
766 { |
|
767 if (len > 1) |
|
768 { |
|
769 char *tmp_msg = strsave (msg); |
|
770 tmp_msg[len - 1] = '\0'; |
5567
|
771 f (id, "%s\n", tmp_msg); |
3934
|
772 retval = tmp_msg; |
1489
|
773 delete [] tmp_msg; |
|
774 } |
|
775 } |
|
776 else |
3934
|
777 { |
5567
|
778 f (id, "%s", msg); |
3934
|
779 retval = msg; |
|
780 } |
528
|
781 |
|
782 return retval; |
|
783 } |
|
784 |
1957
|
785 DEFUN (error, args, , |
3373
|
786 "-*- texinfo -*-\n\ |
|
787 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\ |
5781
|
788 Format the optional arguments under the control of the template string\n\ |
|
789 @var{template} using the same rules as the @code{printf} family of\n\ |
|
790 functions (@pxref{Formatted Output}) and print the resulting message\n\ |
|
791 on the @code{stderr} stream. The message is prefixed by the character\n\ |
|
792 string @samp{error: }.\n\ |
3373
|
793 \n\ |
|
794 Calling @code{error} also sets Octave's internal error state such that\n\ |
|
795 control will return to the top level without evaluating any more\n\ |
|
796 commands. This is useful for aborting from functions or scripts.\n\ |
897
|
797 \n\ |
3373
|
798 If the error message does not end with a new line character, Octave will\n\ |
|
799 print a traceback of all the function calls leading to the error. For\n\ |
|
800 example, given the following function definitions:\n\ |
|
801 \n\ |
|
802 @example\n\ |
|
803 @group\n\ |
|
804 function f () g () end\n\ |
|
805 function g () h () end\n\ |
|
806 function h () nargin == 1 || error (\"nargin != 1\"); end\n\ |
|
807 @end group\n\ |
|
808 @end example\n\ |
1489
|
809 \n\ |
3373
|
810 @noindent\n\ |
|
811 calling the function @code{f} will result in a list of messages that\n\ |
|
812 can help you to quickly locate the exact location of the error:\n\ |
1489
|
813 \n\ |
3373
|
814 @example\n\ |
|
815 @group\n\ |
|
816 f ()\n\ |
|
817 error: nargin != 1\n\ |
|
818 error: evaluating index expression near line 1, column 30\n\ |
|
819 error: evaluating binary operator `||' near line 1, column 27\n\ |
|
820 error: called from `h'\n\ |
|
821 error: called from `g'\n\ |
|
822 error: called from `f'\n\ |
|
823 @end group\n\ |
|
824 @end example\n\ |
|
825 \n\ |
|
826 If the error message ends in a new line character, Octave will print the\n\ |
|
827 message but will not display any traceback messages as it returns\n\ |
|
828 control to the top level. For example, modifying the error message\n\ |
|
829 in the previous example to end in a new line causes Octave to only print\n\ |
|
830 a single message:\n\ |
|
831 \n\ |
|
832 @example\n\ |
|
833 @group\n\ |
|
834 function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\ |
|
835 f ()\n\ |
|
836 error: nargin != 1\n\ |
|
837 @end group\n\ |
|
838 @end example\n\ |
|
839 @end deftypefn") |
897
|
840 { |
5775
|
841 // FIXME -- need to extract and pass message id to |
5567
|
842 // handle_message. |
|
843 |
3934
|
844 octave_value_list retval; |
5567
|
845 handle_message (error_with_id, "", "unspecified error", args); |
3934
|
846 return retval; |
1489
|
847 } |
897
|
848 |
5567
|
849 DEFCMD (warning, args, nargout, |
3373
|
850 "-*- texinfo -*-\n\ |
5781
|
851 @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ |
|
852 @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template})\n\ |
|
853 Format the optional arguments under the control of the template string\n\ |
|
854 @var{template} using the same rules as the @code{printf} family of\n\ |
|
855 functions (@pxref{Formatted Output}) and print the resulting message\n\ |
|
856 on the @code{stderr} stream. The message is prefixed by the character\n\ |
|
857 string @samp{warning: }.\n\ |
|
858 You should use this function when you want to notify the user\n\ |
3600
|
859 of an unusual condition, but only when it makes sense for your program\n\ |
|
860 to go on.\n\ |
5781
|
861 \n\ |
|
862 The optional message identifier allows users to enable or disable\n\ |
|
863 warnings tagged by @var{id}. The special identifier @samp{\"all\"} may\n\ |
|
864 be used to set the state of all warnings.\n\ |
|
865 \n\ |
|
866 @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\ |
|
867 @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\ |
|
868 @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\ |
|
869 @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\ |
|
870 Set or query the the state of a particular warning using the identifier\n\ |
|
871 @var{id}. If the identifier is omitted, a value of @samp{\"all\"} is\n\ |
|
872 assumed. If you set the state of a warning to @samp{\"error\"}, the\n\ |
|
873 warning named by @var{id} is handled as if it were an error instead.\n\ |
5783
|
874 @seealso{warning_ids}\n\ |
3373
|
875 @end deftypefn") |
1489
|
876 { |
5567
|
877 octave_value retval; |
3934
|
878 |
5567
|
879 int nargin = args.length (); |
|
880 int argc = nargin + 1; |
3934
|
881 |
3935
|
882 bool done = false; |
3934
|
883 |
5567
|
884 if (argc > 1 && args.all_strings_p ()) |
3935
|
885 { |
|
886 string_vector argv = args.make_argv ("warning"); |
|
887 |
|
888 if (! error_state) |
3934
|
889 { |
5567
|
890 std::string arg1 = argv(1); |
|
891 std::string arg2 = "all"; |
|
892 |
|
893 if (argc == 3) |
|
894 arg2 = argv(2); |
|
895 |
|
896 if (arg1 == "on" || arg1 == "off" || arg1 == "error") |
3934
|
897 { |
5567
|
898 Octave_map old_warning_options = warning_options; |
|
899 |
|
900 if (arg2 == "all") |
|
901 { |
|
902 Octave_map tmp; |
3934
|
903 |
5567
|
904 tmp.assign ("identifier", arg2); |
|
905 tmp.assign ("state", arg1); |
|
906 |
|
907 warning_options = tmp; |
|
908 |
3935
|
909 done = true; |
|
910 } |
5567
|
911 else if (arg2 == "backtrace") |
|
912 { |
|
913 if (arg1 != "error") |
|
914 { |
|
915 Vbacktrace_on_warning = (arg1 == "on"); |
|
916 done = true; |
|
917 } |
|
918 } |
|
919 else if (arg2 == "debug") |
|
920 { |
|
921 if (arg1 != "error") |
|
922 { |
5794
|
923 Vdebug_on_warning = (arg1 == "on"); |
5567
|
924 done = true; |
|
925 } |
|
926 } |
|
927 else if (arg2 == "verbose") |
|
928 { |
|
929 if (arg1 != "error") |
|
930 { |
|
931 Vverbose_warning = (arg1 == "on"); |
|
932 done = true; |
|
933 } |
|
934 } |
5582
|
935 else if (arg2 == "quiet") |
|
936 { |
|
937 if (arg1 != "error") |
|
938 { |
|
939 Vquiet_warning = (arg1 == "on"); |
|
940 done = true; |
|
941 } |
|
942 } |
5567
|
943 else |
3935
|
944 { |
5567
|
945 if (arg2 == "last") |
|
946 arg2 = Vlast_warning_id; |
|
947 |
|
948 if (arg2 == "all") |
5794
|
949 initialize_warning_options (arg1); |
5567
|
950 else |
|
951 { |
|
952 Cell ident = warning_options.contents ("identifier"); |
|
953 Cell state = warning_options.contents ("state"); |
|
954 |
|
955 octave_idx_type nel = ident.numel (); |
|
956 |
|
957 bool found = false; |
|
958 |
|
959 for (octave_idx_type i = 0; i < nel; i++) |
|
960 { |
|
961 if (ident(i).string_value () == arg2) |
|
962 { |
5775
|
963 // FIXME -- if state for "all" is |
5567
|
964 // same as arg1, we can simply remove the |
|
965 // item from the list. |
|
966 |
|
967 state(i) = arg1; |
|
968 warning_options.assign ("state", state); |
|
969 found = true; |
|
970 break; |
|
971 } |
|
972 } |
|
973 |
|
974 if (! found) |
|
975 { |
5775
|
976 // FIXME -- if state for "all" is |
5567
|
977 // same as arg1, we don't need to do anything. |
|
978 |
|
979 ident.resize (dim_vector (1, nel+1)); |
|
980 state.resize (dim_vector (1, nel+1)); |
|
981 |
|
982 ident(nel) = arg2; |
|
983 state(nel) = arg1; |
|
984 |
|
985 warning_options.clear (); |
|
986 |
|
987 warning_options.assign ("identifier", ident); |
|
988 warning_options.assign ("state", state); |
|
989 } |
|
990 } |
|
991 |
3935
|
992 done = true; |
|
993 } |
5567
|
994 |
|
995 if (done && nargout > 0) |
|
996 retval = warning_options; |
|
997 } |
|
998 else if (arg1 == "query") |
|
999 { |
|
1000 if (arg2 == "all") |
|
1001 retval = warning_options; |
|
1002 else if (arg2 == "backtrace" || arg2 == "debug" |
5582
|
1003 || arg2 == "verbose" || arg2 == "quiet") |
5567
|
1004 { |
|
1005 Octave_map tmp; |
|
1006 tmp.assign ("identifier", arg2); |
|
1007 if (arg2 == "backtrace") |
|
1008 tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off"); |
|
1009 else if (arg2 == "debug") |
|
1010 tmp.assign ("state", Vdebug_on_warning ? "on" : "off"); |
5582
|
1011 else if (arg2 == "verbose") |
|
1012 tmp.assign ("state", Vverbose_warning ? "on" : "off"); |
5567
|
1013 else |
5582
|
1014 tmp.assign ("state", Vquiet_warning ? "on" : "off"); |
|
1015 |
|
1016 retval = tmp; |
5567
|
1017 } |
|
1018 else |
3935
|
1019 { |
5567
|
1020 if (arg2 == "last") |
|
1021 arg2 = Vlast_warning_id; |
|
1022 |
|
1023 Cell ident = warning_options.contents ("identifier"); |
|
1024 Cell state = warning_options.contents ("state"); |
|
1025 |
|
1026 octave_idx_type nel = ident.numel (); |
|
1027 |
|
1028 bool found = false; |
|
1029 |
|
1030 std::string val; |
|
1031 |
|
1032 for (octave_idx_type i = 0; i < nel; i++) |
|
1033 { |
|
1034 if (ident(i).string_value () == arg2) |
|
1035 { |
|
1036 val = state(i).string_value (); |
|
1037 found = true; |
|
1038 break; |
|
1039 } |
|
1040 } |
|
1041 |
5781
|
1042 if (! found) |
|
1043 { |
|
1044 for (octave_idx_type i = 0; i < nel; i++) |
|
1045 { |
|
1046 if (ident(i).string_value () == "all") |
|
1047 { |
|
1048 val = state(i).string_value (); |
|
1049 found = true; |
|
1050 break; |
|
1051 } |
|
1052 } |
|
1053 } |
|
1054 |
5567
|
1055 if (found) |
|
1056 { |
|
1057 Octave_map tmp; |
|
1058 |
|
1059 tmp.assign ("identifier", arg2); |
|
1060 tmp.assign ("state", val); |
|
1061 |
|
1062 retval = tmp; |
|
1063 } |
|
1064 else |
5781
|
1065 error ("warning: unable to find default warning state!"); |
3935
|
1066 } |
5567
|
1067 |
|
1068 done = true; |
3935
|
1069 } |
3934
|
1070 } |
|
1071 } |
5567
|
1072 else if (argc == 1) |
|
1073 { |
|
1074 retval = warning_options; |
3934
|
1075 |
5567
|
1076 done = true; |
|
1077 } |
|
1078 else if (argc == 2) |
|
1079 { |
|
1080 octave_value arg = args(0); |
|
1081 |
|
1082 Octave_map old_warning_options = warning_options; |
|
1083 |
|
1084 if (arg.is_map ()) |
|
1085 { |
|
1086 Octave_map m = arg.map_value (); |
|
1087 |
|
1088 if (m.contains ("identifier") && m.contains ("state")) |
|
1089 warning ("warning: setting state with structure not implemented"); |
|
1090 else |
|
1091 error ("warning: expecting structure with fields `identifier' and `state'"); |
|
1092 |
|
1093 done = true; |
|
1094 |
|
1095 if (nargout > 0) |
|
1096 retval = old_warning_options; |
|
1097 } |
|
1098 } |
|
1099 |
|
1100 if (! (error_state || done)) |
3935
|
1101 { |
5567
|
1102 octave_value_list nargs = args; |
|
1103 |
|
1104 std::string id; |
|
1105 |
|
1106 if (nargin > 1) |
|
1107 { |
|
1108 std::string arg1 = args(0).string_value (); |
|
1109 |
|
1110 if (! error_state) |
|
1111 { |
|
1112 if (arg1.find ('%') == NPOS) |
|
1113 { |
|
1114 id = arg1; |
|
1115 |
|
1116 nargs.resize (nargin-1); |
|
1117 |
|
1118 for (int i = 1; i < nargin; i++) |
|
1119 nargs(i-1) = args(i); |
|
1120 } |
|
1121 } |
|
1122 else |
|
1123 return retval; |
|
1124 } |
|
1125 |
|
1126 // handle_message. |
|
1127 |
3935
|
1128 std::string prev_msg = Vlast_warning_message; |
|
1129 |
5567
|
1130 std::string curr_msg = handle_message (warning_with_id, id.c_str (), |
|
1131 "unspecified warning", nargs); |
3935
|
1132 |
|
1133 if (nargout > 0) |
5567
|
1134 retval = prev_msg; |
3935
|
1135 } |
|
1136 |
3934
|
1137 return retval; |
|
1138 } |
|
1139 |
5904
|
1140 void |
5794
|
1141 disable_warning (const std::string& id) |
|
1142 { |
|
1143 octave_value_list args; |
|
1144 |
|
1145 args(1) = id; |
|
1146 args(0) = "off"; |
|
1147 |
|
1148 Fwarning (args, 0); |
|
1149 } |
|
1150 |
|
1151 void |
|
1152 initialize_default_warning_state (void) |
|
1153 { |
|
1154 initialize_warning_options ("on"); |
|
1155 |
|
1156 // Most people will want to have the following disabled. |
|
1157 |
|
1158 disable_warning ("Octave:array-to-scalar"); |
|
1159 disable_warning ("Octave:array-to-vector"); |
|
1160 disable_warning ("Octave:empty-list-elements"); |
|
1161 disable_warning ("Octave:fortran-indexing"); |
|
1162 disable_warning ("Octave:imag-to-real"); |
|
1163 disable_warning ("Octave:matlab-incompatible"); |
|
1164 disable_warning ("Octave:missing-semicolon"); |
|
1165 disable_warning ("Octave:neg-dim-as-zero"); |
|
1166 disable_warning ("Octave:resize-on-range-error"); |
|
1167 disable_warning ("Octave:separator-insert"); |
|
1168 disable_warning ("Octave:single-quote-string"); |
|
1169 disable_warning ("Octave:str-to-num"); |
|
1170 disable_warning ("Octave:string-concat"); |
|
1171 disable_warning ("Octave:variable-switch-label"); |
|
1172 } |
|
1173 |
5567
|
1174 DEFUN (lasterr, args, nargout, |
3935
|
1175 "-*- texinfo -*-\n\ |
5567
|
1176 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr (@var{msg}, @var{msgid})\n\ |
3935
|
1177 Without any arguments, return the last error message. With one\n\ |
5567
|
1178 argument, set the last error message to @var{msg}. With two arguments,\n\ |
|
1179 also set the last message identifier.\n\ |
3935
|
1180 @end deftypefn") |
|
1181 { |
|
1182 octave_value_list retval; |
|
1183 |
|
1184 int argc = args.length () + 1; |
|
1185 |
5567
|
1186 if (argc < 4) |
5335
|
1187 { |
|
1188 string_vector argv = args.make_argv ("lasterr"); |
3935
|
1189 |
5335
|
1190 if (! error_state) |
|
1191 { |
5567
|
1192 std::string prev_error_id = Vlast_error_id; |
|
1193 std::string prev_error_message = Vlast_error_message; |
|
1194 |
|
1195 if (argc > 2) |
|
1196 Vlast_error_id = argv(2); |
|
1197 |
|
1198 if (argc > 1) |
5335
|
1199 Vlast_error_message = argv(1); |
5567
|
1200 |
|
1201 if (argc == 1 || nargout > 0) |
|
1202 { |
|
1203 retval(1) = prev_error_id; |
|
1204 retval(0) = prev_error_message; |
|
1205 } |
5335
|
1206 } |
5567
|
1207 else |
5582
|
1208 error ("lasterr: expecting arguments to be character strings"); |
5335
|
1209 } |
3935
|
1210 else |
5823
|
1211 print_usage (); |
3935
|
1212 |
|
1213 return retval; |
|
1214 } |
|
1215 |
4699
|
1216 // For backward compatibility. |
|
1217 DEFALIAS (error_text, lasterr); |
|
1218 DEFALIAS (__error_text__, lasterr); |
|
1219 |
5567
|
1220 DEFUN (lastwarn, args, nargout, |
3934
|
1221 "-*- texinfo -*-\n\ |
5567
|
1222 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn (@var{msg}, @var{msgid})\n\ |
3935
|
1223 Without any arguments, return the last warning message. With one\n\ |
5567
|
1224 argument, set the last warning message to @var{msg}. With two arguments,\n\ |
|
1225 also set the last message identifier.\n\ |
3934
|
1226 @end deftypefn") |
|
1227 { |
|
1228 octave_value_list retval; |
|
1229 |
|
1230 int argc = args.length () + 1; |
|
1231 |
5567
|
1232 if (argc < 4) |
|
1233 { |
|
1234 string_vector argv = args.make_argv ("lastwarn"); |
|
1235 |
|
1236 if (! error_state) |
|
1237 { |
|
1238 std::string prev_warning_id = Vlast_warning_id; |
|
1239 std::string prev_warning_message = Vlast_warning_message; |
|
1240 |
|
1241 if (argc > 2) |
|
1242 Vlast_warning_id = argv(2); |
3934
|
1243 |
5567
|
1244 if (argc > 1) |
|
1245 Vlast_warning_message = argv(1); |
|
1246 |
|
1247 if (argc == 1 || nargout > 0) |
|
1248 { |
5582
|
1249 warning_state = 0; |
5567
|
1250 retval(1) = prev_warning_id; |
|
1251 retval(0) = prev_warning_message; |
|
1252 } |
|
1253 } |
|
1254 else |
|
1255 error ("lastwarn: expecting arguments to be character strings"); |
|
1256 } |
3934
|
1257 else |
5823
|
1258 print_usage (); |
3934
|
1259 |
|
1260 return retval; |
897
|
1261 } |
|
1262 |
1957
|
1263 DEFUN (usage, args, , |
3373
|
1264 "-*- texinfo -*-\n\ |
|
1265 @deftypefn {Built-in Function} {} usage (@var{msg})\n\ |
|
1266 Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\ |
|
1267 set Octave's internal error state such that control will return to the\n\ |
|
1268 top level without evaluating any more commands. This is useful for\n\ |
|
1269 aborting from functions.\n\ |
|
1270 \n\ |
|
1271 After @code{usage} is evaluated, Octave will print a traceback of all\n\ |
|
1272 the function calls leading to the usage message.\n\ |
899
|
1273 \n\ |
3373
|
1274 You should use this function for reporting problems errors that result\n\ |
|
1275 from an improper call to a function, such as calling a function with an\n\ |
|
1276 incorrect number of arguments, or with arguments of the wrong type. For\n\ |
|
1277 example, most functions distributed with Octave begin with code like\n\ |
|
1278 this\n\ |
|
1279 \n\ |
|
1280 @example\n\ |
|
1281 @group\n\ |
|
1282 if (nargin != 2)\n\ |
|
1283 usage (\"foo (a, b)\");\n\ |
|
1284 endif\n\ |
|
1285 @end group\n\ |
|
1286 @end example\n\ |
|
1287 \n\ |
|
1288 @noindent\n\ |
|
1289 to check for the proper number of arguments.\n\ |
|
1290 @end deftypefn") |
899
|
1291 { |
3934
|
1292 octave_value_list retval; |
5567
|
1293 handle_message (usage_with_id, "", "unknown", args); |
3934
|
1294 return retval; |
899
|
1295 } |
|
1296 |
5794
|
1297 DEFUN (beep_on_error, args, nargout, |
|
1298 "-*- texinfo -*-\n\ |
|
1299 @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\ |
|
1300 @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\ |
|
1301 Query or set the internal variable that controls whether Octave will try\n\ |
|
1302 to ring the terminal bell before printing an error message.\n\ |
|
1303 @end deftypefn") |
3707
|
1304 { |
5794
|
1305 return SET_INTERNAL_VARIABLE (beep_on_error); |
3707
|
1306 } |
|
1307 |
5794
|
1308 DEFUN (debug_on_error, args, nargout, |
3373
|
1309 "-*- texinfo -*-\n\ |
5794
|
1310 @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\ |
|
1311 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\ |
|
1312 Query or set the internal variable that controls whether Octave will try\n\ |
3707
|
1313 to enter the debugger when an error is encountered. This will also\n\ |
|
1314 inhibit printing of the normal traceback message (you will only see\n\ |
5794
|
1315 the top-level error message).\n\ |
|
1316 @end deftypefn") |
|
1317 { |
|
1318 return SET_INTERNAL_VARIABLE (debug_on_error); |
|
1319 } |
3707
|
1320 |
5794
|
1321 DEFUN (debug_on_warning, args, nargout, |
3707
|
1322 "-*- texinfo -*-\n\ |
5794
|
1323 @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\ |
|
1324 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\ |
|
1325 Query or set the internal variable that controls whether Octave will try\n\ |
|
1326 to enter the debugger when a warning is encountered.\n\ |
|
1327 @end deftypefn") |
|
1328 { |
|
1329 return SET_INTERNAL_VARIABLE (debug_on_warning); |
2174
|
1330 } |
|
1331 |
1
|
1332 /* |
|
1333 ;;; Local Variables: *** |
|
1334 ;;; mode: C++ *** |
|
1335 ;;; End: *** |
|
1336 */ |