Mercurial > octave
diff libinterp/corefcn/help.cc @ 20922:49081851fddc
Eliminate duplicate input arg checking in which.m and __which__.
* which.m: Put input validation and print_usage call at top of fcn.
* help.cc (F__which__): Don't check number of inputs or call print_usage in
internal function. Call make_argv() with no argument to avoid a lot of +1/-1
arithmetic.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 16 Dec 2015 16:47:18 -0800 |
parents | f1b2a2dbc0e1 |
children | b17fda023ca6 |
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc Wed Dec 16 18:21:46 2015 -0500 +++ b/libinterp/corefcn/help.cc Wed Dec 16 16:47:18 2015 -0800 @@ -1282,20 +1282,17 @@ Undocumented internal function.\n\ @end deftypefn") { - string_vector argv = args.make_argv ("which"); + string_vector argv = args.make_argv (""); - int argc = argv.numel (); + int nargin = argv.numel (); - if (argc < 2) - print_usage (); + octave_map m (dim_vector (1, nargin)); - octave_map m (dim_vector (1, argc-1)); + Cell names (1, nargin); + Cell files (1, nargin); + Cell types (1, nargin); - Cell names (1, argc-1); - Cell files (1, argc-1); - Cell types (1, argc-1); - - for (int i = 1; i < argc; i++) + for (int i = 0; i < nargin; i++) { std::string name = argv[i]; @@ -1303,16 +1300,16 @@ std::string file = do_which (name, type); - names(i-1) = name; - files(i-1) = file; - types(i-1) = type; + names(i) = name; + files(i) = file; + types(i) = type; } m.assign ("name", names); m.assign ("file", files); m.assign ("type", types); - return octave_value (m); + return ovl (m); } // FIXME: Are we sure this function always does the right thing?