From 7dd0e39ee3830ff075597db7aa686e07f5ce402f Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 14 Sep 2023 10:12:30 +0200 Subject: [PATCH] strip leading newlines from warnings and take care they always get their own line (#1205) * strip leading newlines from warnings * warnings always get their own new line * all prios but VB_INFO should start on their own line * remove some more leading newlines * finish progress line in R_InitTranMap() --- src/i_printf.c | 17 +++++++++++++++++ src/net_query.c | 10 +++++----- src/r_data.c | 15 +++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/i_printf.c b/src/i_printf.c index 28e8f075..49146cfe 100644 --- a/src/i_printf.c +++ b/src/i_printf.c @@ -119,6 +119,8 @@ void I_InitPrintf(void) I_AtExit(I_ShutdownPrintf, true); } +static boolean whole_line = true; + void I_Printf(verbosity_t prio, const char *msg, ...) { FILE *stream = stdout; @@ -161,6 +163,10 @@ void I_Printf(verbosity_t prio, const char *msg, ...) color_suffix = "\033[0m"; // [FG] reset } + // [FG] warnings always get their own new line + if (!whole_line && prio != VB_INFO) + fprintf(stream, "%s", "\n"); + if (color_prefix) fprintf(stream, "%s", color_prefix); @@ -173,11 +179,22 @@ void I_Printf(verbosity_t prio, const char *msg, ...) // [FG] no newline if format string has trailing space if (msglen && msg[msglen - 1] != ' ') + { fprintf(stream, "%s", "\n"); + whole_line = true; + } + else + { + whole_line = false; + } } void I_PutChar(verbosity_t prio, int c) { if (prio <= verbosity) + { putchar(c); + + whole_line = (c == '\n'); + } } diff --git a/src/net_query.c b/src/net_query.c index 46d2a13a..f387fecb 100644 --- a/src/net_query.c +++ b/src/net_query.c @@ -789,11 +789,11 @@ void NET_LANQuery(void) { if (NET_StartLANQuery()) { - I_Printf(VB_INFO, "\nSearching for servers on local LAN ..."); + I_Printf(VB_INFO, "Searching for servers on local LAN ..."); NET_Query_QueryLoop(NET_QueryPrintCallback, NULL); - I_Printf(VB_INFO, "\n%i server(s) found.", GetNumResponses()); + I_Printf(VB_INFO, "%i server(s) found.", GetNumResponses()); FreeTargets(); } } @@ -802,11 +802,11 @@ void NET_MasterQuery(void) { if (NET_StartMasterQuery()) { - I_Printf(VB_INFO, "\nSearching for servers on Internet ..."); + I_Printf(VB_INFO, "Searching for servers on Internet ..."); NET_Query_QueryLoop(NET_QueryPrintCallback, NULL); - I_Printf(VB_INFO, "\n%i server(s) found.", GetNumResponses()); + I_Printf(VB_INFO, "%i server(s) found.", GetNumResponses()); FreeTargets(); } } @@ -829,7 +829,7 @@ void NET_QueryAddress(const char *addr_str) target = GetTargetForAddr(addr, true); - I_Printf(VB_INFO, "\nQuerying '%s'...", addr_str); + I_Printf(VB_INFO, "Querying '%s'...", addr_str); // Run query loop. diff --git a/src/r_data.c b/src/r_data.c index 2d3e7845..48183116 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -395,7 +395,7 @@ static void R_GenerateLookup(int texnum, int *const errors) if (badcol) { badcol = 0; - I_Printf(VB_DEBUG, "\nWarning: Texture %8.8s " + I_Printf(VB_DEBUG, "Warning: Texture %8.8s " "(height %d) has bad column(s)" " starting at x = %d.", texture->name, texture->height, x); @@ -426,7 +426,7 @@ static void R_GenerateLookup(int texnum, int *const errors) // if (devparm) { // killough 8/8/98 - I_Printf(VB_DEBUG, "\nR_GenerateLookup:" + I_Printf(VB_DEBUG, "R_GenerateLookup:" " Column %d is without a patch in texture %.8s", x, texture->name); // ++*errors; @@ -462,7 +462,7 @@ static void R_GenerateLookup(int texnum, int *const errors) if (err) // killough 10/98: non-verbose output { - I_Printf(VB_WARNING, "\nR_GenerateLookup: Column without a patch in texture %.8s", + I_Printf(VB_WARNING, "R_GenerateLookup: Column without a patch in texture %.8s", texture->name); ++*errors; } @@ -554,12 +554,12 @@ void R_InitTextures (void) patchlookup[i] = (W_CheckNumForName)(name, ns_sprites); if (patchlookup[i] == -1) - I_Printf(VB_DEBUG, "\nWarning: patch %.8s, index %d does not exist",name,i); + I_Printf(VB_DEBUG, "Warning: patch %.8s, index %d does not exist",name,i); } if (patchlookup[i] != -1 && !R_IsPatchLump(patchlookup[i])) { - I_Printf(VB_WARNING, "\nR_InitTextures: patch %.8s, index %d is invalid", name, i); + I_Printf(VB_WARNING, "R_InitTextures: patch %.8s, index %d is invalid", name, i); patchlookup[i] = (W_CheckNumForName)("TNT1A0", ns_sprites); } @@ -681,7 +681,7 @@ void R_InitTextures (void) } if (patch->patch == -1) { // killough 8/8/98 - I_Printf(VB_WARNING, "\nR_InitTextures: Missing patch %d in texture %.8s", + I_Printf(VB_WARNING, "R_InitTextures: Missing patch %d in texture %.8s", SHORT(mpatch->patch), texture->name); // killough 4/17/98 // [FG] treat missing patches as non-fatal, substitute dummy patch // ++errors; @@ -958,6 +958,9 @@ void R_InitTranMap(int progress) while (--color >= 0); } } + // [FG] finish progress line + if (progress) + I_PutChar(VB_INFO, '\n'); } if (cachefp && !force_rebuild) // write out the cached translucency map {