diff options
author | Curtis McEnroe | 2019-07-02 19:34:19 -0400 |
---|---|---|
committer | Curtis McEnroe | 2019-07-02 19:34:19 -0400 |
commit | fe38982b435b557ae6f28985dc2458f762e2ca14 (patch) | |
tree | 53b510fbb4a2bc7e83674457107a58b80d1ae489 | |
parent | fdbc6f2fda4e3d26989b540505a6b8a755c28c23 (diff) |
Clean up input parameter handling
-rw-r--r-- | input.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/input.c b/input.c index 77c57cc..81ff1cf 100644 --- a/input.c +++ b/input.c @@ -56,11 +56,11 @@ static void inputMe(struct Tag tag, char *params) { static void inputNick(struct Tag tag, char *params) { char *nick = strsep(¶ms, " "); - if (nick) { - ircFmt("NICK :%s\r\n", nick); - } else { - uiLog(tag, UIHot, L"/nick requires a nickname"); + if (!nick) { + uiLog(tag, UIHot, L"/nick requires a name"); + return; } + ircFmt("NICK %s\r\n", nick); } static void inputPart(struct Tag tag, char *params) { @@ -69,13 +69,13 @@ static void inputPart(struct Tag tag, char *params) { static void inputQuery(struct Tag tag, char *params) { char *nick = strsep(¶ms, " "); - if (nick) { - tabTouch(TagNone, nick); - uiShowTag(tagFor(nick)); - logReplay(tagFor(nick)); - } else { - uiLog(tag, UIHot, L"/query requires a nickname"); + if (!nick) { + uiLog(tag, UIHot, L"/query requires a nick"); + return; } + tabTouch(TagNone, nick); + uiShowTag(tagFor(nick)); + logReplay(tagFor(nick)); } static void inputQuit(struct Tag tag, char *params) { @@ -103,11 +103,11 @@ static void inputWho(struct Tag tag, char *params) { static void inputWhois(struct Tag tag, char *params) { char *nick = strsep(¶ms, " "); - if (nick) { - ircFmt("WHOIS :%s\r\n", nick); - } else { + if (!nick) { uiLog(tag, UIHot, L"/whois requires a nick"); + return; } + ircFmt("WHOIS %s\r\n", nick); } static void inputZNC(struct Tag tag, char *params) { @@ -129,11 +129,11 @@ static void inputMan(struct Tag tag, char *params) { static void inputMove(struct Tag tag, char *params) { char *num = strsep(¶ms, " "); - if (num) { - uiMoveTag(tag, strtol(num, NULL, 0), num[0] == '+' || num[0] == '-'); - } else { + if (!num) { uiLog(tag, UIHot, L"/move requires a number"); + return; } + uiMoveTag(tag, strtol(num, NULL, 0), num[0] == '+' || num[0] == '-'); } static void inputOpen(struct Tag tag, char *params) { |