Mercurial > hg > octave-lyh
annotate scripts/deprecated/intwarning.m @ 11100:cdf940db26a0
provide mxIsFunctionHandle MEX interface function
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 16 Oct 2010 13:27:18 -0400 |
parents | a4f482e66b65 |
children | fe3c3dfc07eb |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2008, 2009 David Bateman |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
2 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
4 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 ## your option) any later version. |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
13 ## General Public License for more details. |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
18 |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} intwarning (@var{action}) |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 ## @deftypefnx {Function File} {} intwarning (@var{s}) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{s} =} intwarning (@dots{}) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
23 ## Control the state of the warning for integer conversions and math |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
24 ## operations. |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
25 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
26 ## @table @asis |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
27 ## @item "query" |
9810 | 28 ## With an output argument, return the current state of the integer |
29 ## conversion and math warnings. With no output arguments, print the | |
30 ## current state. | |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
31 ## @c Set example in small font to prevent overfull line |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
32 ## |
8516 | 33 ## @smallexample |
34 ## @group | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
35 ## intwarning ("query") |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
36 ## The state of warning "Octave:int-convert-nan" is "off" |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
37 ## The state of warning "Octave:int-convert-non-int-val" is "off" |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
38 ## The state of warning "Octave:int-convert-overflow" is "off" |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 ## The state of warning "Octave:int-math-overflow" is "off" |
8516 | 40 ## @end group |
41 ## @end smallexample | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
42 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
43 ## @item "on" |
9810 | 44 ## @itemx "off" |
45 ## Turn integer conversion and math warnings on (or off). If there is | |
46 ## no output argument, then nothing is printed. Otherwise the original | |
47 ## state of the state of the integer conversion and math warnings is | |
48 ## returned in a structure array. | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
49 ## @end table |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
50 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
51 ## The original state of the integer warnings can be restored by passing |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
52 ## the structure array returned by @code{intwarning} to a later call to |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
53 ## @code{intwarning}. For example: |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
54 ## |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
55 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9036
diff
changeset
|
56 ## @group |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
57 ## s = intwarning ("off"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
58 ## @dots{} |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
59 ## intwarning (s); |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9036
diff
changeset
|
60 ## @end group |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
61 ## @end example |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
62 ## @seealso{warning} |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
63 ## @end deftypefn |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
64 |
10413 | 65 ## Deprecated in v. 3.4 |
66 | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
67 function y = intwarning (x) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
68 |
10413 | 69 persistent warned = false; |
70 if (! warned) | |
71 warned = true; | |
72 warning ("Octave:deprecated-function", | |
73 "intwarning is obsolete and will be removed from a future version of Octave. Integer math no longer produces warnings. Supply your own checks if you need those."); | |
74 endif | |
75 | |
76 return; | |
77 | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
78 if (nargin != 1) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
79 print_usage (); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
80 else |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
81 if (nargout > 0) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
82 y = warning("query", "Octave:int-convert-nan"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
83 y = [y; warning("query", "Octave:int-convert-non-int-val")]; |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
84 y = [y; warning("query", "Octave:int-convert-overflow")]; |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
85 y = [y; warning("query", "Octave:int-math-overflow")]; |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
86 endif |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
87 if (ischar (x)) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
88 if (strcmpi (x, "query")) |
10549 | 89 if (nargout == 0) |
90 __print_int_warn_state__ ("Octave:int-convert-nan"); | |
91 __print_int_warn_state__ ("Octave:int-convert-non-int-val"); | |
92 __print_int_warn_state__ ("Octave:int-convert-overflow"); | |
93 __print_int_warn_state__ ("Octave:int-math-overflow"); | |
94 printf("\n"); | |
95 endif | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
96 elseif (strcmpi (x, "on")) |
10549 | 97 warning ("on", "Octave:int-convert-nan"); |
98 warning ("on", "Octave:int-convert-non-int-val"); | |
99 warning ("on", "Octave:int-convert-overflow"); | |
100 warning ("on", "Octave:int-math-overflow"); | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
101 elseif (strcmpi (x, "off")) |
10549 | 102 warning ("off", "Octave:int-convert-nan"); |
103 warning ("off", "Octave:int-convert-non-int-val"); | |
104 warning ("off", "Octave:int-convert-overflow"); | |
105 warning ("off", "Octave:int-math-overflow"); | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
106 else |
10549 | 107 error ("intwarning: unrecognized argument"); |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
108 endif |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
109 elseif (isstruct(x)) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
110 for fld = fieldnames (x) |
10549 | 111 if (strcmp ("Octave:int-convert-nan") || |
112 strcmp ("Octave:int-convert-non-int-val") || | |
113 strcmp ("Octave:int-convert-overflow") || | |
114 strcmp ("Octave:int-cmath-overflow")) | |
115 s = getfield (x, fld); | |
116 if (! ischar (s) || !(strcmpi("s","on") || strcmpi("s","off"))) | |
117 error ("intwarning: unexpected warning state"); | |
118 endif | |
119 warning (s, fld); | |
120 else | |
121 error ("intwarning: unrecognized integer warning %s", fld); | |
122 endif | |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
123 endfor |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
124 else |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
125 error ("intwarning: unexpected input"); |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
126 endif |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
127 endif |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
128 endfunction |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
129 |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
130 function __print_int_warn_state__ (s) |
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
131 fprintf ("The state of warning \"%s\" is \"%s\"\n", |
10549 | 132 s, warning ("query", s).state); |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
133 endfunction |