From 563493dd6a7e224d68c66c4db63062adc3a7cd3f Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Tue, 16 Jun 2015 19:06:30 +1000 Subject: [PATCH] Add COLOR_CHAR and BELL_CHAR defines to replace open-coded values --- include/irc.h | 30 +++++++++++++++++------------- source/functions.c | 2 +- source/lastlog.c | 2 +- source/parse.c | 4 ++-- source/screen.c | 14 +++++++------- source/status.c | 4 ++-- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/include/irc.h b/include/irc.h index 8de9d41..2f67cfb 100644 --- a/include/irc.h +++ b/include/irc.h @@ -111,22 +111,26 @@ extern char thing_star[4]; #include "newio.h" /* these define what characters do, inverse, underline, bold and all off */ -#define REV_TOG '\026' /* ^V */ -#define REV_TOG_STR "\026" -#define UND_TOG '\037' /* ^_ */ -#define UND_TOG_STR "\037" -#define BOLD_TOG '\002' /* ^B */ +#define REV_TOG '\026' /* ^V */ +#define REV_TOG_STR "\026" +#define UND_TOG '\037' /* ^_ */ +#define UND_TOG_STR "\037" +#define BOLD_TOG '\002' /* ^B */ #define BOLD_TOG_STR "\002" -#define ALL_OFF '\017' /* ^O */ -#define ALL_OFF_STR "\017" -#define BLINK_TOG '\006' /* ^F (think flash) */ +#define ALL_OFF '\017' /* ^O */ +#define ALL_OFF_STR "\017" +#define BLINK_TOG '\006' /* ^F (think flash) */ #define BLINK_TOG_STR "\006" -#define ROM_CHAR '\022' /* ^R */ -#define ROM_CHAR_STR "\022" -#define ALT_TOG '\005' /* ^E (think Extended) */ -#define ALT_TOG_STR "\005" -#define ND_SPACE '\023' /* ^S */ +#define ROM_CHAR '\022' /* ^R */ +#define ROM_CHAR_STR "\022" +#define ALT_TOG '\005' /* ^E (think Extended) */ +#define ALT_TOG_STR "\005" +#define ND_SPACE '\023' /* ^S */ #define ND_SPACE_STR "\023" +#define COLOR_CHAR '\003' /* ^C */ +#define COLOR_CHAR_STR "\003" +#define BELL_CHAR '\007' /* ^G */ +#define BELL_CHAR_STR "\007" #define IRCD_BUFFER_SIZE 512 #define BIG_BUFFER_SIZE (4 * IRCD_BUFFER_SIZE) diff --git a/source/functions.c b/source/functions.c index 8260af9..ccbe232 100644 --- a/source/functions.c +++ b/source/functions.c @@ -2853,7 +2853,7 @@ BUILT_IN_FUNCTION(function_nohighlight, input) case BOLD_TOG: case BLINK_TOG: case ALL_OFF: - case '\003': + case COLOR_CHAR: case '\033': { *ptr++ = REV_TOG; diff --git a/source/lastlog.c b/source/lastlog.c index 31aa17d..2fcdd7b 100644 --- a/source/lastlog.c +++ b/source/lastlog.c @@ -333,7 +333,7 @@ BUILT_IN_COMMAND(lastlog) continue; } else - match = "\007"; + match = BELL_CHAR_STR; } else if (!my_strnicmp(arg, "CLEAR", len)) { diff --git a/source/parse.c b/source/parse.c index 223331c..f0ea9b0 100644 --- a/source/parse.c +++ b/source/parse.c @@ -228,9 +228,9 @@ int annoy_kicks(int list_type, char *to, char *from, char *ptr, NickList *nick) char *buffer = NULL; if (annoy_hl(ptr, BOLD_TOG)) malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " BOLD_TOG_STR "bold" BOLD_TOG_STR); - else if (strchr(ptr, '\007')) + else if (strchr(ptr, BELL_CHAR)) malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for beeping"); - else if (annoy_hl(ptr, '\003')) + else if (annoy_hl(ptr, COLOR_CHAR)) malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " UND_TOG_STR "mirc color" UND_TOG_STR); else if (annoy_hl(ptr, UND_TOG)) malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " UND_TOG_STR "underline" UND_TOG_STR); diff --git a/source/screen.c b/source/screen.c index 67a8736..2381046 100644 --- a/source/screen.c +++ b/source/screen.c @@ -246,7 +246,7 @@ void BX_add_to_window(Window *window, const unsigned char *str) * This is for archon -- he wanted a way to have * a hidden window always beep, even if BEEP is off. */ - if (window->beep_always && strchr(str, '\007')) + if (window->beep_always && strchr(str, BELL_CHAR)) { Window *old_target_window = target_window; target_window = current_window; @@ -456,7 +456,7 @@ const u_char *ptr = NULL; { switch (*ptr) { - case '\007': /* bell */ + case BELL_CHAR: /* bell */ { beep_cnt++; if ((beep_max == -1) || (beep_cnt > beep_max)) @@ -522,14 +522,14 @@ const u_char *ptr = NULL; word_break = pos; break; /* case '\n' */ } - case '\003': + case COLOR_CHAR: { int lhs = 0, rhs = 0; const u_char *end = skip_ctl_c_seq(ptr, &lhs, &rhs, 0); while (ptr < end) buffer[pos++] = *ptr++; ptr = end - 1; - break; /* case '\003' */ + break; /* case COLOR_CHAR */ } case ROM_CHAR: { @@ -1116,7 +1116,7 @@ const u_char *ptr = str; } break; } - case '\007': + case BELL_CHAR: { beep++; break; @@ -1150,7 +1150,7 @@ const u_char *ptr = str; out++; break; } - case '\003': + case COLOR_CHAR: { /* * By the time we get here, we know we need to @@ -2059,7 +2059,7 @@ const u_char *after = start; /* * If we're passed a non ^C code, dont do anything. */ - if (*after != '\003') + if (*after != COLOR_CHAR) return after; /* diff --git a/source/status.c b/source/status.c index 3640a73..b576997 100644 --- a/source/status.c +++ b/source/status.c @@ -515,7 +515,7 @@ int in_rhs = 0, * Skip over color attributes if we're not * doing color. */ - else if (*ptr == '\003') + else if (*ptr == COLOR_CHAR) { const u_char *end = skip_ctl_c_seq(ptr, NULL, NULL, 0); while (ptr < end) @@ -783,7 +783,7 @@ void make_status(Window *win) * Skip over color attributes if we're not * doing color. */ - else if (*ptr == '\003') + else if (*ptr == COLOR_CHAR) { const u_char *end = skip_ctl_c_seq(ptr, NULL, NULL, 0); while (ptr < end)