Mercurial > hg > octave-nkf
diff libinterp/corefcn/variables.cc @ 19600:03067dab10ca
Use stricter input validation when looking for a string as input (bug #42651).
* data.cc (get_sort_mode_option, Fissorted): Use is_string() to check string
input.
* debug.cc (Fdbstep): use "string" rather than "character string" in error
messages.
* error.cc (Flasterr, Flastwarn): use "string" rather than "character string"
in error messages.
* file-io.cc (do_stream_open, do_fread, do_fwrite, Fpopen, Ftempname,
Fmkstemp): Use is_string() to check string input.
* graphics.cc (Fgraphics_toolkit): Use is_string() to check string input.
Rephrase error message.
* help.cc (F__list_functions): Use is_string() to check string input.
* input.cc (Fyes_or_no): Use is_string() to check string input. Rephrase
error message.
* input.cc (Fadd_input_event_hook): Rephrase error message.
* load-path.cc (Fgenpath, Faddpath): Rephrase error message.
* matrix_type.cc (Fmatrix_type): Use is_string() to check string input.
* qz.cc (Fqz): Follow Octave coding convention for space after '!'.
* regexp.cc (parse_options): Use is_string() to check string input.
Rephrase error message.
* schur.cc (Fschur): Use is_string() to check string input.
* strfns.cc (Flist_in_columns): Use is_string() to check string input.
Rephrase error message.
* symtab.cc (Fignore_function_time_stamp): Use is_string() to check string
input. Rephrase error message.
* syscalls.cc (Fexec, Fpopen2, Fcanonicalize_file_name): Use is_string() to
check string input. Rephrase error message.
* sysdep.cc (Fsetenv): Use is_string() to check string input.
* time.cc (Fstrftime, Fstrptime): Use is_string() to check string input.
* toplev.cc (Fsystem, Fatexit): Use is_string() to check string input.
* urlwrite.cc (Furlwrite, Furlread): Rephrase error message.
* utils.cc (Ffile_in_path): Use is_string() to check string input. Rephrase
error message.
* variables.cc (extract_function): Add FIXME about potentially using is_string.
* variables.cc (do_isglobal, Fmunlock, Fmislocked): Use is_string() to check
string input.
* variables.cc (set_internal_variable): Rephrase error message.
* ov-base.cc (make_idx_args): Rephrase error message.
* ov-class.cc (octave_class::all_strings, Fclass): Rephrase error message.
* ov-fcn-handle.cc (Fstr2func): Use is_string() to check string input
* ov-java.cc (FjavaObject, FjavaMethod, F__java_get__, F__java_set__):
Use is_string() to check string input.
* ov.cc (Fdecode_subscripts): Use is_string() to check string input.
Rephrase error message.
* pt-idx.cc (tree_index_expression::get_struct_index): Rephrase error message.
* io.tst: Change %!warning test to %!error test to match stricter checking.
* system.tst: Change %!warning test for setenv to %!error test to match
stricter checking.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 16 Dec 2014 09:21:29 -0800 |
parents | 0f9c5a15c8fa |
children | c2f4f6eb5907 |
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc +++ b/libinterp/corefcn/variables.cc @@ -150,6 +150,8 @@ if (! retval) { + // FIXME: Should is_string () be used instead which will warn more + // broadly about incorrect input? std::string s = arg.string_value (); std::string cmd = header; @@ -341,14 +343,14 @@ return retval; } - std::string name = args(0).string_value (); - - if (error_state) + if (! args(0).is_string ()) { error ("isglobal: NAME must be a string"); return retval; } + std::string name = args(0).string_value (); + return symbol_table::is_global (name); } @@ -946,7 +948,7 @@ error ("%s: value must not be empty", nm); } else - error ("%s: expecting arg to be a character string", nm); + error ("%s: expecting arg to be a string", nm); } else if (nargin > 1) print_usage (); @@ -994,7 +996,7 @@ error ("%s: value not allowed (\"%s\")", nm, sval.c_str ()); } else - error ("%s: expecting arg to be a character string", nm); + error ("%s: expecting arg to be a string", nm); } else if (nargin > 1) print_usage (); @@ -2076,10 +2078,11 @@ if (args.length () == 1) { - std::string name = args(0).string_value (); - - if (! error_state) - munlock (name); + if (args(0).is_string ()) + { + std::string name = args(0).string_value (); + munlock (name); + } else error ("munlock: FCN must be a string"); } @@ -2112,10 +2115,11 @@ if (args.length () == 1) { - std::string name = args(0).string_value (); - - if (! error_state) - retval = mislocked (name); + if (args(0).is_string ()) + { + std::string name = args(0).string_value (); + retval = mislocked (name); + } else error ("mislocked: FCN must be a string"); }