mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Remove some OS-specific code due to VS2010 lacking a va_copy
This commit is contained in:
@@ -50,6 +50,30 @@ int vsnprintf(char *str, size_t bufSize, const char *format, va_list args)
|
||||
return ::utf8printf(str, bufSize, format, args);
|
||||
}
|
||||
|
||||
string Fmt(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
va_list args2;
|
||||
va_copy(args2, args);
|
||||
|
||||
int size = StringFormat::vsnprintf(NULL, 0, format, args2);
|
||||
|
||||
char *buf = new char[size + 1];
|
||||
StringFormat::vsnprintf(buf, size + 1, format, args);
|
||||
buf[size] = 0;
|
||||
|
||||
va_end(args);
|
||||
va_end(args2);
|
||||
|
||||
string ret = buf;
|
||||
|
||||
delete[] buf;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Wide2UTF8(wchar_t chr, char mbchr[4])
|
||||
{
|
||||
// U+00000 -> U+00007F 1 byte 0xxxxxxx
|
||||
|
||||
@@ -363,9 +363,6 @@ namespace StringFormat
|
||||
{
|
||||
void sntimef(char *str, size_t bufSize, const char *format);
|
||||
|
||||
// forwards to vsnprintf below, needed to be here due to va_copy differences
|
||||
string Fmt(const char *format, ...);
|
||||
|
||||
string Wide2UTF8(const std::wstring &s);
|
||||
};
|
||||
|
||||
@@ -376,6 +373,8 @@ namespace StringFormat
|
||||
int vsnprintf(char *str, size_t bufSize, const char *format, va_list v);
|
||||
int snprintf(char *str, size_t bufSize, const char *format, ...);
|
||||
|
||||
string Fmt(const char *format, ...);
|
||||
|
||||
int Wide2UTF8(wchar_t chr, char mbchr[4]);
|
||||
};
|
||||
|
||||
|
||||
@@ -409,28 +409,4 @@ void sntimef(char *str, size_t bufSize, const char *format)
|
||||
|
||||
strftime(str, bufSize, format, tmv);
|
||||
}
|
||||
|
||||
string Fmt(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
va_list args2;
|
||||
va_copy(args2, args);
|
||||
|
||||
int size = StringFormat::vsnprintf(NULL, 0, format, args2);
|
||||
|
||||
char *buf = new char[size + 1];
|
||||
StringFormat::vsnprintf(buf, size + 1, format, args);
|
||||
buf[size] = 0;
|
||||
|
||||
va_end(args);
|
||||
va_end(args2);
|
||||
|
||||
string ret = buf;
|
||||
|
||||
delete[] buf;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -563,33 +563,6 @@ void sntimef(char *str, size_t bufSize, const char *format)
|
||||
}
|
||||
}
|
||||
|
||||
// this function is only platform specific because va_copy isn't implemented
|
||||
// on MSVC
|
||||
string Fmt(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
va_list args2;
|
||||
// va_copy(args2, args); // not implemented on VS2010
|
||||
args2 = args;
|
||||
|
||||
int size = StringFormat::vsnprintf(NULL, 0, format, args2);
|
||||
|
||||
char *buf = new char[size + 1];
|
||||
StringFormat::vsnprintf(buf, size + 1, format, args);
|
||||
buf[size] = 0;
|
||||
|
||||
va_end(args);
|
||||
va_end(args2);
|
||||
|
||||
string ret = buf;
|
||||
|
||||
delete[] buf;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
string Wide2UTF8(const wstring &s)
|
||||
{
|
||||
int bytes_required = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, NULL, 0, NULL, NULL);
|
||||
|
||||
Reference in New Issue
Block a user