Don't search for whitespace beyond the start/end of the text.

This commit is contained in:
tastytea 2021-06-06 23:48:06 +02:00
parent 0470acb00e
commit f59c86e20d
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 5 additions and 10 deletions

View File

@ -232,28 +232,23 @@ match_context context(const boost::match_results<string::const_iterator> &match,
pos_before = std::find_first_of(pos_before, rend_before,
whitespace.begin(),
whitespace.end());
if (pos_before != rend_before)
{
while (helpers::is_whitespace(*pos_before))
while (pos_before != rend_before
&& helpers::is_whitespace(*pos_before))
{
++pos_before;
}
}
}
if (pos_after != end_after)
{
pos_after = std::find_first_of(pos_after, end_after,
whitespace.begin(),
whitespace.end());
if (pos_after != end_after)
{
while (helpers::is_whitespace(*pos_after))
while (pos_after != end_after && helpers::is_whitespace(*pos_after))
{
++pos_after;
}
}
}
words -= 1;
}