From bf4dd1b01bc069d5516b4e8af847bf00d7e8f631 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Wed, 18 Jun 2003 08:05:17 +0000 Subject: [PATCH] strip out colors, etc when printing to stdout --- ChangeLog | 3 +++ main/console.c | 29 ++++++++++++++++++++++++++--- main/hud.c | 20 +++++--------------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa790f33..e778503b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2003-06-18 Bradley Bell + * main/console.c, main/hud.c: strip out colors, etc when printing + to stdout + * include/u_mem.h: fix NDEBUG calloc macro 2003-06-15 Bradley Bell diff --git a/main/console.c b/main/console.c index fa02c897..055e3278 100644 --- a/main/console.c +++ b/main/console.c @@ -1,4 +1,4 @@ -/* $Id: console.c,v 1.15 2003-06-08 01:33:27 btb Exp $ */ +/* $Id: console.c,v 1.16 2003-06-18 08:05:17 btb Exp $ */ /* * * FIXME: put description here @@ -15,6 +15,7 @@ #include #include #include +#include #include #ifdef CONSOLE @@ -148,8 +149,6 @@ void con_printf(int priority, char *fmt, ...) va_start (arglist, fmt); vsprintf (buffer, fmt, arglist); va_end (arglist); - if (text_console_enabled) - printf(buffer); #ifdef CONSOLE if (con_initialized) @@ -160,6 +159,30 @@ void con_printf(int priority, char *fmt, ...) { memcpy(con_display, &buffer[i], min(80, l-i)); }*/ + + if (text_console_enabled) + { + /* Produce a sanitised version and send it to the console */ + char *p1, *p2; + + p1 = p2 = buffer; + do + switch (*p1) + { + case CC_COLOR: + case CC_LSPACING: + p1++; + case CC_UNDERLINE: + p1++; + break; + default: + *p2++ = *p1++; + } + while (*p1); + *p2 = 0; + + printf(buffer); + } } } diff --git a/main/hud.c b/main/hud.c index f0b6fd54..a7dbae1d 100644 --- a/main/hud.c +++ b/main/hud.c @@ -13,13 +13,16 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. /* * $Source: /cvs/cvsroot/d2x/main/hud.c,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * $Author: btb $ - * $Date: 2003-06-06 19:04:27 $ + * $Date: 2003-06-18 08:05:17 $ * * Routines for displaying HUD messages... * * $Log: not supported by cvs2svn $ + * Revision 1.6 2003/06/06 19:04:27 btb + * merge (non-physfs stuff) from physfs branch + * * Revision 1.5.2.1 2003/06/06 03:35:41 btb * finish console conversion away from SDL * @@ -42,7 +45,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include #include -#include #include "hudmsg.h" @@ -364,18 +366,6 @@ int HUD_init_message_va(char * format, va_list args) message = &HUD_messages[hud_last][0]; vsprintf(message,format,args); -#if 0 - /* Produce a sanitised version and send it to the console */ - cleanmessage = d_strdup(message); - for (temp=0,temp2=0; message[temp]!=0; temp++) - { - if (isprint(message[temp])) cleanmessage[temp2++] = message[temp]; - else temp++; /* Skip next character as well */ - } - cleanmessage[temp2] = 0; - con_printf(CON_NORMAL, "%s\n", cleanmessage); - d_free(cleanmessage); -#endif /* Produce a colorised version and send it to the console */ if (HUD_color == -1) -- 2.39.2