annotate libinterp/corefcn/error.cc @ 20780:92958b1ee100

restore stack traces to error messages * error.cc (make_execution_exception): New static function. (usage_1, error_1): Use it to create an octave_execution_object that contains stack trace info.
author John W. Eaton <jwe@octave.org>
date Mon, 30 Nov 2015 22:04:02 -0500
parents 29861f5f28c5
children b6f2909e7f94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19597
diff changeset
3 Copyright (C) 1993-2015 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 189
diff changeset
23 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1165
diff changeset
24 #include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
27 #include <cstdarg>
1633
4a4440aa1262 [project @ 1995-11-14 23:01:31 by jwe]
jwe
parents: 1489
diff changeset
28 #include <cstring>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
29
19439
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
30 #include <iomanip>
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
31 #include <iostream>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5744
diff changeset
32 #include <sstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
33 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
34
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
35 #include "defun.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
36 #include "error.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
37 #include "input.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
38 #include "pager.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
39 #include "oct-obj.h"
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
40 #include "oct-map.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
41 #include "utils.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2200
diff changeset
42 #include "ov.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
43 #include "ov-usr-fcn.h"
18742
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
44 #include "pt-eval.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
45 #include "pt-pr-code.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
46 #include "pt-stmt.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
47 #include "toplev.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
48 #include "unwind-prot.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2200
diff changeset
49 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
50
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
51 // TRUE means that Octave will try to beep obnoxiously before printing
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
52 // error messages.
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
53 static bool Vbeep_on_error = false;
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
54
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
55 // TRUE means that Octave will try to enter the debugger when an error
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
56 // is encountered. This will also inhibit printing of the normal
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
57 // traceback message (you will only see the top-level error message).
7353
516ddd88e45a [project @ 2008-01-07 19:32:40 by jwe]
jwe
parents: 7336
diff changeset
58 bool Vdebug_on_error = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
59
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
60 // TRUE means that Octave will try to enter the debugger when a warning
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
61 // is encountered.
7353
516ddd88e45a [project @ 2008-01-07 19:32:40 by jwe]
jwe
parents: 7336
diff changeset
62 bool Vdebug_on_warning = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
63
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
64 // TRUE means that Octave will try to display a stack trace when a
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
65 // warning is encountered.
18128
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
66 static bool Vbacktrace_on_warning = true;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
67
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
68 // TRUE means that Octave will print a verbose warning. Currently unused.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
69 static bool Vverbose_warning;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
70
18742
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
71 // TRUE means that Octave will print no warnings, but lastwarn will be updated
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
72 static bool Vquiet_warning = false;
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
73
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
74 // A structure containing (most of) the current state of warnings.
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
75 static octave_map warning_options;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
76
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
77 // The text of the last error message.
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
78 static std::string Vlast_error_message;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
79
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
80 // The text of the last warning message.
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
81 static std::string Vlast_warning_message;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
82
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
83 // The last warning message id.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
84 static std::string Vlast_warning_id;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
85
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
86 // The last error message id.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
87 static std::string Vlast_error_id;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
88
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
89 // The last file in which an error occured
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
90 static octave_map Vlast_error_stack;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
91
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 103
diff changeset
92 // Current error state.
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
93 //
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
94 // Valid values:
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
95 //
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
96 // 0: no error
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
97 // 1: an error has occurred
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
98 //
672
066e1551639c [project @ 1994-09-07 21:10:32 by jwe]
jwe
parents: 610
diff changeset
99 int error_state = 0;
066e1551639c [project @ 1994-09-07 21:10:32 by jwe]
jwe
parents: 610
diff changeset
100
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
101 // Tell the error handler whether to print messages, or just store
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
102 // them for later. Used for handling errors in eval() and
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
103 // the 'unwind_protect' statement.
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4452
diff changeset
104 int buffer_error_messages = 0;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
105
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
106 // TRUE means error messages are turned off.
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
107 bool discard_error_messages = false;
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
108
4452
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
109 // TRUE means warning messages are turned off.
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
110 bool discard_warning_messages = false;
f3c21a1d1c62 [project @ 2003-07-09 23:20:18 by jwe]
jwe
parents: 4324
diff changeset
111
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
112 void
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
113 reset_error_handler (void)
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
114 {
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4452
diff changeset
115 buffer_error_messages = 0;
4318
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
116 discard_error_messages = false;
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
117 }
115bffcecfd3 [project @ 2003-02-13 05:52:16 by jwe]
jwe
parents: 4233
diff changeset
118
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
119 static void
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
120 initialize_warning_options (const std::string& state)
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
121 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
122 octave_scalar_map initw;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
123
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
124 initw.setfield ("identifier", "all");
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
125 initw.setfield ("state", state);
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
126
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
127 warning_options = initw;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
128 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
129
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
130 static octave_map
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
131 initialize_last_error_stack (void)
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
132 {
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
133 return octave_call_stack::empty_backtrace ();
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
134 }
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
135
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
136 static void
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
137 verror (bool save_last_error, std::ostream& os,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
138 const char *name, const char *id, const char *fmt, va_list args,
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
139 bool with_cfn = false)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
140 {
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
141 if (discard_error_messages)
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
142 return;
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
143
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
144 if (! buffer_error_messages)
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
145 flush_octave_stdout ();
914
6a10b90623ea [project @ 1994-11-10 21:53:10 by jwe]
jwe
parents: 905
diff changeset
146
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
147 // FIXME: we really want to capture the message before it has all the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
148 // formatting goop attached to it. We probably also want just the
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 // message, not the traceback information.
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
150
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
151 std::ostringstream output_buf;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
152
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
153 octave_vformat (output_buf, fmt, args);
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
154
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
155 std::string base_msg = output_buf.str ();
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
156
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
157 bool to_beep_or_not_to_beep_p = Vbeep_on_error;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
158
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
159 std::string msg_string;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
160
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
161 if (to_beep_or_not_to_beep_p)
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
162 msg_string = "\a";
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
163
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
164 if (name)
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
165 msg_string += std::string (name) + ": ";
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
166
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
167 // If with_fcn is specified, we'll attempt to prefix the message with the name
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
168 // of the current executing function. But we'll do so only if:
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
169 // 1. the name is not empty (anonymous function)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
170 // 2. it is not already there (including the following colon)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
171 if (with_cfn)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
172 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
173 octave_function *curfcn = octave_call_stack::current ();
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
174 if (curfcn)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
175 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
176 std::string cfn = curfcn->name ();
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
177 if (! cfn.empty ())
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
178 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
179 cfn += ':';
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
180 if (cfn.length () > base_msg.length ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
181 || base_msg.compare (0, cfn.length (), cfn) != 0)
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
182 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
183 msg_string += cfn + ' ';
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
184 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
185 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
186 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
187 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
188
7880
7609a985a052 verror fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
189 msg_string += base_msg + "\n";
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
190
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
191 if (save_last_error)
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
192 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
193 // This is the first error in a possible series.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
194
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
195 Vlast_error_id = id;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
196 Vlast_error_message = base_msg;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
197
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
198 octave_user_code *fcn = octave_call_stack::caller_user_code ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
199
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7734
diff changeset
200 if (fcn)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
201 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
202 octave_idx_type curr_frame = -1;
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
203
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
204 Vlast_error_stack = octave_call_stack::backtrace (0, curr_frame);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
205 }
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
206 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
207 Vlast_error_stack = initialize_last_error_stack ();
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
208 }
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
209
13987
2c0765c14e4f eliminate unused error message buffer
John W. Eaton <jwe@octave.org>
parents: 13951
diff changeset
210 if (! buffer_error_messages)
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
211 {
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
212 octave_diary << msg_string;
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
213 os << msg_string;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
214 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
215 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
216
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
217 static void
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
218 pr_where_2 (std::ostream& os, const char *fmt, va_list args)
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
219 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
220 if (fmt)
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
221 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
222 if (*fmt)
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
223 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
224 size_t len = strlen (fmt);
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
225
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
226 if (len > 0)
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
227 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
228 if (fmt[len - 1] == '\n')
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
229 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
230 if (len > 1)
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
231 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
232 char *tmp_fmt = strsave (fmt);
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
233 tmp_fmt[len - 1] = '\0';
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
234 verror (false, os, 0, "", tmp_fmt, args);
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
235 delete [] tmp_fmt;
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
236 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
237 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
238 else
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
239 verror (false, os, 0, "", fmt, args);
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
240 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
241 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
242 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
243 else
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
244 panic ("pr_where_2: invalid format");
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
245 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
246
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
247 static void
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
248 pr_where_1 (std::ostream& os, const char *fmt, ...)
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
249 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
250 va_list args;
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
251 va_start (args, fmt);
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
252 pr_where_2 (os, fmt, args);
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
253 va_end (args);
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
254 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
255
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
256 static void
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
257 pr_where (std::ostream& os, const char *who)
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
258 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
259 std::list<octave_call_stack::stack_frame> frames
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
260 = octave_call_stack::backtrace_frames ();
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
261
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
262 size_t nframes = frames.size ();
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
263
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
264 if (nframes > 0)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
265 pr_where_1 (os, "%s: called from\n", who);
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
266
20511
9502e0142c19 Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents: 20181
diff changeset
267 // Print the error message only if it is different from the previous one;
9502e0142c19 Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents: 20181
diff changeset
268 // Makes the output more concise and readable.
9502e0142c19 Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents: 20181
diff changeset
269 frames.unique ();
9502e0142c19 Simplify error output if max_recursion_depth is exceeded (Bug #45843).
Stefan Miereis <stefan.miereis@gmx.de>
parents: 20181
diff changeset
270
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
271 for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin ();
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
272 p != frames.end (); p++)
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
273 {
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
274 const octave_call_stack::stack_frame& elt = *p;
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
275
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
276 std::string fcn_name = elt.fcn_name ();
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
277 int line = elt.line ();
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
278 int column = elt.column ();
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
279
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
280 pr_where_1 (os, " %s at line %d column %d\n",
19421
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
281 fcn_name.c_str (), line, column);
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
282 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
283 }
8b785ca93de7 don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents: 19415
diff changeset
284
20780
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
285 static octave_execution_exception
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
286 make_execution_exception (const char *who)
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
287 {
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
288 std::ostringstream buf;
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
289
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
290 pr_where (buf, who);
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
291
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
292 octave_execution_exception retval;
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
293
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
294 retval.set_stack_trace (buf.str ());
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
295
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
296 return retval;
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
297 }
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
298
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
299 static void
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
300 debug_or_throw_exception (const octave_execution_exception& e,
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
301 bool show_stack_trace = false)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
302 {
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
303 if ((interactive || forced_interactive)
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
304 && Vdebug_on_error && octave_call_stack::caller_user_code ())
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
305 {
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
306 unwind_protect frame;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
307 frame.protect_var (Vdebug_on_error);
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
308 Vdebug_on_error = false;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
309
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
310 tree_evaluator::debug_mode = true;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
311
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
312 tree_evaluator::current_frame = octave_call_stack::current_frame ();
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
313
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
314 if (show_stack_trace)
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
315 pr_where (std::cerr, "error");
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
316
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
317 do_keyboard (octave_value_list ());
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
318 }
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
319 else
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
320 throw e;
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
321 }
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
322
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
323 // Warning messages are never buffered.
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
324
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
325 static void
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
326 vwarning (const char *name, const char *id, const char *fmt, va_list args)
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
327 {
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
328 if (discard_warning_messages)
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
329 return;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
330
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
331 flush_octave_stdout ();
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
332
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
333 std::ostringstream output_buf;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
334
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
335 octave_vformat (output_buf, fmt, args);
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
336
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
337 // FIXME: we really want to capture the message before it has all the
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
338 // formatting goop attached to it. We probably also want just the
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
339 // message, not the traceback information.
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
340
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
341 std::string base_msg = output_buf.str ();
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
342 std::string msg_string;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
343
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
344 if (name)
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
345 msg_string = std::string (name) + ": ";
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
346
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
347 msg_string += base_msg + "\n";
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
348
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
349 Vlast_warning_id = id;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
350 Vlast_warning_message = base_msg;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
351
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
352 if (! Vquiet_warning)
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
353 {
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
354 octave_diary << msg_string;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
355
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
356 std::cerr << msg_string;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
357 }
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
358 }
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
359
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
360 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
361 vmessage (const char *name, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
362 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
363 verror (false, std::cerr, name, "", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
364 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
365
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
366 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
367 message (const char *name, const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
368 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
369 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
370 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
371 vmessage (name, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
372 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
373 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
374
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
375 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
376 vmessage_with_id (const char *name, const char *id, const char *fmt,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
377 va_list args)
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
378 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
379 verror (false, std::cerr, name, id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
380 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
381
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
382 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
383 message_with_id (const char *name, const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
384 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
385 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
386 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
387 vmessage_with_id (name, id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
388 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
389 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
390
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
391 static void
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
392 usage_1 (const octave_execution_exception& e, const char *id,
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
393 const char *fmt, va_list args)
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
394 {
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
395 verror (true, std::cerr, "usage", id, fmt, args);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
396
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
397 debug_or_throw_exception (e);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
398 }
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
399
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
400 static void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
401 usage_1 (const char *id, const char *fmt, va_list args)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
402 {
20780
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
403 usage_1 (make_execution_exception ("usage"), id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
404 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
405
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
406 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
407 vusage (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
408 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
409 usage_1 ("", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
410 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
411
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
412 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
413 usage (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
414 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
415 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
416 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
417 vusage (fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
418 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
419 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
420
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
421 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
422 vusage_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
423 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
424 usage_1 (id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
425 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
426
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
427 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
428 usage_with_id (const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
429 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
430 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
431 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
432 vusage_with_id (id, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
433 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
434 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
435
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
436 static void
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
437 error_1 (const octave_execution_exception& e, std::ostream& os,
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
438 const char *name, const char *id, const char *fmt,
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
439 va_list args, bool with_cfn = false)
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
440 {
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
441 bool show_stack_trace = false;
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
442
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
443 if (fmt)
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
444 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
445 if (*fmt)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
446 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
447 size_t len = strlen (fmt);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
448
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
449 if (len > 0)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
450 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
451 if (fmt[len - 1] == '\n')
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
452 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
453 if (len > 1)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
454 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
455 char *tmp_fmt = strsave (fmt);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
456 tmp_fmt[len - 1] = '\0';
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
457 verror (true, os, name, id, tmp_fmt, args, with_cfn);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
458 delete [] tmp_fmt;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
459 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
460 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
461 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
462 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
463 verror (true, os, name, id, fmt, args, with_cfn);
18742
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
464
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
465 bool in_user_code = octave_call_stack::caller_user_code () != 0;
18742
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
466
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
467 if (in_user_code && ! discard_error_messages)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
468 show_stack_trace = true;
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
469 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
470 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
471 }
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
472 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
473 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
474 panic ("error_1: invalid format");
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
475
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
476 debug_or_throw_exception (e, show_stack_trace);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
477 }
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
478
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
479 static void
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
480 error_1 (std::ostream& os, const char *name, const char *id,
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
481 const char *fmt, va_list args, bool with_cfn = false)
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
482 {
20780
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
483 error_1 (make_execution_exception ("error"), os, name, id, fmt,
92958b1ee100 restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents: 20777
diff changeset
484 args, with_cfn);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
485 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
486
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
487 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
488 verror (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
489 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
490 error_1 (std::cerr, "error", "", fmt, args);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
491 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
492
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
493 void
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
494 error (const char *fmt, ...)
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
495 {
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
496 va_list args;
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
497 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
498 verror (fmt, args);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
499 va_end (args);
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
500 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
501
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
502 void
20756
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
503 verror (const octave_execution_exception& e, const char *fmt, va_list args)
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
504 {
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
505 error_1 (e, std::cerr, "error", "", fmt, args);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
506 }
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
507
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
508 void
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
509 error (const octave_execution_exception& e, const char *fmt, ...)
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
510 {
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
511 va_list args;
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
512 va_start (args, fmt);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
513 verror (e, fmt, args);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
514 va_end (args);
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
515 }
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
516
200ae1d650b7 propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
517 void
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
518 verror_with_cfn (const char *fmt, va_list args)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
519 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
520 error_1 (std::cerr, "error", "", fmt, args, true);
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
521 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
522
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
523 void
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
524 error_with_cfn (const char *fmt, ...)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
525 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
526 va_list args;
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
527 va_start (args, fmt);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
528 verror_with_cfn (fmt, args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
529 va_end (args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
530 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
531
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
532 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
533 verror_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
534 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
535 error_1 (std::cerr, "error", id, fmt, args);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
536 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
537
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
538 void
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
539 error_with_id (const char *id, const char *fmt, ...)
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
540 {
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
541 va_list args;
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
542 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
543 verror_with_id (id, fmt, args);
6000
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
544 va_end (args);
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
545 }
fbe7ccb47f62 [project @ 2006-09-26 15:43:44 by jwe]
jwe
parents: 5998
diff changeset
546
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
547 void
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
548 verror_with_id_cfn (const char *id, const char *fmt, va_list args)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
549 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
550 error_1 (std::cerr, "error", id, fmt, args, true);
9753
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
551 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
552
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
553 void
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
554 error_with_id_cfn (const char *id, const char *fmt, ...)
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
555 {
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
556 va_list args;
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
557 va_start (args, fmt);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
558 verror_with_id_cfn (id, fmt, args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
559 va_end (args);
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
560 }
892e2aa7bc75 improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents: 9675
diff changeset
561
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
562 static int
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
563 check_state (const std::string& state)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
564 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
565 // -1: not found
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
566 // 0: found, "off"
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
567 // 1: found, "on"
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
568 // 2: found, "error"
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
569
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
570 if (state == "off")
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
571 return 0;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
572 else if (state == "on")
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
573 return 1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
574 else if (state == "error")
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
575 return 2;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
576 else
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
577 return -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
578 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
579
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
580 // For given warning ID, return 0 if warnings are disabled, 1 if
14042
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
581 // enabled, and 2 if the given ID should be an error instead of a
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
582 // warning.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
583
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
584 int
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
585 warning_enabled (const std::string& id)
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
586 {
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
587 int retval = 0;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
588
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
589 int all_state = -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
590 int id_state = -1;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
591
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
592 octave_idx_type nel = warning_options.numel ();
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
593
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
594 if (nel > 0)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
595 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
596 Cell identifier = warning_options.contents ("identifier");
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
597 Cell state = warning_options.contents ("state");
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
598
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
599 bool all_found = false;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
600 bool id_found = false;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
601
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
602 for (octave_idx_type i = 0; i < nel; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
603 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
604 octave_value ov = identifier(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
605 std::string ovs = ov.string_value ();
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
606
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
607 if (! all_found && ovs == "all")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
608 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
609 all_state = check_state (state(i).string_value ());
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
610
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
611 if (all_state >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
612 all_found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
613 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
614
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
615 if (! id_found && ovs == id)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
616 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
617 id_state = check_state (state(i).string_value ());
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
618
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
619 if (id_state >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
620 id_found = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
621 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
622
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
623 if (all_found && id_found)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
624 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
625 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
626 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
627
14042
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
628 // If "all" is not present, assume warnings are enabled.
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
629 if (all_state == -1)
14042
57e19c30b7d6 assume "all" "on" if "all" is not present in warning_state structure (bug #35050)
John W. Eaton <jwe@octave.org>
parents: 13987
diff changeset
630 all_state = 1;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
631
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
632 if (all_state == 0)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
633 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
634 if (id_state >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
635 retval = id_state;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
636 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
637 else if (all_state == 1)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
638 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
639 if (id_state == 0 || id_state == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
640 retval = id_state;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
641 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
642 retval = all_state;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
643 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
644 else if (all_state == 2)
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
645 {
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
646 if (id_state == 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
647 retval= id_state;
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
648 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
649 retval = all_state;
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
650 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
651
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
652 return retval;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
653 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
654
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
655 static void
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
656 warning_1 (const char *id, const char *fmt, va_list args)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
657 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
658 int warn_opt = warning_enabled (id);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
659
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
660 if (warn_opt == 2)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
661 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
662 // Handle this warning as an error.
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
663
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
664 error_1 (std::cerr, "error", id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
665 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
666 else if (warn_opt == 1)
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
667 {
20140
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
668 bool fmt_suppresses_backtrace = false;
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
669 size_t fmt_len = fmt ? strlen (fmt) : 0;
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
670 fmt_suppresses_backtrace = (fmt_len > 0 && fmt[fmt_len-1] == '\n');
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
671
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
672 if (fmt_suppresses_backtrace && fmt_len > 1)
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
673 {
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
674 // Strip newline before issuing warning
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
675 std::string tmp_fmt (fmt, fmt_len - 1);
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
676 vwarning ("warning", id, tmp_fmt.c_str (), args);
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
677 }
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
678 else
64a2d4c87ecb Don't save "warning: " prefix in lastwarn() message.
Rik <rik@octave.org>
parents: 20130
diff changeset
679 vwarning ("warning", id, fmt, args);
8973
ddea8b06ed7c fix warning backtrace
John W. Eaton <jwe@octave.org>
parents: 8950
diff changeset
680
20127
a42de4173533 also provide stack traces for errors in script files (bug #44862)
John W. Eaton <jwe@octave.org>
parents: 20101
diff changeset
681 bool in_user_code = octave_call_stack::caller_user_code () != 0;
a42de4173533 also provide stack traces for errors in script files (bug #44862)
John W. Eaton <jwe@octave.org>
parents: 20101
diff changeset
682
20130
0aed244dbdb3 don't print stack trace if warning format ends with newline character
John W. Eaton <jwe@octave.org>
parents: 20127
diff changeset
683 if (! fmt_suppresses_backtrace && in_user_code
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
684 && Vbacktrace_on_warning
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
685 && ! discard_warning_messages)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
686 pr_where (std::cerr, "warning");
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
687
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
688 if ((interactive || forced_interactive)
20127
a42de4173533 also provide stack traces for errors in script files (bug #44862)
John W. Eaton <jwe@octave.org>
parents: 20101
diff changeset
689 && Vdebug_on_warning && in_user_code)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
690 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9753
diff changeset
691 unwind_protect frame;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
692 frame.protect_var (Vdebug_on_warning);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
693 Vdebug_on_warning = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
694
18742
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
695 tree_evaluator::debug_mode = true;
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
696
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
697 tree_evaluator::current_frame = octave_call_stack::current_frame ();
bd334b6af257 Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents: 18222
diff changeset
698
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
699 do_keyboard (octave_value_list ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
700 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
701 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
702 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
703
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
704 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
705 vwarning (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
706 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
707 warning_1 ("", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
708 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
709
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
710 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
711 warning (const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
712 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
713 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
714 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
715 vwarning (fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
716 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
717 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
718
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
719 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
720 vwarning_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
721 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
722 warning_1 (id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
723 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
724
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
725 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
726 warning_with_id (const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
727 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
728 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
729 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
730 vwarning_with_id (id, fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
731 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
732 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
733
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
734 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
735 vparse_error (const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
736 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
737 error_1 (std::cerr, 0, "", fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
738 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
739
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
740 void
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
741 parse_error (const char *fmt, ...)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
742 {
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
743 va_list args;
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
744 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
745 vparse_error (fmt, args);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
746 va_end (args);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
747 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
748
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
749 void
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
750 vparse_error_with_id (const char *id, const char *fmt, va_list args)
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
751 {
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
752 error_1 (std::cerr, 0, id, fmt, args);
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
753 }
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
754
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
755 void
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
756 parse_error_with_id (const char *id, const char *fmt, ...)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
757 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
758 va_list args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
759 va_start (args, fmt);
6338
ec88b4ab6d10 [project @ 2007-02-22 07:07:19 by jwe]
jwe
parents: 6000
diff changeset
760 vparse_error_with_id (id, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
761 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
762 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
763
189
de0e58f9b064 [project @ 1993-10-28 08:52:15 by jwe]
jwe
parents: 169
diff changeset
764 void
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
765 rethrow_error (const char *id, const char *fmt, ...)
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
766 {
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
767 va_list args;
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
768 va_start (args, fmt);
6640
379244420c72 [project @ 2007-05-21 19:50:45 by jwe]
jwe
parents: 6483
diff changeset
769 error_1 (std::cerr, 0, id, fmt, args);
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
770 va_end (args);
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
771 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
772
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
773 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
774 panic (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
775 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
776 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
777 va_start (args, fmt);
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4452
diff changeset
778 buffer_error_messages = 0;
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
779 discard_error_messages = false;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
780 verror (false, std::cerr, "panic", "", fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
781 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
782 abort ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
783 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
784
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
785 static void
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
786 defun_usage_message_1 (const char *fmt, ...)
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
787 {
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
788 va_list args;
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
789 va_start (args, fmt);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
790 error_1 (octave_stdout, 0, "", fmt, args);
4732
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
791 va_end (args);
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
792 }
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
793
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
794 void
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
795 defun_usage_message (const std::string& msg)
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
796 {
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
797 defun_usage_message_1 ("%s", msg.c_str ());
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
798 }
b484cdca27be [project @ 2004-02-04 04:32:48 by jwe]
jwe
parents: 4731
diff changeset
799
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
800 typedef void (*error_fun)(const char *, const char *, ...);
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
801
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
802 extern octave_value_list Fsprintf (const octave_value_list&, int);
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
803
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
804 static std::string
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
805 handle_message (error_fun f, const char *id, const char *msg,
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
806 const octave_value_list& args, bool have_fmt)
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
807 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
808 std::string retval;
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
809
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
810 std::string tstr;
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
811
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
812 int nargin = args.length ();
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
813
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
814 if (nargin > 0)
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
815 {
3066
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
816 octave_value arg;
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
817
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
818 if (have_fmt)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
819 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
820 octave_value_list tmp = Fsprintf (args, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
821 arg = tmp(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
822 }
3066
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
823 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
824 arg = args(0);
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
825
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
826 if (arg.is_defined ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
827 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
828 if (arg.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
829 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
830 tstr = arg.string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
831 msg = tstr.c_str ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
832
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
833 if (! msg)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
834 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
835 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
836 else if (arg.is_empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
837 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
838 }
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
839 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
840
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
841 // Ugh.
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
842
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
843 size_t len = strlen (msg);
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
844
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
845 if (len > 0)
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
846 {
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
847 if (msg[len - 1] == '\n')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
848 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
849 if (len > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
850 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
851 char *tmp_msg = strsave (msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
852 tmp_msg[len - 1] = '\0';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
853 f (id, "%s\n", tmp_msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
854 retval = tmp_msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
855 delete [] tmp_msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
856 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
857 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
858 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
859 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
860 f (id, "%s", msg);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
861 retval = msg;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
862 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
863 }
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
864
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
865 return retval;
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
866 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
867
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
868 DEFUN (rethrow, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
869 "-*- texinfo -*-\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
870 @deftypefn {Built-in Function} {} rethrow (@var{err})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
871 Reissue a previous error as defined by @var{err}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
872 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
873 @var{err} is a structure that must contain at least the @qcode{\"message\"}\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
874 and @qcode{\"identifier\"} fields. @var{err} can also contain a field\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
875 @qcode{\"stack\"} that gives information on the assumed location of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
876 error. Typically @var{err} is returned from @code{lasterror}.\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
877 @seealso{lasterror, lasterr, error}\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
878 @end deftypefn")
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
879 {
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
880 octave_value retval;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
881 int nargin = args.length ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
882
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
883 if (nargin != 1)
6959
47f4f4e88166 [project @ 2007-10-04 20:43:32 by jwe]
jwe
parents: 6671
diff changeset
884 print_usage ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
885 else
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
886 {
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10605
diff changeset
887 const octave_scalar_map err = args(0).scalar_map_value ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
888
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
889 if (err.contains ("message") && err.contains ("identifier"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
890 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
891 std::string msg = err.contents ("message").string_value ();
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
892 std::string id = err.contents ("identifier").string_value ();
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
893 int len = msg.length ();
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
894
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
895 std::string file;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
896 std::string nm;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
897 int l = -1;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
898 int c = -1;
6483
d00da2148c53 [project @ 2007-04-04 02:58:48 by jwe]
jwe
parents: 6427
diff changeset
899
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
900 octave_map err_stack = initialize_last_error_stack ();
6640
379244420c72 [project @ 2007-05-21 19:50:45 by jwe]
jwe
parents: 6483
diff changeset
901
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
902 if (err.contains ("stack"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
903 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
904 err_stack = err.contents ("stack").map_value ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
905
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
906 if (err_stack.numel () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
907 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
908 if (err_stack.contains ("file"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
909 file = err_stack.contents ("file")(0).string_value ();
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
910
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
911 if (err_stack.contains ("name"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
912 nm = err_stack.contents ("name")(0).string_value ();
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
913
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
914 if (err_stack.contains ("line"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
915 l = err_stack.contents ("line")(0).nint_value ();
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
916
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
917 if (err_stack.contains ("column"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
918 c = err_stack.contents ("column")(0).nint_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
919 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
920 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
921
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
922 // Ugh.
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
923 char *tmp_msg = strsave (msg.c_str ());
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
924 if (tmp_msg[len-1] == '\n')
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
925 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
926 if (len > 1)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
927 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
928 tmp_msg[len - 1] = '\0';
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
929 rethrow_error (id.c_str (), "%s\n", tmp_msg);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
930 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
931 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
932 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
933 rethrow_error (id.c_str (), "%s", tmp_msg);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
934 delete [] tmp_msg;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
935
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
936 // FIXME: is this the right thing to do for Vlast_error_stack?
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
937 // Should it be saved and restored with unwind_protect?
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
938
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
939 Vlast_error_stack = err_stack;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
940
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
941 if (err.contains ("stack"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
942 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
943 if (file.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
944 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
945 if (nm.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
946 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
947 if (l > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
948 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
949 if (c > 0)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
950 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
951 "error: near line %d, column %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
952 l, c);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
953 else
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
954 pr_where_1 (std::cerr, "error: near line %d", l);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
955 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
956 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
957 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
958 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
959 if (l > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
960 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
961 if (c > 0)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
962 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
963 "error: called from '%s' near line %d, column %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
964 nm.c_str (), l, c);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
965 else
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
966 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
967 "error: called from '%d' near line %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
968 nm.c_str (), l);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
969 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
970 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
971 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
972 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
973 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
974 if (nm.empty ())
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
975 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
976 if (l > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
977 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
978 if (c > 0)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
979 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
980 "error: in file %s near line %d, column %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
981 file.c_str (), l, c);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
982 else
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
983 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
984 "error: in file %s near line %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
985 file.c_str (), l);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
986 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
987 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
988 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
989 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
990 if (l > 0)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
991 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
992 if (c > 0)
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
993 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
994 "error: called from '%s' in file %s near line %d, column %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
995 nm.c_str (), file.c_str (), l, c);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
996 else
20666
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
997 pr_where_1 (std::cerr,
e0e2c2ce7e94 defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents: 20535
diff changeset
998 "error: called from '%d' in file %s near line %d",
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
999 nm.c_str (), file.c_str (), l);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1000 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1001 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1002 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1003 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1004 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1005 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1006 error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1007 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1008 return retval;
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1009 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1010
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1011 // Determine whether the first argument to error or warning function
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1012 // should be handled as the message identifier or as the format string.
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1013
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1014 static bool
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1015 maybe_extract_message_id (const std::string& caller,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1016 const octave_value_list& args,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1017 octave_value_list& nargs,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1018 std::string& id)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1019 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1020 nargs = args;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1021 id = std::string ();
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1022
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1023 int nargin = args.length ();
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1024
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1025 bool have_fmt = nargin > 1;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1026
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1027 if (nargin > 0)
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1028 {
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1029 std::string arg1 = args(0).string_value ();
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1030
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1031 // For compatibility with Matlab, an identifier must contain
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1032 // ':', but not at the beginning or the end, and it must not
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1033 // contain '%' (even if it is not a valid conversion
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1034 // operator) or whitespace.
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1035
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1036 if (arg1.find_first_of ("% \f\n\r\t\v") == std::string::npos
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1037 && arg1.find (':') != std::string::npos
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1038 && arg1[0] != ':'
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1039 && arg1[arg1.length ()-1] != ':')
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1040 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1041 if (nargin > 1)
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1042 {
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1043 id = arg1;
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1044
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1045 nargs.resize (nargin-1);
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1046
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1047 for (int i = 1; i < nargin; i++)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1048 nargs(i-1) = args(i);
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1049 }
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1050 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1051 nargs(0) = "call to " + caller
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1052 + " with message identifier requires message";
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1053 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1054 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1055
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1056 return have_fmt;
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1057 }
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1058
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
1059 DEFUN (error, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1060 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1061 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1062 @deftypefnx {Built-in Function} {} error (@var{id}, @var{template}, @dots{})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1063 Display an error message and stop m-file execution.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1064 \n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1065 Format the optional arguments under the control of the template string\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1066 @var{template} using the same rules as the @code{printf} family of\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1067 functions (@pxref{Formatted Output}) and print the resulting message\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1068 on the @code{stderr} stream. The message is prefixed by the character\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1069 string @samp{error: }.\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1070 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1071 Calling @code{error} also sets Octave's internal error state such that\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1072 control will return to the top level without evaluating any further\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1073 commands. This is useful for aborting from functions or scripts.\n\
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1074 \n\
19334
1213af866a89 doc: Fix backslash not showing in error/warning docs due to escape processing.
Rik <rik@octave.org>
parents: 18126
diff changeset
1075 If the error message does not end with a newline character, Octave will\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1076 print a traceback of all the function calls leading to the error. For\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1077 example, given the following function definitions:\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1078 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1079 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1080 @group\n\
6671
9042b00fc45e [project @ 2007-05-30 06:33:29 by jwe]
jwe
parents: 6653
diff changeset
1081 function f () g (); end\n\
9042b00fc45e [project @ 2007-05-30 06:33:29 by jwe]
jwe
parents: 6653
diff changeset
1082 function g () h (); end\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1083 function h () nargin == 1 || error (\"nargin != 1\"); end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1084 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1085 @end example\n\
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1086 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1087 @noindent\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1088 calling the function @code{f} will result in a list of messages that\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1089 can help you to quickly locate the exact location of the error:\n\
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1090 \n\
9153
5247e89688e1 Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents: 9039
diff changeset
1091 @example\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1092 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1093 f ()\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1094 error: nargin != 1\n\
8015
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1095 error: called from:\n\
30629059b72d Update the manual to reflect the changes in error output
sh@sh-laptop
parents: 7977
diff changeset
1096 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
1097 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
1098 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
1099 error: f at line 1, column 15\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1100 @end group\n\
9153
5247e89688e1 Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents: 9039
diff changeset
1101 @end example\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1102 \n\
19334
1213af866a89 doc: Fix backslash not showing in error/warning docs due to escape processing.
Rik <rik@octave.org>
parents: 18126
diff changeset
1103 If the error message ends in a newline character, Octave will print the\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1104 message but will not display any traceback messages as it returns\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1105 control to the top level. For example, modifying the error message\n\
19334
1213af866a89 doc: Fix backslash not showing in error/warning docs due to escape processing.
Rik <rik@octave.org>
parents: 18126
diff changeset
1106 in the previous example to end in a newline causes Octave to only print\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1107 a single message:\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1108 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1109 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1110 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1111 function h () nargin == 1 || error (\"nargin != 1\\n\"); end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1112 f ()\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1113 error: nargin != 1\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1114 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1115 @end example\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1116 \n\
16770
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1117 A null string (\"\") input to @code{error} will be ignored and the code\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1118 will continue running as if the statement were a NOP@. This is for\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1119 compatibility with @sc{matlab}. It also makes it possible to write code such\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1120 as\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1121 \n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1122 @example\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1123 @group\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1124 err_msg = \"\";\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1125 if (CONDITION 1)\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1126 err_msg = \"CONDITION 1 found\";\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1127 elseif (CONDITION2)\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1128 err_msg = \"CONDITION 2 found\";\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1129 @dots{}\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1130 endif\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1131 error (err_msg);\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1132 @end group\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1133 @end example\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1134 \n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1135 @noindent\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1136 which will only stop execution if an error has been found.\n\
2b86cb4e172b doc: clarify docstring regarding null input to error() (bug #39271).
Rik <rik@octave.org>
parents: 16492
diff changeset
1137 \n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1138 Implementation Note: For compatibility with @sc{matlab}, escape\n\
20101
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1139 sequences in @var{template} (e.g., @qcode{\"@xbackslashchar{}n\"} =>\n\
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1140 newline) are processed regardless of whether @var{template} has been defined\n\
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1141 with single quotes, as long as there are two or more input arguments. To\n\
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1142 disable escape sequence expansion use a second backslash before the sequence\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1143 (e.g., @qcode{\"@xbackslashchar{}@xbackslashchar{}n\"}) or use the\n\
20101
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1144 @code{regexptranslate} function.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1145 @seealso{warning, lasterror}\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1146 @end deftypefn")
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1147 {
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1148 octave_value retval;
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1149
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1150 int nargin = args.length ();
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1151
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1152 octave_value_list nargs = args;
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1153
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1154 std::string id;
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1155
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1156 if (nargin == 0)
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1157 print_usage ();
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1158 else
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1159 {
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1160 bool have_fmt = false;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1161
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1162 if (nargin == 1 && args(0).is_map ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1163 {
13709
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1164 // empty struct is not an error. return and resume calling function.
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1165 if (args(0).is_empty ())
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1166 return retval;
a0875c6cab7e error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents: 12705
diff changeset
1167
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1168 octave_value_list tmp;
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1169
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1170 octave_scalar_map m = args(0).scalar_map_value ();
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1171
12705
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1172 // empty struct is not an error. return and resume calling function.
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1173 if (m.nfields () == 0)
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1174 return retval;
4972eb61c6d6 Fix bug with error() not accepting an empty struct input (Bug #33428).
Rik <octave@nomad.inbox5.com>
parents: 12704
diff changeset
1175
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1176 if (m.contains ("message"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1177 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1178 octave_value c = m.getfield ("message");
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1179
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1180 if (c.is_string ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1181 nargs(0) = c.string_value ();
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1182 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1183
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1184 if (m.contains ("identifier"))
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1185 {
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1186 octave_value c = m.getfield ("identifier");
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1187
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1188 if (c.is_string ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1189 id = c.string_value ();
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1190 }
9675
ef45d191d833 error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents: 9588
diff changeset
1191
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1192 // FIXME: also need to handle "stack" field in error structure,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1193 // but that will require some more significant surgery on
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1194 // handle_message, error_with_id, etc.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1195 }
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1196 else
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1197 have_fmt = maybe_extract_message_id ("error", args, nargs, id);
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1198
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1199 handle_message (error_with_id, id.c_str (), "unspecified error",
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1200 nargs, have_fmt);
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1201 }
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1202
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1203 return retval;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1204 }
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
1205
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1206 static octave_scalar_map
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1207 warning_query (const std::string& id_arg)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1208 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1209 octave_scalar_map retval;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1210
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1211 std::string id = id_arg;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1212
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1213 if (id == "last")
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1214 id = Vlast_warning_id;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1215
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1216 Cell ident = warning_options.contents ("identifier");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1217 Cell state = warning_options.contents ("state");
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1218
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1219 octave_idx_type nel = ident.numel ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1220
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1221 assert (nel != 0);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1222
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1223 bool found = false;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1224
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1225 std::string val;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1226
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1227 for (octave_idx_type i = 0; i < nel; i++)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1228 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1229 if (ident(i).string_value () == id)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1230 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1231 val = state(i).string_value ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1232 found = true;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1233 break;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1234 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1235 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1236
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1237 if (! found)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1238 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1239 for (octave_idx_type i = 0; i < nel; i++)
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1240 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1241 if (ident(i).string_value () == "all")
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1242 {
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1243 val = state(i).string_value ();
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1244 found = true;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1245 break;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1246 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1247 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1248 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1249
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1250 // The warning state "all" is always supposed to remain in the list,
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1251 // so we should always find a state, either explicitly or by using the
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1252 // state for "all".
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1253
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1254 assert (found);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1255
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1256 retval.assign ("identifier", id);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1257 retval.assign ("state", val);
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1258
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1259 return retval;
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1260 }
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1261
19439
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1262 static std::string
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1263 default_warning_state (void)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1264 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1265 std::string retval = "on";
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1266
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1267 Cell ident = warning_options.contents ("identifier");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1268 Cell state = warning_options.contents ("state");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1269
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1270 octave_idx_type nel = ident.numel ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1271
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1272 for (octave_idx_type i = 0; i < nel; i++)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1273 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1274 if (ident(i).string_value () == "all")
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1275 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1276 retval = state(i).string_value ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1277 break;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1278 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1279 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1280
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1281 return retval;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1282 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1283
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1284 static void
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1285 display_warning_options (std::ostream& os)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1286 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1287 Cell ident = warning_options.contents ("identifier");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1288 Cell state = warning_options.contents ("state");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1289
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1290 octave_idx_type nel = ident.numel ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1291
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1292 std::string all_state = default_warning_state ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1293
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1294 if (all_state == "on")
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1295 os << "By default, warnings are enabled.";
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1296 else if (all_state == "off")
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1297 os << "By default, warnings are disabled.";
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1298 else if (all_state == "error")
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1299 os << "By default, warnings are treated as errors.";
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1300 else
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1301 panic_impossible ();
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19444
diff changeset
1302
19439
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1303 if (nel > 1)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1304 os << "\n\n";
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1305
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1306 // The state for all is always supposed to be first in the list.
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1307
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1308 for (octave_idx_type i = 1; i < nel; i++)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1309 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1310 std::string tid = ident(i).string_value ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1311 std::string tst = state(i).string_value ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1312
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1313 os << std::setw (7) << tst << " " << tid << "\n";
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1314 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1315
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1316 os << std::endl;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1317 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1318
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1319 static void
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1320 set_warning_option (const std::string& state, const std::string& ident)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1321 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1322 if (ident == "all")
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1323 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1324 initialize_warning_options (state);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1325 return;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1326 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1327
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1328 std::string all_state = default_warning_state ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1329
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1330 if (state != "on" && state != "off" && state != "error")
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1331 error ("invalid warning state: %s", state.c_str ());
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1332
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1333 Cell tid = warning_options.contents ("identifier");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1334 Cell tst = warning_options.contents ("state");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1335
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1336 octave_idx_type nel = tid.numel ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1337
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1338 for (octave_idx_type i = 0; i < nel; i++)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1339 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1340 if (tid(i).string_value () == ident)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1341 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1342 // We found it in the current list of options. If the state
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1343 // for "all" is same as arg1, we can simply remove the item
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1344 // from the list.
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1345
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1346 if (state == all_state)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1347 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1348 for (i = i + 1; i < nel; i++)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1349 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1350 tid(i-1) = tid(i);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1351 tst(i-1) = tst(i);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1352 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1353
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1354 tid.resize (dim_vector (1, nel-1));
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1355 tst.resize (dim_vector (1, nel-1));
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1356 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1357 else
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1358 tst(i) = state;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1359
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1360 warning_options.clear ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1361
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1362 warning_options.assign ("identifier", tid);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1363 warning_options.assign ("state", tst);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1364
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1365 return;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1366 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1367 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1368
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1369 // The option wasn't already in the list. Append it.
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1370
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1371 tid.resize (dim_vector (1, nel+1));
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1372 tst.resize (dim_vector (1, nel+1));
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1373
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1374 tid(nel) = ident;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1375 tst(nel) = state;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1376
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1377 warning_options.clear ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1378
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1379 warning_options.assign ("identifier", tid);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1380 warning_options.assign ("state", tst);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1381 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1382
8746
5dd06f19e9be handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents: 8347
diff changeset
1383 DEFUN (warning, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1384 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1385 @deftypefn {Built-in Function} {} warning (@var{template}, @dots{})\n\
7252
d35fa45980c6 [project @ 2007-12-04 19:02:46 by jwe]
jwe
parents: 7206
diff changeset
1386 @deftypefnx {Built-in Function} {} warning (@var{id}, @var{template}, @dots{})\n\
14072
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1387 @deftypefnx {Built-in Function} {} warning (\"on\", @var{id})\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1388 @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1389 @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1390 @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\
18128
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
1391 @deftypefnx {Built-in Function} {} warning (@var{state}, \"backtrace\")\n\
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1392 @deftypefnx {Built-in Function} {} warning (@var{state}, @var{id}, \"local\")\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1393 Display a warning message or control the behavior of Octave's warning system.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1394 \n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1395 Format the optional arguments under the control of the template string\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1396 @var{template} using the same rules as the @code{printf} family of\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1397 functions (@pxref{Formatted Output}) and print the resulting message\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1398 on the @code{stderr} stream. The message is prefixed by the character\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1399 string @samp{warning: }.\n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1400 You should use this function when you want to notify the user\n\
3600
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3585
diff changeset
1401 of an unusual condition, but only when it makes sense for your program\n\
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3585
diff changeset
1402 to go on.\n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1403 \n\
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1404 The optional message identifier allows users to enable or disable\n\
15524
15628a84a4fa Document form of warning IDs is NAMESPACE:WARNING-NAME (bug #37559)
Rik <rik@octave.org>
parents: 15466
diff changeset
1405 warnings tagged by @var{id}. A message identifier is of the form\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1406 \"NAMESPACE:WARNING-NAME\". Octave's own warnings use the @qcode{\"Octave\"}\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1407 namespace (@pxref{XREFwarning_ids}). The special identifier @qcode{\"all\"}\n\
15524
15628a84a4fa Document form of warning IDs is NAMESPACE:WARNING-NAME (bug #37559)
Rik <rik@octave.org>
parents: 15466
diff changeset
1408 may be used to set the state of all warnings.\n\
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5775
diff changeset
1409 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1410 If the first argument is @qcode{\"on\"} or @qcode{\"off\"},\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1411 set the state of a particular warning using the identifier @var{id}. If the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1412 first argument is @qcode{\"query\"}, query the state of this warning\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1413 instead. If the identifier is omitted, a value of @qcode{\"all\"} is\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1414 assumed. If you set the state of a warning to @qcode{\"error\"}, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1415 warning named by @var{id} is handled as if it were an error instead. So,\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1416 for example, the following handles all warnings as errors:\n\
14072
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1417 \n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1418 @example\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1419 @group\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1420 warning (\"error\");\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1421 @end group\n\
d0d9c5d2e434 doc: Reformat and clarify warning's docstring
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14055
diff changeset
1422 @end example\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1423 \n\
18128
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
1424 If the state is @qcode{\"on\"} or @qcode{\"off\"} and the third argument\n\
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
1425 is @qcode{\"backtrace\"}, then a stack trace is printed along with the\n\
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
1426 warning message when warnings occur inside function calls. This option\n\
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
1427 is enabled by default.\n\
d96747f74b1e enable "backtrace" warning by default and document option
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
1428 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1429 If the state is @qcode{\"on\"}, @qcode{\"off\"}, or @qcode{\"error\"}\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1430 and the third argument is @qcode{\"local\"}, then the warning state\n\
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1431 will be set temporarily, until the end of the current function.\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1432 Changes to warning states that are set locally affect the current\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1433 function and all functions called from the current scope. The\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1434 previous warning state is restored on return from the current\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1435 function. The @qcode{\"local\"} option is ignored if used in the top-level\n\
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1436 workspace.\n\
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1437 \n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1438 Implementation Note: For compatibility with @sc{matlab}, escape\n\
20101
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1439 sequences in @var{template} (e.g., @qcode{\"@xbackslashchar{}n\"} =>\n\
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1440 newline) are processed regardless of whether @var{template} has been defined\n\
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1441 with single quotes, as long as there are two or more input arguments. To\n\
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1442 disable escape sequence expansion use a second backslash before the sequence\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1443 (e.g., @qcode{\"@xbackslashchar{}@xbackslashchar{}n\"}) or use the\n\
20101
e51473fdb622 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 20041
diff changeset
1444 @code{regexptranslate} function.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1445 @seealso{warning_ids, lastwarn, error}\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
1446 @end deftypefn")
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
1447 {
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1448 octave_value retval;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1449
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1450 int nargin = args.length ();
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1451 int argc = nargin + 1;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1452
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1453 bool done = false;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1454
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1455 if (argc > 1 && args.all_strings_p ())
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1456 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1457 string_vector argv = args.make_argv ("warning");
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1458
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1459 std::string arg1 = argv(1);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1460 std::string arg2 = "all";
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1461
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1462 if (argc >= 3)
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1463 arg2 = argv(2);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1464
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1465 if (arg1 == "on" || arg1 == "off" || arg1 == "error")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1466 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1467 octave_map old_warning_options = warning_options;
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1468
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1469 if (argc == 4 && argv(3) == "local"
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1470 && ! symbol_table::at_top_level ())
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1471 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1472 symbol_table::scope_id scope
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1473 = octave_call_stack::current_scope ();
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1474
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1475 symbol_table::context_id context
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1476 = octave_call_stack::current_context ();
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1477
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1478 octave_scalar_map val = warning_query (arg2);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1479
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1480 octave_value curr_state = val.contents ("state");
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1481
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1482 // FIXME: this might be better with a dictionary object.
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1483
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1484 octave_value curr_warning_states
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1485 = symbol_table::varval (".saved_warning_states.",
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1486 scope, context);
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1487
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1488 octave_map m;
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1489
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1490 if (curr_warning_states.is_defined ())
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1491 m = curr_warning_states.map_value ();
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1492 else
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1493 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1494 string_vector fields (2);
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1495
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1496 fields(0) = "identifier";
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1497 fields(1) = "state";
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1498
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1499 m = octave_map (dim_vector (0, 1), fields);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1500 }
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1501
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1502 Cell ids = m.contents ("identifier");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1503 Cell states = m.contents ("state");
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1504
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1505 octave_idx_type nel = states.numel ();
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1506 bool found = false;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1507 octave_idx_type i;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1508 for (i = 0; i < nel; i++)
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1509 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1510 std::string id = ids(i).string_value ();
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1511
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1512 if (id == arg2)
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1513 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1514 states(i) = curr_state;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1515 found = true;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1516 break;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1517 }
15427
6823ad7a25b1 implement local option for warnings
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1518 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1519
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1520 if (! found)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1521 {
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1522 m.resize (dim_vector (nel+1, 1));
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1523
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1524 ids.resize (dim_vector (nel+1, 1));
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1525 states.resize (dim_vector (nel+1, 1));
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1526
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1527 ids(nel) = arg2;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1528 states(nel) = curr_state;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1529 }
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1530
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1531 m.contents ("identifier") = ids;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1532 m.contents ("state") = states;
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1533
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1534 symbol_table::assign
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1535 (".saved_warning_states.", m, scope, context);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1536
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1537 // Now ignore the "local" argument and continue to
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1538 // handle the current setting.
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1539 argc--;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1540 }
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1541
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1542 if (arg2 == "all")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1543 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1544 octave_map tmp;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1545
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1546 Cell id (1, 1);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1547 Cell st (1, 1);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1548
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1549 id(0) = arg2;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1550 st(0) = arg1;
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
1551
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1552 // Since internal Octave functions are not
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1553 // compatible, turning all warnings into errors
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1554 // should leave the state of
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1555 // Octave:language-extension alone.
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1556
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1557 if (arg1 == "error"
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1558 && warning_options.contains ("identifier"))
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1559 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1560 octave_idx_type n = 1;
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1561
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1562 Cell tid = warning_options.contents ("identifier");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1563 Cell tst = warning_options.contents ("state");
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1564
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1565 for (octave_idx_type i = 0; i < tid.numel (); i++)
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1566 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1567 octave_value vid = tid(i);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1568
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1569 if (vid.is_string ())
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1570 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1571 std::string key = vid.string_value ();
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7031
diff changeset
1572
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1573 if (key == "Octave:language-extension"
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1574 || key == "Octave:single-quote-string")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1575 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1576 id.resize (dim_vector (1, n+1));
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1577 st.resize (dim_vector (1, n+1));
7206
6e4ceeeb1940 [project @ 2007-11-27 22:40:20 by jwe]
jwe
parents: 7202
diff changeset
1578
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1579 id(n) = tid(i);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1580 st(n) = tst(i);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1581
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1582 n++;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1583 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1584 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1585 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1586 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1587
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1588 tmp.assign ("identifier", id);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1589 tmp.assign ("state", st);
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents: 5567
diff changeset
1590
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1591 warning_options = tmp;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1592
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1593 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1594 }
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1595 else if (arg2 == "backtrace")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1596 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1597 if (arg1 != "error")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1598 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1599 Vbacktrace_on_warning = (arg1 == "on");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1600 done = true;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1601 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1602 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1603 else if (arg2 == "debug")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1604 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1605 if (arg1 != "error")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1606 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1607 Vdebug_on_warning = (arg1 == "on");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1608 done = true;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1609 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1610 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1611 else if (arg2 == "verbose")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1612 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1613 if (arg1 != "error")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1614 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1615 Vverbose_warning = (arg1 == "on");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1616 done = true;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1617 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1618 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1619 else if (arg2 == "quiet")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1620 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1621 if (arg1 != "error")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1622 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1623 Vquiet_warning = (arg1 == "on");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1624 done = true;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1625 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1626 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1627 else
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1628 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1629 if (arg2 == "last")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1630 arg2 = Vlast_warning_id;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1631
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1632 set_warning_option (arg1, arg2);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1633
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1634 done = true;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1635 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1636
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1637 if (done && nargout > 0)
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1638 retval = old_warning_options;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1639 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1640 else if (arg1 == "query")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1641 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1642 if (arg2 == "all")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1643 retval = warning_options;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1644 else if (arg2 == "backtrace" || arg2 == "debug"
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1645 || arg2 == "verbose" || arg2 == "quiet")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1646 {
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1647 octave_scalar_map tmp;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1648 tmp.assign ("identifier", arg2);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1649 if (arg2 == "backtrace")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1650 tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1651 else if (arg2 == "debug")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1652 tmp.assign ("state", Vdebug_on_warning ? "on" : "off");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1653 else if (arg2 == "verbose")
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1654 tmp.assign ("state", Vverbose_warning ? "on" : "off");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1655 else
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1656 tmp.assign ("state", Vquiet_warning ? "on" : "off");
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1657
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1658 retval = tmp;
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1659 }
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1660 else
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1661 retval = warning_query (arg2);
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1662
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1663 done = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1664 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1665 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1666 else if (argc == 1)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1667 {
19439
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1668 if (nargout > 0)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1669 retval = warning_options;
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1670 else
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1671 display_warning_options (octave_stdout);
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1672
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1673 done = true;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1674 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1675 else if (argc == 2)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1676 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1677 octave_value arg = args(0);
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1678
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1679 octave_map old_warning_options = warning_options;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1680
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1681 if (arg.is_map ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1682 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1683 octave_map m = arg.map_value ();
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1684
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1685 if (m.contains ("identifier") && m.contains ("state"))
19439
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1686 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1687 // Simply step through the struct elements one at a time.
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1688
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1689 Cell ident = m.contents ("identifier");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1690 Cell state = m.contents ("state");
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1691
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1692 octave_idx_type nel = ident.numel ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1693
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1694 for (octave_idx_type i = 0; i < nel; i++)
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1695 {
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1696 std::string tst = state(i).string_value ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1697 std::string tid = ident(i).string_value ();
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1698
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1699 set_warning_option (tst, tid);
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1700 }
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1701 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1702 else
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20678
diff changeset
1703 error ("warning: STATE structure must have fields 'identifier' and 'state'");
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1704
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1705 done = true;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1706
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1707 if (nargout > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1708 retval = old_warning_options;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1709 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1710 }
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1711
20678
4b00afb5e9c3 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20666
diff changeset
1712 if (! done)
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1713 {
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1714 octave_value_list nargs = args;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1715
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1716 std::string id;
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1717
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1718 bool have_fmt = maybe_extract_message_id ("warning", args, nargs, id);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1719
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1720 std::string prev_msg = Vlast_warning_message;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1721
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1722 std::string curr_msg = handle_message (warning_with_id, id.c_str (),
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1723 "unspecified warning", nargs,
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
1724 have_fmt);
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1725
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1726 if (nargout > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1727 retval = prev_msg;
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1728 }
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1729
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1730 return retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1731 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
1732
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1733 octave_value_list
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1734 set_warning_state (const std::string& id, const std::string& state)
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1735 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1736 octave_value_list args;
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1737
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1738 args(1) = id;
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1739 args(0) = state;
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1740
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1741 return Fwarning (args, 1);
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1742 }
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1743
10605
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1744 octave_value_list
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1745 set_warning_state (const octave_value_list& args)
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1746 {
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1747 return Fwarning (args, 1);
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1748 }
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1749
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1750 void
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1751 disable_warning (const std::string& id)
1834132fb50b allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents: 10405
diff changeset
1752 {
19439
93fbdbcb3349 fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents: 19421
diff changeset
1753 set_warning_option ("off", id);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1754 }
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1755
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1756 void
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1757 initialize_default_warning_state (void)
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1758 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1759 initialize_warning_options ("on");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1760
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1761 // Most people will want to have the following disabled.
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1762
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1763 disable_warning ("Octave:array-to-scalar");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1764 disable_warning ("Octave:array-to-vector");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1765 disable_warning ("Octave:imag-to-real");
19852
e9a0bd0b125c Rename 'matlab-incompatible' warning to 'language-extension'.
Carnë Draug <carandraug@octave.org>
parents: 19849
diff changeset
1766 disable_warning ("Octave:language-extension");
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1767 disable_warning ("Octave:missing-semicolon");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1768 disable_warning ("Octave:neg-dim-as-zero");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1769 disable_warning ("Octave:resize-on-range-error");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1770 disable_warning ("Octave:separator-insert");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1771 disable_warning ("Octave:single-quote-string");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1772 disable_warning ("Octave:str-to-num");
13841
0a158dbdb04a Remove 3 unused warning ids
Rik <octave@nomad.inbox5.com>
parents: 13709
diff changeset
1773 disable_warning ("Octave:mixed-string-concat");
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1774 disable_warning ("Octave:variable-switch-label");
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1775 }
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
1776
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1777 DEFUN (lasterror, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1778 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
1779 @deftypefn {Built-in Function} {@var{lasterr} =} lasterror ()\n\
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
1780 @deftypefnx {Built-in Function} {} lasterror (@var{err})\n\
14361
8de863b7126b doc: Use Octave preference for double quote in docstrings in all .cc files
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1781 @deftypefnx {Built-in Function} {} lasterror (\"reset\")\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1782 Query or set the last error message structure.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1783 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1784 When called without arguments, return a structure containing the last error\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1785 message and other information related to this error. The elements of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1786 structure are:\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1787 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1788 @table @code\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1789 @item message\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1790 The text of the last error message\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1791 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1792 @item identifier\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1793 The message identifier of this error message\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1794 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1795 @item stack\n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1796 A structure containing information on where the message occurred. This may\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1797 be an empty structure if the information cannot be obtained. The fields of\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1798 the structure are:\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1799 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1800 @table @code\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1801 @item file\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1802 The name of the file where the error occurred\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1803 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1804 @item name\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6959
diff changeset
1805 The name of function in which the error occurred\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1806 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1807 @item line\n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6959
diff changeset
1808 The line number at which the error occurred\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
1809 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1810 @item column\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1811 An optional field with the column number at which the error occurred\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1812 @end table\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1813 @end table\n\
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1814 \n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1815 The last error structure may be set by passing a scalar structure, @var{err},\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1816 as input. Any fields of @var{err} that match those above are set while any\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1817 unspecified fields are initialized with default values.\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1818 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1819 If @code{lasterror} is called with the argument @qcode{\"reset\"}, all\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
1820 fields are set to their default values.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1821 @seealso{lasterr, error, lastwarn}\n\
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1822 @end deftypefn")
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1823 {
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1824 octave_value retval;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1825 int nargin = args.length ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1826
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1827 if (nargin < 2)
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1828 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1829 octave_scalar_map err;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1830
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1831 err.assign ("message", Vlast_error_message);
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1832 err.assign ("identifier", Vlast_error_id);
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1833
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1834 err.assign ("stack", octave_value (Vlast_error_stack));
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1835
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1836 if (nargin == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1837 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1838 if (args(0).is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1839 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1840 if (args(0).string_value () == "reset")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1841 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1842 Vlast_error_message = std::string ();
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14559
diff changeset
1843 Vlast_error_id = std::string ();
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1844
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1845 Vlast_error_stack = initialize_last_error_stack ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1846 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1847 else
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1848 error ("lasterror: unrecognized string argument");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1849 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1850 else if (args(0).is_map ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1851 {
11058
3329616444f0 replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 11029
diff changeset
1852 octave_scalar_map new_err = args(0).scalar_map_value ();
16492
91c32a702284 Correctly fill stack field in lasterror() when given as input.
Rik <rik@octave.org>
parents: 16442
diff changeset
1853 octave_scalar_map new_err_stack;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1854 std::string new_error_message;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1855 std::string new_error_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1856 std::string new_error_file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1857 std::string new_error_name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1858 int new_error_line = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1859 int new_error_column = -1;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1860
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1861 if (new_err.contains ("message"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1862 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1863 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1864 new_err.getfield ("message").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1865 new_error_message = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1866 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1867
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1868 if (new_err.contains ("identifier"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1869 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1870 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1871 new_err.getfield ("identifier").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1872 new_error_id = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1873 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1874
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1875 if (new_err.contains ("stack"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1876 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1877 new_err_stack =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1878 new_err.getfield ("stack").scalar_map_value ();
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1879
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1880 if (new_err_stack.contains ("file"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1881 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1882 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1883 new_err_stack.getfield ("file").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1884 new_error_file = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1885 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1886
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1887 if (new_err_stack.contains ("name"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1888 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1889 const std::string tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1890 new_err_stack.getfield ("name").string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1891 new_error_name = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1892 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1893
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1894 if (new_err_stack.contains ("line"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1895 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1896 const int tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1897 new_err_stack.getfield ("line").nint_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1898 new_error_line = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1899 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1900
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1901 if (new_err_stack.contains ("column"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1902 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1903 const int tmp =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1904 new_err_stack.getfield ("column").nint_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1905 new_error_column = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1906 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1907 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1908
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1909 Vlast_error_message = new_error_message;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1910 Vlast_error_id = new_error_id;
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1911
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1912 if (new_err.contains ("stack"))
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1913 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1914 new_err_stack.setfield ("file", new_error_file);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1915 new_err_stack.setfield ("name", new_error_name);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1916 new_err_stack.setfield ("line", new_error_line);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1917 new_err_stack.setfield ("column", new_error_column);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1918 Vlast_error_stack = new_err_stack;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1919 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1920 else
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1921 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1922 // No stack field. Fill it in with backtrace info.
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1923 octave_idx_type curr_frame = -1;
9166
69088b7b139c use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents: 9153
diff changeset
1924
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1925 Vlast_error_stack
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1926 = octave_call_stack::backtrace (0, curr_frame);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1927 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1928 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1929 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1930 error ("lasterror: argument must be a structure or a string");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1931 }
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1932
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1933 retval = err;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1934 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1935 else
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1936 print_usage ();
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1937
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1938 return retval;
6361
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1939 }
776e657c9422 [project @ 2007-02-27 09:45:03 by dbateman]
dbateman
parents: 6338
diff changeset
1940
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1941 DEFUN (lasterr, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1942 "-*- texinfo -*-\n\
12692
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1943 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lasterr ()\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1944 @deftypefnx {Built-in Function} {} lasterr (@var{msg})\n\
e7b03b8662a2 doc: Update docstrings for a few functions
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1945 @deftypefnx {Built-in Function} {} lasterr (@var{msg}, @var{msgid})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1946 Query or set the last error message.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1947 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1948 When called without input arguments, return the last error message and\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1949 message identifier.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1950 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1951 With one argument, set the last error message to @var{msg}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1952 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1953 With two arguments, also set the last message identifier.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1954 @seealso{lasterror, error, lastwarn}\n\
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1955 @end deftypefn")
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1956 {
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1957 octave_value_list retval;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1958
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1959 int argc = args.length () + 1;
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1960
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1961 if (argc < 4)
5335
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1962 {
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1963 string_vector argv = args.make_argv ("lasterr");
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1964
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1965 std::string prev_error_id = Vlast_error_id;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1966 std::string prev_error_message = Vlast_error_message;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1967
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1968 if (argc > 2)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1969 Vlast_error_id = argv(2);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1970
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1971 if (argc > 1)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1972 Vlast_error_message = argv(1);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1973
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1974 if (argc == 1 || nargout > 0)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1975 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1976 retval(1) = prev_error_id;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
1977 retval(0) = prev_error_message;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1978 }
5335
a892ee7ac114 [project @ 2005-05-02 20:33:48 by jwe]
jwe
parents: 5307
diff changeset
1979 }
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1980 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
1981 print_usage ();
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1982
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1983 return retval;
3935
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1984 }
1ea29376e43e [project @ 2002-05-16 05:30:51 by jwe]
jwe
parents: 3934
diff changeset
1985
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
1986 DEFUN (lastwarn, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1987 "-*- texinfo -*-\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1988 @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} lastwarn ()\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1989 @deftypefnx {Built-in Function} {} lastwarn (@var{msg})\n\
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1990 @deftypefnx {Built-in Function} {} lastwarn (@var{msg}, @var{msgid})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1991 Query or set the last warning message.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1992 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1993 When called without input arguments, return the last warning message and\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1994 message identifier.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1995 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1996 With one argument, set the last warning message to @var{msg}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1997 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
1998 With two arguments, also set the last message identifier.\n\
15173
8593bed236f1 doc: Document escape character processing within single quotes for regexp, warning, error.
Rik <rik@octave.org>
parents: 15088
diff changeset
1999 @seealso{warning, lasterror, lasterr}\n\
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2000 @end deftypefn")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2001 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2002 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2003
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2004 int argc = args.length () + 1;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2005
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2006 if (argc < 4)
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2007 {
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2008 string_vector argv = args.make_argv ("lastwarn");
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2009
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2010 std::string prev_warning_id = Vlast_warning_id;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2011 std::string prev_warning_message = Vlast_warning_message;
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2012
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2013 if (argc > 2)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2014 Vlast_warning_id = argv(2);
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2015
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2016 if (argc > 1)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2017 Vlast_warning_message = argv(1);
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2018
20535
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2019 if (argc == 1 || nargout > 0)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2020 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2021 retval(1) = prev_warning_id;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20511
diff changeset
2022 retval(0) = prev_warning_message;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
2023 }
5567
80e629357483 [project @ 2005-12-07 06:31:28 by jwe]
jwe
parents: 5335
diff changeset
2024 }
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2025 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5794
diff changeset
2026 print_usage ();
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2027
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2028 return retval;
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
2029 }
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
2030
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2031 /* FIXME: Deprecated in 4.0 and scheduled for removal in 4.4 */
19111
d4a920d28242 Depecrate usage() function.
Rik <rik@octave.org>
parents: 18742
diff changeset
2032 DEFUN (__usage__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2033 "-*- texinfo -*-\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2034 @deftypefn {Built-in Function} {} usage (@var{msg})\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2035 Print the message @var{msg}, prefixed by the string @samp{usage: }, and\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2036 set Octave's internal error state such that control will return to the\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2037 top level without evaluating any more commands. This is useful for\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2038 aborting from functions.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2039 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2040 After @code{usage} is evaluated, Octave will print a traceback of all\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2041 the function calls leading to the usage message.\n\
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
2042 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2043 You should use this function for reporting problems errors that result\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2044 from an improper call to a function, such as calling a function with an\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2045 incorrect number of arguments, or with arguments of the wrong type. For\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2046 example, most functions distributed with Octave begin with code like\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2047 this\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2048 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2049 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2050 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2051 if (nargin != 2)\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2052 usage (\"foo (a, b)\");\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2053 endif\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2054 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2055 @end example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2056 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2057 @noindent\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2058 to check for the proper number of arguments.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
2059 @end deftypefn")
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
2060 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2061 octave_value_list retval;
14558
0c9c85e702ca better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents: 14361
diff changeset
2062 handle_message (usage_with_id, "", "unknown", args, true);
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
2063 return retval;
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
2064 }
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
2065
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2066 DEFUN (beep_on_error, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2067 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
2068 @deftypefn {Built-in Function} {@var{val} =} beep_on_error ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2069 @deftypefnx {Built-in Function} {@var{old_val} =} beep_on_error (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
2070 @deftypefnx {Built-in Function} {} beep_on_error (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2071 Query or set the internal variable that controls whether Octave will try\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2072 to ring the terminal bell before printing an error message.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
2073 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
2074 When called from inside a function with the @qcode{\"local\"} option, the\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2075 variable is changed locally for the function and any subroutines it calls.\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
2076 The original variable value is restored when exiting the function.\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2077 @end deftypefn")
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
2078 {
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2079 return SET_INTERNAL_VARIABLE (beep_on_error);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
2080 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
2081
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2082 DEFUN (debug_on_error, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2083 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
2084 @deftypefn {Built-in Function} {@var{val} =} debug_on_error ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2085 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_error (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
2086 @deftypefnx {Built-in Function} {} debug_on_error (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2087 Query or set the internal variable that controls whether Octave will try\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2088 to enter the debugger when an error is encountered.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2089 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2090 This will also inhibit printing of the normal traceback message (you will\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2091 only see the top-level error message).\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
2092 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
2093 When called from inside a function with the @qcode{\"local\"} option, the\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2094 variable is changed locally for the function and any subroutines it calls.\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
2095 The original variable value is restored when exiting the function.\n\
15573
63d024333bee doc: Add seealso links between debug_on_XXX functions (bug #37576)
Rik <rik@octave.org>
parents: 15524
diff changeset
2096 @seealso{debug_on_warning, debug_on_interrupt}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2097 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2098 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2099 return SET_INTERNAL_VARIABLE (debug_on_error);
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2100 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
2101
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2102 DEFUN (debug_on_warning, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2103 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10767
diff changeset
2104 @deftypefn {Built-in Function} {@var{val} =} debug_on_warning ()\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2105 @deftypefnx {Built-in Function} {@var{old_val} =} debug_on_warning (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
2106 @deftypefnx {Built-in Function} {} debug_on_warning (@var{new_val}, \"local\")\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2107 Query or set the internal variable that controls whether Octave will try\n\
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2108 to enter the debugger when a warning is encountered.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13841
diff changeset
2109 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
2110 When called from inside a function with the @qcode{\"local\"} option, the\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20140
diff changeset
2111 variable is changed locally for the function and any subroutines it calls.\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
2112 The original variable value is restored when exiting the function.\n\
15573
63d024333bee doc: Add seealso links between debug_on_XXX functions (bug #37576)
Rik <rik@octave.org>
parents: 15524
diff changeset
2113 @seealso{debug_on_error, debug_on_interrupt}\n\
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2114 @end deftypefn")
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2115 {
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5783
diff changeset
2116 return SET_INTERNAL_VARIABLE (debug_on_warning);
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
2117 }
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
2118
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
2119 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
2120 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
2121 {
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
2122 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
2123 }
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
2124
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
2125 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
2126 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
2127 {
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
2128 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
2129 }
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
2130
18222
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 18130
diff changeset
2131 octave_map
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 18130
diff changeset
2132 last_error_stack (void)
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 18130
diff changeset
2133 {
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 18130
diff changeset
2134 return Vlast_error_stack;
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 18130
diff changeset
2135 }
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 18130
diff changeset
2136
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
2137 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
2138 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
2139 {
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
2140 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
2141 }
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
2142
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
2143 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
2144 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
2145 {
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
2146 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
2147 }
11029
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2148
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2149 void
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2150 interpreter_try (unwind_protect& frame)
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2151 {
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2152 frame.protect_var (buffer_error_messages);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2153 frame.protect_var (Vdebug_on_error);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2154 frame.protect_var (Vdebug_on_warning);
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2155
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2156 buffer_error_messages++;
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2157 Vdebug_on_error = false;
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2158 Vdebug_on_warning = false;
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2159 }
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2160
4ab04ea74b08 make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
2161