aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-10-06 00:19:06 +0100
committerJames Booth <boothj5@gmail.com>2016-10-06 00:19:06 +0100
commit4ba496a46605ba4766071ff0f7828f1fa187d612 (patch)
treee988c395e4599b0919850f8d9da84b8a8ddfcc8f
parentc40660b0d84509869ff261e8f4a76585b0cb9131 (diff)
downloadprofani-tty-4ba496a46605ba4766071ff0f7828f1fa187d612.tar.gz
Minor code tidy cmd_ac.c
-rw-r--r--src/command/cmd_ac.c101
1 files changed, 47 insertions, 54 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 535a86b1..47655114 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -745,17 +745,21 @@ cmd_ac_init(void)
void
cmd_ac_add(const char *const value)
{
- if (commands_ac) {
- autocomplete_add(commands_ac, value);
+ if (commands_ac == NULL) {
+ return;
}
+
+ autocomplete_add(commands_ac, value);
}
void
cmd_ac_add_help(const char *const value)
{
- if (help_ac) {
- autocomplete_add(help_ac, value);
+ if (help_ac == NULL) {
+ return;
}
+
+ autocomplete_add(help_ac, value);
}
void
@@ -778,33 +782,40 @@ cmd_ac_add_alias(ProfAlias *alias)
void
cmd_ac_add_alias_value(char *value)
{
- if (aliases_ac) {
- autocomplete_add(aliases_ac, value);
+ if (aliases_ac == NULL) {
+ return;
}
+
+ autocomplete_add(aliases_ac, value);
}
void
cmd_ac_remove_alias_value(char *value)
{
- if (aliases_ac) {
- autocomplete_remove(aliases_ac, value);
+ if (aliases_ac == NULL) {
+ return;
}
+ autocomplete_remove(aliases_ac, value);
}
void
cmd_ac_remove(const char *const value)
{
- if (commands_ac) {
- autocomplete_remove(commands_ac, value);
+ if (commands_ac == NULL) {
+ return;
}
+
+ autocomplete_remove(commands_ac, value);
}
void
cmd_ac_remove_help(const char *const value)
{
- if (help_ac) {
- autocomplete_remove(help_ac, value);
+ if (help_ac == NULL) {
+ return;
}
+
+ autocomplete_remove(help_ac, value);
}
gboolean
@@ -812,9 +823,9 @@ cmd_ac_exists(char *cmd)
{
if (commands_ac == NULL) {
return FALSE;
- } else {
- return autocomplete_contains(commands_ac, cmd);
}
+
+ return autocomplete_contains(commands_ac, cmd);
}
void
@@ -2310,42 +2321,38 @@ _time_autocomplete(ProfWin *window, const char *const input)
static char*
_kick_autocomplete(ProfWin *window, const char *const input)
{
- char *result = NULL;
-
- if (window->type == WIN_MUC) {
- ProfMucWin *mucwin = (ProfMucWin*)window;
- assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
- Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
+ if (window->type != WIN_MUC) {
+ return NULL;
+ }
- if (nick_ac) {
- result = autocomplete_param_with_ac(input, "/kick", nick_ac, TRUE);
- if (result) {
- return result;
- }
- }
+ ProfMucWin *mucwin = (ProfMucWin*)window;
+ assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
+ Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
+ if (nick_ac == NULL) {
+ return NULL;
}
+ char *result = autocomplete_param_with_ac(input, "/kick", nick_ac, TRUE);
+
return result;
}
static char*
_ban_autocomplete(ProfWin *window, const char *const input)
{
- char *result = NULL;
-
- if (window->type == WIN_MUC) {
- ProfMucWin *mucwin = (ProfMucWin*)window;
- assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
- Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
+ if (window->type != WIN_MUC) {
+ return NULL;
+ }
- if (jid_ac) {
- result = autocomplete_param_with_ac(input, "/ban", jid_ac, TRUE);
- if (result) {
- return result;
- }
- }
+ ProfMucWin *mucwin = (ProfMucWin*)window;
+ assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
+ Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
+ if (jid_ac == NULL) {
+ return NULL;
}
+ char *result = autocomplete_param_with_ac(input, "/ban", jid_ac, TRUE);
+
return result;
}
@@ -2717,27 +2724,13 @@ _console_autocomplete(ProfWin *window, const char *const input)
static char*
_win_autocomplete(ProfWin *window, const char *const input)
{
- char *found = NULL;
-
- found = autocomplete_param_with_func(input, "/win", win_autocomplete);
- if (found) {
- return found;
- }
-
- return NULL;
+ return autocomplete_param_with_func(input, "/win", win_autocomplete);
}
static char*
_close_autocomplete(ProfWin *window, const char *const input)
{
- char *found = NULL;
-
- found = autocomplete_param_with_func(input, "/close", win_close_autocomplete);
- if (found) {
- return found;
- }
-
- return NULL;
+ return autocomplete_param_with_func(input, "/close", win_close_autocomplete);
}
static char*