Mercurial > octave
diff libinterp/corefcn/error.cc @ 20897:9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
* cellfun.cc (Fnum2cell): Remove extra space in nargin declaration.
* error.cc (Fwarning): Rename argc variable to nargin and update code.
* graphics.cc (create): Surround tertiary expression with parentheses before
assignment to variable.
* pager.cc (Fmore): Rename argc variable to nargin and update code. Replace
make_argv() with xstring_value() call. Make error messages more specific.
* pr-output.cc (Fformat): Return empty octave_value_list rather than declaring
retval and then returning it.
* variables.cc (Fwho, Fwhos): Remove unused variable retval.
* variables.cc (Fclear): Return empty octave_value_list rather than declaring
retval and then returning it.
* pt-funcall.cc (print_raw): Rename variable "len" to "n" for clarity.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 14 Dec 2015 15:34:39 -0800 |
parents | 1142cf6abc0d |
children | 6f0bd96f93c0 |
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/corefcn/error.cc Mon Dec 14 15:34:39 2015 -0800 @@ -1469,25 +1469,24 @@ { octave_value retval; - int argc = args.length () + 1; - + int nargin = args.length (); bool done = false; - if (argc > 1 && args.all_strings_p ()) + if (nargin > 0 && args.all_strings_p ()) { string_vector argv = args.make_argv ("warning"); std::string arg1 = argv(1); std::string arg2 = "all"; - if (argc >= 3) + if (nargin >= 2) arg2 = argv(2); if (arg1 == "on" || arg1 == "off" || arg1 == "error") { octave_map old_warning_options = warning_options; - if (argc == 4 && argv(3) == "local" + if (nargin == 3 && argv(3) == "local" && ! symbol_table::at_top_level ()) { symbol_table::scope_id scope @@ -1557,7 +1556,7 @@ // Now ignore the "local" argument and continue to // handle the current setting. - argc--; + nargin--; } if (arg2 == "all") @@ -1570,13 +1569,11 @@ id(0) = arg2; st(0) = arg1; - // Since internal Octave functions are not - // compatible, turning all warnings into errors - // should leave the state of + // Since internal Octave functions are not compatible, + // turning all warnings into errors should leave the state of // Octave:language-extension alone. - if (arg1 == "error" - && warning_options.contains ("identifier")) + if (arg1 == "error" && warning_options.contains ("identifier")) { octave_idx_type n = 1; @@ -1684,7 +1681,7 @@ done = true; } } - else if (argc == 1) + else if (nargin == 0) { if (nargout > 0) retval = warning_options; @@ -1693,7 +1690,7 @@ done = true; } - else if (argc == 2) + else if (nargin == 1) { octave_value arg = args(0); @@ -1703,25 +1700,23 @@ { octave_map m = arg.map_value (); - if (m.contains ("identifier") && m.contains ("state")) - { - // Simply step through the struct elements one at a time. + if (! m.contains ("identifier") || ! m.contains ("state")) + error ("warning: STATE structure must have fields 'identifier' and 'state'"); - Cell ident = m.contents ("identifier"); - Cell state = m.contents ("state"); + // Simply step through the struct elements one at a time. - octave_idx_type nel = ident.numel (); + Cell ident = m.contents ("identifier"); + Cell state = m.contents ("state"); - for (octave_idx_type i = 0; i < nel; i++) - { - std::string tst = state(i).string_value (); - std::string tid = ident(i).string_value (); + octave_idx_type nel = ident.numel (); - set_warning_option (tst, tid); - } + for (octave_idx_type i = 0; i < nel; i++) + { + std::string tst = state(i).string_value (); + std::string tid = ident(i).string_value (); + + set_warning_option (tst, tid); } - else - error ("warning: STATE structure must have fields 'identifier' and 'state'"); done = true;