Mercurial > hg > octave-jordi
changeset 20995:20bd3d4fabad
Clean up instances of make_argv().
* error.cc (Fwarning, Flasterr, Flastwarn): Use '[]' to access element of
vector, rather than '()'.
* help.cc (F__which__): Call make_argv without an argument rather than with "".
* input.cc: (Fecho): Call make_argv without an argument rather than with "".
* load-save.cc: Remove useless comments. Re-indent lines. Join lines
unnecessarily split.
* ovl.cc (make_argv): Invert if/else/error.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 27 Dec 2015 12:25:03 -0800 |
parents | aab7a3c7168e |
children | d03babf77549 |
files | libinterp/corefcn/error.cc libinterp/corefcn/help.cc libinterp/corefcn/input.cc libinterp/corefcn/load-save.cc libinterp/octave-value/ovl.cc |
diffstat | 5 files changed, 47 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc +++ b/libinterp/corefcn/error.cc @@ -1475,17 +1475,17 @@ { string_vector argv = args.make_argv ("warning"); - std::string arg1 = argv(1); + std::string arg1 = argv[1]; std::string arg2 = "all"; if (nargin >= 2) - arg2 = argv(2); + arg2 = argv[2]; if (arg1 == "on" || arg1 == "off" || arg1 == "error") { octave_map old_warning_options = warning_options; - if (nargin == 3 && argv(3) == "local" + if (nargin == 3 && argv[3] == "local" && ! symbol_table::at_top_level ()) { symbol_table::scope_id scope @@ -1974,13 +1974,13 @@ if (nargin == 2) { - Vlast_error_id = argv(2); - Vlast_error_message = argv(1); + Vlast_error_id = argv[2]; + Vlast_error_message = argv[1]; } else if (nargin == 1) { Vlast_error_id = ""; - Vlast_error_message = argv(1); + Vlast_error_message = argv[1]; } if (nargin == 0 || nargout > 0) @@ -2017,13 +2017,13 @@ if (nargin == 2) { - Vlast_warning_id = argv(2); - Vlast_warning_message = argv(1); + Vlast_warning_id = argv[2]; + Vlast_warning_message = argv[1]; } else if (nargin == 1) { Vlast_warning_id = ""; - Vlast_warning_message = argv(1); + Vlast_warning_message = argv[1]; } if (nargin == 0 || nargout > 0)
--- a/libinterp/corefcn/help.cc +++ b/libinterp/corefcn/help.cc @@ -1272,7 +1272,7 @@ Undocumented internal function.\n\ @end deftypefn") { - string_vector argv = args.make_argv (""); + string_vector argv = args.make_argv (); int nargin = argv.numel ();
--- a/libinterp/corefcn/input.cc +++ b/libinterp/corefcn/input.cc @@ -965,7 +965,7 @@ { octave_value_list retval; - string_vector argv = args.make_argv (""); + string_vector argv = args.make_argv (); switch (args.length ()) {
--- a/libinterp/corefcn/load-save.cc +++ b/libinterp/corefcn/load-save.cc @@ -652,7 +652,6 @@ bool list_only = false; bool verbose = false; - //for (i; i < argc; i++) for (; i < argc; i++) { if (argv[i] == "-force" || argv[i] == "-f") @@ -816,7 +815,7 @@ retval = do_load (file, orig_fname, format, flt_fmt, list_only, swap, verbose, - argv, i, argc, nargout); + argv, i, argc, nargout); file.close (); } @@ -1138,8 +1137,7 @@ static string_vector parse_save_options (const std::string &arg, load_save_format &format, - bool &append, bool &save_as_floats, - bool &use_zlib) + bool &append, bool &save_as_floats, bool &use_zlib) { std::istringstream is (arg); std::string str; @@ -1151,8 +1149,7 @@ argv.append (str); } - return parse_save_options (argv, format, append, save_as_floats, - use_zlib); + return parse_save_options (argv, format, append, save_as_floats, use_zlib); } void @@ -1591,8 +1588,7 @@ // override from command line string_vector argv = args.make_argv (); - argv = parse_save_options (argv, format, append, save_as_floats, - use_zlib); + argv = parse_save_options (argv, format, append, save_as_floats, use_zlib); int argc = argv.numel (); int i = 0;
--- a/libinterp/octave-value/ovl.cc +++ b/libinterp/octave-value/ovl.cc @@ -215,49 +215,47 @@ { string_vector argv; - if (all_strings_p ()) + if (! all_strings_p ()) + error ("%s: all arguments must be strings", fcn_name.c_str ()); + + octave_idx_type len = length (); + + octave_idx_type total_nr = 0; + + for (octave_idx_type i = 0; i < len; i++) { - octave_idx_type len = length (); + // An empty std::string ("") has zero columns and zero rows + // (a change that was made for Matlab contemptibility. - octave_idx_type total_nr = 0; + octave_idx_type n = elem (i).rows (); + + total_nr += n ? n : 1; + } - for (octave_idx_type i = 0; i < len; i++) - { - // An empty std::string ("") has zero columns and zero rows (a - // change that was made for Matlab contemptibility. + octave_idx_type k = 0; + if (! fcn_name.empty ()) + { + argv.resize (total_nr+1); + argv[0] = fcn_name; + k = 1; + } + else + argv.resize (total_nr); - octave_idx_type n = elem(i).rows (); + for (octave_idx_type i = 0; i < len; i++) + { + octave_idx_type nr = elem (i).rows (); - total_nr += n ? n : 1; - } - - octave_idx_type k = 0; - if (! fcn_name.empty ()) + if (nr < 2) + argv[k++] = elem (i).string_value (); + else { - argv.resize (total_nr+1); - argv[0] = fcn_name; - k = 1; - } - else - argv.resize (total_nr); + string_vector tmp = elem (i).string_vector_value (); - for (octave_idx_type i = 0; i < len; i++) - { - octave_idx_type nr = elem(i).rows (); - - if (nr < 2) - argv[k++] = elem(i).string_value (); - else - { - string_vector tmp = elem(i).string_vector_value (); - - for (octave_idx_type j = 0; j < nr; j++) - argv[k++] = tmp[j]; - } + for (octave_idx_type j = 0; j < nr; j++) + argv[k++] = tmp[j]; } } - else - error ("%s: all arguments must be strings", fcn_name.c_str ()); return argv; }