This commit is contained in:
Бранимир Караџић
2024-10-24 21:36:05 -07:00
parent ce6de42aad
commit fd71b74bfc
4 changed files with 19 additions and 21 deletions

View File

@@ -319,6 +319,9 @@ namespace bx
/// Returns string view with suffix trimmed.
StringView strTrimSuffix(const StringView& _str, const StringView& _suffix);
/// Returns string view `_num` from the right.
StringView strTail(const StringView _str, uint32_t _num);
/// Find new line. Returns pointer after new line terminator.
StringView strFindNl(const StringView& _str);

View File

@@ -274,22 +274,6 @@ namespace bx
return 1;
}
// If offset in UTF-8 string doesn't land on rune, walk back until first byte of rune is reached.
static const char* fixPtrToRune(const char* _strBegin, const char* _curr)
{
for (; _curr > _strBegin && (*_curr & 0xc0) == 0x80; --_curr);
return _curr;
}
StringView strTail(const StringView _str, uint32_t _num)
{
return StringView(
fixPtrToRune(_str.getPtr(), _str.getTerm() - min(_num, _str.getLength() ) )
, _str.getTerm()
);
}
int32_t writeCallstack(WriterI* _writer, uintptr_t* _stack, uint32_t _num, Error* _err)
{
BX_ERROR_SCOPE(_err);

View File

@@ -556,6 +556,22 @@ namespace bx
return strLTrimSpace(strRTrimSpace(_str) );
}
// If offset in UTF-8 string doesn't land on rune, walk back until first byte of rune is reached.
static const char* fixPtrToRune(const char* _strBegin, const char* _curr)
{
for (; _curr > _strBegin && (*_curr & 0xc0) == 0x80; --_curr);
return _curr;
}
StringView strTail(const StringView _str, uint32_t _num)
{
return StringView(
fixPtrToRune(_str.getPtr(), _str.getTerm() - min(_num, _str.getLength() ) )
, _str.getTerm()
);
}
constexpr uint32_t kFindStep = 1024;
StringView strFindNl(const StringView& _str)

View File

@@ -8,11 +8,6 @@
#include <bx/string.h>
#include <bx/file.h>
namespace bx
{
void debugOutputCallstack(uint32_t _skip);
}
bool testAssertHandler(const bx::Location& _location, const char* _format, va_list _argList)
{
bx::printf("%s(%d): ", _location.filePath, _location.line);