mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-07 00:00:17 +02:00
ltrim had the issue that it would always consume the left-most character even if it wasn't whitespace. So `FEXLoader` would turn in to `EXLoader`, even without any whitespace in the string. Adds a test to ensure this doesn't occur again.
17 lines
449 B
C++
17 lines
449 B
C++
// SPDX-License-Identifier: MIT
|
|
#include "Common/StringUtil.h"
|
|
|
|
namespace FEX::StringUtil {
|
|
void ltrim(fextl::string& s) {
|
|
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !std::isspace(ch); }));
|
|
}
|
|
|
|
void rtrim(fextl::string& s) {
|
|
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
|
|
}
|
|
void trim(fextl::string& s) {
|
|
ltrim(s);
|
|
rtrim(s);
|
|
}
|
|
} // namespace FEX::StringUtil
|