Match commands case-insensitively

Also include the slash in their names so that they can be added to
tab-complete later.
master
Curtis McEnroe 2018-08-07 15:59:27 -04:00
parent fe21b1410f
commit 2fe8b4e614
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
1 changed files with 7 additions and 8 deletions

15
input.c
View File

@ -77,12 +77,12 @@ static const struct {
const char *command;
Handler handler;
} COMMANDS[] = {
{ "me", inputMe },
{ "names", inputWho },
{ "nick", inputNick },
{ "quit", inputQuit },
{ "topic", inputTopic },
{ "who", inputWho },
{ "/me", inputMe },
{ "/names", inputWho },
{ "/nick", inputNick },
{ "/quit", inputQuit },
{ "/topic", inputTopic },
{ "/who", inputWho },
};
static const size_t COMMANDS_LEN = sizeof(COMMANDS) / sizeof(COMMANDS[0]);
@ -91,10 +91,9 @@ void input(char *input) {
privmsg(false, input);
return;
}
input++;
char *command = strsep(&input, " ");
for (size_t i = 0; i < COMMANDS_LEN; ++i) {
if (strcmp(command, COMMANDS[i].command)) continue;
if (strcasecmp(command, COMMANDS[i].command)) continue;
COMMANDS[i].handler(input);
return;
}