mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-18 13:03:06 +01:00
Fix various trim functions (#271)
Trim doesn't handle the case where the whole string should be trimmed, due to being composed of only trimmable chars. For example the string "\n" when trimmed with chars " \t\n\r" should yield the empty string "" and not return "\n". Some test cases were fixed and some were added.
This commit is contained in:
@@ -480,7 +480,7 @@ namespace bx
|
||||
}
|
||||
}
|
||||
|
||||
return _str;
|
||||
return StringView(_str.getTerm(), _str.getTerm() );
|
||||
}
|
||||
|
||||
StringView strLTrimSpace(const StringView& _str)
|
||||
@@ -523,7 +523,9 @@ namespace bx
|
||||
{
|
||||
return StringView(ptr, ii + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return StringView(_str.getPtr(), _str.getPtr());
|
||||
}
|
||||
|
||||
return _str;
|
||||
@@ -542,6 +544,8 @@ namespace bx
|
||||
return StringView(ptr, ii + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return StringView(_str.getPtr(), _str.getPtr());
|
||||
}
|
||||
|
||||
return _str;
|
||||
|
||||
Reference in New Issue
Block a user