From b458082800b4224854db46824195cdc4557b7260 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Tue, 28 Nov 2017 14:40:19 +1100 Subject: [PATCH] Simplify putchar_x() definition Introduce an inline helper xlate_char() to isolate the character translation code. This halves the permutations of putchar_x() required. --- include/ircterm.h | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/include/ircterm.h b/include/ircterm.h index 53e26ed..08127d1 100644 --- a/include/ircterm.h +++ b/include/ircterm.h @@ -62,32 +62,25 @@ void avio_refresh_screen(void); #ifdef TRANSLATE #include "translat.h" +static inline int xlate_char(int c) +{ + return translation ? transToClient[c] : c; +} +#else +static inline int xlate_char(int c) +{ + return c; +} +#endif + static inline int putchar_x (int c) { #ifdef GUI -#if 1 - return gui_putc((int) (translation ? transToClient[c] : c)); + return gui_putc(xlate_char(c)); #else - return gui_putc((int) c); -#endif -#else -#if 1 - return fputc((int) (translation ? transToClient[c] : c), current_ftarget); -#else - return fputc((int) c, current_ftarget); -#endif + return fputc(xlate_char(c), current_ftarget); #endif } -#else -static inline int putchar_x (int c) -{ -#ifdef GUI - return gui_putc((int) c); -#else - return fputc((unsigned int) c, current_ftarget); -#endif -} -#endif static inline void term_flush (void) {