Бранимир Караџић 1 سال پیش
والد
کامیت
fd71b74bfc
4فایلهای تغییر یافته به همراه19 افزوده شده و 21 حذف شده
  1. 3 0
      include/bx/string.h
  2. 0 16
      src/debug.cpp
  3. 16 0
      src/string.cpp
  4. 0 5
      tests/run_test.cpp

+ 3 - 0
include/bx/string.h

@@ -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);
 

+ 0 - 16
src/debug.cpp

@@ -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);

+ 16 - 0
src/string.cpp

@@ -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)

+ 0 - 5
tests/run_test.cpp

@@ -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);