From e347375cb31463c0e870317ff14f420f00f77c7a Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Mon, 8 Jul 2019 17:34:08 +1000 Subject: [PATCH] Very minor simplification/cleanup of is_channel() --- include/irc.h | 2 +- include/modval.h | 2 +- source/parse.c | 14 ++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/irc.h b/include/irc.h index 37cccc0..c154440 100644 --- a/include/irc.h +++ b/include/irc.h @@ -321,7 +321,7 @@ extern int cpu_saver; extern struct sockaddr_foobar local_ip_address; -int BX_is_channel (char *); +int BX_is_channel (const char *); void BX_irc_exit (int, char *, char *, ...); void BX_beep_em (int); void got_initial_version (char *); diff --git a/include/modval.h b/include/modval.h index b5182be..26be7ec 100644 --- a/include/modval.h +++ b/include/modval.h @@ -404,7 +404,7 @@ extern Function_ptr *global; #define add_completion_type (*(int (*)(char *, int , enum completion ))global[ADD_COMPLETION_TYPE]) /* names.c */ -#define is_channel (*(int (*)(char *))global[IS_CHANNEL]) +#define is_channel (*(int (*)(const char *))global[IS_CHANNEL]) #define make_channel (*(char *(*)(char *))global[MAKE_CHANNEL]) #define is_chanop (*(int (*)(char *, char *))global[IS_CHANOP]) #define is_halfop (*(int (*)(char *, char *))global[IS_HALFOP]) diff --git a/source/parse.c b/source/parse.c index 2d785e3..7ee7f85 100644 --- a/source/parse.c +++ b/source/parse.c @@ -285,15 +285,13 @@ int annoy_kicks(int list_type, char *to, char *from, char *ptr, NickList *nick) * begins with MULTI_CHANNEL and has no '*', or STRING_CHANNEL, then its a * channel */ -int BX_is_channel(char *to) +int BX_is_channel(const char *to) { - if (!to || !*to) - return 0; - - return ( (to) && ((*to == MULTI_CHANNEL) - || (*to == STRING_CHANNEL) - || (*to == ID_CHANNEL) - || (*to == LOCAL_CHANNEL))); + return to && + (*to == MULTI_CHANNEL || + *to == STRING_CHANNEL || + *to == ID_CHANNEL || + *to == LOCAL_CHANNEL); }