diff src/utils.cc @ 10605:1834132fb50b

allow non-integer ranges as indices conditionally
author John W. Eaton <jwe@octave.org>
date Wed, 05 May 2010 14:20:58 -0400
parents f13bf183a003
children e103fb2182ce
line wrap: on
line diff
--- a/src/utils.cc	Tue May 04 12:56:27 2010 -0400
+++ b/src/utils.cc	Wed May 05 14:20:58 2010 -0400
@@ -60,6 +60,7 @@
 #include "oct-hist.h"
 #include "oct-obj.h"
 #include "pager.h"
+#include "parse.h"
 #include "sysdep.h"
 #include "toplev.h"
 #include "unwind-prot.h"
@@ -1303,6 +1304,17 @@
     }
 }
 
+// FIXME -- is there some way to fix the declarations in unwind-prot.h
+// so that this function's argument can be declared as
+// "const octave_value_list&"?
+
+static void
+reset_warning_state (octave_value_list args)
+{
+  if (! args.empty ())
+    set_warning_state (args);
+}
+
 DEFUN (isindex, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} isindex (@var{ind}, @var{n})\n\
@@ -1325,7 +1337,15 @@
   if (! error_state)
     {
       unwind_protect frame;
+
+      octave_value_list current_warning_state
+        = set_warning_state ("Octave:allow-noninteger-ranges-as-indices",
+                             "error");
+
+      frame.add_fcn (reset_warning_state, current_warning_state);
+
       frame.protect_var (error_state);
+
       frame.protect_var (discard_error_messages);
       discard_error_messages = true;