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 <jwakely@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Jonathan Wakely 2018-04-10 15:22:58 +01:00 committed by Dodji Seketeli
parent 76764f6f12
commit 4d99280d27
3 changed files with 9 additions and 13 deletions

View File

@ -71,7 +71,7 @@ string get_library_version_string();
bool execute_command_and_get_output(const string&, vector<string>&);
bool get_dsos_provided_by_rpm(const string& rpm_path,
set<string>& 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);

View File

@ -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.

View File

@ -864,7 +864,7 @@ get_dsos_provided_by_rpm(const string& rpm_path, set<string>& 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<string>& 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 "";