- irc.c:irc_parse(): minor cleanups
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Mon, 29 Dec 2014 14:58:35 +0000 (14:58 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Mon, 29 Dec 2014 14:58:35 +0000 (14:58 +0000)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@5191 82007160-df01-0410-b94d-b575c5fd34c7

src/irc.c

index f3065d96ab6c864056593178d3d95129ddde0a6d..572c243086df18f30241c05daa5fcf04d9b019a6 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -128,7 +128,8 @@ static struct CommandHash COMMAND_TABLE[] =
   { "473",      m_cannot_join },
   { "474",      m_cannot_join },
   { "475",      m_cannot_join },
-  { "KILL",     m_kill        }
+  { "KILL",     m_kill        },
+  { NULL,       NULL          }
 };
 
 /* irc_cycle
@@ -514,11 +515,9 @@ irc_parse(void)
    * parv[0] is ALWAYS the source, and is the server name of the source
    * did not exist
    */
-  static char            *parv[17];
-  static unsigned int     parc;
-  static char             msg[MSGLENMAX];    /* Temporarily stores IRC msg to pass to handlers */
-
-  parc = 1;
+  char            *parv[17];
+  unsigned int     parc = 1;
+  char             msg[MSGLENMAX];    /* Temporarily stores IRC msg to pass to handlers */
 
   if (IRC_RAW_LEN == 0)
     return;
@@ -575,11 +574,11 @@ irc_parse(void)
    * Determine which command this is from the command table
    * and let the handler for that command take control
    */
-  for (unsigned int i = 0; i < (sizeof(COMMAND_TABLE) / sizeof(struct CommandHash)); ++i)
+  for (const struct CommandHash *cmd = COMMAND_TABLE; cmd->command; ++cmd)
   {
-    if (strcasecmp(COMMAND_TABLE[i].command, parv[1]) == 0)
+    if (strcasecmp(cmd->command, parv[1]) == 0)
     {
-      (*COMMAND_TABLE[i].handler)(parv, parc, msg, source_p);
+      cmd->handler(parv, parc, msg, source_p);
       break;
     }
   }