Mercurial > octave-nkf
annotate examples/unwinddemo.cc @ 19025:a66548dc07b0 stable release-3-8-2
Version 3.8.2 released.
* configure.ac (OCTAVE_VERSION): Now 3.8.2.
(OCTAVE_MINOR_VERSION): Now 2.
(OCTAVE_RELEASE_DATE): Set to 2014-06-06.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Aug 2014 11:41:28 -0400 |
parents | be41c30bcb44 |
children |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/unwind-prot.h> | |
3 | |
4 void | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
5 my_err_handler (const char *fmt, ...) |
6572 | 6 { |
7 // Do nothing!! | |
8 } | |
9 | |
10 DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo") | |
11 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
12 octave_value retval; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
13 int nargin = args.length (); |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
14 |
6572 | 15 if (nargin < 2) |
16 print_usage (); | |
17 else | |
18 { | |
19 NDArray a = args(0).array_value (); | |
20 NDArray b = args(1).array_value (); | |
21 | |
22 if (! error_state) | |
23 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
24 // Declare unwind_protect frame which lasts as long as |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
25 // the variable frame has scope. |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
26 unwind_protect frame; |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
27 frame.protect_var (current_liboctave_warning_handler); |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
28 |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14855
diff
changeset
|
29 set_liboctave_warning_handler (my_err_handler); |
6572 | 30 retval = octave_value (quotient (a, b)); |
31 } | |
32 } | |
33 return retval; | |
34 } |