From 4d99280d27343ba585f13e28479e4264598d8f35 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 10 Apr 2018 15:22:58 +0100 Subject: [PATCH] Rename misleading remove_trailing_white_spaces functions Trailing implies only whitespace at the end is removed, but these functions also remove leading whitespace. * include/abg-tools-utils.h (trim_white_space): Renamed remove_trailing_white_spaces into this. * src/abg-ini.cc (trim_white_space): Likewise. * src/abg-tools-utils.cc (get_dsos_provided_by_rpm): Adjust. Signed-off-by: Jonathan Wakely Signed-off-by: Dodji Seketeli --- include/abg-tools-utils.h | 2 +- src/abg-ini.cc | 13 +++++-------- src/abg-tools-utils.cc | 7 +++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h index defc7ba0..2e592568 100644 --- a/include/abg-tools-utils.h +++ b/include/abg-tools-utils.h @@ -71,7 +71,7 @@ string get_library_version_string(); bool execute_command_and_get_output(const string&, vector&); bool get_dsos_provided_by_rpm(const string& rpm_path, set& provided_dsos); -string remove_trailing_white_spaces(const string&); +string trim_white_space(const string&); suppr::type_suppression_sptr gen_suppr_spec_from_headers(const string& hdrs_root_dir); diff --git a/src/abg-ini.cc b/src/abg-ini.cc index c33e2ae9..7558c2f3 100644 --- a/src/abg-ini.cc +++ b/src/abg-ini.cc @@ -168,15 +168,13 @@ static bool char_is_white_space(int b) {return b == ' ' || b == '\t' || b == '\n';} -/// Remove the trailing spaces at the begining and at the end of a -/// given string. +/// Remove the spaces at the begining and at the end of a given string. /// -/// @param str the string to remove trailing white spaces from. +/// @param str the string to remove leading and trailing white spaces from. /// -/// @return the string resulting from the removal of trailing white -/// space from @p str. +/// @return the string resulting from the removal of white space from @p str. static string -remove_trailing_white_spaces(const string& str) +trim_white_space(const string& str) { string result; @@ -1401,8 +1399,7 @@ public: assert(read_next_char(c)); v += c; } - string result = remove_trailing_white_spaces(v); - return result; + return trim_white_space(v); } /// Read a string property value. diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 38c49408..c560fb01 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -864,7 +864,7 @@ get_dsos_provided_by_rpm(const string& rpm_path, set& provided_dsos) ++line) { string dso = line->substr(0, line->find('(')); - dso = remove_trailing_white_spaces(dso); + dso = trim_white_space(dso); if (!dso.empty()) provided_dsos.insert(dso); } @@ -875,10 +875,9 @@ get_dsos_provided_by_rpm(const string& rpm_path, set& provided_dsos) /// /// @param str the input string to consider. /// -/// @return the @p str string from which trailing white spaces have -/// been removed. +/// @return the @p str string with leading and trailing white spaces removed. string -remove_trailing_white_spaces(const string& str) +trim_white_space(const string& str) { if (str.empty()) return "";