Mercurial > hg > octave-lyh
annotate src/error.cc @ 9039:51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Spellcheck
Stylecheck
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Sun, 22 Mar 2009 13:14:15 -0700 |
parents | ddea8b06ed7c |
children | 5247e89688e1 |
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 | |
8973 | 408 pr_where (const char *who) |
3707 | 409 { |
8973 | 410 octave_idx_type curr_frame = -1; |
3707 | 411 |
8973 | 412 Octave_map stk = octave_call_stack::backtrace (0, curr_frame); |
4976 | 413 |
8973 | 414 octave_idx_type nframes_to_display = stk.numel (); |
4976 | 415 |
8973 | 416 if (nframes_to_display > 0) |
417 { | |
418 pr_where_1 ("%s: called from\n", who); | |
3708 | 419 |
8973 | 420 Cell names = stk.contents ("name"); |
421 Cell lines = stk.contents ("line"); | |
422 Cell columns = stk.contents ("column"); | |
3707 | 423 |
8973 | 424 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
4976 | 425 { |
8973 | 426 octave_value name = names(i); |
427 octave_value line = lines(i); | |
428 octave_value column = columns(i); | |
3707 | 429 |
8973 | 430 std::string nm = name.string_value (); |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7353
diff
changeset
|
431 |
8973 | 432 pr_where_1 (" %s at line %d column %d\n", nm.c_str (), |
433 line.int_value (), column.int_value ()); | |
4719 | 434 } |
3707 | 435 } |
436 } | |
437 | |
6000 | 438 static void |
439 error_2 (const char *id, const char *fmt, va_list args) | |
440 { | |
441 int init_state = error_state; | |
442 | |
443 error_1 (std::cerr, "error", id, fmt, args); | |
444 | |
445 if ((interactive || forced_interactive) | |
446 && 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
|
447 && octave_call_stack::caller_user_code ()) |
6000 | 448 { |
449 unwind_protect_bool (Vdebug_on_error); | |
450 Vdebug_on_error = false; | |
451 | |
8973 | 452 error_state = 0; |
6000 | 453 |
8973 | 454 pr_where ("error"); |
6000 | 455 |
456 do_keyboard (octave_value_list ()); | |
457 | |
458 unwind_protect::run (); | |
459 } | |
460 } | |
461 | |
462 void | |
6338 | 463 verror (const char *fmt, va_list args) |
464 { | |
465 error_2 ("", fmt, args); | |
466 } | |
467 | |
468 void | |
6000 | 469 error (const char *fmt, ...) |
470 { | |
471 va_list args; | |
472 va_start (args, fmt); | |
6338 | 473 verror (fmt, args); |
6000 | 474 va_end (args); |
475 } | |
476 | |
477 void | |
6338 | 478 verror_with_id (const char *id, const char *fmt, va_list args) |
479 { | |
480 error_2 (id, fmt, args); | |
481 } | |
482 | |
483 void | |
6000 | 484 error_with_id (const char *id, const char *fmt, ...) |
485 { | |
486 va_list args; | |
487 va_start (args, fmt); | |
6338 | 488 verror_with_id (id, fmt, args); |
6000 | 489 va_end (args); |
490 } | |
491 | |
5567 | 492 static int |
493 check_state (const std::string& state) | |
494 { | |
495 // -1: not found | |
496 // 0: found, "off" | |
497 // 1: found, "on" | |
498 // 2: found, "error" | |
499 | |
500 if (state == "off") | |
501 return 0; | |
502 else if (state == "on") | |
503 return 1; | |
504 else if (state == "error") | |
505 return 2; | |
506 else | |
507 return -1; | |
508 } | |
509 | |
510 // For given warning ID, return 0 if warnings are disabled, 1 if | |
511 // enabled, and 2 if this ID should be an error instead of a warning. | |
512 | |
5781 | 513 int |
5567 | 514 warning_enabled (const std::string& id) |
1 | 515 { |
5567 | 516 int retval = 0; |
517 | |
518 int all_state = -1; | |
519 int id_state = -1; | |
520 | |
521 octave_idx_type nel = warning_options.numel (); | |
522 | |
523 if (nel > 0) | |
524 { | |
525 Cell identifier = warning_options.contents ("identifier"); | |
526 Cell state = warning_options.contents ("state"); | |
527 | |
528 bool all_found = false; | |
529 bool id_found = false; | |
530 | |
531 for (octave_idx_type i = 0; i < nel; i++) | |
532 { | |
533 octave_value ov = identifier(i); | |
534 std::string ovs = ov.string_value (); | |
535 | |
536 if (! all_found && ovs == "all") | |
537 { | |
538 all_state = check_state (state(i).string_value ()); | |
539 | |
540 if (all_state >= 0) | |
541 all_found = true; | |
542 } | |
543 | |
544 if (! id_found && ovs == id) | |
545 { | |
546 id_state = check_state (state(i).string_value ()); | |
547 | |
548 if (id_state >= 0) | |
549 id_found = true; | |
550 } | |
551 | |
552 if (all_found && id_found) | |
553 break; | |
554 } | |
555 } | |
556 | |
557 if (all_state == -1) | |
558 panic_impossible (); | |
559 | |
560 if (all_state == 0) | |
561 { | |
562 if (id_state >= 0) | |
563 retval = id_state; | |
564 } | |
565 else if (all_state == 1) | |
566 { | |
567 if (id_state == 0 || id_state == 2) | |
568 retval = id_state; | |
569 else | |
570 retval = all_state; | |
571 } | |
572 else if (all_state == 2) | |
7206 | 573 { |
574 if (id_state == 0) | |
575 retval= id_state; | |
576 else | |
577 retval = all_state; | |
578 } | |
5567 | 579 |
580 return retval; | |
581 } | |
582 | |
583 static void | |
584 warning_1 (const char *id, const char *fmt, va_list args) | |
585 { | |
586 int warn_opt = warning_enabled (id); | |
587 | |
588 if (warn_opt == 2) | |
589 { | |
590 // Handle this warning as an error. | |
591 | |
5998 | 592 error_2 (id, fmt, args); |
5567 | 593 } |
594 else if (warn_opt == 1) | |
3934 | 595 { |
8973 | 596 vwarning ("warning", id, fmt, args); |
597 | |
598 if (! symbol_table::at_top_level () | |
5567 | 599 && Vbacktrace_on_warning |
4452 | 600 && ! warning_state |
601 && ! discard_warning_messages) | |
8973 | 602 pr_where ("warning"); |
3707 | 603 |
3935 | 604 warning_state = 1; |
605 | |
3934 | 606 if ((interactive || forced_interactive) |
5743 | 607 && 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
|
608 && octave_call_stack::caller_user_code ()) |
3934 | 609 { |
610 unwind_protect_bool (Vdebug_on_warning); | |
611 Vdebug_on_warning = false; | |
3707 | 612 |
3934 | 613 do_keyboard (octave_value_list ()); |
3707 | 614 |
3934 | 615 unwind_protect::run (); |
616 } | |
3707 | 617 } |
1 | 618 } |
619 | |
620 void | |
6338 | 621 vwarning (const char *fmt, va_list args) |
622 { | |
623 warning_1 ("", fmt, args); | |
624 } | |
625 | |
626 void | |
5567 | 627 warning (const char *fmt, ...) |
628 { | |
629 va_list args; | |
630 va_start (args, fmt); | |
6338 | 631 vwarning (fmt, args); |
5567 | 632 va_end (args); |
633 } | |
634 | |
635 void | |
6338 | 636 vwarning_with_id (const char *id, const char *fmt, va_list args) |
637 { | |
638 warning_1 (id, fmt, args); | |
639 } | |
640 | |
641 void | |
5567 | 642 warning_with_id (const char *id, const char *fmt, ...) |
643 { | |
644 va_list args; | |
645 va_start (args, fmt); | |
6338 | 646 vwarning_with_id (id, fmt, args); |
5567 | 647 va_end (args); |
648 } | |
649 | |
650 void | |
6338 | 651 vparse_error (const char *fmt, va_list args) |
652 { | |
653 error_1 (std::cerr, 0, "", fmt, args); | |
654 } | |
655 | |
656 void | |
1005 | 657 parse_error (const char *fmt, ...) |
658 { | |
659 va_list args; | |
660 va_start (args, fmt); | |
6338 | 661 vparse_error (fmt, args); |
5567 | 662 va_end (args); |
663 } | |
664 | |
665 void | |
6338 | 666 vparse_error_with_id (const char *id, const char *fmt, va_list args) |
667 { | |
668 error_1 (std::cerr, 0, id, fmt, args); | |
669 } | |
670 | |
671 void | |
5567 | 672 parse_error_with_id (const char *id, const char *fmt, ...) |
673 { | |
674 va_list args; | |
675 va_start (args, fmt); | |
6338 | 676 vparse_error_with_id (id, fmt, args); |
1 | 677 va_end (args); |
678 } | |
679 | |
189 | 680 void |
6361 | 681 rethrow_error (const char *id, const char *fmt, ...) |
682 { | |
683 va_list args; | |
684 va_start (args, fmt); | |
6640 | 685 error_1 (std::cerr, 0, id, fmt, args); |
6361 | 686 va_end (args); |
687 } | |
688 | |
689 void | |
1 | 690 panic (const char *fmt, ...) |
691 { | |
692 va_list args; | |
693 va_start (args, fmt); | |
4699 | 694 buffer_error_messages = 0; |
3815 | 695 discard_error_messages = false; |
5567 | 696 verror (false, std::cerr, "panic", "", fmt, args); |
1 | 697 va_end (args); |
698 abort (); | |
699 } | |
700 | |
4732 | 701 static void |
702 defun_usage_message_1 (const char *fmt, ...) | |
703 { | |
704 va_list args; | |
705 va_start (args, fmt); | |
5567 | 706 error_1 (octave_stdout, 0, "", fmt, args); |
4732 | 707 va_end (args); |
708 } | |
709 | |
710 void | |
711 defun_usage_message (const std::string& msg) | |
712 { | |
713 defun_usage_message_1 ("%s", msg.c_str ()); | |
714 } | |
715 | |
5567 | 716 typedef void (*error_fun)(const char *, const char *, ...); |
1489 | 717 |
2086 | 718 extern octave_value_list Fsprintf (const octave_value_list&, int); |
1489 | 719 |
3934 | 720 static std::string |
5567 | 721 handle_message (error_fun f, const char *id, const char *msg, |
722 const octave_value_list& args) | |
528 | 723 { |
3934 | 724 std::string retval; |
528 | 725 |
3523 | 726 std::string tstr; |
1728 | 727 |
528 | 728 int nargin = args.length (); |
729 | |
2745 | 730 if (nargin > 0) |
528 | 731 { |
3066 | 732 octave_value arg; |
733 | |
734 if (nargin > 1) | |
735 { | |
736 octave_value_list tmp = Fsprintf (args, 1); | |
737 arg = tmp(0); | |
738 } | |
739 else | |
740 arg = args(0); | |
2745 | 741 |
742 if (arg.is_defined ()) | |
528 | 743 { |
2745 | 744 if (arg.is_string ()) |
745 { | |
746 tstr = arg.string_value (); | |
747 msg = tstr.c_str (); | |
748 | |
749 if (! msg) | |
750 return retval; | |
751 } | |
752 else if (arg.is_empty ()) | |
528 | 753 return retval; |
754 } | |
755 } | |
756 | |
1489 | 757 // Ugh. |
758 | |
759 int len = strlen (msg); | |
760 if (msg[len - 1] == '\n') | |
761 { | |
762 if (len > 1) | |
763 { | |
764 char *tmp_msg = strsave (msg); | |
765 tmp_msg[len - 1] = '\0'; | |
5567 | 766 f (id, "%s\n", tmp_msg); |
3934 | 767 retval = tmp_msg; |
1489 | 768 delete [] tmp_msg; |
769 } | |
770 } | |
771 else | |
3934 | 772 { |
5567 | 773 f (id, "%s", msg); |
3934 | 774 retval = msg; |
775 } | |
528 | 776 |
777 return retval; | |
778 } | |
779 | |
6361 | 780 DEFUN (rethrow, args, , |
781 "-*- texinfo -*-\n\ | |
782 @deftypefn {Built-in Function} {} rethrow (@var{err})\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
783 Reissues a previous error as defined by @var{err}. @var{err} is a structure\n\ |
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
784 that must contain at least the 'message' and 'identifier' fields. @var{err}\n\ |
6361 | 785 can also contain a field 'stack' that gives information on the assumed\n\ |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
786 location of the error. Typically @var{err} is returned from\n\ |
6361 | 787 @code{lasterror}.\n\ |
788 @seealso{lasterror, lasterr, error}\n\ | |
789 @end deftypefn") | |
790 { | |
791 octave_value retval; | |
792 int nargin = args.length(); | |
793 | |
794 if (nargin != 1) | |
6959 | 795 print_usage (); |
6361 | 796 else |
797 { | |
6483 | 798 Octave_map err = args(0).map_value (); |
6361 | 799 |
6483 | 800 if (! error_state) |
6361 | 801 { |
6483 | 802 if (err.contains ("message") && err.contains ("identifier")) |
6361 | 803 { |
6483 | 804 std::string msg = err.contents("message")(0).string_value (); |
805 std::string id = err.contents("identifier")(0).string_value (); | |
6361 | 806 int len = msg.length(); |
807 std::string file; | |
808 std::string nm; | |
809 int l = -1; | |
810 int c = -1; | |
811 | |
6483 | 812 if (err.contains ("stack")) |
6361 | 813 { |
6483 | 814 Octave_map err_stack = err.contents("stack")(0).map_value (); |
815 | |
6640 | 816 if (err_stack.numel () > 0) |
817 { | |
818 if (err_stack.contains ("file")) | |
819 file = err_stack.contents("file")(0).string_value (); | |
6483 | 820 |
6640 | 821 if (err_stack.contains ("name")) |
822 nm = err_stack.contents("name")(0).string_value (); | |
6483 | 823 |
6640 | 824 if (err_stack.contains ("line")) |
825 l = err_stack.contents("line")(0).nint_value (); | |
826 | |
827 if (err_stack.contains ("column")) | |
828 c = err_stack.contents("column")(0).nint_value (); | |
829 } | |
6361 | 830 } |
831 | |
832 // Ugh. | |
6483 | 833 char *tmp_msg = strsave (msg.c_str ()); |
6361 | 834 if (tmp_msg[len-1] == '\n') |
835 { | |
836 if (len > 1) | |
837 { | |
838 tmp_msg[len - 1] = '\0'; | |
6483 | 839 rethrow_error (id.c_str (), "%s\n", tmp_msg); |
6361 | 840 } |
841 } | |
842 else | |
6483 | 843 rethrow_error (id.c_str (), "%s", tmp_msg); |
6361 | 844 delete [] tmp_msg; |
845 | |
8333 | 846 // FIXME -- Need to restore the stack as rethrow_error sets it? |
6361 | 847 Vlast_error_file = file; |
848 Vlast_error_name = nm; | |
849 Vlast_error_line = l; | |
850 Vlast_error_column = c; | |
851 | |
6483 | 852 if (err.contains ("stack")) |
6361 | 853 { |
854 if (file.empty ()) | |
855 { | |
856 if (nm.empty ()) | |
857 { | |
858 if (l > 0) | |
6483 | 859 { |
860 if (c > 0) | |
861 pr_where_1 ("error: near line %d, column %d", | |
862 l, c); | |
863 else | |
864 pr_where_1 ("error: near line %d", l); | |
865 } | |
6361 | 866 } |
867 else | |
868 { | |
869 if (l > 0) | |
6483 | 870 { |
871 if (c > 0) | |
872 pr_where_1 ("error: called from `%s' near line %d, column %d", | |
873 nm.c_str (), l, c); | |
874 else | |
875 pr_where_1 ("error: called from `%d' near line %d", nm.c_str (), l); | |
876 } | |
6361 | 877 } |
878 } | |
879 else | |
880 { | |
881 if (nm.empty ()) | |
882 { | |
883 if (l > 0) | |
6483 | 884 { |
885 if (c > 0) | |
886 pr_where_1 ("error: in file %s near line %d, column %d", | |
887 file.c_str (), l, c); | |
888 else | |
889 pr_where_1 ("error: in file %s near line %d", file.c_str (), l); | |
890 } | |
6361 | 891 } |
892 else | |
893 { | |
894 if (l > 0) | |
6483 | 895 { |
896 if (c > 0) | |
897 pr_where_1 ("error: called from `%s' in file %s near line %d, column %d", | |
898 nm.c_str (), file.c_str (), l, c); | |
899 else | |
900 pr_where_1 ("error: called from `%d' in file %s near line %d", nm.c_str (), file.c_str (), l); | |
901 } | |
6361 | 902 } |
903 } | |
904 } | |
905 } | |
906 else | |
907 error ("rethrow: structure must contain the fields 'message and 'identifier'"); | |
908 } | |
909 } | |
910 return retval; | |
911 } | |
912 | |
1957 | 913 DEFUN (error, args, , |
3373 | 914 "-*- texinfo -*-\n\ |
915 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\ | |
7252 | 916 @deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\ |
5781 | 917 Format the optional arguments under the control of the template string\n\ |
918 @var{template} using the same rules as the @code{printf} family of\n\ | |
919 functions (@pxref{Formatted Output}) and print the resulting message\n\ | |
920 on the @code{stderr} stream. The message is prefixed by the character\n\ | |
921 string @samp{error: }.\n\ | |
3373 | 922 \n\ |
923 Calling @code{error} also sets Octave's internal error state such that\n\ | |
924 control will return to the top level without evaluating any more\n\ | |
925 commands. This is useful for aborting from functions or scripts.\n\ | |
897 | 926 \n\ |
3373 | 927 If the error message does not end with a new line character, Octave will\n\ |
928 print a traceback of all the function calls leading to the error. For\n\ | |
929 example, given the following function definitions:\n\ | |
930 \n\ | |
931 @example\n\ | |
932 @group\n\ | |
6671 | 933 function f () g (); end\n\ |
934 function g () h (); end\n\ | |
3373 | 935 function h () nargin == 1 || error (\"nargin != 1\"); end\n\ |
936 @end group\n\ | |
937 @end example\n\ | |
1489 | 938 \n\ |
3373 | 939 @noindent\n\ |
940 calling the function @code{f} will result in a list of messages that\n\ | |
941 can help you to quickly locate the exact location of the error:\n\ | |
1489 | 942 \n\ |
7031 | 943 @smallexample\n\ |
3373 | 944 @group\n\ |
945 f ()\n\ | |
946 error: nargin != 1\n\ | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
947 error: called from:\n\ |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7977
diff
changeset
|
948 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
|
949 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
|
950 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
|
951 error: f at line 1, column 15\n\ |
3373 | 952 @end group\n\ |
7031 | 953 @end smallexample\n\ |
3373 | 954 \n\ |
955 If the error message ends in a new line character, Octave will print the\n\ | |
956 message but will not display any traceback messages as it returns\n\ | |
957 control to the top level. For example, modifying the error message\n\ | |
958 in the previous example to end in a new line causes Octave to only print\n\ | |
959 a single message:\n\ | |
960 \n\ | |
961 @example\n\ | |
962 @group\n\ | |
963 function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\ | |
964 f ()\n\ | |
965 error: nargin != 1\n\ | |
966 @end group\n\ | |
967 @end example\n\ | |
968 @end deftypefn") | |
897 | 969 { |
7252 | 970 octave_value retval; |
971 | |
972 int nargin = args.length (); | |
973 | |
974 octave_value_list nargs = args; | |
975 | |
976 std::string id; | |
977 | |
978 if (nargin > 1) | |
979 { | |
980 std::string arg1 = args(0).string_value (); | |
5567 | 981 |
7252 | 982 if (! error_state) |
983 { | |
8021 | 984 if (arg1.find ('%') == std::string::npos) |
7252 | 985 { |
986 id = arg1; | |
987 | |
988 nargs.resize (nargin-1); | |
989 | |
990 for (int i = 1; i < nargin; i++) | |
991 nargs(i-1) = args(i); | |
992 } | |
993 } | |
994 else | |
995 return retval; | |
996 } | |
997 | |
998 handle_message (error_with_id, id.c_str (), "unspecified error", nargs); | |
999 | |
3934 | 1000 return retval; |
1489 | 1001 } |
897 | 1002 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
1003 DEFUN (warning, args, nargout, |
3373 | 1004 "-*- texinfo -*-\n\ |
5781 | 1005 @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\ |
7252 | 1006 @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\ |
5781 | 1007 Format the optional arguments under the control of the template string\n\ |
1008 @var{template} using the same rules as the @code{printf} family of\n\ | |
1009 functions (@pxref{Formatted Output}) and print the resulting message\n\ | |
1010 on the @code{stderr} stream. The message is prefixed by the character\n\ | |
1011 string @samp{warning: }.\n\ | |
1012 You should use this function when you want to notify the user\n\ | |
3600 | 1013 of an unusual condition, but only when it makes sense for your program\n\ |
1014 to go on.\n\ | |
5781 | 1015 \n\ |
1016 The optional message identifier allows users to enable or disable\n\ | |
1017 warnings tagged by @var{id}. The special identifier @samp{\"all\"} may\n\ | |
1018 be used to set the state of all warnings.\n\ | |
1019 \n\ | |
1020 @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\ | |
1021 @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\ | |
1022 @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\ | |
1023 @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\ | |
6653 | 1024 Set or query the state of a particular warning using the identifier\n\ |
5781 | 1025 @var{id}. If the identifier is omitted, a value of @samp{\"all\"} is\n\ |
1026 assumed. If you set the state of a warning to @samp{\"error\"}, the\n\ | |
1027 warning named by @var{id} is handled as if it were an error instead.\n\ | |
5783 | 1028 @seealso{warning_ids}\n\ |
3373 | 1029 @end deftypefn") |
1489 | 1030 { |
5567 | 1031 octave_value retval; |
3934 | 1032 |
5567 | 1033 int nargin = args.length (); |
1034 int argc = nargin + 1; | |
3934 | 1035 |
3935 | 1036 bool done = false; |
3934 | 1037 |
5567 | 1038 if (argc > 1 && args.all_strings_p ()) |
3935 | 1039 { |
1040 string_vector argv = args.make_argv ("warning"); | |
1041 | |
1042 if (! error_state) | |
3934 | 1043 { |
5567 | 1044 std::string arg1 = argv(1); |
1045 std::string arg2 = "all"; | |
1046 | |
1047 if (argc == 3) | |
1048 arg2 = argv(2); | |
1049 | |
1050 if (arg1 == "on" || arg1 == "off" || arg1 == "error") | |
3934 | 1051 { |
5567 | 1052 Octave_map old_warning_options = warning_options; |
1053 | |
1054 if (arg2 == "all") | |
1055 { | |
1056 Octave_map tmp; | |
3934 | 1057 |
7202 | 1058 Cell id (1, 1); |
1059 Cell st (1, 1); | |
1060 | |
1061 id(0) = arg2; | |
1062 st(0) = arg1; | |
1063 | |
1064 // Since internal Octave functions are not | |
1065 // compatible, turning all warnings into errors | |
1066 // should leave the state of | |
1067 // Octave:matlab-incompatible alone. | |
1068 | |
1069 if (arg1 == "error" | |
1070 && warning_options.contains ("identifier")) | |
1071 { | |
7206 | 1072 octave_idx_type n = 1; |
1073 | |
7202 | 1074 Cell tid = warning_options.contents ("identifier"); |
1075 Cell tst = warning_options.contents ("state"); | |
1076 | |
1077 for (octave_idx_type i = 0; i < tid.numel (); i++) | |
1078 { | |
1079 octave_value vid = tid(i); | |
1080 | |
7206 | 1081 if (vid.is_string ()) |
7202 | 1082 { |
7206 | 1083 std::string key = vid.string_value (); |
7202 | 1084 |
7206 | 1085 if (key == "Octave:matlab-incompatible" |
1086 || key == "Octave:single-quote-string") | |
1087 { | |
1088 id.resize (dim_vector (1, n+1)); | |
1089 st.resize (dim_vector (1, n+1)); | |
7202 | 1090 |
7206 | 1091 id(n) = tid(i); |
1092 st(n) = tst(i); | |
1093 | |
1094 n++; | |
1095 } | |
7202 | 1096 } |
1097 } | |
1098 } | |
1099 | |
1100 tmp.assign ("identifier", id); | |
1101 tmp.assign ("state", st); | |
5567 | 1102 |
1103 warning_options = tmp; | |
1104 | |
3935 | 1105 done = true; |
1106 } | |
5567 | 1107 else if (arg2 == "backtrace") |
1108 { | |
1109 if (arg1 != "error") | |
1110 { | |
1111 Vbacktrace_on_warning = (arg1 == "on"); | |
1112 done = true; | |
1113 } | |
1114 } | |
1115 else if (arg2 == "debug") | |
1116 { | |
1117 if (arg1 != "error") | |
1118 { | |
5794 | 1119 Vdebug_on_warning = (arg1 == "on"); |
5567 | 1120 done = true; |
1121 } | |
1122 } | |
1123 else if (arg2 == "verbose") | |
1124 { | |
1125 if (arg1 != "error") | |
1126 { | |
1127 Vverbose_warning = (arg1 == "on"); | |
1128 done = true; | |
1129 } | |
1130 } | |
5582 | 1131 else if (arg2 == "quiet") |
1132 { | |
1133 if (arg1 != "error") | |
1134 { | |
1135 Vquiet_warning = (arg1 == "on"); | |
1136 done = true; | |
1137 } | |
1138 } | |
5567 | 1139 else |
3935 | 1140 { |
5567 | 1141 if (arg2 == "last") |
1142 arg2 = Vlast_warning_id; | |
1143 | |
1144 if (arg2 == "all") | |
5794 | 1145 initialize_warning_options (arg1); |
5567 | 1146 else |
1147 { | |
1148 Cell ident = warning_options.contents ("identifier"); | |
1149 Cell state = warning_options.contents ("state"); | |
1150 | |
1151 octave_idx_type nel = ident.numel (); | |
1152 | |
1153 bool found = false; | |
1154 | |
1155 for (octave_idx_type i = 0; i < nel; i++) | |
1156 { | |
1157 if (ident(i).string_value () == arg2) | |
1158 { | |
5775 | 1159 // FIXME -- if state for "all" is |
5567 | 1160 // same as arg1, we can simply remove the |
1161 // item from the list. | |
1162 | |
1163 state(i) = arg1; | |
1164 warning_options.assign ("state", state); | |
1165 found = true; | |
1166 break; | |
1167 } | |
1168 } | |
1169 | |
1170 if (! found) | |
1171 { | |
5775 | 1172 // FIXME -- if state for "all" is |
5567 | 1173 // same as arg1, we don't need to do anything. |
1174 | |
1175 ident.resize (dim_vector (1, nel+1)); | |
1176 state.resize (dim_vector (1, nel+1)); | |
1177 | |
1178 ident(nel) = arg2; | |
1179 state(nel) = arg1; | |
1180 | |
1181 warning_options.clear (); | |
1182 | |
1183 warning_options.assign ("identifier", ident); | |
1184 warning_options.assign ("state", state); | |
1185 } | |
1186 } | |
1187 | |
3935 | 1188 done = true; |
1189 } | |
5567 | 1190 |
1191 if (done && nargout > 0) | |
6427 | 1192 retval = old_warning_options; |
5567 | 1193 } |
1194 else if (arg1 == "query") | |
1195 { | |
1196 if (arg2 == "all") | |
1197 retval = warning_options; | |
1198 else if (arg2 == "backtrace" || arg2 == "debug" | |
5582 | 1199 || arg2 == "verbose" || arg2 == "quiet") |
5567 | 1200 { |
1201 Octave_map tmp; | |
1202 tmp.assign ("identifier", arg2); | |
1203 if (arg2 == "backtrace") | |
1204 tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off"); | |
1205 else if (arg2 == "debug") | |
1206 tmp.assign ("state", Vdebug_on_warning ? "on" : "off"); | |
5582 | 1207 else if (arg2 == "verbose") |
1208 tmp.assign ("state", Vverbose_warning ? "on" : "off"); | |
5567 | 1209 else |
5582 | 1210 tmp.assign ("state", Vquiet_warning ? "on" : "off"); |
1211 | |
1212 retval = tmp; | |
5567 | 1213 } |
1214 else | |
3935 | 1215 { |
5567 | 1216 if (arg2 == "last") |
1217 arg2 = Vlast_warning_id; | |
1218 | |
1219 Cell ident = warning_options.contents ("identifier"); | |
1220 Cell state = warning_options.contents ("state"); | |
1221 | |
1222 octave_idx_type nel = ident.numel (); | |
1223 | |
1224 bool found = false; | |
1225 | |
1226 std::string val; | |
1227 | |
1228 for (octave_idx_type i = 0; i < nel; i++) | |
1229 { | |
1230 if (ident(i).string_value () == arg2) | |
1231 { | |
1232 val = state(i).string_value (); | |
1233 found = true; | |
1234 break; | |
1235 } | |
1236 } | |
1237 | |
5781 | 1238 if (! found) |
1239 { | |
1240 for (octave_idx_type i = 0; i < nel; i++) | |
1241 { | |
1242 if (ident(i).string_value () == "all") | |
1243 { | |
1244 val = state(i).string_value (); | |
1245 found = true; | |
1246 break; | |
1247 } | |
1248 } | |
1249 } | |
1250 | |
5567 | 1251 if (found) |
1252 { | |
1253 Octave_map tmp; | |
1254 | |
1255 tmp.assign ("identifier", arg2); | |
1256 tmp.assign ("state", val); | |
1257 | |
1258 retval = tmp; | |
1259 } | |
1260 else | |
5781 | 1261 error ("warning: unable to find default warning state!"); |
3935 | 1262 } |
5567 | 1263 |
1264 done = true; | |
3935 | 1265 } |
3934 | 1266 } |
1267 } | |
5567 | 1268 else if (argc == 1) |
1269 { | |
1270 retval = warning_options; | |
3934 | 1271 |
5567 | 1272 done = true; |
1273 } | |
1274 else if (argc == 2) | |
1275 { | |
1276 octave_value arg = args(0); | |
1277 | |
1278 Octave_map old_warning_options = warning_options; | |
1279 | |
1280 if (arg.is_map ()) | |
1281 { | |
1282 Octave_map m = arg.map_value (); | |
1283 | |
1284 if (m.contains ("identifier") && m.contains ("state")) | |
6427 | 1285 warning_options = m; |
5567 | 1286 else |
1287 error ("warning: expecting structure with fields `identifier' and `state'"); | |
1288 | |
1289 done = true; | |
1290 | |
1291 if (nargout > 0) | |
1292 retval = old_warning_options; | |
1293 } | |
1294 } | |
1295 | |
1296 if (! (error_state || done)) | |
3935 | 1297 { |
5567 | 1298 octave_value_list nargs = args; |
1299 | |
1300 std::string id; | |
1301 | |
1302 if (nargin > 1) | |
1303 { | |
1304 std::string arg1 = args(0).string_value (); | |
1305 | |
1306 if (! error_state) | |
1307 { | |
8021 | 1308 if (arg1.find ('%') == std::string::npos) |
5567 | 1309 { |
1310 id = arg1; | |
1311 | |
1312 nargs.resize (nargin-1); | |
1313 | |
1314 for (int i = 1; i < nargin; i++) | |
1315 nargs(i-1) = args(i); | |
1316 } | |
1317 } | |
1318 else | |
1319 return retval; | |
1320 } | |
1321 | |
3935 | 1322 std::string prev_msg = Vlast_warning_message; |
1323 | |
5567 | 1324 std::string curr_msg = handle_message (warning_with_id, id.c_str (), |
1325 "unspecified warning", nargs); | |
3935 | 1326 |
1327 if (nargout > 0) | |
5567 | 1328 retval = prev_msg; |
3935 | 1329 } |
1330 | |
3934 | 1331 return retval; |
1332 } | |
1333 | |
5904 | 1334 void |
5794 | 1335 disable_warning (const std::string& id) |
1336 { | |
1337 octave_value_list args; | |
1338 | |
1339 args(1) = id; | |
1340 args(0) = "off"; | |
1341 | |
1342 Fwarning (args, 0); | |
1343 } | |
1344 | |
1345 void | |
1346 initialize_default_warning_state (void) | |
1347 { | |
1348 initialize_warning_options ("on"); | |
1349 | |
1350 // Most people will want to have the following disabled. | |
1351 | |
1352 disable_warning ("Octave:array-to-scalar"); | |
1353 disable_warning ("Octave:array-to-vector"); | |
1354 disable_warning ("Octave:empty-list-elements"); | |
1355 disable_warning ("Octave:fortran-indexing"); | |
1356 disable_warning ("Octave:imag-to-real"); | |
1357 disable_warning ("Octave:matlab-incompatible"); | |
1358 disable_warning ("Octave:missing-semicolon"); | |
1359 disable_warning ("Octave:neg-dim-as-zero"); | |
1360 disable_warning ("Octave:resize-on-range-error"); | |
1361 disable_warning ("Octave:separator-insert"); | |
1362 disable_warning ("Octave:single-quote-string"); | |
1363 disable_warning ("Octave:str-to-num"); | |
1364 disable_warning ("Octave:string-concat"); | |
1365 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
|
1366 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
|
1367 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
|
1368 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
|
1369 disable_warning ("Octave:int-math-overflow"); |
5794 | 1370 } |
1371 | |
6361 | 1372 DEFUN (lasterror, args, , |
1373 "-*- texinfo -*-\n\ | |
1374 @deftypefn {Built-in Function} {@var{err} =} lasterror (@var{err})\n\ | |
1375 @deftypefnx {Built-in Function} {} lasterror ('reset')\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1376 Returns or sets the last error message. Called without any arguments\n\ |
6361 | 1377 returns a structure containing the last error message, as well as other\n\ |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1378 information related to this error. The elements of this structure are:\n\ |
6361 | 1379 \n\ |
1380 @table @asis\n\ | |
1381 @item 'message'\n\ | |
1382 The text of the last error message\n\ | |
1383 @item 'identifier'\n\ | |
1384 The message identifier of this error message\n\ | |
1385 @item 'stack'\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1386 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
|
1387 be an empty structure if this in the case where this information cannot\n\ |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1388 be obtained. The fields of this structure are:\n\ |
6361 | 1389 \n\ |
1390 @table @asis\n\ | |
1391 @item 'file'\n\ | |
1392 The name of the file where the error occurred\n\ | |
1393 @item 'name'\n\ | |
7001 | 1394 The name of function in which the error occurred\n\ |
6361 | 1395 @item 'line'\n\ |
7001 | 1396 The line number at which the error occurred\n\ |
6361 | 1397 @item 'column'\n\ |
1398 An optional field with the column number at which the error occurred\n\ | |
1399 @end table\n\ | |
1400 @end table\n\ | |
1401 \n\ | |
1402 The @var{err} structure may also be passed to @code{lasterror} to set the\n\ | |
9039
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1403 information about the last error. The only constraint on @var{err} in that\n\ |
51dc9691f23f
Cleanup documentation files errors.texi, debug.texi, io.texi
Rik <rdrider0-list@yahoo.com>
parents:
8973
diff
changeset
|
1404 case is that it is a scalar structure. Any fields of @var{err} that match\n\ |
6361 | 1405 the above are set to the value passed in @var{err}, while other fields are\n\ |
1406 set to their default values.\n\ | |
1407 \n\ | |
1408 If @code{lasterror} is called with the argument 'reset', all values take\n\ | |
1409 their default values.\n\ | |
1410 @end deftypefn") | |
1411 { | |
1412 octave_value retval; | |
1413 int nargin = args.length(); | |
1414 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1415 unwind_protect::begin_frame ("Flasterror"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1416 |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1417 unwind_protect_int (error_state); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1418 error_state = 0; |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1419 |
6361 | 1420 if (nargin < 2) |
1421 { | |
1422 Octave_map err; | |
1423 | |
1424 err.assign ("message", Vlast_error_message); | |
1425 err.assign ("identifier", Vlast_error_id); | |
1426 | |
1427 if (! (Vlast_error_file.empty() && Vlast_error_name.empty() && | |
1428 Vlast_error_line < 0 && Vlast_error_column < 0)) | |
1429 { | |
1430 Octave_map err_stack; | |
1431 | |
1432 err_stack.assign ("file", Vlast_error_file); | |
1433 err_stack.assign ("name", Vlast_error_name); | |
1434 err_stack.assign ("line", Vlast_error_line); | |
1435 err_stack.assign ("column", Vlast_error_column); | |
1436 | |
1437 err.assign ("stack", octave_value (err_stack)); | |
1438 } | |
1439 else | |
1440 { | |
1441 string_vector sv(4); | |
1442 sv[0] = "file"; | |
1443 sv[1] = "name"; | |
1444 sv[2] = "line"; | |
1445 sv[3] = "column"; | |
1446 err.assign ("stack", octave_value (Octave_map (dim_vector (0,1), | |
1447 sv))); | |
1448 } | |
1449 | |
1450 if (nargin == 1) | |
1451 { | |
1452 if (args(0).is_string()) | |
1453 { | |
6483 | 1454 if (args(0).string_value () == "reset") |
6361 | 1455 { |
1456 Vlast_error_message = std::string(); | |
1457 Vlast_error_id = std::string(); | |
1458 Vlast_error_file = std::string(); | |
1459 Vlast_error_name = std::string(); | |
1460 Vlast_error_line = -1; | |
1461 Vlast_error_column = -1; | |
1462 } | |
1463 else | |
1464 error("lasterror: unrecognized string argument"); | |
1465 } | |
1466 else if (args(0).is_map ()) | |
1467 { | |
6483 | 1468 Octave_map new_err = args(0).map_value (); |
6361 | 1469 std::string new_error_message; |
1470 std::string new_error_id; | |
1471 std::string new_error_file; | |
1472 std::string new_error_name; | |
1473 int new_error_line = -1; | |
1474 int new_error_column = -1; | |
1475 | |
6483 | 1476 if (! error_state && new_err.contains ("message")) |
6361 | 1477 { |
1478 const std::string tmp = | |
6483 | 1479 new_err.contents("message")(0).string_value (); |
6361 | 1480 new_error_message = tmp; |
1481 } | |
1482 | |
6483 | 1483 if (! error_state && new_err.contains ("identifier")) |
6361 | 1484 { |
1485 const std::string tmp = | |
6483 | 1486 new_err.contents("identifier")(0).string_value (); |
6361 | 1487 new_error_id = tmp; |
1488 } | |
1489 | |
6483 | 1490 if (! error_state && new_err.contains ("stack")) |
6361 | 1491 { |
1492 Octave_map new_err_stack = | |
6483 | 1493 new_err.contents("identifier")(0).map_value (); |
6361 | 1494 |
6483 | 1495 if (! error_state && new_err_stack.contains ("file")) |
6361 | 1496 { |
1497 const std::string tmp = | |
6483 | 1498 new_err_stack.contents("file")(0).string_value (); |
6361 | 1499 new_error_file = tmp; |
1500 } | |
1501 | |
6483 | 1502 if (! error_state && new_err_stack.contains ("name")) |
6361 | 1503 { |
1504 const std::string tmp = | |
6483 | 1505 new_err_stack.contents("name")(0).string_value (); |
6361 | 1506 new_error_name = tmp; |
1507 } | |
1508 | |
6483 | 1509 if (! error_state && new_err_stack.contains ("line")) |
6361 | 1510 { |
1511 const int tmp = | |
6483 | 1512 new_err_stack.contents("line")(0).nint_value (); |
6361 | 1513 new_error_line = tmp; |
1514 } | |
1515 | |
6483 | 1516 if (! error_state && new_err_stack.contains ("column")) |
6361 | 1517 { |
1518 const int tmp = | |
6483 | 1519 new_err_stack.contents("column")(0).nint_value (); |
6361 | 1520 new_error_column = tmp; |
1521 } | |
1522 } | |
1523 | |
1524 if (! error_state) | |
1525 { | |
1526 Vlast_error_message = new_error_message; | |
1527 Vlast_error_id = new_error_id; | |
1528 Vlast_error_file = new_error_file; | |
1529 Vlast_error_name = new_error_name; | |
1530 Vlast_error_line = new_error_line; | |
1531 Vlast_error_column = new_error_column; | |
1532 } | |
1533 } | |
1534 else | |
1535 error ("lasterror: argument must be a structure or a string"); | |
1536 } | |
1537 | |
6483 | 1538 if (! error_state) |
6361 | 1539 retval = err; |
1540 } | |
1541 else | |
1542 print_usage (); | |
1543 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1544 unwind_protect::run_frame ("Flasterror"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1545 |
6361 | 1546 return retval; |
1547 } | |
1548 | |
5567 | 1549 DEFUN (lasterr, args, nargout, |
3935 | 1550 "-*- texinfo -*-\n\ |
5567 | 1551 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr (@var{msg}, @var{msgid})\n\ |
3935 | 1552 Without any arguments, return the last error message. With one\n\ |
5567 | 1553 argument, set the last error message to @var{msg}. With two arguments,\n\ |
1554 also set the last message identifier.\n\ | |
3935 | 1555 @end deftypefn") |
1556 { | |
1557 octave_value_list retval; | |
1558 | |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1559 unwind_protect::begin_frame ("Flasterr"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1560 |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1561 unwind_protect_int (error_state); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1562 error_state = 0; |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1563 |
3935 | 1564 int argc = args.length () + 1; |
1565 | |
5567 | 1566 if (argc < 4) |
5335 | 1567 { |
1568 string_vector argv = args.make_argv ("lasterr"); | |
3935 | 1569 |
5335 | 1570 if (! error_state) |
1571 { | |
5567 | 1572 std::string prev_error_id = Vlast_error_id; |
1573 std::string prev_error_message = Vlast_error_message; | |
1574 | |
1575 if (argc > 2) | |
1576 Vlast_error_id = argv(2); | |
1577 | |
1578 if (argc > 1) | |
5335 | 1579 Vlast_error_message = argv(1); |
5567 | 1580 |
1581 if (argc == 1 || nargout > 0) | |
1582 { | |
1583 retval(1) = prev_error_id; | |
1584 retval(0) = prev_error_message; | |
1585 } | |
5335 | 1586 } |
5567 | 1587 else |
5582 | 1588 error ("lasterr: expecting arguments to be character strings"); |
5335 | 1589 } |
3935 | 1590 else |
5823 | 1591 print_usage (); |
3935 | 1592 |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1593 unwind_protect::run_frame ("Flasterr"); |
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1594 |
3935 | 1595 return retval; |
1596 } | |
1597 | |
4699 | 1598 // For backward compatibility. |
1599 DEFALIAS (error_text, lasterr); | |
1600 DEFALIAS (__error_text__, lasterr); | |
1601 | |
5567 | 1602 DEFUN (lastwarn, args, nargout, |
3934 | 1603 "-*- texinfo -*-\n\ |
5567 | 1604 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn (@var{msg}, @var{msgid})\n\ |
3935 | 1605 Without any arguments, return the last warning message. With one\n\ |
5567 | 1606 argument, set the last warning message to @var{msg}. With two arguments,\n\ |
1607 also set the last message identifier.\n\ | |
3934 | 1608 @end deftypefn") |
1609 { | |
1610 octave_value_list retval; | |
1611 | |
1612 int argc = args.length () + 1; | |
1613 | |
5567 | 1614 if (argc < 4) |
1615 { | |
1616 string_vector argv = args.make_argv ("lastwarn"); | |
1617 | |
1618 if (! error_state) | |
1619 { | |
1620 std::string prev_warning_id = Vlast_warning_id; | |
1621 std::string prev_warning_message = Vlast_warning_message; | |
1622 | |
1623 if (argc > 2) | |
1624 Vlast_warning_id = argv(2); | |
3934 | 1625 |
5567 | 1626 if (argc > 1) |
1627 Vlast_warning_message = argv(1); | |
1628 | |
1629 if (argc == 1 || nargout > 0) | |
1630 { | |
5582 | 1631 warning_state = 0; |
5567 | 1632 retval(1) = prev_warning_id; |
1633 retval(0) = prev_warning_message; | |
1634 } | |
1635 } | |
1636 else | |
1637 error ("lastwarn: expecting arguments to be character strings"); | |
1638 } | |
3934 | 1639 else |
5823 | 1640 print_usage (); |
3934 | 1641 |
1642 return retval; | |
897 | 1643 } |
1644 | |
1957 | 1645 DEFUN (usage, args, , |
3373 | 1646 "-*- texinfo -*-\n\ |
1647 @deftypefn {Built-in Function} {} usage (@var{msg})\n\ | |
1648 Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\ | |
1649 set Octave's internal error state such that control will return to the\n\ | |
1650 top level without evaluating any more commands. This is useful for\n\ | |
1651 aborting from functions.\n\ | |
1652 \n\ | |
1653 After @code{usage} is evaluated, Octave will print a traceback of all\n\ | |
1654 the function calls leading to the usage message.\n\ | |
899 | 1655 \n\ |
3373 | 1656 You should use this function for reporting problems errors that result\n\ |
1657 from an improper call to a function, such as calling a function with an\n\ | |
1658 incorrect number of arguments, or with arguments of the wrong type. For\n\ | |
1659 example, most functions distributed with Octave begin with code like\n\ | |
1660 this\n\ | |
1661 \n\ | |
1662 @example\n\ | |
1663 @group\n\ | |
1664 if (nargin != 2)\n\ | |
1665 usage (\"foo (a, b)\");\n\ | |
1666 endif\n\ | |
1667 @end group\n\ | |
1668 @end example\n\ | |
1669 \n\ | |
1670 @noindent\n\ | |
1671 to check for the proper number of arguments.\n\ | |
1672 @end deftypefn") | |
899 | 1673 { |
3934 | 1674 octave_value_list retval; |
5567 | 1675 handle_message (usage_with_id, "", "unknown", args); |
3934 | 1676 return retval; |
899 | 1677 } |
1678 | |
5794 | 1679 DEFUN (beep_on_error, args, nargout, |
1680 "-*- texinfo -*-\n\ | |
1681 @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\ | |
1682 @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\ | |
1683 Query or set the internal variable that controls whether Octave will try\n\ | |
1684 to ring the terminal bell before printing an error message.\n\ | |
1685 @end deftypefn") | |
3707 | 1686 { |
5794 | 1687 return SET_INTERNAL_VARIABLE (beep_on_error); |
3707 | 1688 } |
1689 | |
5794 | 1690 DEFUN (debug_on_error, args, nargout, |
3373 | 1691 "-*- texinfo -*-\n\ |
5794 | 1692 @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\ |
1693 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\ | |
1694 Query or set the internal variable that controls whether Octave will try\n\ | |
3707 | 1695 to enter the debugger when an error is encountered. This will also\n\ |
1696 inhibit printing of the normal traceback message (you will only see\n\ | |
5794 | 1697 the top-level error message).\n\ |
1698 @end deftypefn") | |
1699 { | |
1700 return SET_INTERNAL_VARIABLE (debug_on_error); | |
1701 } | |
3707 | 1702 |
5794 | 1703 DEFUN (debug_on_warning, args, nargout, |
3707 | 1704 "-*- texinfo -*-\n\ |
5794 | 1705 @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\ |
1706 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\ | |
1707 Query or set the internal variable that controls whether Octave will try\n\ | |
1708 to enter the debugger when a warning is encountered.\n\ | |
1709 @end deftypefn") | |
1710 { | |
1711 return SET_INTERNAL_VARIABLE (debug_on_warning); | |
2174 | 1712 } |
1713 | |
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
|
1714 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
|
1715 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
|
1716 { |
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
|
1717 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
|
1718 } |
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
|
1719 |
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
|
1720 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
|
1721 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
|
1722 { |
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
|
1723 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
|
1724 } |
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
|
1725 |
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
|
1726 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
|
1727 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
|
1728 { |
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
|
1729 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
|
1730 } |
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
|
1731 |
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
|
1732 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
|
1733 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
|
1734 { |
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
|
1735 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
|
1736 } |
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
|
1737 |
1 | 1738 /* |
1739 ;;; Local Variables: *** | |
1740 ;;; mode: C++ *** | |
1741 ;;; End: *** | |
1742 */ |