changeset 10413:271c5262975b

deprecate intwarning
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 16 Mar 2010 12:29:49 +0100
parents d2ac9433cd09
children 2a8b1db1e2ca
files scripts/ChangeLog scripts/deprecated/intwarning.m scripts/deprecated/module.mk scripts/miscellaneous/intwarning.m scripts/miscellaneous/module.mk
diffstat 5 files changed, 138 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon Mar 15 16:56:14 2010 -0400
+++ b/scripts/ChangeLog	Tue Mar 16 12:29:49 2010 +0100
@@ -1,3 +1,7 @@
+2010-03-16  Jaroslav Hajek  <highegg@gmail.com>
+
+	* miscellaneous/intwarning.m: Deprecate.
+
 2010-03-11  Jaroslav Hajek  <highegg@gmail.com>
 
 	* strings/index.m: Make it a wrapper for strfind.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/intwarning.m	Tue Mar 16 12:29:49 2010 +0100
@@ -0,0 +1,133 @@
+## Copyright (C) 2008, 2009 David Bateman
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} intwarning (@var{action})
+## @deftypefnx {Function File} {} intwarning (@var{s})
+## @deftypefnx {Function File} {@var{s} =} intwarning (@dots{})
+## Control the state of the warning for integer conversions and math
+## operations.
+##
+## @table @asis
+## @item "query"
+## With an output argument, return the current state of the integer
+## conversion and math warnings.  With no output arguments, print the
+## current state.
+##
+## @c Set example in small font to prevent overfull line
+## @smallexample
+## @group
+## intwarning ("query")
+## The state of warning "Octave:int-convert-nan" is "off"
+## The state of warning "Octave:int-convert-non-int-val" is "off"
+## The state of warning "Octave:int-convert-overflow" is "off"
+## The state of warning "Octave:int-math-overflow" is "off"
+## @end group
+## @end smallexample 
+##
+## @item "on"
+## @itemx "off"
+## Turn integer conversion and math warnings on (or off).  If there is
+## no output argument, then nothing is printed.  Otherwise the original
+## state of the state of the integer conversion and math warnings is
+## returned in a structure array.
+## @end table
+##
+## The original state of the integer warnings can be restored by passing
+## the structure array returned by @code{intwarning} to a later call to
+## @code{intwarning}.  For example
+##
+## @example
+## @group
+## s = intwarning ("off");
+## @dots{}
+## intwarning (s);
+## @end group
+## @end example
+## @seealso{warning}
+## @end deftypefn
+
+## Deprecated in v. 3.4
+
+function y = intwarning (x)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "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.");
+  endif
+
+  return;
+
+  if (nargin != 1)
+    print_usage ();
+  else
+    if (nargout > 0)
+      y = warning("query", "Octave:int-convert-nan");
+      y = [y; warning("query", "Octave:int-convert-non-int-val")];
+      y = [y; warning("query", "Octave:int-convert-overflow")];
+      y = [y; warning("query", "Octave:int-math-overflow")];
+    endif
+    if (ischar (x))
+      if (strcmpi (x, "query"))
+	if (nargout == 0)
+	  __print_int_warn_state__ ("Octave:int-convert-nan");
+	  __print_int_warn_state__ ("Octave:int-convert-non-int-val");
+	  __print_int_warn_state__ ("Octave:int-convert-overflow");
+	  __print_int_warn_state__ ("Octave:int-math-overflow");
+	  printf("\n");
+	endif
+      elseif (strcmpi (x, "on"))
+	warning ("on", "Octave:int-convert-nan");
+	warning ("on", "Octave:int-convert-non-int-val");
+	warning ("on", "Octave:int-convert-overflow");
+	warning ("on", "Octave:int-math-overflow");
+      elseif (strcmpi (x, "off"))
+	warning ("off", "Octave:int-convert-nan");
+	warning ("off", "Octave:int-convert-non-int-val");
+	warning ("off", "Octave:int-convert-overflow");    
+	warning ("off", "Octave:int-math-overflow");    
+      else
+	error ("intwarning: unrecognized argument");
+      endif
+    elseif (isstruct(x))
+      for fld = fieldnames (x)
+	if (strcmp ("Octave:int-convert-nan") || 
+	    strcmp ("Octave:int-convert-non-int-val") || 
+	    strcmp ("Octave:int-convert-overflow") ||
+	    strcmp ("Octave:int-cmath-overflow"))
+	  s = getfield (x, fld);
+	  if (! ischar (s) || !(strcmpi("s","on") || strcmpi("s","off")))
+	    error ("intwarning: unexpected warning state");
+	  endif
+	  warning (s, fld);
+	else
+	  error ("intwarning: unrecognized integer warning %s", fld);
+	endif
+      endfor
+    else
+      error ("intwarning: unexpected input");
+    endif
+  endif
+endfunction
+
+function __print_int_warn_state__ (s)
+  fprintf ("The state of warning \"%s\" is \"%s\"\n", 
+	   s, warning ("query", s).state);
+endfunction
--- a/scripts/deprecated/module.mk	Mon Mar 15 16:56:14 2010 -0400
+++ b/scripts/deprecated/module.mk	Tue Mar 16 12:29:49 2010 +0100
@@ -7,6 +7,7 @@
   deprecated/create_set.m \
   deprecated/dmult.m \
   deprecated/fstat.m \
