From 172c9135ef9003f5f6044bbfcbe0066e576e7b6a Mon Sep 17 00:00:00 2001 From: dashodanger Date: Sun, 18 Aug 2024 23:12:25 -0600 Subject: [PATCH] Adjust log buffer length; suppress some noisy translation file warnings --- source/m_trans.cc | 8 -------- source/sys_debug.cc | 37 ++++++++++++++++--------------------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/source/m_trans.cc b/source/m_trans.cc index e60403a2f..fd1ddeb35 100644 --- a/source/m_trans.cc +++ b/source/m_trans.cc @@ -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) @@ -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; diff --git a/source/sys_debug.cc b/source/sys_debug.cc index c6be1560b..a858aec36 100644 --- a/source/sys_debug.cc +++ b/source/sys_debug.cc @@ -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; @@ -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; @@ -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) { @@ -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; @@ -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) { @@ -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; @@ -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) { @@ -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; @@ -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) @@ -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; @@ -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) {