util/StringUtil: add StripRight() overload with "end" argument
This commit is contained in:
@@ -35,6 +35,24 @@ StripLeft(const char *p)
|
||||
return p;
|
||||
}
|
||||
|
||||
const char *
|
||||
StripLeft(const char *p, const char *end)
|
||||
{
|
||||
while (p < end && IsWhitespaceOrNull(*p))
|
||||
++p;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
const char *
|
||||
StripRight(const char *p, const char *end)
|
||||
{
|
||||
while (end > p && IsWhitespaceOrNull(end[-1]))
|
||||
--end;
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
size_t
|
||||
StripRight(const char *p, size_t length)
|
||||
{
|
||||
|
@@ -39,6 +39,28 @@ StripLeft(char *p)
|
||||
return const_cast<char *>(StripLeft((const char *)p));
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
const char *
|
||||
StripLeft(const char *p, const char *end);
|
||||
|
||||
/**
|
||||
* Determine the string's end as if it was stripped on the right side.
|
||||
*/
|
||||
gcc_pure
|
||||
const char *
|
||||
StripRight(const char *p, const char *end);
|
||||
|
||||
/**
|
||||
* Determine the string's end as if it was stripped on the right side.
|
||||
*/
|
||||
gcc_pure
|
||||
static inline char *
|
||||
StripRight(char *p, char *end)
|
||||
{
|
||||
return const_cast<char *>(StripRight((const char *)p,
|
||||
(const char *)end));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the string's length as if it was stripped on the right
|
||||
* side.
|
||||
|
Reference in New Issue
Block a user