+  deprecated/intwarning.m \
   deprecated/iscommand.m \
   deprecated/israwcommand.m \
   deprecated/isstr.m \
--- a/scripts/miscellaneous/intwarning.m	Mon Mar 15 16:56:14 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-## Copyright (C) 2008, 2009 David Bateman
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} intwarning (@var{action})
-## @deftypefnx {Function File} {} intwarning (@var{s})
-## @deftypefnx {Function File} {@var{s} =} intwarning (@dots{})
-## Control the state of the warning for integer conversions and math
-## operations.
-##
-## @table @asis
-## @item "query"
-## With an output argument, return the current state of the integer
-## conversion and math warnings.  With no output arguments, print the
-## current state.
-##
-## @c Set example in small font to prevent overfull line
-## @smallexample
-## @group
-## intwarning ("query")
-## The state of warning "Octave:int-convert-nan" is "off"
-## The state of warning "Octave:int-convert-non-int-val" is "off"
-## The state of warning "Octave:int-convert-overflow" is "off"
-## The state of warning "Octave:int-math-overflow" is "off"
-## @end group
-## @end smallexample 
-##
-## @item "on"
-## @itemx "off"
-## Turn integer conversion and math warnings on (or off).  If there is
-## no output argument, then nothing is printed.  Otherwise the original
-## state of the state of the integer conversion and math warnings is
-## returned in a structure array.
-## @end table
-##
-## The original state of the integer warnings can be restored by passing
-## the structure array returned by @code{intwarning} to a later call to
-## @code{intwarning}.  For example
-##
-## @example
-## @group
-## s = intwarning ("off");
-## @dots{}
-## intwarning (s);
-## @end group
-## @end example
-## @seealso{warning}
-## @end deftypefn
-
-function y = intwarning (x)
-
-  if (nargin != 1)
-    print_usage ();
-  else
-    if (nargout > 0)
-      y = warning("query", "Octave:int-convert-nan");
-      y = [y; warning("query", "Octave:int-convert-non-int-val")];
-      y = [y; warning("query", "Octave:int-convert-overflow")];
-      y = [y; warning("query", "Octave:int-math-overflow")];
-    endif
-    if (ischar (x))
-      if (strcmpi (x, "query"))
-	if (nargout == 0)
-	  __print_int_warn_state__ ("Octave:int-convert-nan");
-	  __print_int_warn_state__ ("Octave:int-convert-non-int-val");
-	  __print_int_warn_state__ ("Octave:int-convert-overflow");
-	  __print_int_warn_state__ ("Octave:int-math-overflow");
-	  printf("\n");
-	endif
-      elseif (strcmpi (x, "on"))
-	warning ("on", "Octave:int-convert-nan");
-	warning ("on", "Octave:int-convert-non-int-val");
-	warning ("on", "Octave:int-convert-overflow");
-	warning ("on", "Octave:int-math-overflow");
-      elseif (strcmpi (x, "off"))
-	warning ("off", "Octave:int-convert-nan");
-	warning ("off", "Octave:int-convert-non-int-val");
-	warning ("off", "Octave:int-convert-overflow");    
-	warning ("off", "Octave:int-math-overflow");    
-      else
-	error ("intwarning: unrecognized argument");
-      endif
-    elseif (isstruct(x))
-      for fld = fieldnames (x)
-	if (strcmp ("Octave:int-convert-nan") || 
-	    strcmp ("Octave:int-convert-non-int-val") || 
-	    strcmp ("Octave:int-convert-overflow") ||
-	    strcmp ("Octave:int-cmath-overflow"))
-	  s = getfield (x, fld);
-	  if (! ischar (s) || !(strcmpi("s","on") || strcmpi("s","off")))
-	    error ("intwarning: unexpected warning state");
-	  endif
-	  warning (s, fld);
-	else
-	  error ("intwarning: unrecognized integer warning %s", fld);
-	endif
-      endfor
-    else
-      error ("intwarning: unexpected input");
-    endif
-  endif
-endfunction
-
-function __print_int_warn_state__ (s)
-  fprintf ("The state of warning \"%s\" is \"%s\"\n", 
-	   s, warning ("query", s).state);
-endfunction
--- a/scripts/miscellaneous/module.mk	Mon Mar 15 16:56:14 2010 -0400
+++ b/scripts/miscellaneous/module.mk	Tue Mar 16 12:29:49 2010 +0100
@@ -29,7 +29,6 @@
   miscellaneous/gzip.m \
   miscellaneous/info.m \
   miscellaneous/inputname.m \
-  miscellaneous/intwarning.m \
   miscellaneous/ismac.m \
   miscellaneous/ispc.m \
   miscellaneous/isunix.m \