util/StringUtil: move strip functions to StringStrip.cxx

This commit is contained in:
Max Kellermann
2017-07-05 17:20:02 +02:00
parent dad7d7e798
commit 501a4af914
23 changed files with 199 additions and 128 deletions

View File

@@ -22,59 +22,6 @@
#include "ASCII.hxx"
#include <assert.h>
#include <string.h>
const char *
StripLeft(const char *p) noexcept
{
while (IsWhitespaceNotNull(*p))
++p;
return p;
}
const char *
StripLeft(const char *p, const char *end) noexcept
{
while (p < end && IsWhitespaceOrNull(*p))
++p;
return p;
}
const char *
StripRight(const char *p, const char *end) noexcept
{
while (end > p && IsWhitespaceOrNull(end[-1]))
--end;
return end;
}
size_t
StripRight(const char *p, size_t length) noexcept
{
while (length > 0 && IsWhitespaceOrNull(p[length - 1]))
--length;
return length;
}
void
StripRight(char *p) noexcept
{
size_t old_length = strlen(p);
size_t new_length = StripRight(p, old_length);
p[new_length] = 0;
}
char *
Strip(char *p) noexcept
{
p = StripLeft(p);
StripRight(p);
return p;
}
bool
StringArrayContainsCase(const char *const*haystack,