Mercurial > octave-nkf
comparison examples/code/unwinddemo.cc @ 20578:2f8500ca91d3
eliminate error_state from example files
* addtwomatrices.cc, celldemo.cc, embedded.cc, fortrandemo.cc,
funcdemo.cc, globaldemo.cc, helloworld.cc, make_int.cc, paramdemo.cc,
stringdemo.cc, structdemo.cc, unwinddemo.cc:
Eliminate use of global error_state variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 03 Oct 2015 16:05:27 -0400 |
parents | 95c533ed464b |
children |
comparison
equal
deleted
inserted
replaced
20577:c547458dc10e | 20578:2f8500ca91d3 |
---|---|
13 // Do nothing!! | 13 // Do nothing!! |
14 } | 14 } |
15 | 15 |
16 DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo") | 16 DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo") |
17 { | 17 { |
18 octave_value retval; | 18 if (args.length () < 2) |
19 int nargin = args.length (); | 19 print_usage (); |
20 | 20 |
21 if (nargin < 2) | 21 NDArray a = args(0).array_value (); |
22 print_usage (); | 22 NDArray b = args(1).array_value (); |
23 else | |
24 { | |
25 NDArray a = args(0).array_value (); | |
26 NDArray b = args(1).array_value (); | |
27 | 23 |
28 if (! error_state) | 24 // Declare unwind_protect frame which lasts as long as |
29 { | 25 // the variable frame has scope. |
30 // Declare unwind_protect frame which lasts as long as | 26 unwind_protect frame; |
31 // the variable frame has scope. | 27 frame.add_fcn (set_liboctave_warning_handler, |
32 unwind_protect frame; | 28 current_liboctave_warning_handler); |
33 frame.add_fcn (set_liboctave_warning_handler, | |
34 current_liboctave_warning_handler); | |
35 | 29 |
36 frame.add_fcn (set_liboctave_warning_with_id_handler, | 30 frame.add_fcn (set_liboctave_warning_with_id_handler, |
37 current_liboctave_warning_with_id_handler); | 31 current_liboctave_warning_with_id_handler); |
38 | 32 |
39 set_liboctave_warning_handler (my_err_handler); | 33 set_liboctave_warning_handler (my_err_handler); |
40 set_liboctave_warning_with_id_handler (my_err_with_id_handler); | 34 set_liboctave_warning_with_id_handler (my_err_with_id_handler); |
41 | 35 |
42 retval = octave_value (quotient (a, b)); | 36 return octave_value (quotient (a, b)); |
43 } | |
44 } | |
45 | |
46 return retval; | |
47 } | 37 } |