annotate src/error.cc @ 10405:cc69a17ec801

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