Mercurial > hg > octave-lyh
annotate src/error.cc @ 8950:d865363208d6
include <iosfwd> instead of <iostream> in header files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 10 Mar 2009 13:55:52 -0400 |
parents | eb63fbe60fab |
children | ddea8b06ed7c |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
8920 | 4 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
1 | 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. | |
1 | 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/>. | |
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 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
31 #include <iostream> |
5765 | 32 #include <sstream> |
1728 | 33 #include <string> |
34 | |
1352 | 35 #include "defun.h" |
1 | 36 #include "error.h" |
3707 | 37 #include "input.h" |
1742 | 38 #include "pager.h" |
1352 | 39 #include "oct-obj.h" |
5567 | 40 #include "oct-map.h" |
1352 | 41 #include "utils.h" |
2370 | 42 #include "ov.h" |
3707 | 43 #include "ov-usr-fcn.h" |
44 #include "pt-pr-code.h" | |
45 #include "pt-stmt.h" | |
46 #include "toplev.h" | |
47 #include "unwind-prot.h" | |
2370 | 48 #include "variables.h" |
1 | 49 |
2174 | 50 // TRUE means that Octave will try to beep obnoxiously before printing |
51 // error messages. | |
5794 | 52 static bool Vbeep_on_error = false; |
2174 | 53 |
3707 | 54 // TRUE means that Octave will try to enter the debugger when an error |
55 // is encountered. This will also inhibit printing of the normal | |
56 // traceback message (you will only see the top-level error message). | |
7353 | 57 bool Vdebug_on_error = false; |
3707 | 58 |
59 // TRUE means that Octave will try to enter the debugger when a warning | |
60 // is encountered. | |
7353 | 61 bool Vdebug_on_warning = false; |
3707 | 62 |
5567 | 63 // TRUE means that Octave will try to display a stack trace when a |
64 // warning is encountered. | |
65 static bool Vbacktrace_on_warning = false; | |
66 | |
67 // TRUE means that Octave will print a verbose warning. Currently unused. | |
68 static bool Vverbose_warning; | |
69 | |
5582 | 70 // TRUE means that Octave will print no warnings, but lastwarn will be |
71 //updated | |
72 static bool Vquiet_warning = false; | |
73 | |
5567 | 74 // A structure containing (most of) the current state of warnings. |
75 static Octave_map warning_options; | |
76 | |
3935 | 77 // The text of the last error message. |
78 static std::string Vlast_error_message; | |
79 | |
3934 | 80 // The text of the last warning message. |
81 static std::string Vlast_warning_message; | |
82 | |
5567 | 83 // The last warning message id. |
84 static std::string Vlast_warning_id; | |
3934 | 85 |
5567 | 86 // The last error message id. |
87 static std::string Vlast_error_id; | |
3934 | 88 |
6361 | 89 // The last file in which an error occured |
90 static std::string Vlast_error_file; | |
91 | |
92 // The last function in which an error occured | |
93 static std::string Vlast_error_name; | |
94 | |
95 // The last line in a function at which an error occured | |
96 static int Vlast_error_line = -1; | |
97 | |
98 // The last column in a function at which an error occured | |
99 static int Vlast_error_column = -1; | |
100 | |
143 | 101 // Current error state. |
3935 | 102 // |
103 // Valid values: | |
104 // | |
105 // -2: an error has occurred, but don't print any messages. | |
106 // -1: an error has occurred, we are printing a traceback | |
107 // 0: no error | |
108 // 1: an error has occurred | |
109 // | |
672 | 110 int error_state = 0; |
111 | |
3489 | 112 // Current warning state. |
3935 | 113 // |
114 // Valid values: | |
115 // | |
116 // 0: no warning | |
117 // 1: a warning has occurred | |
118 // | |
3489 | 119 int warning_state = 0; |
120 | |
1489 | 121 // Tell the error handler whether to print messages, or just store |
122 // them for later. Used for handling errors in eval() and | |
123 // the `unwind_protect' statement. | |
4699 | 124 int buffer_error_messages = 0; |
1489 | 125 |
3815 | 126 // TRUE means error messages are turned off. |
127 bool discard_error_messages = false; | |
128 | |
4452 | 129 // TRUE means warning messages are turned off. |
130 bool discard_warning_messages = false; | |
131 | |
3811 | 132 // The message buffer. |
5765 | 133 static std::ostringstream *error_message_buffer = 0; |
143 | 134 |
4318 | 135 void |
136 reset_error_handler (void) | |
137 { | |
138 error_state = 0; | |
139 warning_state = 0; | |
4699 | 140 buffer_error_messages = 0; |
4318 | 141 discard_error_messages = false; |
142 } | |
143 | |
5567 | 144 static void |
5794 | 145 initialize_warning_options (const std::string& state) |
5567 | 146 { |
147 warning_options.clear (); | |
148 | |
149 warning_options.assign ("identifier", "all"); | |
150 warning_options.assign ("state", state); | |
151 } | |
152 | |
3491 | 153 // Warning messages are never buffered. |
154 | |
155 static void | |
5567 | 156 vwarning (const char *name, const char *id, const char *fmt, va_list args) |
3491 | 157 { |
4452 | 158 if (discard_warning_messages) |
159 return; | |
160 | |
3491 | 161 flush_octave_stdout (); |
162 | |
5765 | 163 std::ostringstream output_buf; |
3491 | 164 |
165 if (name) | |
3761 | 166 output_buf << name << ": "; |
167 | |
168 octave_vformat (output_buf, fmt, args); | |
169 | |
5765 | 170 output_buf << std::endl; |
3491 | 171 |
5775 | 172 // FIXME -- we really want to capture the message before it |
3935 | 173 // has all the formatting goop attached to it. We probably also |
174 // want just the message, not the traceback information. | |
175 | |
5765 | 176 std::string msg_string = output_buf.str (); |
3934 | 177 |
3935 | 178 if (! warning_state) |
179 { | |
180 // This is the first warning in a possible series. | |
5567 | 181 |
182 Vlast_warning_id = id; | |
3935 | 183 Vlast_warning_message = msg_string; |
184 } | |
3934 | 185 |
5582 | 186 if (! Vquiet_warning) |
187 { | |
188 octave_diary << msg_string; | |
3935 | 189 |
5582 | 190 std::cerr << msg_string; |
191 } | |
3491 | 192 } |
193 | |
1 | 194 static void |
4732 | 195 verror (bool save_last_error, std::ostream& os, |
5567 | 196 const char *name, const char *id, const char *fmt, va_list args) |
1 | 197 { |
3815 | 198 if (discard_error_messages) |
199 return; | |
200 | |
3585 | 201 if (! buffer_error_messages) |
202 flush_octave_stdout (); | |
914 | 203 |
5775 | 204 // FIXME -- we really want to capture the message before it |
3935 | 205 // has all the formatting goop attached to it. We probably also |
206 // want just the message, not the traceback information. | |
207 | |
7877 | 208 std::ostringstream output_buf; |
209 | |
210 octave_vformat (output_buf, fmt, args); | |
211 | |
212 std::string base_msg = output_buf.str (); | |
213 | |
214 bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state; | |
215 | |
216 std::string msg_string; | |
217 | |
218 if (to_beep_or_not_to_beep_p) | |
219 msg_string = "\a"; | |
220 | |
221 if (name) | |
222 msg_string += std::string (name) + ": "; | |
223 | |
7880 | 224 msg_string += base_msg + "\n"; |
3935 | 225 |
4731 | 226 if (! error_state && save_last_error) |
3935 | 227 { |
228 // This is the first error in a possible series. | |
5567 | 229 |
230 Vlast_error_id = id; | |
7877 | 231 Vlast_error_message = base_msg; |
6361 | 232 |
233 Vlast_error_line = -1; | |
234 Vlast_error_column = -1; | |
235 Vlast_error_name = std::string (); | |
236 Vlast_error_file = std::string (); | |
237 | |
7877 | 238 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
6361 | 239 |
7877 | 240 if (fcn) |
241 { | |
242 Vlast_error_file = fcn->fcn_file_name (); | |
243 Vlast_error_name = fcn->name (); | |
244 Vlast_error_line = octave_call_stack::caller_user_code_line (); | |
245 Vlast_error_column = octave_call_stack::caller_user_code_column (); | |
6361 | 246 } |
3935 | 247 } |
248 | |
1489 | 249 if (buffer_error_messages) |
250 { | |
7882 | 251 if (error_message_buffer) |
252 msg_string = "error: " + msg_string; | |
253 else | |
7880 | 254 error_message_buffer = new std::ostringstream (); |
1489 | 255 |
7880 | 256 *error_message_buffer << msg_string; |
1489 | 257 } |
258 else | |
259 { | |
3935 | 260 octave_diary << msg_string; |
4732 | 261 os << msg_string; |
1489 | 262 } |
1 | 263 } |
264 | |
1266 | 265 // Note that we don't actually print any message if the error string |
266 // is just "" or "\n". This allows error ("") and error ("\n") to | |
267 // just set the error state. | |
268 | |
1005 | 269 static void |
5567 | 270 error_1 (std::ostream& os, const char *name, const char *id, |
271 const char *fmt, va_list args) | |
1005 | 272 { |
273 if (error_state != -2) | |
274 { | |
1489 | 275 if (fmt) |
1005 | 276 { |
1489 | 277 if (*fmt) |
1005 | 278 { |
1489 | 279 int len = strlen (fmt); |
280 if (fmt[len - 1] == '\n') | |
1266 | 281 { |
1489 | 282 if (len > 1) |
1266 | 283 { |
1489 | 284 char *tmp_fmt = strsave (fmt); |
285 tmp_fmt[len - 1] = '\0'; | |
5567 | 286 verror (true, os, name, id, tmp_fmt, args); |
1489 | 287 delete [] tmp_fmt; |
288 } | |
1423 | 289 |
1489 | 290 error_state = -2; |
1266 | 291 } |
1489 | 292 else |
5567 | 293 verror (true, os, name, id, fmt, args); |
1005 | 294 } |
295 } | |
1489 | 296 else |
297 panic ("error_1: invalid format"); | |
1423 | 298 |
299 if (! error_state) | |
300 error_state = 1; | |
1005 | 301 } |
302 } | |
303 | |
1 | 304 void |
6338 | 305 vmessage (const char *name, const char *fmt, va_list args) |
306 { | |
307 verror (false, std::cerr, name, "", fmt, args); | |
308 } | |
309 | |
310 void | |
1 | 311 message (const char *name, const char *fmt, ...) |
312 { | |
313 va_list args; | |
314 va_start (args, fmt); | |
6338 | 315 vmessage (name, fmt, args); |
1 | 316 va_end (args); |
317 } | |
318 | |
319 void | |
6338 | 320 vmessage_with_id (const char *name, const char *id, const char *fmt, |
321 va_list args) | |
322 { | |
323 verror (false, std::cerr, name, id, fmt, args); | |
324 } | |
325 | |
326 void | |
5567 | 327 message_with_id (const char *name, const char *id, const char *fmt, ...) |
328 { | |
329 va_list args; | |
330 va_start (args, fmt); | |
6338 | 331 vmessage_with_id (name, id, fmt, args); |
5567 | 332 va_end (args); |
333 } | |
334 | |
335 void | |
336 usage_1 (const char *id, const char *fmt, va_list args) | |
337 { | |
338 verror (true, std::cerr, "usage", id, fmt, args); | |
339 error_state = -1; | |
340 } | |
341 | |
342 void | |
6338 | 343 vusage (const char *fmt, va_list args) |
344 { | |
345 usage_1 ("", fmt, args); | |
346 } | |
347 | |
348 void | |
1 | 349 usage (const char *fmt, ...) |
350 { | |
351 va_list args; | |
352 va_start (args, fmt); | |
6338 | 353 vusage (fmt, args); |
5567 | 354 va_end (args); |
355 } | |
356 | |
357 void | |
6338 | 358 vusage_with_id (const char *id, const char *fmt, va_list args) |
359 { | |
360 usage_1 (id, fmt, args); | |
361 } | |
362 | |
363 void | |
5567 | 364 usage_with_id (const char *id, const char *fmt, ...) |
365 { | |
366 va_list args; | |
367 va_start (args, fmt); | |
6338 | 368 vusage_with_id (id, fmt, args); |
1 | 369 va_end (args); |
370 } | |
371 | |
3707 | 372 static void |
3719 | 373 pr_where_2 (const char *fmt, va_list args) |
374 { | |
375 if (fmt) | |
376 { | |
377 if (*fmt) | |
378 { | |
379 int len = strlen (fmt); | |
380 if (fmt[len - 1] == '\n') | |
381 { | |
382 if (len > 1) | |
383 { | |
384 char *tmp_fmt = strsave (fmt); | |
385 tmp_fmt[len - 1] = '\0'; | |
5567 | 386 verror (false, std::cerr, 0, "", tmp_fmt, args); |
3719 | 387 delete [] tmp_fmt; |
388 } | |
389 } | |
390 else | |
5567 | 391 verror (false, std::cerr, 0, "", fmt, args); |
3719 | 392 } |
393 } | |
394 else | |
395 panic ("pr_where_2: invalid format"); | |
396 } | |
397 | |
398 static void | |
3707 | 399 pr_where_1 (const char *fmt, ...) |
400 { | |
401 va_list args; | |
402 va_start (args, fmt); | |
3719 | 403 pr_where_2 (fmt, args); |
3707 | 404 va_end (args); |
405 } | |
406 | |
407 static void | |
4719 | 408 pr_where (const char *name, bool print_code = true) |
3707 | 409 { |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
410 if (octave_call_stack::current_statement ()) |
3707 | 411 { |
4976 | 412 std::string nm; |
3707 | 413 |
4976 | 414 int l = -1; |
415 int c = -1; | |
416 | |
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
|
417 octave_user_code *fcn = octave_call_stack::caller_user_code (); |
4976 | 418 |
419 if (fcn) | |
3708 | 420 { |
5743 | 421 nm = fcn->fcn_file_name (); |
4976 | 422 |
5743 | 423 if (nm.empty ()) |
424 nm = fcn->name (); | |
3708 | 425 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
426 l = octave_call_stack::current_line (); |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
427 c = octave_call_stack::current_column (); |
3708 | 428 } |
3707 | 429 |
4976 | 430 if (nm.empty ()) |
431 { | |
432 if (l > 0 && c > 0) | |
433 pr_where_1 ("%s: near line %d, column %d:", name, l, c); | |
434 } | |
3708 | 435 else |
4976 | 436 { |
437 if (l > 0 && c > 0) | |
438 pr_where_1 ("%s: in %s near line %d, column %d:", | |
439 name, nm.c_str (), l, c); | |
440 else | |
441 pr_where_1 ("%s: in %s", name, nm.c_str ()); | |
442 } | |
3707 | 443 |
4719 | 444 if (print_code) |
445 { | |
5775 | 446 // FIXME -- Note that the column number is probably |
4719 | 447 // not going to mean much here since the code is being |
448 // reproduced from the parse tree, and we are only showing | |
449 // one statement even if there were multiple statements on | |
450 // the original source line. | |
3707 | 451 |
5765 | 452 std::ostringstream output_buf; |
3708 | 453 |
4719 | 454 output_buf << std::endl; |
3707 | 455 |
4719 | 456 tree_print_code tpc (output_buf, ">>> "); |
457 | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
458 tree_statement *curr_stmt = octave_call_stack::current_statement (); |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7353
diff
changeset
|
459 |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7353
diff
changeset
|
460 if (curr_stmt) |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7353
diff
changeset
|
461 curr_stmt->accept (tpc); |
3707 | 462 |
5765 | 463 output_buf << std::endl; |
3707 | 464 |
5765 | 465 std::string msg = output_buf.str (); |
3707 | 466 |
5765 | 467 pr_where_1 ("%s", msg.c_str ()); |
4719 | 468 } |
3707 | 469 } |
470 } | |
471 | |
6000 | 472 static void |
473 error_2 (const char *id, const char *fmt, va_list args) | |
474 { | |
475 int init_state = error_state; | |
476 | |
477 error_1 (std::cerr, "error", id, fmt, args); | |
478 | |
479 if ((interactive || forced_interactive) | |
480 && Vdebug_on_error && init_state == 0 | |
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
|
481 && octave_call_stack::caller_user_code ()) |
6000 | 482 { |
483 unwind_protect_bool (Vdebug_on_error); | |
484 Vdebug_on_error = false; | |
485 | |
486 pr_where ("error"); | |
487 | |
488 error_state = 0; | |
489 | |
490 do_keyboard (octave_value_list ()); | |
491 | |
492 unwind_protect::run (); | |
493 } | |
494 } | |
495 | |
496 void | |
6338 | 497 verror (const char *fmt, va_list args) |
498 { | |
499 error_2 ("", fmt, args); | |
500 } | |
501 | |
502 void | |
6000 | 503 error (const char *fmt, ...) |
504 { | |
505 va_list args; | |
506 va_start (args, fmt); | |
6338 | 507 verror (fmt, args); |
6000 | 508 va_end (args); |
509 } | |
510 | |
511 void | |
6338 | 512 verror_with_id (const char *id, const char *fmt, va_list args) |
513 { | |
514 error_2 (id, fmt, args); | |
515 } | |
516 | |
517 void | |
6000 | 518 error_with_id (const char *id, const char *fmt, ...) |
519 { | |
520 va_list args; | |
521 va_start (args, fmt); | |
6338 | 522 verror_with_id (id, fmt, args); |
6000 | 523 va_end (args); |
524 } | |
525 | |
5567 | 526 static int |
527 check_state (const std::string& state) | |
528 { | |
529 // -1: not found | |
530 // 0: found, "off" | |
531 // 1: found, "on" | |
532 // 2: found, "error" | |
533 | |
534 if (state == "off") | |
535 return 0; | |
536 else if (state == "on") | |
537 return 1; | |
538 else if (state == "error") | |
539 return 2; | |
540 else | |
541 return -1; | |
542 } | |
543 | |
544 // For given warning ID, return 0 if warnings are disabled, 1 if | |
545 // enabled, and 2 if this ID should be an error instead of a warning. | |
546 | |
5781 | 547 int |
5567 | 548 warning_enabled (const std::string& id) |
1 | 549 { |
5567 | 550 int retval = 0; |
551 | |
552 int all_state = -1; | |
553 int id_state = -1; | |
554 | |
555 octave_idx_type nel = warning_options.numel (); | |
556 | |
557 if (nel > 0) | |
558 { | |
559 Cell identifier = warning_options.contents ("identifier"); | |
560 Cell state = warning_options.contents ("state"); | |
561 | |
562 bool all_found = false; | |
563 bool id_found = false; | |
564 | |
565 for (octave_idx_type i = 0; i < nel; i++) | |
566 { | |
567 octave_value ov = identifier(i); | |
568 std::string ovs = ov.string_value (); | |
569 | |
570 if (! all_found && ovs == "all") | |
571 { | |
572 all_state = check_state (state(i).string_value ()); | |
573 | |
574 if (all_state >= 0) | |
575 all_found = true; | |
576 } | |
577 | |
578 if (! id_found && ovs == id) | |
579 { | |
580 id_state = check_state (state(i).string_value ()); | |
581 | |
582 if (id_state >= 0) | |
583 id_found = true; | |
584 } | |
585 | |
586 if (all_found && id_found) | |
587 break; | |
588 } | |
589 } | |
590 | |
591 if (all_state == -1) | |
592 panic_impossible (); | |
593 | |
594 if (all_state == 0) | |
595 { | |
596 if (id_state >= 0) | |
597 retval = id_state; | |
598 } | |
599 else if (all_state == 1) | |
600 { | |
601 if (id_state == 0 || id_state == 2) | |
602 retval = id_state; | |
603 else | |
604 retval = all_state; | |
605 } | |
606 else if (all_state == 2) | |
7206 | 607 { |
608 if (id_state == 0) | |
609 retval= id_state; | |
610 else | |
611 retval = all_state; | |
612 } | |
5567 | 613 |
614 return retval; | |
615 } | |
616 | |
617 static void | |
618 warning_1 (const char *id, const char *fmt, va_list args) | |
619 { | |
620 int warn_opt = warning_enabled (id); | |
621 | |
622 if (warn_opt == 2) | |
623 { | |
624 // Handle this warning as an error. | |
625 | |
5998 | 626 error_2 (id, fmt, args); |
5567 | 627 } |
628 else if (warn_opt == 1) | |
3934 | 629 { |
7336 | 630 if (symbol_table::at_top_level () |
5567 | 631 && Vbacktrace_on_warning |
4452 | 632 && ! warning_state |
633 && ! discard_warning_messages) | |
4719 | 634 pr_where ("warning", false); |
3986 | 635 |
5567 | 636 vwarning ("warning", id, fmt, args); |
3707 | 637 |
3935 | 638 warning_state = 1; |
639 | |
3934 | 640 if ((interactive || forced_interactive) |
5743 | 641 && Vdebug_on_warning |
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
|
642 && octave_call_stack::caller_user_code ()) |
3934 | 643 { |
644 unwind_protect_bool (Vdebug_on_warning); | |
645 Vdebug_on_warning = false; | |
3707 | 646 |
3934 | 647 do_keyboard (octave_value_list ()); |
3707 | 648 |
3934 | 649 unwind_protect::run (); |
650 } | |
3707 | 651 } |
1 | 652 } |
653 | |
654 void | |
6338 | 655 vwarning (const char *fmt, va_list args) |
656 { | |
657 warning_1 ("", fmt, args); | |
658 } | |
659 | |
660 void | |
5567 | 661 warning (const char *fmt, ...) |
662 { | |
663 va_list args; | |
664 va_start (args, fmt); | |
6338 | 665 vwarning (fmt, args); |
5567 | 666 va_end (args); |
667 } | |
668 | |
669 void | |
6338 | 670 vwarning_with_id (const char *id, const char *fmt, va_list args) |
671 { | |
672 warning_1 (id, fmt, args); | |
673 } | |
674 | |
675 void | |
5567 | 676 warning_with_id (const char *id, const char *fmt, ...) |
677 { | |
678 va_list args; | |
679 va_start (args, fmt); | |
6338 | 680 vwarning_with_id (id, fmt, args); |
5567 | 681 va_end (args); |
682 } | |
683 | |
684 void | |
6338 | 685 vparse_error (const char *fmt, va_list args) |
686 { | |
687 error_1 (std::cerr, 0, "", fmt, args); | |
688 } | |
689 | |
690 void | |
1005 | 691 parse_error (const char *fmt, ...) |
692 { | |
693 va_list args; | |
694 va_start (args, fmt); | |
6338 | 695 vparse_error (fmt, args); |
5567 | 696 va_end (args); |
697 } | |
698 | |
699 void | |
6338 | 700 vparse_error_with_id (const char *id, const char *fmt, va_list args) |
701 { | |
702 error_1 (std::cerr, 0, id, fmt, args); | |
703 } | |
704 | |
705 void | |
5567 | 706 parse_error_with_id (const char *id, const char *fmt, ...) |
707 { | |
708 va_list args; | |
709 va_start (args, fmt); | |
6338 | 710 vparse_error_with_id (id, fmt, args); |
1 | 711 va_end (args); |
712 } | |
713 | |
189 | 714 void |
6361 | 715 rethrow_error (const char *id, const char *fmt, ...) |
716 { | |
717 va_list args; | |
718 va_start (args, fmt); | |
6640 | 719 error_1 (std::cerr, 0, id, fmt, args); |
6361 | 720 va_end (args); |
721 } | |
722 | |
723 void | |
1 | 724 panic (const char *fmt, ...) |
725 { | |
726 va_list args; | |
727 va_start (args, fmt); | |
4699 | 728 buffer_error_messages = 0; |
3815 | 729 discard_error_messages = false; |
5567 | 730 verror (false, std::cerr, "panic", "", fmt, args); |
1 | 731 va_end (args); |
732 abort (); | |
733 } | |
734 | |
4732 | 735 static void |
736 defun_usage_message_1 (const char *fmt, ...) | |
737 { | |
738 va_list args; | |
739 va_start (args, fmt); | |
5567 | 740 error_1 (octave_stdout, 0, "", fmt, args); |
4732 | 741 va_end (args); |
742 } | |
743 | |
744 void | |
745 defun_usage_message (const std::string& msg) | |
746 { | |
747 defun_usage_message_1 ("%s", msg.c_str ()); | |
748 } | |
749 | |
5567 | 750 typedef void (*error_fun)(const char *, const char *, ...); |
1489 | 751 |
2086 | 752 extern octave_value_list Fsprintf (const octave_value_list&, int); |
1489 | 753 |
3934 | 754 static std::string |
5567 | 755 handle_message (error_fun f, const char *id, const char *msg, |
756 const octave_value_list& args) | |
528 | 757 { |
3934 | 758 std::string retval; |
528 | 759 |
3523 | 760 std::string tstr; |
1728 | 761 |
528 | 762 int nargin = args.length (); |
763 | |
2745 | 764 if (nargin > 0) |
528 | 765 { |
3066 | 766 octave_value arg; |
767 | |
768 if (nargin > 1) | |
769 { | |
770 octave_value_list tmp = Fsprintf (args, 1); | |
771 arg = tmp(0); | |
772 } | |
773 else | |
774 arg = args(0); | |
2745 | 775 |
776 if (arg.is_defined ()) | |
528 | 777 { |
2745 | 778 if (arg.is_string ()) |
779 { | |
780 tstr = arg.string_value (); | |
781 msg = tstr.c_str (); | |
782 | |
783 if (! msg) | |
784 return retval; | |
785 } | |
786 else if (arg.is_empty ()) | |
528 | 787 return retval; |
788 } | |
789 } | |
790 | |
1489 | 791 // Ugh. |
792 | |
793 int len = strlen (msg); | |
794 if (msg[len - 1] == '\n') | |
795 { | |
796 if (len > 1) | |
797 { | |
798 char *tmp_msg = strsave (msg); | |
799 tmp_msg[len - 1] = '\0'; | |
5567 | 800 f (id, "%s\n", tmp_msg); |
3934 | 801 retval = tmp_msg; |
1489 | 802 delete [] tmp_msg; |
803 } | |
804 } | |
805 else | |
3934 | 806 { |
5567 | 807 f (id, "%s", msg); |
3934 | 808 retval = msg; |
809 } | |
528 | 810 |
811 return retval; | |
812 } | |
813 | |
6361 | 814 DEFUN (rethrow, args, , |
815 "-*- texinfo -*-\n\ | |
816 @deftypefn {Built-in Function} {} rethrow (@var{err})\n\ | |
817 Reissues a previous error as defined by @var{err}. @var{err} is a structure\n\ | |
818 that must contain at least the 'message' and 'identifier' fields. @var{err}\n\ | |
819 can also contain a field 'stack' that gives information on the assumed\n\ | |
820 location of the error. Typically @var{err} is returned from\n\ | |
821 @code{lasterror}.\n\ | |
822 @seealso{lasterror, lasterr, error}\n\ | |
823 @end deftypefn") | |
824 { | |
825 octave_value retval; | |
826 int nargin = args.length(); | |
827 | |
828 if (nargin != 1) | |
6959 | 829 print_usage (); |
6361 | 830 else |
831 { | |
6483 | 832 Octave_map err = args(0).map_value (); |
6361 | 833 |
6483 | 834 if (! error_state) |
6361 | 835 { |
6483 | 836 if (err.contains ("message") && err.contains ("identifier")) |
6361 | 837 { |
6483 | 838 std::string msg = err.contents("message")(0).string_value (); |
839 std::string id = err.contents("identifier")(0).string_value (); | |
6361 | 840 int len = msg.length(); |
841 std::string file; | |
842 std::string nm; | |
843 int l = -1; | |
844 int c = -1; | |
845 | |
6483 | 846 if (err.contains ("stack")) |
6361 | 847 { |
6483 | 848 Octave_map err_stack = err.contents("stack")(0).map_value (); |
849 | |
6640 | 850 if (err_stack.numel () > 0) |
851 { | |
852 if (err_stack.contains ("file")) | |
853 file = err_stack.contents("file")(0).string_value (); | |
6483 | 854 |
6640 | 855 if (err_stack.contains ("name")) |
856 nm = err_stack.contents("name")(0).string_value (); | |
6483 | 857 |
6640 | 858 if (err_stack.contains ("line")) |
859 l = err_stack.contents("line")(0).nint_value (); | |
860 | |
861 if (err_stack.contains ("column")) | |
862 c = err_stack.contents("column")(0).nint_value (); | |
863 } | |
6361 | 864 } |
865 | |
866 // Ugh. | |
6483 | 867 char *tmp_msg = strsave (msg.c_str ()); |
6361 | 868 if (tmp_msg[len-1] == '\n') |
869 { | |
870 if (len > 1) | |
871 { | |
872 tmp_msg[len - 1] = '\0'; | |
6483 | 873 rethrow_error (id.c_str (), "%s\n", tmp_msg); |
6361 | 874 } |
875 } | |
876 else | |
6483 | 877 rethrow_error (id.c_str (), "%s", tmp_msg); |
6361 | 878 delete [] tmp_msg; |
879 | |
8333 | 880 // FIXME -- Need to restore the stack as rethrow_error sets it? |
6361 | 881 Vlast_error_file = file; |
882 Vlast_error_name = nm; | |
883 Vlast_error_line = l; | |
884 Vlast_error_column = c; | |
885 | |
6483 | 886 if (err.contains ("stack")) |
6361 | 887 { |
888 if (file.empty ()) | |
889 { | |
890 if (nm.empty ()) | |
891 { | |
892 if (l > 0) | |
6483 | 893 { |
894 if (c > 0) | |
895 pr_where_1 ("error: near line %d, column %d", | |
896 l, c); | |
897 else | |
898 pr_where_1 ("error: near line %d", l); | |
899 } | |
6361 | 900 } |
901 else | |
902 { | |
903 if (l > 0) | |
6483 | 904 { |
905 if (c > 0) | |
906 pr_where_1 ("error: called from `%s' near line %d, column %d", | |
907 nm.c_str (), l, c); | |
908 else | |
909 pr_where_1 ("error: called from `%d' near line %d", nm.c_str (), l); | |
910 } | |
6361 | 911 } |
912 } | |
913 else | |
914 { | |
915 if (nm.empty ()) | |
916 { | |
917 if (l > 0) | |
6483 | 918 { |
919 if (c > 0) | |
920 pr_where_1 ("error: in file %s near line %d, column %d", | |
921 file.c_str (), l, c); | |
922 else | |
923 pr_where_1 ("error: in file %s near line %d", file.c_str (), l); | |
924 } | |
6361 | 925 } |
926 else | |
927 { | |
928 if (l > 0) | |
6483 | 929 { |
930 if (c > 0) | |
931 pr_where_1 ("error: called from `%s' in file %s near line %d, column %d", | |
932 nm.c_str (), file.c_str (), l, c); | |
933 else | |
934 pr_where_1 ("error: called from `%d' in file %s near line %d", nm.c_str (), file.c_str (), l); | |
935 } | |
6361 | 936 } |
937 } | |
938 } | |
939 } | |
940 else | |
941 error ("rethrow: structure must contain the fields 'message and 'identifier'"); | |
942 } | |
943 } | |
944 return retval; | |
945 } | |
946 | |
1957 | 947 DEFUN (error, args, , |
3373 | 948 "-*- texinfo -*-\n\ |
949 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\ | |
7252 | 950 @deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\ |
5781 | 951 Format the optional arguments under the control of the template string\n\ |
952 @var{template} using the same rules as the @code{printf} family of\n\ | |
953 functions (@pxref{Formatted Output}) and print the resulting message\n\ | |
954 on the @code{stderr} stream. The message is prefixed by the character\n\ | |
955 string @samp{error: }.\n\ | |
3373 | 956 \n\ |
957 Calling @code{error} also sets Octave's internal error state such that\n\ | |
958 control will return to the top level without evaluating any more\n\ | |
959 commands. This is useful for aborting from functions or scripts.\n\ | |
897 | 960 \n\ |
3373 | 961 If the error message does not end with a new line character, Octave will\n\ |
962 print a traceback of all the function calls leading to the error. For\n\ | |
963 example, given the following function definitions:\n\ | |
964 \n\ | |
965 @example\n\ | |
966 @group\n\ | |
6671 | 967 function f () g (); end\n\ |
968 function g () h (); end\n\ | |
3373 | 969 function h () nargin == 1 || error (\"nargin != 1\"); end\n\ |
970 @end group\n\ | |
971 @end example\n\ | |
1489 | 972 \n\ |
3373 | 973 @noindent\n\ |
974 calling the function @code{f} will result in a list of messages that\n\ | |
975 can help you to quickly locate the exact location of the error:\n\ | |
1489 | 976 \n\ |
7031 | 977 @smallexample\n\ |
3373 | 978 @group\n\ |
979 f ()\n\ | |
980 error: nargin != 1\n\ | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
981 error: called from:\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
982 error: error at line -1, column -1\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
983 error: h at line 1, column 27\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
984 error: g at line 1, column 15\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
985 error: f at line 1, column 15\n\ |
3373 | 986 @end group\n\ |
7031 | 987 @end smallexample\n\ |
3373 | 988 \n\ |
989 If the error message ends in a new line character, Octave will print the\n\ | |
990 message but will not display any traceback messages as it returns\n\ | |
991 control to the top level. For example, modifying the error message\n\ | |
992 in the previous example to end in a new line causes Octave to only print\n\ | |
993 a single message:\n\ | |
994 \n\ | |
995 @example\n\ | |
996 @group\n\ | |
997 function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\ | |
998 f ()\n\ | |
999 error: nargin != 1\n\ | |
1000 @end group\n\ | |
1001 @end example\n\ | |
1002 @end deftypefn") | |
897 | 1003 { |
7252 | 1004 octave_value retval; |
1005 | |
1006 int nargin = args.length (); | |
1007 | |
1008 octave_value_list nargs = args; | |
1009 | |
1010 std::string id; | |
1011 | |
1012 if (nargin > 1) | |
1013 { | |
1014 std::string arg1 = args(0).string_value (); | |
5567 | 1015 |
7252 | 1016 if (! error_state) |
1017 { | |
8021 | 1018 if (arg1.find ('%') == std::string::npos) |
7252 | 1019 { |
1020 id = arg1; | |
1021 | |
1022 nargs.resize (nargin-1); | |
1023 | |
1024 for (int i = 1; i < nargin; i++) | |
1025 nargs(i-1) = args(i); | |
1026 } | |
1027 } | |
1028 else | |
1029 return retval; | |
1030 } | |
1031 | |
1032 handle_message (error_with_id, id.c_str (), "unspecified error", nargs); | |
1033 | |
3934 | 1034 return retval; |
1489 | 1035 } |
897 | 1036 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
1037 DEFUN (warning, args, nargout, |
3373 | 1038 "-*- texinfo -*-\n\ |
5781 | 1039 @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ |
7252 | 1040 @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\ |
5781 | 1041 Format the optional arguments under the control of the template string\n\ |
1042 @var{template} using the same rules as the @code{printf} family of\n\ | |
1043 functions (@pxref{Formatted Output}) and print the resulting message\n\ | |
1044 on the @code{stderr} stream. The message is prefixed by the character\n\ | |
1045 string @samp{warning: }.\n\ | |
1046 You should use this function when you want to notify the user\n\ | |
3600 | 1047 of an unusual condition, but only when it makes sense for your program\n\ |
1048 to go on.\n\ | |
5781 | 1049 \n\ |
1050 The optional message identifier allows users to enable or disable\n\ | |
1051 warnings tagged by @var{id}. The special identifier @samp{\"all\"} may\n\ | |
1052 be used to set the state of all warnings.\n\ | |
1053 \n\ | |
1054 @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\ | |
1055 @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\ | |
1056 @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\ | |
1057 @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\ | |
6653 | 1058 Set or query the state of a particular warning using the identifier\n\ |
5781 | 1059 @var{id}. If the identifier is omitted, a value of @samp{\"all\"} is\n\ |
1060 assumed. If you set the state of a warning to @samp{\"error\"}, the\n\ | |
1061 warning named by @var{id} is handled as if it were an error instead.\n\ | |
5783 | 1062 @seealso{warning_ids}\n\ |
3373 | 1063 @end deftypefn") |
1489 | 1064 { |
5567 | 1065 octave_value retval; |
3934 | 1066 |
5567 | 1067 int nargin = args.length (); |
1068 int argc = nargin + 1; | |
3934 | 1069 |
3935 | 1070 bool done = false; |
3934 | 1071 |
5567 | 1072 if (argc > 1 && args.all_strings_p ()) |
3935 | 1073 { |
1074 string_vector argv = args.make_argv ("warning"); | |
1075 | |
1076 if (! error_state) | |
3934 | 1077 { |
5567 | 1078 std::string arg1 = argv(1); |
1079 std::string arg2 = "all"; | |
1080 | |
1081 if (argc == 3) | |
1082 arg2 = argv(2); | |
1083 | |
1084 if (arg1 == "on" || arg1 == "off" || arg1 == "error") | |
3934 | 1085 { |
5567 | 1086 Octave_map old_warning_options = warning_options; |
1087 | |
1088 if (arg2 == "all") | |
1089 { | |
1090 Octave_map tmp; | |
3934 | 1091 |
7202 | 1092 Cell id (1, 1); |
1093 Cell st (1, 1); | |
1094 | |
1095 id(0) = arg2; | |
1096 st(0) = arg1; | |
1097 | |
1098 // Since internal Octave functions are not | |
1099 // compatible, turning all warnings into errors | |
1100 // should leave the state of | |
1101 // Octave:matlab-incompatible alone. | |
1102 | |
1103 if (arg1 == "error" | |
1104 && warning_options.contains ("identifier")) | |
1105 { | |
7206 | 1106 octave_idx_type n = 1; |
1107 | |
7202 | 1108 Cell tid = warning_options.contents ("identifier"); |
1109 Cell tst = warning_options.contents ("state"); | |
1110 | |
1111 for (octave_idx_type i = 0; i < tid.numel (); i++) | |
1112 { | |
1113 octave_value vid = tid(i); | |
1114 | |
7206 | 1115 if (vid.is_string ()) |
7202 | 1116 { |
7206 | 1117 std::string key = vid.string_value (); |
7202 | 1118 |
7206 | 1119 if (key == "Octave:matlab-incompatible" |
1120 || key == "Octave:single-quote-string") | |
1121 { | |
1122 id.resize (dim_vector (1, n+1)); | |
1123 st.resize (dim_vector (1, n+1)); | |
7202 | 1124 |
7206 | 1125 id(n) = tid(i); |
1126 st(n) = tst(i); | |
1127 | |
1128 n++; | |
1129 } | |
7202 | 1130 } |
1131 } | |
1132 } | |
1133 | |
1134 tmp.assign ("identifier", id); | |
1135 tmp.assign ("state", st); | |
5567 | 1136 |
1137 warning_options = tmp; | |
1138 | |
3935 | 1139 done = true; |
1140 } | |
5567 | 1141 else if (arg2 == "backtrace") |
1142 { | |
1143 if (arg1 != "error") | |
1144 { | |
1145 Vbacktrace_on_warning = (arg1 == "on"); | |
1146 done = true; | |
1147 } | |
1148 } | |
1149 else if (arg2 == "debug") | |
1150 { | |
1151 if (arg1 != "error") | |
1152 { | |
5794 | 1153 Vdebug_on_warning = (arg1 == "on"); |
5567 | 1154 done = true; |
1155 } | |
1156 } | |
1157 else if (arg2 == "verbose") | |
1158 { | |
1159 if (arg1 != "error") | |
1160 { | |
1161 Vverbose_warning = (arg1 == "on"); | |
1162 done = true; | |
1163 } | |
1164 } | |
5582 | 1165 else if (arg2 == "quiet") |
1166 { | |
1167 if (arg1 != "error") | |
1168 { | |
1169 Vquiet_warning = (arg1 == "on"); | |
1170 done = true; | |
1171 } | |
1172 } | |
5567 | 1173 else |
3935 | 1174 { |
5567 | 1175 if (arg2 == "last") |
1176 arg2 = Vlast_warning_id; | |
1177 | |
1178 if (arg2 == "all") | |
5794 | 1179 initialize_warning_options (arg1); |
5567 | 1180 else |
1181 { | |
1182 Cell ident = warning_options.contents ("identifier"); | |
1183 Cell state = warning_options.contents ("state"); | |
1184 | |
1185 octave_idx_type nel = ident.numel (); | |
1186 | |
1187 bool found = false; | |
1188 | |
1189 for (octave_idx_type i = 0; i < nel; i++) | |
1190 { | |
1191 if (ident(i).string_value () == arg2) | |
1192 { | |
5775 | 1193 // FIXME -- if state for "all" is |
5567 | 1194 // same as arg1, we can simply remove the |
1195 // item from the list. | |
1196 | |
1197 state(i) = arg1; | |
1198 warning_options.assign ("state", state); | |
1199 found = true; | |
1200 break; | |
1201 } | |
1202 } | |
1203 | |
1204 if (! found) | |
1205 { | |
5775 | 1206 // FIXME -- if state for "all" is |
5567 | 1207 // same as arg1, we don't need to do anything. |
1208 | |
1209 ident.resize (dim_vector (1, nel+1)); | |
1210 state.resize (dim_vector (1, nel+1)); | |
1211 | |
1212 ident(nel) = arg2; | |
1213 state(nel) = arg1; | |
1214 | |
1215 warning_options.clear (); | |
1216 | |
1217 warning_options.assign ("identifier", ident); | |
1218 warning_options.assign ("state", state); | |
1219 } | |
1220 } | |
1221 | |
3935 | 1222 done = true; |
1223 } | |
5567 | 1224 |
1225 if (done && nargout > 0) | |
6427 | 1226 retval = old_warning_options; |
5567 | 1227 } |
1228 else if (arg1 == "query") | |
1229 { | |
1230 if (arg2 == "all") | |
1231 retval = warning_options; | |
1232 else if (arg2 == "backtrace" || arg2 == "debug" | |
5582 | 1233 || arg2 == "verbose" || arg2 == "quiet") |
5567 | 1234 { |
1235 Octave_map tmp; | |
1236 tmp.assign ("identifier", arg2); | |
1237 if (arg2 == "backtrace") | |
1238 tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off"); | |
1239 else if (arg2 == "debug") | |
1240 tmp.assign ("state", Vdebug_on_warning ? "on" : "off"); | |
5582 | 1241 else if (arg2 == "verbose") |
1242 tmp.assign ("state", Vverbose_warning ? "on" : "off"); | |
5567 | 1243 else |
5582 | 1244 tmp.assign ("state", Vquiet_warning ? "on" : "off"); |
1245 | |
1246 retval = tmp; | |
5567 | 1247 } |
1248 else | |
3935 | 1249 { |
5567 | 1250 if (arg2 == "last") |
1251 arg2 = Vlast_warning_id; | |
1252 | |
1253 Cell ident = warning_options.contents ("identifier"); | |
1254 Cell state = warning_options.contents ("state"); | |
1255 | |
1256 octave_idx_type nel = ident.numel (); | |
1257 | |
1258 bool found = false; | |
1259 | |
1260 std::string val; | |
1261 | |
1262 for (octave_idx_type i = 0; i < nel; i++) | |
1263 { | |
1264 if (ident(i).string_value () == arg2) | |
1265 { | |
1266 val = state(i).string_value (); | |
1267 found = true; | |
1268 break; | |
1269 } | |
1270 } | |
1271 | |
5781 | 1272 if (! found) |
1273 { | |
1274 for (octave_idx_type i = 0; i < nel; i++) | |
1275 { | |
1276 if (ident(i).string_value () == "all") | |
1277 { | |
1278 val = state(i).string_value (); | |
1279 found = true; | |
1280 break; | |
1281 } | |
1282 } | |
1283 } | |
1284 | |
5567 | 1285 if (found) |
1286 { | |
1287 Octave_map tmp; | |
1288 | |
1289 tmp.assign ("identifier", arg2); | |
1290 tmp.assign ("state", val); | |
1291 | |
1292 retval = tmp; | |
1293 } | |
1294 else | |
5781 | 1295 error ("warning: unable to find default warning state!"); |
3935 | 1296 } |
5567 | 1297 |
1298 done = true; | |
3935 | 1299 } |
3934 | 1300 } |
1301 } | |
5567 | 1302 else if (argc == 1) |
1303 { | |
1304 retval = warning_options; | |
3934 | 1305 |
5567 | 1306 done = true; |
1307 } | |
1308 else if (argc == 2) | |
1309 { | |
1310 octave_value arg = args(0); | |
1311 | |
1312 Octave_map old_warning_options = warning_options; | |
1313 | |
1314 if (arg.is_map ()) | |
1315 { | |
1316 Octave_map m = arg.map_value (); | |
1317 | |
1318 if (m.contains ("identifier") && m.contains ("state")) | |
6427 | 1319 warning_options = m; |
5567 | 1320 else |
1321 error ("warning: expecting structure with fields `identifier' and `state'"); | |
1322 | |
1323 done = true; | |
1324 | |
1325 if (nargout > 0) | |
1326 retval = old_warning_options; | |
1327 } | |
1328 } | |
1329 | |
1330 if (! (error_state || done)) | |
3935 | 1331 { |
5567 | 1332 octave_value_list nargs = args; |
1333 | |
1334 std::string id; | |
1335 | |
1336 if (nargin > 1) | |
1337 { | |
1338 std::string arg1 = args(0).string_value (); | |
1339 | |
1340 if (! error_state) | |
1341 { | |
8021 | 1342 if (arg1.find ('%') == std::string::npos) |
5567 | 1343 { |
1344 id = arg1; | |
1345 | |
1346 nargs.resize (nargin-1); | |
1347 | |
1348 for (int i = 1; i < nargin; i++) | |
1349 nargs(i-1) = args(i); | |
1350 } | |
1351 } | |
1352 else | |
1353 return retval; | |
1354 } | |
1355 | |
3935 | 1356 std::string prev_msg = Vlast_warning_message; |
1357 | |
5567 | 1358 std::string curr_msg = handle_message (warning_with_id, id.c_str (), |
1359 "unspecified warning", nargs); | |
3935 | 1360 |
1361 if (nargout > 0) | |
5567 | 1362 retval = prev_msg; |
3935 | 1363 } |
1364 | |
3934 | 1365 return retval; |
1366 } | |
1367 | |
5904 | 1368 void |
5794 | 1369 disable_warning (const std::string& id) |
1370 { | |
1371 octave_value_list args; | |
1372 | |
1373 args(1) = id; | |
1374 args(0) = "off"; | |
1375 | |
1376 Fwarning (args, 0); | |
1377 } | |
1378 | |
1379 void | |
1380 initialize_default_warning_state (void) | |
1381 { | |
1382 initialize_warning_options ("on"); | |
1383 | |
1384 // Most people will want to have the following disabled. | |
1385 | |
1386 disable_warning ("Octave:array-to-scalar"); | |
1387 disable_warning ("Octave:array-to-vector"); | |
1388 disable_warning ("Octave:empty-list-elements"); | |
1389 disable_warning ("Octave:fortran-indexing"); | |
1390 disable_warning ("Octave:imag-to-real"); | |
1391 disable_warning ("Octave:matlab-incompatible"); | |
1392 disable_warning ("Octave:missing-semicolon"); | |
1393 disable_warning ("Octave:neg-dim-as-zero"); | |
1394 disable_warning ("Octave:resize-on-range-error"); | |
1395 disable_warning ("Octave:separator-insert"); | |
1396 disable_warning ("Octave:single-quote-string"); | |
1397 disable_warning ("Octave:str-to-num"); | |
1398 disable_warning ("Octave:string-concat"); | |
1399 disable_warning ("Octave:variable-switch-label"); | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1400 disable_warning ("Octave:int-convert-nan"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1401 disable_warning ("Octave:int-convert-non-int-val"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1402 disable_warning ("Octave:int-convert-overflow"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
1403 disable_warning ("Octave:int-math-overflow"); |
5794 | 1404 } |
1405 | |
6361 | 1406 DEFUN (lasterror, args, , |
1407 "-*- texinfo -*-\n\ | |
1408 @deftypefn {Built-in Function} {@var{err} =} lasterror (@var{err})\n\ | |
1409 @deftypefnx {Built-in Function} {} lasterror ('reset')\n\ | |
1410 Returns or sets the last error message. Called without any arguments\n\ | |
1411 returns a structure containing the last error message, as well as other\n\ | |
1412 information related to this error. The elements of this structure are:\n\ | |
1413 \n\ | |
1414 @table @asis\n\ | |
1415 @item 'message'\n\ | |
1416 The text of the last error message\n\ | |
1417 @item 'identifier'\n\ | |
1418 The message identifier of this error message\n\ | |
1419 @item 'stack'\n\ | |
7001 | 1420 A structure containing information on where the message occurred. This might\n\ |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8333
diff
changeset
|
1421 be an empty structure if this in the case where this information cannot\n\ |
6361 | 1422 be obtained. The fields of this structure are:\n\ |
1423 \n\ | |
1424 @table @asis\n\ | |
1425 @item 'file'\n\ | |
1426 The name of the file where the error occurred\n\ | |
1427 @item 'name'\n\ | |
7001 | 1428 The name of function in which the error occurred\n\ |
6361 | 1429 @item 'line'\n\ |
7001 | 1430 The line number at which the error occurred\n\ |
6361 | 1431 @item 'column'\n\ |
1432 An optional field with the column number at which the error occurred\n\ | |
1433 @end table\n\ | |
1434 @end table\n\ | |
1435 \n\ | |
1436 The @var{err} structure may also be passed to @code{lasterror} to set the\n\ | |
1437 information about the last error. The only constraint on @var{err} in that\n\ | |
1438 case is that it is a scalar structure. Any fields of @var{err} that match\n\ | |
1439 the above are set to the value passed in @var{err}, while other fields are\n\ | |
1440 set to their default values.\n\ | |
1441 \n\ | |
1442 If @code{lasterror} is called with the argument 'reset', all values take\n\ | |
1443 their default values.\n\ | |
1444 @end deftypefn") | |
1445 { | |
1446 octave_value retval; | |
1447 int nargin = args.length(); | |
1448 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1449 unwind_protect::begin_frame ("Flasterror"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1450 |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1451 unwind_protect_int (error_state); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1452 error_state = 0; |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1453 |
6361 | 1454 if (nargin < 2) |
1455 { | |
1456 Octave_map err; | |
1457 | |
1458 err.assign ("message", Vlast_error_message); | |
1459 err.assign ("identifier", Vlast_error_id); | |
1460 | |
1461 if (! (Vlast_error_file.empty() && Vlast_error_name.empty() && | |
1462 Vlast_error_line < 0 && Vlast_error_column < 0)) | |
1463 { | |
1464 Octave_map err_stack; | |
1465 | |
1466 err_stack.assign ("file", Vlast_error_file); | |
1467 err_stack.assign ("name", Vlast_error_name); | |
1468 err_stack.assign ("line", Vlast_error_line); | |
1469 err_stack.assign ("column", Vlast_error_column); | |
1470 | |
1471 err.assign ("stack", octave_value (err_stack)); | |
1472 } | |
1473 else | |
1474 { | |
1475 string_vector sv(4); | |
1476 sv[0] = "file"; | |
1477 sv[1] = "name"; | |
1478 sv[2] = "line"; | |
1479 sv[3] = "column"; | |
1480 err.assign ("stack", octave_value (Octave_map (dim_vector (0,1), | |
1481 sv))); | |
1482 } | |
1483 | |
1484 if (nargin == 1) | |
1485 { | |
1486 if (args(0).is_string()) | |
1487 { | |
6483 | 1488 if (args(0).string_value () == "reset") |
6361 | 1489 { |
1490 Vlast_error_message = std::string(); | |
1491 Vlast_error_id = std::string(); | |
1492 Vlast_error_file = std::string(); | |
1493 Vlast_error_name = std::string(); | |
1494 Vlast_error_line = -1; | |
1495 Vlast_error_column = -1; | |
1496 } | |
1497 else | |
1498 error("lasterror: unrecognized string argument"); | |
1499 } | |
1500 else if (args(0).is_map ()) | |
1501 { | |
6483 | 1502 Octave_map new_err = args(0).map_value (); |
6361 | 1503 std::string new_error_message; |
1504 std::string new_error_id; | |
1505 std::string new_error_file; | |
1506 std::string new_error_name; | |
1507 int new_error_line = -1; | |
1508 int new_error_column = -1; | |
1509 | |
6483 | 1510 if (! error_state && new_err.contains ("message")) |
6361 | 1511 { |
1512 const std::string tmp = | |
6483 | 1513 new_err.contents("message")(0).string_value (); |
6361 | 1514 new_error_message = tmp; |
1515 } | |
1516 | |
6483 | 1517 if (! error_state && new_err.contains ("identifier")) |
6361 | 1518 { |
1519 const std::string tmp = | |
6483 | 1520 new_err.contents("identifier")(0).string_value (); |
6361 | 1521 new_error_id = tmp; |
1522 } | |
1523 | |
6483 | 1524 if (! error_state && new_err.contains ("stack")) |
6361 | 1525 { |
1526 Octave_map new_err_stack = | |
6483 | 1527 new_err.contents("identifier")(0).map_value (); |
6361 | 1528 |
6483 | 1529 if (! error_state && new_err_stack.contains ("file")) |
6361 | 1530 { |
1531 const std::string tmp = | |
6483 | 1532 new_err_stack.contents("file")(0).string_value (); |
6361 | 1533 new_error_file = tmp; |
1534 } | |
1535 | |
6483 | 1536 if (! error_state && new_err_stack.contains ("name")) |
6361 | 1537 { |
1538 const std::string tmp = | |
6483 | 1539 new_err_stack.contents("name")(0).string_value (); |
6361 | 1540 new_error_name = tmp; |
1541 } | |
1542 | |
6483 | 1543 if (! error_state && new_err_stack.contains ("line")) |
6361 | 1544 { |
1545 const int tmp = | |
6483 | 1546 new_err_stack.contents("line")(0).nint_value (); |
6361 | 1547 new_error_line = tmp; |
1548 } | |
1549 | |
6483 | 1550 if (! error_state && new_err_stack.contains ("column")) |
6361 | 1551 { |
1552 const int tmp = | |
6483 | 1553 new_err_stack.contents("column")(0).nint_value (); |
6361 | 1554 new_error_column = tmp; |
1555 } | |
1556 } | |
1557 | |
1558 if (! error_state) | |
1559 { | |
1560 Vlast_error_message = new_error_message; | |
1561 Vlast_error_id = new_error_id; | |
1562 Vlast_error_file = new_error_file; | |
1563 Vlast_error_name = new_error_name; | |
1564 Vlast_error_line = new_error_line; | |
1565 Vlast_error_column = new_error_column; | |
1566 } | |
1567 } | |
1568 else | |
1569 error ("lasterror: argument must be a structure or a string"); | |
1570 } | |
1571 | |
6483 | 1572 if (! error_state) |
6361 | 1573 retval = err; |
1574 } | |
1575 else | |
1576 print_usage (); | |
1577 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1578 unwind_protect::run_frame ("Flasterror"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1579 |
6361 | 1580 return retval; |
1581 } | |
1582 | |
5567 | 1583 DEFUN (lasterr, args, nargout, |
3935 | 1584 "-*- texinfo -*-\n\ |
5567 | 1585 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr (@var{msg}, @var{msgid})\n\ |
3935 | 1586 Without any arguments, return the last error message. With one\n\ |
5567 | 1587 argument, set the last error message to @var{msg}. With two arguments,\n\ |
1588 also set the last message identifier.\n\ | |
3935 | 1589 @end deftypefn") |
1590 { | |
1591 octave_value_list retval; | |
1592 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1593 unwind_protect::begin_frame ("Flasterr"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1594 |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1595 unwind_protect_int (error_state); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1596 error_state = 0; |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1597 |
3935 | 1598 int argc = args.length () + 1; |
1599 | |
5567 | 1600 if (argc < 4) |
5335 | 1601 { |
1602 string_vector argv = args.make_argv ("lasterr"); | |
3935 | 1603 |
5335 | 1604 if (! error_state) |
1605 { | |
5567 | 1606 std::string prev_error_id = Vlast_error_id; |
1607 std::string prev_error_message = Vlast_error_message; | |
1608 | |
1609 if (argc > 2) | |
1610 Vlast_error_id = argv(2); | |
1611 | |
1612 if (argc > 1) | |
5335 | 1613 Vlast_error_message = argv(1); |
5567 | 1614 |
1615 if (argc == 1 || nargout > 0) | |
1616 { | |
1617 retval(1) = prev_error_id; | |
1618 retval(0) = prev_error_message; | |
1619 } | |
5335 | 1620 } |
5567 | 1621 else |
5582 | 1622 error ("lasterr: expecting arguments to be character strings"); |
5335 | 1623 } |
3935 | 1624 else |
5823 | 1625 print_usage (); |
3935 | 1626 |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1627 unwind_protect::run_frame ("Flasterr"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1628 |
3935 | 1629 return retval; |
1630 } | |
1631 | |
4699 | 1632 // For backward compatibility. |
1633 DEFALIAS (error_text, lasterr); | |
1634 DEFALIAS (__error_text__, lasterr); | |
1635 | |
5567 | 1636 DEFUN (lastwarn, args, nargout, |
3934 | 1637 "-*- texinfo -*-\n\ |
5567 | 1638 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn (@var{msg}, @var{msgid})\n\ |
3935 | 1639 Without any arguments, return the last warning message. With one\n\ |
5567 | 1640 argument, set the last warning message to @var{msg}. With two arguments,\n\ |
1641 also set the last message identifier.\n\ | |
3934 | 1642 @end deftypefn") |
1643 { | |
1644 octave_value_list retval; | |
1645 | |
1646 int argc = args.length () + 1; | |
1647 | |
5567 | 1648 if (argc < 4) |
1649 { | |
1650 string_vector argv = args.make_argv ("lastwarn"); | |
1651 | |
1652 if (! error_state) | |
1653 { | |
1654 std::string prev_warning_id = Vlast_warning_id; | |
1655 std::string prev_warning_message = Vlast_warning_message; | |
1656 | |
1657 if (argc > 2) | |
1658 Vlast_warning_id = argv(2); | |
3934 | 1659 |
5567 | 1660 if (argc > 1) |
1661 Vlast_warning_message = argv(1); | |
1662 | |
1663 if (argc == 1 || nargout > 0) | |
1664 { | |
5582 | 1665 warning_state = 0; |
5567 | 1666 retval(1) = prev_warning_id; |
1667 retval(0) = prev_warning_message; | |
1668 } | |
1669 } | |
1670 else | |
1671 error ("lastwarn: expecting arguments to be character strings"); | |
1672 } | |
3934 | 1673 else |
5823 | 1674 print_usage (); |
3934 | 1675 |
1676 return retval; | |
897 | 1677 } |
1678 | |
1957 | 1679 DEFUN (usage, args, , |
3373 | 1680 "-*- texinfo -*-\n\ |
1681 @deftypefn {Built-in Function} {} usage (@var{msg})\n\ | |
1682 Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\ | |
1683 set Octave's internal error state such that control will return to the\n\ | |
1684 top level without evaluating any more commands. This is useful for\n\ | |
1685 aborting from functions.\n\ | |
1686 \n\ | |
1687 After @code{usage} is evaluated, Octave will print a traceback of all\n\ | |
1688 the function calls leading to the usage message.\n\ | |
899 | 1689 \n\ |
3373 | 1690 You should use this function for reporting problems errors that result\n\ |
1691 from an improper call to a function, such as calling a function with an\n\ | |
1692 incorrect number of arguments, or with arguments of the wrong type. For\n\ | |
1693 example, most functions distributed with Octave begin with code like\n\ | |
1694 this\n\ | |
1695 \n\ | |
1696 @example\n\ | |
1697 @group\n\ | |
1698 if (nargin != 2)\n\ | |
1699 usage (\"foo (a, b)\");\n\ | |
1700 endif\n\ | |
1701 @end group\n\ | |
1702 @end example\n\ | |
1703 \n\ | |
1704 @noindent\n\ | |
1705 to check for the proper number of arguments.\n\ | |
1706 @end deftypefn") | |
899 | 1707 { |
3934 | 1708 octave_value_list retval; |
5567 | 1709 handle_message (usage_with_id, "", "unknown", args); |
3934 | 1710 return retval; |
899 | 1711 } |
1712 | |
5794 | 1713 DEFUN (beep_on_error, args, nargout, |
1714 "-*- texinfo -*-\n\ | |
1715 @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\ | |
1716 @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\ | |
1717 Query or set the internal variable that controls whether Octave will try\n\ | |
1718 to ring the terminal bell before printing an error message.\n\ | |
1719 @end deftypefn") | |
3707 | 1720 { |
5794 | 1721 return SET_INTERNAL_VARIABLE (beep_on_error); |
3707 | 1722 } |
1723 | |
5794 | 1724 DEFUN (debug_on_error, args, nargout, |
3373 | 1725 "-*- texinfo -*-\n\ |
5794 | 1726 @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\ |
1727 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\ | |
1728 Query or set the internal variable that controls whether Octave will try\n\ | |
3707 | 1729 to enter the debugger when an error is encountered. This will also\n\ |
1730 inhibit printing of the normal traceback message (you will only see\n\ | |
5794 | 1731 the top-level error message).\n\ |
1732 @end deftypefn") | |
1733 { | |
1734 return SET_INTERNAL_VARIABLE (debug_on_error); | |
1735 } | |
3707 | 1736 |
5794 | 1737 DEFUN (debug_on_warning, args, nargout, |
3707 | 1738 "-*- texinfo -*-\n\ |
5794 | 1739 @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\ |
1740 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\ | |
1741 Query or set the internal variable that controls whether Octave will try\n\ | |
1742 to enter the debugger when a warning is encountered.\n\ | |
1743 @end deftypefn") | |
1744 { | |
1745 return SET_INTERNAL_VARIABLE (debug_on_warning); | |
2174 | 1746 } |
1747 | |
7977
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1748 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1749 last_error_message (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1750 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1751 return Vlast_error_message; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1752 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1753 |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1754 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1755 last_error_id (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1756 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1757 return Vlast_error_id; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1758 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1759 |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1760 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1761 last_warning_message (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1762 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1763 return Vlast_warning_message; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1764 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1765 |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1766 std::string |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1767 last_warning_id (void) |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1768 { |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1769 return Vlast_warning_id; |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1770 } |
065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
David Bateman <dbateman@free.fr>
parents:
7976
diff
changeset
|
1771 |
1 | 1772 /* |
1773 ;;; Local Variables: *** | |
1774 ;;; mode: C++ *** | |
1775 ;;; End: *** | |
1776 */ |