From aa44835c3f8330b4ce2f3b120d601c687a6f3115 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 1 May 2024 14:12:16 +0200 Subject: Reformatted match_command() --- FICS/command.c | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/FICS/command.c b/FICS/command.c index e0d65da..a8a0390 100644 --- a/FICS/command.c +++ b/FICS/command.c @@ -181,31 +181,39 @@ PRIVATE void alias_substitute(alias_type *alias_list, int num_alias, } } -/* Returns pointer to command that matches */ -PRIVATE int match_command(char *comm, int p) +/* + * Returns pointer to command that matches + */ +PRIVATE int +match_command(char *comm, int p) { - int i = 0; - int gotIt = -1; - int len = strlen(comm); - - while (command_list[i].comm_name) { - if (!strncmp(command_list[i].comm_name, comm, len) - && parray[p].adminLevel >= command_list[i].adminLevel) { - if (gotIt >= 0) - return -COM_AMBIGUOUS; - gotIt = i; - } - i++; - } - if (in_list(p, L_REMOVEDCOM, command_list[gotIt].comm_name)) { - pprintf(p, "Due to a bug - this command has been temporarily removed.\n"); - return -COM_FAILED; - } - if (gotIt >= 0) { - lastCommandFound = gotIt; - return gotIt; - } - return -COM_FAILED; + int gotIt = -1; + int i = 0; + int len = strlen(comm); + + while (command_list[i].comm_name) { + if (!strncmp(command_list[i].comm_name, comm, len) && + parray[p].adminLevel >= command_list[i].adminLevel) { + if (gotIt >= 0) + return -COM_AMBIGUOUS; + gotIt = i; + } + + i++; + } + + if (in_list(p, L_REMOVEDCOM, command_list[gotIt].comm_name)) { + pprintf(p, "Due to a bug - this command has been temporarily " + "removed.\n"); + return -COM_FAILED; + } + + if (gotIt >= 0) { + lastCommandFound = gotIt; + return gotIt; + } + + return -COM_FAILED; } /* -- cgit v1.2.3