Editing Refactor C++ code to use ovl() when returning multiple values
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
Some Octave | Some functions In Octave C++ error handling mechanism in core Octave has been changed to use exceptions. Previously, calling print_usage() or error() in C++ would always return execution to the calling function. This made it necessary to explicitly use the return keyword to exit a function, or arrange for an if/else tree in the original function so that normal function execution would not continue in the case of an error. With exceptions, the C++ code may now be written in a manner that closely resembles Octave's own m-file language. | ||
The principal work for this sprint topic is to convert the C++ code to the new syntax. In general, this means moving the input validation to the start of the function and logically negating the conditional used to test for an error condition. For a single condition, the condition itself should be reversed rather than just adding the negation operator '!' to the start of the conditional. For a test with multiple conditions, use DeMorgan's Law ([https://en.wikipedia.org/wiki/Demorgans_law Demorgan's Law]). In brief, you will need to negate each individual conditional and then change all && to || or vice versa. | |||
==== Example 1 : Simple Conditional (colloc() from colloc.cc) ==== | |||
==== Example 1 : | |||
{| | {| | ||
!Before !! After | !Before !! After | ||
Line 46: | Line 22: | ||
|} | |} | ||
==== Example 2 : | ==== Example 2 : Multiple Conditional (fopen() from file-io.cc) ==== | ||
{| | {| | ||
!Before !! After | !Before !! After | ||
Line 79: | Line 55: | ||
== Detailed Instructions == | == Detailed Instructions == | ||
The list of files which contain | The list of files which contain an instance of print_usage() is shown in the Files section of this page. The actual instances, including line numbers, are shown in the Instances section. To avoid duplication, sign up for a particular file by editing the Files section of this wiki page and replacing '???' with your name. When you have edited a file you should verify that everything is okay by executing | ||
<pre> | <pre> | ||
Line 95: | Line 71: | ||
Total: 61 | Total: 61 | ||
Fixed: | Fixed: 0 | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 101: | Line 77: | ||
|- | |- | ||
| | | ??? || corefcn/__dsearchn__.cc | ||
|- | |- | ||
| | | ??? || corefcn/__ilu__.cc | ||
|- | |- | ||
| | | ??? || corefcn/__qp__.cc | ||
|- | |- | ||
| | | ??? || corefcn/balance.cc | ||
|- | |- | ||
| | | ??? || corefcn/besselj.cc | ||
|- | |- | ||
| | | ??? || corefcn/colloc.cc | ||
|- | |- | ||
| | | ??? || corefcn/daspk.cc | ||
|- | |- | ||
| | | ??? || corefcn/dasrt.cc | ||
|- | |- | ||
| | | ??? || corefcn/dassl.cc | ||
|- | |- | ||
| | | ??? || corefcn/data.cc | ||
|- | |- | ||
| | | ??? || corefcn/debug.cc | ||
|- | |- | ||
| | | ??? || corefcn/det.cc | ||
|- | |- | ||
| | | ??? || corefcn/dirfns.cc | ||
|- | |- | ||
| | | ??? || corefcn/eig.cc | ||
|- | |- | ||
| | | ??? || corefcn/ellipj.cc | ||
|- | |- | ||
| | | ??? || corefcn/file-io.cc | ||
|- | |- | ||
| | | ??? || corefcn/filter.cc | ||
|- | |- | ||
| | | ??? || corefcn/find.cc | ||
|- | |- | ||
| | | ??? || corefcn/getgrent.cc | ||
|- | |- | ||
| | | ??? || corefcn/getpwent.cc | ||
|- | |- | ||
| | | ??? || corefcn/givens.cc | ||
|- | |- | ||
| | | ??? || corefcn/graphics.cc | ||
|- | |- | ||
| | | ??? || corefcn/help.cc | ||
|- | |- | ||
| | | ??? || corefcn/hess.cc | ||
|- | |- | ||
| | | ??? || corefcn/inv.cc | ||
|- | |- | ||
| | | ??? || corefcn/lsode.cc | ||
|- | |- | ||
| | | ??? || corefcn/lu.cc | ||
|- | |- | ||
| | | ??? || corefcn/luinc.cc | ||
|- | |- | ||
| | | ??? || corefcn/max.cc | ||
|- | |- | ||
| | | ??? || corefcn/mgorth.cc | ||
|- | |- | ||
| | | ??? || corefcn/oct-stream.cc | ||
|- | |- | ||
| | | ??? || corefcn/octave-link.cc | ||
|- | |- | ||
| | | ??? || corefcn/ordschur.cc | ||
|- | |- | ||
| | | ??? || corefcn/profiler.cc | ||
|- | |- | ||
| | | ??? || corefcn/quad.cc | ||
|- | |- | ||
| | | ??? || corefcn/quadcc.cc | ||
|- | |- | ||
| | | ??? || corefcn/qz.cc | ||
|- | |- | ||
| | | ??? || corefcn/regexp.cc | ||
|- | |- | ||
| | | ??? || corefcn/schur.cc | ||
|- | |- | ||
| | | ??? || corefcn/spparms.cc | ||
|- | |- | ||
| | | ??? || corefcn/sqrtm.cc | ||
|- | |- | ||
| | | ??? || corefcn/svd.cc | ||
|- | |- | ||
| | | ??? || corefcn/symtab.cc | ||
|- | |- | ||
| | | ??? || corefcn/syscalls.cc | ||
|- | |- | ||
| | | ??? || corefcn/time.cc | ||
|- | |- | ||
| | | ??? || corefcn/toplev.cc | ||
|- | |- | ||
| | | ??? || corefcn/urlwrite.cc | ||
|- | |- | ||
| | | ??? || dldfcn/__eigs__.cc | ||
|- | |- | ||
| | | ??? || dldfcn/__fltk_uigetfile__.cc | ||
|- | |- | ||
| | | ??? || dldfcn/__glpk__.cc | ||
|- | |- | ||
| | | ??? || dldfcn/__magick_read__.cc | ||
|- | |- | ||
| | | ??? || dldfcn/__voronoi__.cc | ||
|- | |- | ||
| | | ??? || dldfcn/amd.cc | ||
|- | |- | ||
| | | ??? || dldfcn/audioread.cc | ||
|- | |- | ||
| | | ??? || dldfcn/ccolamd.cc | ||
|- | |- | ||
| | | ??? || dldfcn/chol.cc | ||
|- | |- | ||
| | | ??? || dldfcn/colamd.cc | ||
|- | |- | ||
| | | ??? || dldfcn/convhulln.cc | ||
|- | |- | ||
| | | ??? || dldfcn/dmperm.cc | ||
|- | |- | ||
| | | ??? || dldfcn/qr.cc | ||
|- | |- | ||
| | | ??? || dldfcn/symbfact.cc | ||
|- | |- | ||
Line 577: | Line 553: | ||
dldfcn/__eigs__.cc:521 | dldfcn/__eigs__.cc:521 | ||
dldfcn/__eigs__.cc:567 | dldfcn/__eigs__.cc:567 | ||
dldfcn/__fltk_uigetfile__.cc:129 | dldfcn/__fltk_uigetfile__.cc:129 | ||
dldfcn/__fltk_uigetfile__.cc:131 | dldfcn/__fltk_uigetfile__.cc:131 | ||
dldfcn/__glpk__.cc:632 | dldfcn/__glpk__.cc:632 | ||
dldfcn/__magick_read__.cc:279 | dldfcn/__magick_read__.cc:279 |