mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 02:48:59 -04:00
Fix str::trim to handle all whitespace characters
Use std::isspace() instead of comparing only to space character. Now handles tabs, newlines, carriage returns, etc.
This commit is contained in:
parent
e43be3c221
commit
56cd831ec8
1 changed files with 3 additions and 2 deletions
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
|
@ -304,9 +305,9 @@ str::trim(const std::string &str_)
|
|||
|
||||
rv = str_;
|
||||
|
||||
while(!rv.empty() && (rv[0] == ' '))
|
||||
while(!rv.empty() && std::isspace(static_cast<unsigned char>(rv[0])))
|
||||
rv.erase(0);
|
||||
while(!rv.empty() && (rv[rv.size()-1] == ' '))
|
||||
while(!rv.empty() && std::isspace(static_cast<unsigned char>(rv[rv.size()-1])))
|
||||
rv.erase(rv.size()-1);
|
||||
|
||||
return rv;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue