[apparmor] [patch 06/18] parser: replace reverse iterator [resend]
John Johansen
john.johansen at canonical.com
Fri Jan 24 10:40:59 UTC 2014
On 01/16/2014 02:06 PM, Steve Beattie wrote:
> As suggested by Seth Arnold, we can use string::find_last_not_of()
> instead of using C++'s hideous reverse iterators.
>
hrmmm honestly I don't think it is much different but
> Signed-off-by: Steve Beattie <steve at nxnw.org>
Acked-by: John Johansen <john.johansen at canonical.com>
> ---
> parser/parser_variable.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> Index: b/parser/parser_variable.c
> ===================================================================
> --- a/parser/parser_variable.c
> +++ b/parser/parser_variable.c
> @@ -137,11 +137,11 @@ void free_var_string(struct var_string *
>
> 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,
>
>
> -- AppArmor mailing list AppArmor at lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
>
More information about the AppArmor
mailing list