Skip to content

Commit

Permalink
remove_trailing_whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Jul 6, 2024
1 parent 4222f9b commit e383802
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stringhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ inline bool my_isspace(char c) {
inline cSv remove_trailing_whitespace(cSv sv) {
// return a string_view with trailing whitespace from sv removed
// for performance: see remove_leading_whitespace
for (size_t i = sv.length() - 1; i >= 0; --i) {
i = sv.find_last_not_of(' ', i);
for (size_t i = sv.length(); i > 0; ) {
i = sv.find_last_not_of(' ', i-1);
if (i == std::string_view::npos) return cSv(); // only ' '
if (sv[i] > 0x0d || sv[i] < 0x09) return sv.substr(0, i+1); // non whitespace found at i -> length i+1 !!!
}
Expand Down

0 comments on commit e383802

Please sign in to comment.