mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Fix compilation on windows
const int wasn't detected as compile-time constant.
This commit is contained in:
parent
8bcd40fa91
commit
2d81b2fc33
|
@ -109,19 +109,20 @@ void dbg_msg(const char *sys, const char *fmt, ...)
|
|||
static void logger_stdout(const char *line)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
static const size_t MAX_LENGTH = 1024;
|
||||
static const size_t MAX_LENGTH_ERROR = 1024 + 32;
|
||||
#define _MAX_LENGTH 1024
|
||||
#define _MAX_LENGTH_ERROR (_MAX_LENGTH+32)
|
||||
|
||||
static const int UNICODE_REPLACEMENT_CHAR = 0xfffd;
|
||||
|
||||
static const char *STR_TOO_LONG = "(str too long)";
|
||||
static const char *INVALID_UTF8 = "(invalid utf8)";
|
||||
|
||||
wchar_t wline[MAX_LENGTH_ERROR];
|
||||
wchar_t wline[_MAX_LENGTH_ERROR];
|
||||
size_t len = 0;
|
||||
|
||||
const char *read = line;
|
||||
const char *error = STR_TOO_LONG;
|
||||
while(len < MAX_LENGTH)
|
||||
while(len < _MAX_LENGTH)
|
||||
{
|
||||
// Read a character. This also advances the read pointer
|
||||
int glyph = str_utf8_decode(&read);
|
||||
|
@ -165,20 +166,23 @@ static void logger_stdout(const char *line)
|
|||
if(character == 0)
|
||||
break;
|
||||
|
||||
dbg_assert(len < MAX_LENGTH_ERROR, "str too short for error");
|
||||
dbg_assert(len < _MAX_LENGTH_ERROR, "str too short for error");
|
||||
wline[len++] = character;
|
||||
read++;
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate the line
|
||||
dbg_assert(len < MAX_LENGTH_ERROR, "str too short for \\r");
|
||||
dbg_assert(len < _MAX_LENGTH_ERROR, "str too short for \\r");
|
||||
wline[len++] = '\r';
|
||||
dbg_assert(len < MAX_LENGTH_ERROR, "str too short for \\n");
|
||||
dbg_assert(len < _MAX_LENGTH_ERROR, "str too short for \\n");
|
||||
wline[len++] = '\n';
|
||||
|
||||
// Ignore any error that might occur
|
||||
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wline, len, 0, 0);
|
||||
|
||||
#undef _MAX_LENGTH
|
||||
#undef _MAX_LENGTH_ERROR
|
||||
#else
|
||||
printf("%s\n", line);
|
||||
fflush(stdout);
|
||||
|
|
Loading…
Reference in a new issue