Skip to content

Commit

Permalink
Adjust log buffer length; suppress some noisy translation file warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Aug 19, 2024
1 parent 161e9d8 commit 172c913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
8 changes: 0 additions & 8 deletions source/m_trans.cc
Original file line number Diff line number Diff line change
Expand Up @@ -970,10 +970,6 @@ struct po_parse_state_t
{
ParseString(p, id, sizeof(id));
}
else
{
LogPrint("WARNING: unexpected string on line %d\n", line_number);
}
}

void SetContext(const char *p)
Expand Down Expand Up @@ -1060,10 +1056,6 @@ void Trans_Read_PO_File(FILE *fp)
{
po_state.SetString(p + 7);
}
else
{
LogPrint("WARNING: unsupported keyword on line %d\n", po_state.line_number);
}

if (feof(fp) || ferror(fp))
break;
Expand Down
37 changes: 16 additions & 21 deletions source/sys_debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "main.h"
#include "sys_assert.h"

static constexpr uint16_t DEBUG_BUF_LEN = 20000;
static constexpr uint16_t LOG_BUF_LEN = 8192;

static FILE *log_file = nullptr;
static FILE *ref_file = nullptr;
Expand Down Expand Up @@ -134,9 +134,9 @@ void LogPrint(const char *message, ...)
if (!log_file && !terminal)
return;

char message_buf[4096];
char message_buf[LOG_BUF_LEN];

message_buf[4095] = 0;
message_buf[LOG_BUF_LEN-1] = 0;

// Print the message into a text string
va_list argptr;
Expand All @@ -145,8 +145,7 @@ void LogPrint(const char *message, ...)
vsprintf(message_buf, message, argptr);
va_end(argptr);

// I hope nobody is printing strings longer than 4096 chars...
SYS_ASSERT(message_buf[4095] == 0);
SYS_ASSERT(message_buf[LOG_BUF_LEN-1] == 0);

if (log_file)
{
Expand All @@ -166,9 +165,9 @@ void RefPrint(const char *message, ...)
if (!ref_file && !terminal)
return;

char message_buf[4096];
char message_buf[LOG_BUF_LEN];

message_buf[4095] = 0;
message_buf[LOG_BUF_LEN-1] = 0;

// Print the message into a text string
va_list argptr;
Expand All @@ -177,8 +176,7 @@ void RefPrint(const char *message, ...)
vsprintf(message_buf, message, argptr);
va_end(argptr);

// I hope nobody is printing strings longer than 4096 chars...
SYS_ASSERT(message_buf[4095] == 0);
SYS_ASSERT(message_buf[LOG_BUF_LEN-1] == 0);

if (ref_file)
{
Expand All @@ -198,9 +196,9 @@ void DebugPrint(const char *message, ...)
if (!debugging || (!log_file && !terminal))
return;

char message_buf[4096];
char message_buf[LOG_BUF_LEN];

message_buf[4095] = 0;
message_buf[LOG_BUF_LEN-1] = 0;

// Print the message into a text string
va_list argptr;
Expand All @@ -209,8 +207,7 @@ void DebugPrint(const char *message, ...)
vsprintf(message_buf, message, argptr);
va_end(argptr);

// I hope nobody is printing strings longer than 4096 chars...
SYS_ASSERT(message_buf[4095] == 0);
SYS_ASSERT(message_buf[LOG_BUF_LEN-1] == 0);

if (log_file)
{
Expand All @@ -227,9 +224,9 @@ void DebugPrint(const char *message, ...)

void ProgStatus(const char *message, ...)
{
char message_buf[4096];
char message_buf[LOG_BUF_LEN];

message_buf[4095] = 0;
message_buf[LOG_BUF_LEN-1] = 0;

// Print the message into a text string
va_list argptr;
Expand All @@ -238,8 +235,7 @@ void ProgStatus(const char *message, ...)
vsprintf(message_buf, message, argptr);
va_end(argptr);

// I hope nobody is printing strings longer than 4096 chars...
SYS_ASSERT(message_buf[4095] == 0);
SYS_ASSERT(message_buf[LOG_BUF_LEN-1] == 0);

#ifndef OBSIDIAN_CONSOLE_ONLY
if (main_win)
Expand Down Expand Up @@ -277,9 +273,9 @@ void ProgStatus(const char *message, ...)

[[noreturn]] void FatalError(const char *message, ...)
{
char message_buf[4096];
char message_buf[LOG_BUF_LEN];

message_buf[4095] = 0;
message_buf[LOG_BUF_LEN-1] = 0;

// Print the message into a text string
va_list argptr;
Expand All @@ -288,8 +284,7 @@ void ProgStatus(const char *message, ...)
vsprintf(message_buf, message, argptr);
va_end(argptr);

// I hope nobody is printing strings longer than 4096 chars...
SYS_ASSERT(message_buf[4095] == 0);
SYS_ASSERT(message_buf[LOG_BUF_LEN-1] == 0);

if (log_file)
{
Expand Down

0 comments on commit 172c913

Please sign in to comment.