Match commands case-insensitively
Also include the slash in their names so that they can be added to tab-complete later.weechat-hashes
parent
fe21b1410f
commit
2fe8b4e614
15
input.c
15
input.c
|
@ -77,12 +77,12 @@ static const struct {
|
||||||
const char *command;
|
const char *command;
|
||||||
Handler handler;
|
Handler handler;
|
||||||
} COMMANDS[] = {
|
} COMMANDS[] = {
|
||||||
{ "me", inputMe },
|
{ "/me", inputMe },
|
||||||
{ "names", inputWho },
|
{ "/names", inputWho },
|
||||||
{ "nick", inputNick },
|
{ "/nick", inputNick },
|
||||||
{ "quit", inputQuit },
|
{ "/quit", inputQuit },
|
||||||
{ "topic", inputTopic },
|
{ "/topic", inputTopic },
|
||||||
{ "who", inputWho },
|
{ "/who", inputWho },
|
||||||
};
|
};
|
||||||
static const size_t COMMANDS_LEN = sizeof(COMMANDS) / sizeof(COMMANDS[0]);
|
static const size_t COMMANDS_LEN = sizeof(COMMANDS) / sizeof(COMMANDS[0]);
|
||||||
|
|
||||||
|
@ -91,10 +91,9 @@ void input(char *input) {
|
||||||
privmsg(false, input);
|
privmsg(false, input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input++;
|
|
||||||
char *command = strsep(&input, " ");
|
char *command = strsep(&input, " ");
|
||||||
for (size_t i = 0; i < COMMANDS_LEN; ++i) {
|
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);
|
COMMANDS[i].handler(input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue