# HG changeset patch # User jwe # Date 949566764 0 # Node ID 4290f11c8d3b1b91ab96e49738ecc9d4353c1964 # Parent 403039c85792a3cc328ee5135932defba8e7cb0c [project @ 2000-02-03 08:32:41 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2000-02-03 John W. Eaton + * pt-plot.cc (send_to_plot_stream): Use operator== and substr + method to do limited-length string comparison. + * input.cc (generate_completion): Likewise. + * ov-dld-fcn.cc (octave_dld_function::octave_dld_function): Likewise. + * ov-usr-fcn.cc (octave_user_function::mark_as_system_fcn_file): + Likewise. + + * utils.cc (check_preference): Expect exact string matches. + * variables.cc (ignore_function_time_stamp): Likewise. + * lex.l (whitespace_in_literal_matrix): Likewise. + * mappers.cc (xconj, ximag, xreal): New functions. Use them in DEFUN_MAPPER calls. diff --git a/src/input.cc b/src/input.cc --- a/src/input.cc +++ b/src/input.cc @@ -425,7 +425,7 @@ matches = 0; for (int i = 0; i < name_list_len; i++) - if (! name_list[i].compare (hint, 0, hint_len)) + if (hint == name_list[i].substr (0, hint_len)) matches++; } @@ -437,7 +437,7 @@ list_index++; - if (! name.compare (hint, 0, hint_len)) + if (hint == name.substr (0, hint_len)) { if (! prefix.empty ()) retval = prefix + "." + name; diff --git a/src/lex.l b/src/lex.l --- a/src/lex.l +++ b/src/lex.l @@ -2287,9 +2287,9 @@ if (! val.empty ()) { - if (val.compare ("ignore", 0, 6) == 0) + if (val == "ignore") pref = 2; - else if (val.compare ("traditional", 0, 11) == 0) + else if (val == "traditional") pref = 1; } diff --git a/src/ov-dld-fcn.cc b/src/ov-dld-fcn.cc --- a/src/ov-dld-fcn.cc +++ b/src/ov-dld-fcn.cc @@ -54,7 +54,7 @@ system_fcn_file = (! file_name.empty () - && Vfcn_file_dir.compare (file_name, 0, Vfcn_file_dir.length ()) == 0); + && Vfcn_file_dir == file_name.substr (0, Vfcn_file_dir.length ())); } octave_dld_function::~octave_dld_function (void) diff --git a/src/ov-usr-fcn.cc b/src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -138,7 +138,7 @@ std::string ff_name = fcn_file_in_path (file_name); - if (Vfcn_file_dir.compare (ff_name, 0, Vfcn_file_dir.length ()) == 0) + if (Vfcn_file_dir == ff_name.substr (0, Vfcn_file_dir.length ())) system_fcn_file = 1; } else diff --git a/src/pt-plot.cc b/src/pt-plot.cc --- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -208,9 +208,11 @@ int splot_len = Vgnuplot_command_splot.length (); int plot_len = Vgnuplot_command_plot.length (); - bool is_replot = (Vgnuplot_command_replot.compare (cmd, 0, replot_len) == 0); - bool is_splot = (Vgnuplot_command_splot.compare (cmd, 0, splot_len) == 0); - bool is_plot = (Vgnuplot_command_plot.compare (cmd, 0, plot_len) == 0); + std::string s = cmd; + + bool is_replot = (Vgnuplot_command_replot == s.substr (0, replot_len)); + bool is_splot = (Vgnuplot_command_splot == s.substr (0, splot_len)); + bool is_plot = (Vgnuplot_command_plot == s.substr (0, plot_len)); if (plot_line_count == 0 && is_replot) error ("replot: no previous plot"); diff --git a/src/utils.cc b/src/utils.cc --- a/src/utils.cc +++ b/src/utils.cc @@ -592,15 +592,12 @@ } else { - if (val.compare ("yes", 0, 3) == 0 - || val.compare ("true", 0, 4) == 0) + if (val == "yes" || val == "true") { warn_old_style_preference (true, val); pref = 1; } - else if (val.compare ("never", 0, 5) == 0 - || val.compare ("no", 0, 2) == 0 - || val.compare ("false", 0, 5) == 0) + else if (val == "never" || val == "no" || val == "false") { warn_old_style_preference (false, val); pref = 0; diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -1298,9 +1298,9 @@ if (! val.empty ()) { - if (val.compare ("all", 0, 3) == 0) + if (val == "all") pref = 2; - if (val.compare ("system", 0, 6) == 0) + else if (val == "system") pref = 1; }