mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: replace reverse iterator
As suggested by Seth Arnold, we can use string::find_last_not_of() instead of using C++'s hideous reverse iterators. Signed-off-by: Steve Beattie <steve@nxnw.org> Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
39564bbdf5
commit
78fe398a2f
1 changed files with 5 additions and 5 deletions
|
@ -137,11 +137,11 @@ void free_var_string(struct var_string *var)
|
|||
|
||||
static void trim_trailing_slash(std::string& str)
|
||||
{
|
||||
for (std::string::reverse_iterator rit = str.rbegin();
|
||||
rit != str.rend() && *rit == '/'; ++rit) {
|
||||
/* yuck, reverse_iterators are ugly */
|
||||
str.erase(--rit.base());
|
||||
}
|
||||
std::size_t found = str.find_last_not_of('/');
|
||||
if (found != std::string::npos)
|
||||
str.erase(found + 1);
|
||||
else
|
||||
str.clear(); // str is all '/'
|
||||
}
|
||||
|
||||
static void write_replacement(const char separator, const char* value,
|
||||
|
|
Loading…
Add table
Reference in a new issue