Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
10604:d7ff75c977e2 | 10605:1834132fb50b |
---|---|
58 #include "load-path.h" | 58 #include "load-path.h" |
59 #include "oct-errno.h" | 59 #include "oct-errno.h" |
60 #include "oct-hist.h" | 60 #include "oct-hist.h" |
61 #include "oct-obj.h" | 61 #include "oct-obj.h" |
62 #include "pager.h" | 62 #include "pager.h" |
63 #include "parse.h" | |
63 #include "sysdep.h" | 64 #include "sysdep.h" |
64 #include "toplev.h" | 65 #include "toplev.h" |
65 #include "unwind-prot.h" | 66 #include "unwind-prot.h" |
66 #include "utils.h" | 67 #include "utils.h" |
67 #include "variables.h" | 68 #include "variables.h" |
1301 | 1302 |
1302 octave_quit (); | 1303 octave_quit (); |
1303 } | 1304 } |
1304 } | 1305 } |
1305 | 1306 |
1307 // FIXME -- is there some way to fix the declarations in unwind-prot.h | |
1308 // so that this function's argument can be declared as | |
1309 // "const octave_value_list&"? | |
1310 | |
1311 static void | |
1312 reset_warning_state (octave_value_list args) | |
1313 { | |
1314 if (! args.empty ()) | |
1315 set_warning_state (args); | |
1316 } | |
1317 | |
1306 DEFUN (isindex, args, , | 1318 DEFUN (isindex, args, , |
1307 "-*- texinfo -*-\n\ | 1319 "-*- texinfo -*-\n\ |
1308 @deftypefn {Built-in Function} {} isindex (@var{ind}, @var{n})\n\ | 1320 @deftypefn {Built-in Function} {} isindex (@var{ind}, @var{n})\n\ |
1309 Returns true if @var{ind} is a valid index. Valid indices can be\n\ | 1321 Returns true if @var{ind} is a valid index. Valid indices can be\n\ |
1310 either positive integers (though possibly real data), or logical arrays.\n\ | 1322 either positive integers (though possibly real data), or logical arrays.\n\ |
1323 print_usage (); | 1335 print_usage (); |
1324 | 1336 |
1325 if (! error_state) | 1337 if (! error_state) |
1326 { | 1338 { |
1327 unwind_protect frame; | 1339 unwind_protect frame; |
1340 | |
1341 octave_value_list current_warning_state | |
1342 = set_warning_state ("Octave:allow-noninteger-ranges-as-indices", | |
1343 "error"); | |
1344 | |
1345 frame.add_fcn (reset_warning_state, current_warning_state); | |
1346 | |
1328 frame.protect_var (error_state); | 1347 frame.protect_var (error_state); |
1348 | |
1329 frame.protect_var (discard_error_messages); | 1349 frame.protect_var (discard_error_messages); |
1330 discard_error_messages = true; | 1350 discard_error_messages = true; |
1331 | 1351 |
1332 try | 1352 try |
1333 { | 1353 { |