comparison libinterp/octave-value/ov.cc @ 19437: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 9e5b64b3c1fe
children 76478d2da117
comparison
equal deleted inserted replaced
19436:5cd83b466a3e 19437:03067dab10ca
2872 const Cell type = m.contents ("type"); 2872 const Cell type = m.contents ("type");
2873 const Cell subs = m.contents ("subs"); 2873 const Cell subs = m.contents ("subs");
2874 2874
2875 for (int k = 0; k < nel; k++) 2875 for (int k = 0; k < nel; k++)
2876 { 2876 {
2877 std::string item = type(k).string_value (); 2877 if (type(k).is_string ())
2878 2878 {
2879 if (! error_state) 2879 std::string item = type(k).string_value ();
2880 {
2881 if (item == "{}") 2880 if (item == "{}")
2882 type_string[k] = '{'; 2881 type_string[k] = '{';
2883 else if (item == "()") 2882 else if (item == "()")
2884 type_string[k] = '('; 2883 type_string[k] = '(';
2885 else if (item == ".") 2884 else if (item == ".")
2890 return; 2889 return;
2891 } 2890 }
2892 } 2891 }
2893 else 2892 else
2894 { 2893 {
2895 error ("%s: expecting type(%d) to be a character string", 2894 error ("%s: type(%d) must be a string", name, k+1);
2896 name, k+1);
2897 return; 2895 return;
2898 } 2896 }
2899 2897
2900 octave_value_list idx_item; 2898 octave_value_list idx_item;
2901 2899
2914 idx_item(n) = subs_cell(n); 2912 idx_item(n) = subs_cell(n);
2915 } 2913 }
2916 } 2914 }
2917 else 2915 else
2918 { 2916 {
2919 error ("%s: expecting subs(%d) to be a character string or cell array", 2917 error ("%s: subs(%d) must be a string or cell array", name, k+1);
2920 name, k+1);
2921 return; 2918 return;
2922 } 2919 }
2923 2920
2924 idx.push_back (idx_item); 2921 idx.push_back (idx_item);
2925 } 2922 }