aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-18 08:20:47 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-18 08:34:37 +0200
commit87a44fb8070da327e777c8dfbfdbd7fcaa34d416 (patch)
treee910ccedb0caceb0015cad4ee4ffb85a3b53ac02 /degesch.c
parentf09313f08b8a580823f6aeced57cf790da28c11a (diff)
downloadxK-87a44fb8070da327e777c8dfbfdbd7fcaa34d416.tar.gz
xK-87a44fb8070da327e777c8dfbfdbd7fcaa34d416.tar.xz
xK-87a44fb8070da327e777c8dfbfdbd7fcaa34d416.zip
degesch: cleanup
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/degesch.c b/degesch.c
index 989a95f..6dd1454 100644
--- a/degesch.c
+++ b/degesch.c
@@ -6320,48 +6320,28 @@ handle_command_mode (struct app_context *ctx, char *arguments)
// Channel names prefixed by "+" collide with mode strings,
// so we just disallow specifying these channels
- char *channel_name = NULL;
- char *nickname = NULL;
-
- if (*arguments != '+')
- channel_name = maybe_cut_word (&arguments, validate_channel_name, s);
- if (!channel_name
- && !strchr ("+-\0", *arguments))
- nickname = cut_word (&arguments);
-
- if (!channel_name
- && !nickname)
+ char *target = NULL;
+ if (strchr ("+-\0", *arguments)
+ || !(target = maybe_cut_word (&arguments, validate_channel_name, s))
+ || !(target = cut_word (&arguments)))
{
if (ctx->current_buffer->type == BUFFER_CHANNEL)
- channel_name = ctx->current_buffer->channel->name;
+ target = ctx->current_buffer->channel->name;
if (ctx->current_buffer->type == BUFFER_PM)
- nickname = ctx->current_buffer->user->nickname;
+ target = ctx->current_buffer->user->nickname;
if (ctx->current_buffer->type == BUFFER_SERVER)
- nickname = ctx->current_buffer->server->irc_user->nickname;
- }
-
- if (channel_name)
- {
- if (*arguments)
- // XXX: split as necessary using irc_max_modes?
- irc_send (s, "MODE %s %s", channel_name, arguments);
- else
- irc_send (s, "MODE %s", channel_name);
- return true;
+ target = ctx->current_buffer->server->irc_user->nickname;
}
- if (nickname)
- {
- if (*arguments)
- irc_send (s, "MODE %s %s", nickname, arguments);
- else
- irc_send (s, "MODE %s", nickname);
- return true;
- }
-
- buffer_send_error (ctx, ctx->current_buffer,
- "%s: %s", "Can't change mode",
- "no target given and this buffer is neither a PM nor a channel");
+ if (!target)
+ buffer_send_error (ctx, ctx->current_buffer,
+ "%s: %s", "Can't change mode",
+ "no target given and this buffer is neither a PM nor a channel");
+ else if (*arguments)
+ // XXX: split channel mode params as necessary using irc_max_modes?
+ irc_send (s, "MODE %s %s", target, arguments);
+ else
+ irc_send (s, "MODE %s", target);
return true;
}