|
@@ -12,6 +12,7 @@
|
|
|
#include <stdio.h> // vsnprintf
|
|
#include <stdio.h> // vsnprintf
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
#include <string>
|
|
#include <string>
|
|
|
|
|
+#include <wchar.h> // wchar_t
|
|
|
|
|
|
|
|
namespace bx
|
|
namespace bx
|
|
|
{
|
|
{
|
|
@@ -172,21 +173,34 @@ namespace bx
|
|
|
/// Cross platform implementation of vsnprintf that returns number of
|
|
/// Cross platform implementation of vsnprintf that returns number of
|
|
|
/// characters which would have been written to the final string if
|
|
/// characters which would have been written to the final string if
|
|
|
/// enough space had been available.
|
|
/// enough space had been available.
|
|
|
- inline int32_t vsnprintf(char* _str, size_t _size, const char* _format, va_list _argList)
|
|
|
|
|
|
|
+ inline int32_t vsnprintf(char* _str, size_t _count, const char* _format, va_list _argList)
|
|
|
{
|
|
{
|
|
|
#if BX_COMPILER_MSVC
|
|
#if BX_COMPILER_MSVC
|
|
|
- int32_t len = ::vsnprintf(_str, _size, _format, _argList);
|
|
|
|
|
|
|
+ int32_t len = ::vsnprintf(_str, _count, _format, _argList);
|
|
|
return -1 == len ? ::_vscprintf(_format, _argList) : len;
|
|
return -1 == len ? ::_vscprintf(_format, _argList) : len;
|
|
|
#else
|
|
#else
|
|
|
- return ::vsnprintf(_str, _size, _format, _argList);
|
|
|
|
|
|
|
+ return ::vsnprintf(_str, _count, _format, _argList);
|
|
|
#endif // BX_COMPILER_MSVC
|
|
#endif // BX_COMPILER_MSVC
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- inline int32_t snprintf(char* _str, size_t _size, const char* _format, ...) // BX_PRINTF_ARGS(3, 4)
|
|
|
|
|
|
|
+ inline int32_t snprintf(char* _str, size_t _count, const char* _format, ...) // BX_PRINTF_ARGS(3, 4)
|
|
|
{
|
|
{
|
|
|
va_list argList;
|
|
va_list argList;
|
|
|
va_start(argList, _format);
|
|
va_start(argList, _format);
|
|
|
- int32_t len = vsnprintf(_str, _size, _format, argList);
|
|
|
|
|
|
|
+ int32_t len = vsnprintf(_str, _count, _format, argList);
|
|
|
|
|
+ va_end(argList);
|
|
|
|
|
+ return len;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ inline int32_t swnprintf(wchar_t* _out, size_t _count, const wchar_t* _format, ...)
|
|
|
|
|
+ {
|
|
|
|
|
+ va_list argList;
|
|
|
|
|
+ va_start(argList, _format);
|
|
|
|
|
+#if defined(__MINGW32__)
|
|
|
|
|
+ int32_t len = swprintf(_out, _format, argList);
|
|
|
|
|
+#else
|
|
|
|
|
+ int32_t len = swprintf(_out, _count, _format, argList);
|
|
|
|
|
+#endif // defined(__MINGW__)
|
|
|
va_end(argList);
|
|
va_end(argList);
|
|
|
return len;
|
|
return len;
|
|
|
}
|
|
}
|
|
@@ -213,6 +227,7 @@ namespace bx
|
|
|
stringPrintfVargs(_out, _format, argList);
|
|
stringPrintfVargs(_out, _format, argList);
|
|
|
va_end(argList);
|
|
va_end(argList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
} // namespace bx
|
|
} // namespace bx
|
|
|
|
|
|
|
|
#endif // __BX_PRINTF_H__
|
|
#endif // __BX_PRINTF_H__
|