Mercurial > octave-nkf
diff libinterp/corefcn/symtab.cc @ 20617:ba2b07c13913
use new string_value method to handle value extraction errors
* __dispatch__.cc, balance.cc, colloc.cc, conv2.cc, data.cc, debug.cc,
graphics.cc, input.cc, matrix_type.cc, oct-hist.cc, schur.cc,
spparms.cc, symtab.cc, sysdep.cc, toplev.cc, utils.cc:
Use new string_value method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Oct 2015 10:06:39 -0400 |
parents | 33b03b06442b |
children |
line wrap: on
line diff
--- a/libinterp/corefcn/symtab.cc Thu Oct 08 19:00:51 2015 -0400 +++ b/libinterp/corefcn/symtab.cc Fri Oct 09 10:06:39 2015 -0400 @@ -1688,20 +1688,16 @@ if (nargin == 1) { - if (args(0).is_string ()) - { - std::string sval = args(0).string_value (); - if (sval == "all") - Vignore_function_time_stamp = 2; - else if (sval == "system") - Vignore_function_time_stamp = 1; - else if (sval == "none") - Vignore_function_time_stamp = 0; - else - error ("ignore_function_time_stamp: argument must be \"all\", \"system\", or \"none\""); - } + std::string sval = args(0).string_value ("ignore_function_time_stamp: expecting argument to be a string"); + + if (sval == "all") + Vignore_function_time_stamp = 2; + else if (sval == "system") + Vignore_function_time_stamp = 1; + else if (sval == "none") + Vignore_function_time_stamp = 0; else - error ("ignore_function_time_stamp: expecting argument to be character string"); + error ("ignore_function_time_stamp: argument must be \"all\", \"system\", or \"none\""); } else if (nargin > 1) print_usage (); @@ -1823,27 +1819,22 @@ if (args.length () == 1) { - std::string name = args(0).string_value (); + std::string name = args(0).string_value ("__get_cmd_line_function_text__: expecting function name"); - if (! error_state) - { - octave_value ov = symbol_table::find_cmdline_function (name); + octave_value ov = symbol_table::find_cmdline_function (name); - octave_user_function *f = ov.user_function_value (); + octave_user_function *f = ov.user_function_value (); - if (f) - { - std::ostringstream buf; - - tree_print_code tpc (buf); + if (f) + { + std::ostringstream buf; - f->accept (tpc); + tree_print_code tpc (buf); - retval = buf.str (); - } + f->accept (tpc); + + retval = buf.str (); } - else - error ("__get_cmd_line_function_text__: expecting function name"); } else print_usage (); @@ -1861,12 +1852,9 @@ if (args.length () == 2) { - std::string name = args(0).string_value (); + std::string name = args(0).string_value ("set_variable: expecting variable name as first argument"); - if (! error_state) - symbol_table::assign (name, args(1)); - else - error ("set_variable: expecting variable name as first argument"); + symbol_table::assign (name, args(1)); } else print_usage (); @@ -1880,18 +1868,13 @@ if (args.length () == 1) { - std::string name = args(0).string_value (); + std::string name = args(0).string_value ("variable_value: expecting variable name as first argument"); - if (! error_state) - { - retval = symbol_table::varval (name); + retval = symbol_table::varval (name); - if (retval.is_undefined ()) - error ("variable_value: '%s' is not a variable in the current scope", - name.c_str ()); - } - else - error ("variable_value: expecting variable name as first argument"); + if (retval.is_undefined ()) + error ("variable_value: '%s' is not a variable in the current scope", + name.c_str ()); } else print_usage ();