# HG changeset patch # User Rik # Date 1450136079 28800 # Node ID 9aad16a799c941536b253b98f1263bb61de679e2 # Parent 5e16d687a7018d78b4f9db9a22450bae4ea3d176 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. diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/corefcn/cellfun.cc Mon Dec 14 15:34:39 2015 -0800 @@ -1809,7 +1809,7 @@ { octave_value retval; - int nargin = args.length (); + int nargin = args.length (); if (nargin < 1 || nargin > 2) print_usage (); diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/corefcn/error.cc --- 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; diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/corefcn/graphics.cc Mon Dec 14 15:34:39 2015 -0800 @@ -1699,8 +1699,8 @@ } else if (type.compare ("any")) { - octave_value ov = args.length () > 0 ? args(0) - : octave_value (Matrix ()); + octave_value ov = (args.length () > 0 ? args(0) + : octave_value (Matrix ())); retval = property (new any_property (name, h, ov)); } diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/corefcn/pager.cc --- a/libinterp/corefcn/pager.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/corefcn/pager.cc Mon Dec 14 15:34:39 2015 -0800 @@ -608,30 +608,26 @@ @seealso{page_screen_output, page_output_immediately, PAGER, PAGER_FLAGS}\n\ @end deftypefn") { - octave_value_list retval; + int nargin = args.length (); - int argc = args.length () + 1; - - if (argc < 1 || argc > 2) + if (nargin > 1) print_usage (); - string_vector argv = args.make_argv ("more"); - - if (argc == 2) + if (nargin > 0) { - std::string arg = argv[1]; + std::string arg = args(0).xstring_value ("more: argument must be string \"on\" or \"off\""); if (arg == "on") Vpage_screen_output = true; else if (arg == "off") Vpage_screen_output = false; else - error ("more: unrecognized argument '%s'", arg.c_str ()); + error ("more: argument must be \"on\" or \"off\""); } else Vpage_screen_output = ! Vpage_screen_output; - return retval; + return octave_value_list (); } DEFUN (terminal_size, , , diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/corefcn/pr-output.cc Mon Dec 14 15:34:39 2015 -0800 @@ -4033,15 +4033,13 @@ @seealso{fixed_point_format, output_max_field_width, output_precision, split_long_rows, print_empty_dimensions, rats}\n\ @end deftypefn") { - octave_value_list retval; - int argc = args.length () + 1; string_vector argv = args.make_argv ("format"); set_format_style (argc, argv); - return retval; + return octave_value_list (); } DEFUN (__compactformat__, args, nargout, diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/corefcn/variables.cc Mon Dec 14 15:34:39 2015 -0800 @@ -1820,8 +1820,6 @@ @seealso{whos, isglobal, isvarname, exist, regexp}\n\ @end deftypefn") { - octave_value retval; - if (nargout > 1) print_usage (); @@ -1896,8 +1894,6 @@ @seealso{who, whos_line_format}\n\ @end deftypefn") { - octave_value retval; - if (nargout > 1) print_usage (); @@ -2376,8 +2372,6 @@ @seealso{who, whos, exist}\n\ @end deftypefn") { - octave_value_list retval; - int argc = args.length () + 1; string_vector argv = args.make_argv ("clear"); @@ -2458,9 +2452,7 @@ if (idx <= argc) { if (! have_dash_option) - { - do_matlab_compatible_clear (argv, argc, idx); - } + do_matlab_compatible_clear (argv, argc, idx); else { if (clear_all) @@ -2468,8 +2460,7 @@ maybe_warn_exclusive (exclusive); if (++idx < argc) - warning - ("clear: ignoring extra arguments after -all"); + warning ("clear: ignoring extra arguments after -all"); symbol_table::clear_all (); } @@ -2505,7 +2496,7 @@ } } - return retval; + return octave_value_list (); } DEFUN (whos_line_format, args, nargout, diff -r 5e16d687a701 -r 9aad16a799c9 libinterp/parse-tree/pt-funcall.cc --- a/libinterp/parse-tree/pt-funcall.cc Mon Dec 14 14:34:57 2015 -0800 +++ b/libinterp/parse-tree/pt-funcall.cc Mon Dec 14 15:34:39 2015 -0800 @@ -52,12 +52,12 @@ os << nm << " ("; - octave_idx_type len = args.length (); - for (octave_idx_type i = 0; i < len; i++) + octave_idx_type n = args.length (); + for (octave_idx_type i = 0; i < n; i++) { args(i).print_raw (os, pr_as_read_syntax); - if (i < len - 1) + if (i < n - 1) os << ", "; }