annotate src/error.cc @ 3934:31393822395b

[project @ 2002-05-15 19:18:09 by jwe]
author jwe
date Wed, 15 May 2002 19:18:09 +0000
parents c554ad71bafc
children 1ea29376e43e
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
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2802
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10 later version.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1266
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
240
a99f28f5e351 [project @ 1993-11-30 20:24:36 by jwe]
jwe
parents: 189
diff changeset
23 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1165
diff changeset
24 #include <config.h>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
27 #include <cstdarg>
1633
4a4440aa1262 [project @ 1995-11-14 23:01:31 by jwe]
jwe
parents: 1489
diff changeset
28 #include <cstring>
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
29
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3491
diff changeset
30 #include <strstream>
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
31 #include <string>
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
32
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
33 #include "defun.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
34 #include "error.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
35 #include "input.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1728
diff changeset
36 #include "pager.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
37 #include "oct-obj.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1343
diff changeset
38 #include "utils.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2200
diff changeset
39 #include "ov.h"
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
40 #include "ov-usr-fcn.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
41 #include "pt-pr-code.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
42 #include "pt-stmt.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
43 #include "toplev.h"
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
44 #include "unwind-prot.h"
2370
a45c7d64b5e3 [project @ 1996-10-11 23:51:15 by jwe]
jwe
parents: 2200
diff changeset
45 #include "variables.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
46
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
47 // 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
48 // error messages.
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
49 static bool Vbeep_on_error;
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
50
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
51 // 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
52 // 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
53 // traceback message (you will only see the top-level error message).
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
54 static bool Vdebug_on_error;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
55
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
56 // 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
57 // is encountered.
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
58 static bool Vdebug_on_warning;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
59
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
60 // The text of the last warning message.
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
61 static std::string Vlast_warning_message;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
62
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
63 // The warning frequency for Matlab handle graphics backwards
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
64 // compatibility warnings (currently not used).
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
65 static std::string Vwarning_frequency = "once";
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
66
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
67 // The current warning state. Valid values are "on", "off",
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
68 // "backtrace", or "debug".
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
69 static std::string Vwarning_option = "backtrace";
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
70
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 103
diff changeset
71 // Current error state.
672
066e1551639c [project @ 1994-09-07 21:10:32 by jwe]
jwe
parents: 610
diff changeset
72 int error_state = 0;
066e1551639c [project @ 1994-09-07 21:10:32 by jwe]
jwe
parents: 610
diff changeset
73
3489
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3402
diff changeset
74 // Current warning state.
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3402
diff changeset
75 int warning_state = 0;
cbee5fbb696d [project @ 2000-01-28 09:14:32 by jwe]
jwe
parents: 3402
diff changeset
76
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
77 // 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
78 // 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
79 // the `unwind_protect' statement.
3136
af7ec9d3a5e6 [project @ 1998-02-01 20:11:06 by jwe]
jwe
parents: 3066
diff changeset
80 bool buffer_error_messages = false;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
81
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
82 // TRUE means error messages are turned off.
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
83 bool discard_error_messages = false;
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
84
3811
855bf76e1fe1 [project @ 2001-04-18 03:44:30 by jwe]
jwe
parents: 3764
diff changeset
85 // The message buffer.
855bf76e1fe1 [project @ 2001-04-18 03:44:30 by jwe]
jwe
parents: 3764
diff changeset
86 static std::ostrstream *error_message_buffer = 0;
143
7849db4b6dbc [project @ 1993-10-04 02:36:45 by jwe]
jwe
parents: 103
diff changeset
87
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
88 // Warning messages are never buffered.
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
89 // XXX FIXME XXX -- we should provide another way to turn them off...
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
90
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
91 static void
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
92 vwarning (const char *name, const char *fmt, va_list args)
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
93 {
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
94 flush_octave_stdout ();
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
95
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
96 std::ostrstream output_buf;
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
97
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
98 if (name)
3761
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
99 output_buf << name << ": ";
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
100
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
101 octave_vformat (output_buf, fmt, args);
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
102
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
103 output_buf << std::endl << std::ends;
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
104
3761
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
105 char *msg = output_buf.str ();
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
106
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
107 Vlast_warning_message = msg;
3761
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
108
dfb1bfa12afd [project @ 2001-01-05 16:38:01 by jwe]
jwe
parents: 3719
diff changeset
109 delete [] msg;
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
110
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
111 octave_diary << Vlast_warning_message;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
112
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
113 std::cerr << Vlast_warning_message;
3491
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
114 }
2c7524ffdbf5 [project @ 2000-01-28 22:44:13 by jwe]
jwe
parents: 3490
diff changeset
115
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
116 static void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
117 verror (const char *name, const char *fmt, va_list args)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
118 {
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
119 if (discard_error_messages)
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
120 return;
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
121
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
122 if (! buffer_error_messages)
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
123 flush_octave_stdout ();
914
6a10b90623ea [project @ 1994-11-10 21:53:10 by jwe]
jwe
parents: 905
diff changeset
124
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
125 bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state;
1423
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
126
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
127 std::ostrstream output_buf;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
128
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
129 if (to_beep_or_not_to_beep_p)
1423
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
130 output_buf << "\a";
3620
0886bbb236cb [project @ 2000-03-23 05:17:23 by jwe]
jwe
parents: 3600
diff changeset
131
599
3ed5cf2aef94 [project @ 1994-08-12 04:20:27 by jwe]
jwe
parents: 581
diff changeset
132 if (name)
3ed5cf2aef94 [project @ 1994-08-12 04:20:27 by jwe]
jwe
parents: 581
diff changeset
133 output_buf << name << ": ";
3620
0886bbb236cb [project @ 2000-03-23 05:17:23 by jwe]
jwe
parents: 3600
diff changeset
134
0886bbb236cb [project @ 2000-03-23 05:17:23 by jwe]
jwe
parents: 3600
diff changeset
135 octave_vformat (output_buf, fmt, args);
0886bbb236cb [project @ 2000-03-23 05:17:23 by jwe]
jwe
parents: 3600
diff changeset
136
3538
0ff7323dab8b [project @ 2000-02-02 12:36:25 by jwe]
jwe
parents: 3531
diff changeset
137 output_buf << std::endl << std::ends;
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 528
diff changeset
138
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 528
diff changeset
139 char *msg = output_buf.str ();
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 528
diff changeset
140
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
141 if (buffer_error_messages)
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
142 {
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
143 char *ptr = msg;
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
144
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
145 if (! error_message_buffer)
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
146 {
3548
ab7fa5a8f23f [project @ 2000-02-03 01:17:15 by jwe]
jwe
parents: 3538
diff changeset
147 error_message_buffer = new std::ostrstream;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
148
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
149 // XXX FIXME XXX -- this is ugly, but it prevents
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
150 //
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
151 // eval ("error (\"msg\")", "error (__error_text__)");
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
152 //
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
153 // from printing `error: ' twice. Assumes that the NAME we
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
154 // have been given doesn't contain `:'.
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
155
3162
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
156 ptr = strchr (msg, ':');
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
157
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
158 if (ptr)
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
159 {
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
160 if (*++ptr != '\0')
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
161 ++ptr;
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
162 }
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
163 else
7c96e85c76db [project @ 1998-04-08 18:19:35 by jwe]
jwe
parents: 3141
diff changeset
164 ptr = msg;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
165 }
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
166
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
167 *error_message_buffer << ptr;
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
168 }
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
169 else
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
170 {
2095
36903d507b0e [project @ 1996-04-28 09:00:07 by jwe]
jwe
parents: 2086
diff changeset
171 octave_diary << msg;
3531
97cf542676e1 [project @ 2000-02-02 11:30:40 by jwe]
jwe
parents: 3523
diff changeset
172 std::cerr << msg;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
173 }
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 528
diff changeset
174
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 528
diff changeset
175 delete [] msg;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
176 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
177
1266
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
178 // 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
179 // 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
180 // just set the error state.
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
181
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
182 static void
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
183 error_1 (const char *name, const char *fmt, va_list args)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
184 {
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
185 if (error_state != -2)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
186 {
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
187 if (fmt)
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
188 {
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
189 if (*fmt)
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
190 {
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
191 int len = strlen (fmt);
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
192 if (fmt[len - 1] == '\n')
1266
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
193 {
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
194 if (len > 1)
1266
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
195 {
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
196 char *tmp_fmt = strsave (fmt);
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
197 tmp_fmt[len - 1] = '\0';
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
198 verror (name, tmp_fmt, args);
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
199 delete [] tmp_fmt;
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
200 }
1423
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
201
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
202 error_state = -2;
1266
e1ddfb12566d [project @ 1995-04-20 18:56:04 by jwe]
jwe
parents: 1192
diff changeset
203 }
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
204 else
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
205 verror (name, fmt, args);
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
206 }
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
207 }
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
208 else
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
209 panic ("error_1: invalid format");
1423
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
210
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
211 if (! error_state)
2d88758ed94b [project @ 1995-09-18 16:04:37 by jwe]
jwe
parents: 1363
diff changeset
212 error_state = 1;
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
213 }
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
214 }
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
215
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
216 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
217 message (const char *name, const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
218 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
219 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
220 va_start (args, fmt);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
221 verror (name, fmt, args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
222 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
223 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
224
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
225 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
226 usage (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
227 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
228 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
229 va_start (args, fmt);
905
0f3237aa35b7 [project @ 1994-11-09 21:49:34 by jwe]
jwe
parents: 899
diff changeset
230 error_state = -1;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
231 verror ("usage", fmt, args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
232 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
233 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
234
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
235 static void
3719
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
236 pr_where_2 (const char *fmt, va_list args)
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
237 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
238 if (fmt)
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
239 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
240 if (*fmt)
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
241 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
242 int len = strlen (fmt);
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
243 if (fmt[len - 1] == '\n')
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
244 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
245 if (len > 1)
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
246 {
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
247 char *tmp_fmt = strsave (fmt);
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
248 tmp_fmt[len - 1] = '\0';
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
249 verror (0, tmp_fmt, args);
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
250 delete [] tmp_fmt;
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
251 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
252 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
253 else
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
254 verror (0, fmt, args);
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
255 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
256 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
257 else
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
258 panic ("pr_where_2: invalid format");
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
259 }
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
260
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
261 static void
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
262 pr_where_1 (const char *fmt, ...)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
263 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
264 va_list args;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
265 va_start (args, fmt);
3719
744755872311 [project @ 2000-10-10 21:42:20 by jwe]
jwe
parents: 3708
diff changeset
266 pr_where_2 (fmt, args);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
267 va_end (args);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
268 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
269
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
270 static void
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
271 pr_where (const char *name)
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
272 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
273 if (curr_statement)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
274 {
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
275 const char *f_nm = 0;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
276
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
277 if (curr_function)
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
278 {
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
279 std::string fcn_name = curr_function->function_name ();
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
280 std::string file_name = curr_function->fcn_file_name ();
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
281
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
282 f_nm = file_name.empty () ? fcn_name.c_str () : file_name.c_str ();
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
283 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
284
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
285 int l = curr_statement->line ();
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
286 int c = curr_statement->column ();
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
287
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
288 if (f_nm)
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
289 pr_where_1 ("%s: in %s near line %d, column %d:", name, f_nm, l, c);
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
290 else
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
291 pr_where_1 ("%s: near line %d, column %d:", name, l, c);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
292
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
293 // XXX FIXME XXX -- Note that the column number is probably not
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
294 // going to mean much here since the code is being reproduced
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
295 // from the parse tree, and we are only showing one statement
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
296 // even if there were multiple statements on the original source
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
297 // line.
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
298
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
299 std::ostrstream output_buf;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
300
3764
0ac9388e7e1f [project @ 2001-01-17 03:41:39 by jwe]
jwe
parents: 3761
diff changeset
301 output_buf << std::endl;
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
302
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
303 tree_print_code tpc (output_buf, ">>> ");
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
304
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
305 curr_statement->accept (tpc);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
306
3764
0ac9388e7e1f [project @ 2001-01-17 03:41:39 by jwe]
jwe
parents: 3761
diff changeset
307 output_buf << std::endl << std::ends;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
308
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
309 char *msg = output_buf.str ();
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
310
3764
0ac9388e7e1f [project @ 2001-01-17 03:41:39 by jwe]
jwe
parents: 3761
diff changeset
311 pr_where_1 ("%s", msg);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
312
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
313 delete [] msg;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
314 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
315 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
316
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
317 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
318 warning (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
319 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
320 if (Vwarning_option != "off")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
321 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
322 va_list args;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
323 va_start (args, fmt);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
324 warning_state = 1;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
325 vwarning ("warning", fmt, args);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
326 va_end (args);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
327
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
328 if (Vwarning_option == "backtrace")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
329 pr_where ("warning");
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
330
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
331 if ((interactive || forced_interactive)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
332 && Vdebug_on_warning && curr_function)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
333 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
334 unwind_protect_bool (Vdebug_on_warning);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
335 Vdebug_on_warning = false;
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
336
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
337 do_keyboard (octave_value_list ());
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
338
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
339 unwind_protect::run ();
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
340 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
341 }
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
342 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
343
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
344 void
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
345 error (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
346 {
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
347 int init_state = error_state;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
348
1
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);
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
351 error_1 ("error", fmt, args);
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
352 va_end (args);
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
353
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
354 if ((interactive || forced_interactive)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
355 && Vdebug_on_error && init_state == 0 && curr_function)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
356 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
357 unwind_protect_bool (Vdebug_on_error);
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
358 Vdebug_on_error = false;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
359
3708
9b9efdcbdfd3 [project @ 2000-07-28 20:50:58 by jwe]
jwe
parents: 3707
diff changeset
360 pr_where ("error");
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
361
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
362 error_state = 0;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
363
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
364 do_keyboard (octave_value_list ());
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
365
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
366 unwind_protect::run ();
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
367 }
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
368 }
436
f7314b67a142 [project @ 1994-05-26 00:44:37 by jwe]
jwe
parents: 240
diff changeset
369
1005
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
370 void
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
371 parse_error (const char *fmt, ...)
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
372 {
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
373 va_list args;
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
374 va_start (args, fmt);
46a2983cb297 [project @ 1995-01-03 02:08:32 by jwe]
jwe
parents: 914
diff changeset
375 error_1 (0, fmt, args);
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
376 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
377 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
378
189
de0e58f9b064 [project @ 1993-10-28 08:52:15 by jwe]
jwe
parents: 169
diff changeset
379 void
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
380 panic (const char *fmt, ...)
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
381 {
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
382 va_list args;
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
383 va_start (args, fmt);
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3548
diff changeset
384 buffer_error_messages = false;
3815
c554ad71bafc [project @ 2001-04-19 19:50:52 by jwe]
jwe
parents: 3811
diff changeset
385 discard_error_messages = false;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
386 verror ("panic", fmt, args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
387 va_end (args);
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
388 abort ();
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
389 }
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
390
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
391 typedef void (*error_fun)(const char *, ...);
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
392
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
393 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
394
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
395 static std::string
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 1996
diff changeset
396 handle_message (error_fun f, const char *msg, const octave_value_list& args)
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
397 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
398 std::string retval;
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
399
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3503
diff changeset
400 std::string tstr;
1728
42b4f904f1af [project @ 1996-01-09 11:36:01 by jwe]
jwe
parents: 1633
diff changeset
401
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
402 int nargin = args.length ();
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
403
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
404 if (nargin > 0)
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
405 {
3066
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
406 octave_value arg;
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
407
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
408 if (nargin > 1)
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
409 {
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
410 octave_value_list tmp = Fsprintf (args, 1);
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
411 arg = tmp(0);
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
412 }
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
413 else
2d485faf2fa3 [project @ 1997-07-02 21:48:29 by jwe]
jwe
parents: 3018
diff changeset
414 arg = args(0);
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
415
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
416 if (arg.is_defined ())
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
417 {
2745
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
418 if (arg.is_string ())
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
419 {
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
420 tstr = arg.string_value ();
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
421 msg = tstr.c_str ();
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
422
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
423 if (! msg)
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
424 return retval;
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
425 }
76411ce43c05 [project @ 1997-02-26 07:52:14 by jwe]
jwe
parents: 2620
diff changeset
426 else if (arg.is_empty ())
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
427 return retval;
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
428 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
429 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
430
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
431 // Ugh.
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
432
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
433 int len = strlen (msg);
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
434 if (msg[len - 1] == '\n')
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
435 {
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
436 if (len > 1)
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
437 {
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
438 char *tmp_msg = strsave (msg);
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
439 tmp_msg[len - 1] = '\0';
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
440 f ("%s\n", tmp_msg);
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
441 retval = tmp_msg;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
442 delete [] tmp_msg;
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
443 }
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
444 }
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
445 else
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
446 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
447 f ("%s", msg);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
448 retval = msg;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
449 }
528
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
450
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
451 return retval;
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
452 }
e1e6e33e26f8 [project @ 1994-07-20 18:53:50 by jwe]
jwe
parents: 514
diff changeset
453
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
454 DEFUN (error, args, ,
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
455 "-*- texinfo -*-\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
456 @deftypefn {Built-in Function} {} error (@var{template}, @dots{})\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
457 The @code{error} function formats the optional arguments under the\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
458 control of the template string @var{template} using the same rules as\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
459 the @code{printf} family of functions (@pxref{Formatted Output}).\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
460 The resulting message is prefixed by the string @samp{error: } and\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
461 printed on the @code{stderr} stream.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
462 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
463 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
464 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
465 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
466 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
467 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
468 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
469 example, given the following function definitions:\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
470 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
471 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
472 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
473 function f () g () end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
474 function g () h () end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
475 function h () nargin == 1 || error (\"nargin != 1\"); end\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
476 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
477 @end example\n\
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
478 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
479 @noindent\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
480 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
481 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
482 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
483 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
484 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
485 f ()\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
486 error: nargin != 1\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
487 error: evaluating index expression near line 1, column 30\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
488 error: evaluating binary operator `||' near line 1, column 27\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
489 error: called from `h'\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
490 error: called from `g'\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
491 error: called from `f'\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
492 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
493 @end example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
494 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
495 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
496 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
497 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
498 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
499 a single message:\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
500 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
501 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
502 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
503 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
504 f ()\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
505 error: nargin != 1\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
506 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
507 @end example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
508 @end deftypefn")
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
509 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
510 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
511 handle_message (error, "unspecified error", args);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
512 return retval;
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
513 }
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
514
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
515 static inline octave_value_list
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
516 set_warning_option (const std::string& state,
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
517 const std::string& frequency, int nargout)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
518 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
519 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
520
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
521 if (nargout > 1)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
522 retval(1) = Vwarning_frequency;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
523
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
524 if (nargout > 0)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
525 retval(0) = Vwarning_option;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
526
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
527 if (! state.empty ())
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
528 Vwarning_option = state;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
529
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
530 if (! frequency.empty ())
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
531 Vwarning_frequency = frequency;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
532
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
533 return retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
534 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
535
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
536 DEFUN_TEXT (warning, args, nargout,
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
537 "-*- texinfo -*-\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
538 @deftypefn {Built-in Function} {} warning (@var{msg})\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
539 Print a warning message @var{msg} prefixed by the string @samp{warning: }. \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
540 After printing the warning message, Octave will continue to execute\n\
3600
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3585
diff changeset
541 commands. You should use this function when you want to notify the user\n\
c11d138d654a [project @ 2000-02-24 03:55:32 by jwe]
jwe
parents: 3585
diff changeset
542 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
543 to go on.\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
544 @end deftypefn")
1489
3e705c864019 [project @ 1995-09-28 05:38:26 by jwe]
jwe
parents: 1488
diff changeset
545 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
546 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
547
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
548 int argc = args.length () + 1;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
549
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
550 string_vector argv = args.make_argv ("warning");
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
551
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
552 if (! error_state)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
553 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
554 bool done = false;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
555
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
556 if (argc == 1)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
557 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
558 retval = set_warning_option ("", "", nargout);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
559 done = true;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
560 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
561 else if (argc == 2)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
562 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
563 std::string arg = argv(1);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
564
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
565 if (arg == "on" || arg == "off" || arg == "backtrace")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
566 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
567 retval = set_warning_option (arg, "", nargout);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
568 done = true;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
569 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
570 else if (arg == "once" || arg == "always")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
571 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
572 retval = set_warning_option ("", arg, nargout);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
573 done = true;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
574 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
575 else if (arg == "debug")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
576 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
577 bind_builtin_variable ("debug_on_warning", 1.0);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
578 retval = set_warning_option ("", "", nargout);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
579 done = true;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
580 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
581 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
582
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
583 if (! done)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
584 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
585 std::string curr_msg
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
586 = handle_message (warning, "unspecified warning", args);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
587
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
588 if (nargout > 0)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
589 retval(0) = Vlast_warning_message;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
590
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
591 Vlast_warning_message = curr_msg;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
592 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
593 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
594
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
595 return retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
596 }
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
597
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
598 DEFUN (lastwarn, args, ,
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
599 "-*- texinfo -*-\n\
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
600 @deftypefn {Built-in Function} {} lastwarn ()\n\
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
601 @deftypefnx {Built-in Function} {} lastwarn (@var{msg})\n\
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
602 Without any arguments, return the last error message. With one\n\
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
603 argument, set the last warning message to @var{msg}.\n\
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
604 @end deftypefn")
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
605 {
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
606 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
607
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
608 int argc = args.length () + 1;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
609
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
610 string_vector argv = args.make_argv ("lastwarn");
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
611
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
612 if (argc == 1)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
613 retval(0) = Vlast_warning_message;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
614 else if (argc == 2)
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
615 Vlast_warning_message = argv(1);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
616 else
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
617 print_usage ("lastwarn");
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
618
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
619 return retval;
897
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
620 }
54921d080295 [project @ 1994-11-09 18:01:33 by jwe]
jwe
parents: 729
diff changeset
621
1957
0e6a0a271998 [project @ 1996-02-15 01:08:15 by jwe]
jwe
parents: 1884
diff changeset
622 DEFUN (usage, args, ,
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
623 "-*- texinfo -*-\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
624 @deftypefn {Built-in Function} {} usage (@var{msg})\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
625 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
626 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
627 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
628 aborting from functions.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
629 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
630 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
631 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
632 \n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
633 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
634 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
635 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
636 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
637 this\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
638 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
639 @example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
640 @group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
641 if (nargin != 2)\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
642 usage (\"foo (a, b)\");\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
643 endif\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
644 @end group\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
645 @end example\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
646 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
647 @noindent\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
648 to check for the proper number of arguments.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
649 @end deftypefn")
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
650 {
3934
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
651 octave_value_list retval;
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
652 handle_message (usage, "unknown", args);
31393822395b [project @ 2002-05-15 19:18:09 by jwe]
jwe
parents: 3815
diff changeset
653 return retval;
899
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
654 }
00e903c95534 [project @ 1994-11-09 18:06:56 by jwe]
jwe
parents: 897
diff changeset
655
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
656 void
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
657 bind_global_error_variable (void)
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
658 {
3490
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
659 if (error_message_buffer)
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
660 {
3538
0ff7323dab8b [project @ 2000-02-02 12:36:25 by jwe]
jwe
parents: 3531
diff changeset
661 *error_message_buffer << std::ends;
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
662
3490
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
663 char *error_text = error_message_buffer->str ();
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
664
3811
855bf76e1fe1 [project @ 2001-04-18 03:44:30 by jwe]
jwe
parents: 3764
diff changeset
665 bind_builtin_variable ("__error_text__", error_text, true);
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
666
3490
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
667 delete [] error_text;
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
668
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
669 delete error_message_buffer;
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
670
3490
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
671 error_message_buffer = 0;
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
672 }
fc5eac74640d [project @ 2000-01-28 10:13:25 by jwe]
jwe
parents: 3489
diff changeset
673 else
3811
855bf76e1fe1 [project @ 2001-04-18 03:44:30 by jwe]
jwe
parents: 3764
diff changeset
674 bind_builtin_variable ("__error_text__", "", true);
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
675 }
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
676
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
677 void
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
678 clear_global_error_variable (void *)
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
679 {
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
680 delete error_message_buffer;
3811
855bf76e1fe1 [project @ 2001-04-18 03:44:30 by jwe]
jwe
parents: 3764
diff changeset
681
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
682 error_message_buffer = 0;
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
683
3811
855bf76e1fe1 [project @ 2001-04-18 03:44:30 by jwe]
jwe
parents: 3764
diff changeset
684 bind_builtin_variable ("__error_text__", "", true);
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
685 }
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
686
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
687 static int
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
688 beep_on_error (void)
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
689 {
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
690 Vbeep_on_error = check_preference ("beep_on_error");
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
691
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
692 return 0;
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
693 }
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
694
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
695 static int
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
696 debug_on_error (void)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
697 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
698 Vdebug_on_error = check_preference ("debug_on_error");
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
699
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
700 return 0;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
701 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
702
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
703 static int
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
704 debug_on_warning (void)
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
705 {
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
706 Vdebug_on_warning = check_preference ("debug_on_warning");
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
708 return 0;
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
709 }
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
710
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
711 void
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
712 symbols_of_error (void)
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
713 {
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3162
diff changeset
714 DEFVAR (beep_on_error, 0.0, beep_on_error,
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
715 "-*- texinfo -*-\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
716 @defvr {Built-in Variable} beep_on_error\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
717 If the value of @code{beep_on_error} is nonzero, Octave will try\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
718 to ring your terminal's bell before printing an error message. The\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
719 default value is 0.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
720 @end defvr");
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 2847
diff changeset
721
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
722 DEFVAR (debug_on_error, 0.0, debug_on_error,
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
723 "-*- texinfo -*-\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
724 @defvr {Built-in Variable} debug_on_error\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
725 If the value of @code{debug_on_error} is nonzero, Octave will try\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
726 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
727 inhibit printing of the normal traceback message (you will only see\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
728 the top-level error message). The default value is 0.\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
729 @end defvr");
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
730
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
731 DEFVAR (debug_on_warning, 0.0, debug_on_warning,
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
732 "-*- texinfo -*-\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
733 @defvr {Built-in Variable} debug_on_warning\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
734 If the value of @code{debug_on_warning} is nonzero, Octave will try\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
735 to enter the debugger when a warning is encountered. The default\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
736 value is 0.\n\
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
737 @end defvr");
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3620
diff changeset
738
3141
292ff0bf484b [project @ 1998-02-03 08:11:07 by jwe]
jwe
parents: 3136
diff changeset
739 DEFCONST (error_text, "",
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
740 "-*- texinfo -*-\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
741 @defvr {Built-in Variable} error_text\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
742 This variable contains the text of error messages that would have\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
743 been printed in the body of the most recent @code{unwind_protect} or\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
744 @code{try} statement or the @var{try} part of the most recent call to\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
745 the @code{eval} function. Outside of the @code{unwind_protect} and\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
746 @code{try} statements or the @code{eval} function, or if no error has\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
747 occurred within them, the value of @code{error_text} is guaranteed to be\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
748 the empty string.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
749 \n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
750 Note that the message does not include the first @samp{error: } prefix,\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
751 so that it may easily be passed to the @code{error} function without\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
752 additional processing@footnote{Yes, it's a kluge, but it seems to be a\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
753 reasonably useful one.}.\n\
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
754 \n\
3402
9610d364e444 [project @ 2000-01-05 04:36:38 by jwe]
jwe
parents: 3373
diff changeset
755 @xref{The try Statement}, and @ref{The unwind_protect Statement}.\n\
3373
36405da8e173 [project @ 1999-11-23 20:54:17 by jwe]
jwe
parents: 3259
diff changeset
756 @end defvr");
2174
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
757 }
68b02495a5ac [project @ 1996-05-13 16:08:39 by jwe]
jwe
parents: 2095
diff changeset
758
1
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 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
761 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
762 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
763 */