util/FormatString: remove obsolete Windows fallback
Since 7d353bbe2a
, _GNU_SOURCE is always
defined, which implies __USE_MINGW_ANSI_STDIO and thus switches to
the mingw implementations of the printf() family. That's
standards-compliant, unlike Microsoft's CRT implementations.
This commit is contained in:
parent
fe1f3df36e
commit
be137a191e
@ -23,14 +23,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AllocatedString<>
|
AllocatedString<>
|
||||||
FormatStringV(const char *fmt, va_list args) noexcept
|
FormatStringV(const char *fmt, va_list args) noexcept
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
|
||||||
va_list tmp;
|
va_list tmp;
|
||||||
va_copy(tmp, args);
|
va_copy(tmp, args);
|
||||||
const int length = vsnprintf(NULL, 0, fmt, tmp);
|
const int length = vsnprintf(NULL, 0, fmt, tmp);
|
||||||
@ -43,22 +38,6 @@ FormatStringV(const char *fmt, va_list args) noexcept
|
|||||||
char *buffer = new char[length + 1];
|
char *buffer = new char[length + 1];
|
||||||
vsnprintf(buffer, length + 1, fmt, args);
|
vsnprintf(buffer, length + 1, fmt, args);
|
||||||
return AllocatedString<>::Donate(buffer);
|
return AllocatedString<>::Donate(buffer);
|
||||||
#else
|
|
||||||
/* On mingw32, snprintf() expects a 64 bit integer instead of
|
|
||||||
a "long int" for "%li". This is not consistent with our
|
|
||||||
expectation, so we're using plain sprintf() here, hoping
|
|
||||||
the static buffer is large enough. Sorry for this hack,
|
|
||||||
but WIN32 development is so painful, I'm not in the mood to
|
|
||||||
do it properly now. */
|
|
||||||
|
|
||||||
char buffer[16384];
|
|
||||||
vsprintf(buffer, fmt, args);
|
|
||||||
|
|
||||||
const size_t length = strlen(buffer);
|
|
||||||
char *p = new char[length + 1];
|
|
||||||
memcpy(p, buffer, length + 1);
|
|
||||||
return AllocatedString<>::Donate(p);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatedString<>
|
AllocatedString<>
|
||||||
|
Loading…
Reference in New Issue
Block a user