1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
5755
|
28 #include "defun.h" |
1352
|
29 #include "error.h" |
1
|
30 #include "gripes.h" |
4055
|
31 #include "oct-obj.h" |
5755
|
32 #include "utils.h" |
|
33 |
|
34 // Allow divide by zero errors to be suppressed. |
5758
|
35 static bool Vwarn_divide_by_zero; |
1
|
36 |
|
37 void |
2078
|
38 gripe_not_supported (const char *fcn) |
|
39 { |
|
40 error ("%s: not supported on this system", fcn); |
|
41 } |
|
42 |
|
43 void |
1
|
44 gripe_string_invalid (void) |
|
45 { |
3523
|
46 error ("std::string constant used in invalid context"); |
1
|
47 } |
|
48 |
|
49 void |
|
50 gripe_range_invalid (void) |
|
51 { |
|
52 error ("range constant used in invalid context"); |
|
53 } |
|
54 |
|
55 void |
|
56 gripe_nonconformant (void) |
|
57 { |
|
58 error ("nonconformant matrices"); |
|
59 } |
|
60 |
|
61 void |
5275
|
62 gripe_nonconformant (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) |
143
|
63 { |
|
64 error ("nonconformant matrices (op1 is %dx%d, op2 is %dx%d)", |
|
65 r1, c1, r2, c2); |
|
66 } |
|
67 |
|
68 void |
2799
|
69 gripe_empty_arg (const char *name, bool is_error) |
1
|
70 { |
|
71 if (is_error) |
|
72 error ("%s: empty matrix is invalid as an argument", name); |
|
73 else |
|
74 warning ("%s: argument is empty matrix", name); |
|
75 } |
|
76 |
|
77 void |
|
78 gripe_square_matrix_required (const char *name) |
|
79 { |
|
80 error ("%s: argument must be a square matrix", name); |
|
81 } |
|
82 |
|
83 void |
|
84 gripe_user_supplied_eval (const char *name) |
|
85 { |
|
86 error ("%s: evaluation of user-supplied function failed", name); |
|
87 } |
|
88 |
|
89 void |
|
90 gripe_user_returned_invalid (const char *name) |
|
91 { |
|
92 error ("%s: user-supplied function returned invalid value", name); |
|
93 } |
|
94 |
628
|
95 void |
3523
|
96 gripe_invalid_conversion (const std::string& from, const std::string& to) |
628
|
97 { |
2374
|
98 error ("invalid conversion from %s to %s", from.c_str (), to.c_str ()); |
628
|
99 } |
|
100 |
777
|
101 void |
1416
|
102 gripe_invalid_value_specified (const char *name) |
|
103 { |
|
104 warning ("invalid value specified for `%s'", name); |
|
105 } |
|
106 |
|
107 void |
777
|
108 gripe_2_or_3_dim_plot (void) |
|
109 { |
|
110 error ("plot: can only plot in 2 or 3 dimensions"); |
|
111 } |
|
112 |
|
113 void |
|
114 gripe_unrecognized_float_fmt (void) |
|
115 { |
|
116 error ("unrecognized floating point format requested"); |
|
117 } |
|
118 |
|
119 void |
|
120 gripe_unrecognized_data_fmt (const char *warn_for) |
|
121 { |
|
122 error ("%s: unrecognized data format requested", warn_for); |
|
123 } |
|
124 |
|
125 void |
|
126 gripe_data_conversion (const char *from, const char *to) |
|
127 { |
|
128 error ("unable to convert from %s to %s format", from, to); |
|
129 } |
|
130 |
|
131 void |
5602
|
132 gripe_wrong_type_arg (const char *name, const char *s, bool is_error) |
2668
|
133 { |
2799
|
134 if (is_error) |
5602
|
135 error ("%s: wrong type argument `%s'", name, s); |
2799
|
136 else |
5602
|
137 warning ("%s: wrong type argument `%s'", name, s); |
|
138 } |
|
139 |
|
140 void |
|
141 gripe_wrong_type_arg (const char *name, const std::string& s, bool is_error) |
|
142 { |
|
143 gripe_wrong_type_arg (name, s.c_str (), is_error); |
2668
|
144 } |
|
145 |
|
146 void |
2799
|
147 gripe_wrong_type_arg (const char *name, const octave_value& tc, |
|
148 bool is_error) |
777
|
149 { |
3523
|
150 std::string type = tc.type_name (); |
2799
|
151 |
5602
|
152 gripe_wrong_type_arg (name, type, is_error); |
777
|
153 } |
|
154 |
|
155 void |
2086
|
156 gripe_wrong_type_arg_for_unary_op (const octave_value& op) |
777
|
157 { |
3523
|
158 std::string type = op.type_name (); |
2374
|
159 error ("invalid operand `%s' for unary operator", type.c_str ()); |
777
|
160 } |
|
161 |
|
162 void |
2086
|
163 gripe_wrong_type_arg_for_binary_op (const octave_value& op) |
777
|
164 { |
3523
|
165 std::string type = op.type_name (); |
2374
|
166 error ("invalid operand `%s' for binary operator", type.c_str ()); |
|
167 } |
|
168 |
|
169 void |
|
170 gripe_implicit_conversion (const char *from, const char *to) |
|
171 { |
|
172 warning ("implicit conversion from %s to %s", from, to); |
|
173 } |
|
174 |
|
175 void |
4452
|
176 gripe_implicit_conversion (const std::string& from, const std::string& to) |
|
177 { |
|
178 warning ("implicit conversion from %s to %s", from.c_str (), to.c_str ()); |
|
179 } |
|
180 |
|
181 void |
2374
|
182 gripe_divide_by_zero (void) |
|
183 { |
|
184 if (Vwarn_divide_by_zero) |
|
185 warning ("division by zero"); |
777
|
186 } |
|
187 |
5755
|
188 static int |
|
189 warn_divide_by_zero (void) |
|
190 { |
|
191 Vwarn_divide_by_zero = check_preference ("warn_divide_by_zero"); |
|
192 |
|
193 return 0; |
|
194 } |
|
195 |
|
196 void |
|
197 symbols_of_gripes (void) |
|
198 { |
|
199 DEFVAR (warn_divide_by_zero, true, warn_divide_by_zero, |
|
200 "-*- texinfo -*-\n\ |
|
201 @defvr {Built-in Variable} warn_divide_by_zero\n\ |
|
202 If the value of @code{warn_divide_by_zero} is nonzero, a warning\n\ |
|
203 is issued when Octave encounters a division by zero. If the value is\n\ |
|
204 0, the warning is omitted. The default value is 1.\n\ |
|
205 @end defvr"); |
|
206 } |
|
207 |
1
|
208 /* |
|
209 ;;; Local Variables: *** |
|
210 ;;; mode: C++ *** |
|
211 ;;; End: *** |
|
212 */ |