diff options
author | James Booth <boothj5@gmail.com> | 2015-05-04 23:40:58 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-04 23:40:58 +0100 |
commit | 3fd9692aecf190d079b119f66e046c8ed9013031 (patch) | |
tree | f2688404a0b898365d1e9e26f4c8f1335ca134b8 /src/command | |
parent | 176fba84a04d8c0864b57feb848cccfe5c4814e3 (diff) | |
parent | 6f3750c6aa1ba72378ac004e6abceb19ed1ddecb (diff) | |
download | profani-tty-3fd9692aecf190d079b119f66e046c8ed9013031.tar.gz |
Merge branch 'master' into pgp
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 220 | ||||
-rw-r--r-- | src/command/commands.c | 100 |
2 files changed, 160 insertions, 160 deletions
diff --git a/src/command/command.c b/src/command/command.c index 519550a3..55f7d457 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1258,7 +1258,7 @@ cmd_init(void) // load aliases GList *aliases = prefs_get_aliases(); GList *curr = aliases; - while (curr != NULL) { + while (curr) { ProfAlias *alias = curr->data; GString *ac_alias = g_string_new("/"); g_string_append(ac_alias, alias->name); @@ -1664,7 +1664,7 @@ cmd_exists(char *cmd) void cmd_autocomplete_add(char *value) { - if (commands_ac != NULL) { + if (commands_ac) { autocomplete_add(commands_ac, value); } } @@ -1706,7 +1706,7 @@ cmd_autocomplete_remove_form_fields(DataForm *form) void cmd_autocomplete_remove(char *value) { - if (commands_ac != NULL) { + if (commands_ac) { autocomplete_remove(commands_ac, value); } } @@ -1714,7 +1714,7 @@ cmd_autocomplete_remove(char *value) void cmd_alias_add(char *value) { - if (aliases_ac != NULL) { + if (aliases_ac) { autocomplete_add(aliases_ac, value); } } @@ -1722,7 +1722,7 @@ cmd_alias_add(char *value) void cmd_alias_remove(char *value) { - if (aliases_ac != NULL) { + if (aliases_ac) { autocomplete_remove(aliases_ac, value); } } @@ -1735,7 +1735,7 @@ cmd_autocomplete(const char * const input) if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, strlen(input), ' '))) { char *found = NULL; found = autocomplete_complete(commands_ac, input, TRUE); - if (found != NULL) { + if (found) { return found; } @@ -1775,7 +1775,7 @@ cmd_reset_autocomplete() autocomplete_reset(autoaway_mode_ac); autocomplete_reset(autoconnect_ac); autocomplete_reset(theme_ac); - if (theme_load_ac != NULL) { + if (theme_load_ac) { autocomplete_free(theme_load_ac); theme_load_ac = NULL; } @@ -1907,7 +1907,7 @@ _cmd_execute(const char * const command, const char * const inp) Command *cmd = g_hash_table_lookup(commands, command); gboolean result = FALSE; - if (cmd != NULL) { + if (cmd) { gchar **args = cmd->parser(inp, cmd->min_args, cmd->max_args, &result); if (result == FALSE) { ui_invalid_command_usage(cmd->help.usage, cmd->setting_func); @@ -2054,7 +2054,7 @@ _cmd_complete_parameters(const char * const input) parsed[i] = '\0'; char * (*ac_func)(const char * const) = g_hash_table_lookup(ac_funcs, parsed); - if (ac_func != NULL) { + if (ac_func) { result = ac_func(input); if (result) { g_hash_table_destroy(ac_funcs); @@ -2078,15 +2078,15 @@ _sub_autocomplete(const char * const input) { char *result = NULL; result = autocomplete_param_with_func(input, "/sub allow", presence_sub_request_find); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/sub deny", presence_sub_request_find); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/sub", sub_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2101,7 +2101,7 @@ _who_autocomplete(const char * const input) if (win_type == WIN_MUC) { result = autocomplete_param_with_ac(input, "/who", who_room_ac, TRUE); - if (result != NULL) { + if (result) { return result; } } else { @@ -2112,13 +2112,13 @@ _who_autocomplete(const char * const input) for (i = 0; i < ARRAY_SIZE(group_commands); i++) { result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete); - if (result != NULL) { + if (result) { return result; } } result = autocomplete_param_with_ac(input, "/who", who_roster_ac, TRUE); - if (result != NULL) { + if (result) { return result; } } @@ -2131,31 +2131,31 @@ _roster_autocomplete(const char * const input) { char *result = NULL; result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/roster clearnick", roster_barejid_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/roster remove", roster_barejid_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/roster show", roster_option_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/roster hide", roster_option_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/roster by", roster_by_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2167,28 +2167,28 @@ _group_autocomplete(const char * const input) { char *result = NULL; result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_no_with_func(input, "/group add", 4, roster_contact_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_no_with_func(input, "/group remove", 4, roster_contact_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/group add", roster_group_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/group remove", roster_group_autocomplete); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/group", group_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2249,7 +2249,7 @@ _bookmark_autocomplete(const char * const input) found = autocomplete_param_with_ac(input, beginning->str, bookmark_property_ac, TRUE); } g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } @@ -2258,15 +2258,15 @@ _bookmark_autocomplete(const char * const input) g_strfreev(args); found = autocomplete_param_with_func(input, "/bookmark remove", bookmark_find); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_func(input, "/bookmark join", bookmark_find); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_func(input, "/bookmark update", bookmark_find); - if (found != NULL) { + if (found) { return found; } @@ -2281,42 +2281,42 @@ _notify_autocomplete(const char * const input) char *result = NULL; result = autocomplete_param_with_func(input, "/notify room current", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/notify message current", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/notify typing current", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/notify room text", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/notify message text", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/notify room", notify_room_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/notify message", notify_message_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/notify typing", notify_typing_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2324,13 +2324,13 @@ _notify_autocomplete(const char * const input) for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } } result = autocomplete_param_with_ac(input, "/notify", notify_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2343,16 +2343,16 @@ _autoaway_autocomplete(const char * const input) char *result = NULL; result = autocomplete_param_with_ac(input, "/autoaway mode", autoaway_mode_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/autoaway check", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/autoaway", autoaway_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2366,16 +2366,16 @@ _log_autocomplete(const char * const input) result = autocomplete_param_with_func(input, "/log rotate", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/log shared", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/log", log_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2388,12 +2388,12 @@ _autoconnect_autocomplete(const char * const input) char *result = NULL; result = autocomplete_param_with_func(input, "/autoconnect set", accounts_find_enabled); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/autoconnect", autoconnect_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2406,12 +2406,12 @@ _otr_autocomplete(const char * const input) char *found = NULL; found = autocomplete_param_with_func(input, "/otr start", roster_contact_autocomplete); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/otr log", otr_log_ac, TRUE); - if (found != NULL) { + if (found) { return found; } @@ -2426,7 +2426,7 @@ _otr_autocomplete(const char * const input) found = autocomplete_param_with_func(input, beginning->str, roster_contact_autocomplete); g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } @@ -2435,18 +2435,18 @@ _otr_autocomplete(const char * const input) g_strfreev(args); found = autocomplete_param_with_ac(input, "/otr policy", otr_policy_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_func(input, "/otr warn", prefs_autocomplete_boolean_choice); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/otr", otr_ac, TRUE); - if (found != NULL) { + if (found) { return found; } @@ -2462,7 +2462,7 @@ _theme_autocomplete(const char * const input) theme_load_ac = autocomplete_new(); GSList *themes = theme_list(); GSList *curr = themes; - while (curr != NULL) { + while (curr) { autocomplete_add(theme_load_ac, curr->data); curr = g_slist_next(curr); } @@ -2470,12 +2470,12 @@ _theme_autocomplete(const char * const input) autocomplete_add(theme_load_ac, "default"); } result = autocomplete_param_with_ac(input, "/theme load", theme_load_ac, TRUE); - if (result != NULL) { + if (result) { return result; } } result = autocomplete_param_with_ac(input, "/theme", theme_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2494,24 +2494,24 @@ _resource_autocomplete(const char * const input) if (contact) { Autocomplete ac = p_contact_resource_ac(contact); found = autocomplete_param_with_ac(input, "/resource set", ac, FALSE); - if (found != NULL) { + if (found) { return found; } } } found = autocomplete_param_with_func(input, "/resource title", prefs_autocomplete_boolean_choice); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_func(input, "/resource message", prefs_autocomplete_boolean_choice); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/resource", resource_ac, FALSE); - if (found != NULL) { + if (found) { return found; } @@ -2524,17 +2524,17 @@ _titlebar_autocomplete(const char * const input) char *found = NULL; found = autocomplete_param_with_func(input, "/titlebar show", prefs_autocomplete_boolean_choice); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_func(input, "/titlebar goodbye", prefs_autocomplete_boolean_choice); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/titlebar", titlebar_ac, FALSE); - if (found != NULL) { + if (found) { return found; } @@ -2547,12 +2547,12 @@ _inpblock_autocomplete(const char * const input) char *found = NULL; found = autocomplete_param_with_func(input, "/inpblock dynamic", prefs_autocomplete_boolean_choice); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/inpblock", inpblock_ac, FALSE); - if (found != NULL) { + if (found) { return found; } @@ -2573,13 +2573,13 @@ _form_autocomplete(const char * const input) DataForm *form = confwin->form; if (form) { found = autocomplete_param_with_ac(input, "/form help", form->tag_ac, TRUE); - if (found != NULL) { + if (found) { return found; } } found = autocomplete_param_with_ac(input, "/form", form_ac, TRUE); - if (found != NULL) { + if (found) { return found; } @@ -2663,32 +2663,32 @@ _occupants_autocomplete(const char * const input) char *found = NULL; found = autocomplete_param_with_ac(input, "/occupants default show", occupants_show_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/occupants default hide", occupants_show_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/occupants default", occupants_default_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/occupants show", occupants_show_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/occupants hide", occupants_show_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/occupants", occupants_ac, TRUE); - if (found != NULL) { + if (found) { return found; } @@ -2701,12 +2701,12 @@ _time_autocomplete(const char * const input) char *found = NULL; found = autocomplete_param_with_ac(input, "/time statusbar", time_statusbar_ac, TRUE); - if (found != NULL) { + if (found) { return found; } found = autocomplete_param_with_ac(input, "/time", time_ac, TRUE); - if (found != NULL) { + if (found) { return found; } @@ -2722,9 +2722,9 @@ _kick_autocomplete(const char * const input) ProfMucWin *mucwin = wins_get_current_muc(); Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid); - if (nick_ac != NULL) { + if (nick_ac) { result = autocomplete_param_with_ac(input, "/kick", nick_ac, TRUE); - if (result != NULL) { + if (result) { return result; } } @@ -2742,9 +2742,9 @@ _ban_autocomplete(const char * const input) ProfMucWin *mucwin = wins_get_current_muc(); Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid); - if (jid_ac != NULL) { + if (jid_ac) { result = autocomplete_param_with_ac(input, "/ban", jid_ac, TRUE); - if (result != NULL) { + if (result) { return result; } } @@ -2773,7 +2773,7 @@ _affiliation_autocomplete(const char * const input) result = autocomplete_param_with_ac(input, beginning->str, jid_ac, TRUE); g_string_free(beginning, TRUE); - if (result != NULL) { + if (result) { g_strfreev(args); return result; } @@ -2783,17 +2783,17 @@ _affiliation_autocomplete(const char * const input) } result = autocomplete_param_with_ac(input, "/affiliation set", affiliation_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/affiliation list", affiliation_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/affiliation", privilege_cmd_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2820,7 +2820,7 @@ _role_autocomplete(const char * const input) result = autocomplete_param_with_ac(input, beginning->str, nick_ac, TRUE); g_string_free(beginning, TRUE); - if (result != NULL) { + if (result) { g_strfreev(args); return result; } @@ -2830,17 +2830,17 @@ _role_autocomplete(const char * const input) } result = autocomplete_param_with_ac(input, "/role set", role_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/role list", role_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/role", privilege_cmd_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2853,22 +2853,22 @@ _statuses_autocomplete(const char * const input) char *result = NULL; result = autocomplete_param_with_ac(input, "/statuses console", statuses_setting_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/statuses chat", statuses_setting_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/statuses muc", statuses_setting_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/statuses", statuses_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2881,17 +2881,17 @@ _receipts_autocomplete(const char * const input) char *result = NULL; result = autocomplete_param_with_func(input, "/receipts send", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_func(input, "/receipts request", prefs_autocomplete_boolean_choice); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/receipts", receipts_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2904,12 +2904,12 @@ _alias_autocomplete(const char * const input) char *result = NULL; result = autocomplete_param_with_ac(input, "/alias remove", aliases_ac, TRUE); - if (result != NULL) { + if (result) { return result; } result = autocomplete_param_with_ac(input, "/alias", alias_ac, TRUE); - if (result != NULL) { + if (result) { return result; } @@ -2927,7 +2927,7 @@ _connect_autocomplete(const char * const input) if ((strncmp(input, "/connect", 8) == 0) && (result == TRUE)) { GString *beginning = g_string_new("/connect "); g_string_append(beginning, args[0]); - if (args[1] != NULL && args[2] != NULL) { + if (args[1] && args[2]) { g_string_append(beginning, " "); g_string_append(beginning, args[1]); g_string_append(beginning, " "); @@ -2935,7 +2935,7 @@ _connect_autocomplete(const char * const input) } found = autocomplete_param_with_ac(input, beginning->str, connect_property_ac, TRUE); g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } @@ -2944,7 +2944,7 @@ _connect_autocomplete(const char * const input) g_strfreev(args); found = autocomplete_param_with_func(input, "/connect", accounts_find_enabled); - if (found != NULL) { + if (found) { return found; } @@ -2958,7 +2958,7 @@ _join_autocomplete(const char * const input) gboolean result = FALSE; found = autocomplete_param_with_func(input, "/join", bookmark_find); - if (found != NULL) { + if (found) { return found; } @@ -2967,7 +2967,7 @@ _join_autocomplete(const char * const input) if ((strncmp(input, "/join", 5) == 0) && (result == TRUE)) { GString *beginning = g_string_new("/join "); g_string_append(beginning, args[0]); - if (args[1] != NULL && args[2] != NULL) { + if (args[1] && args[2]) { g_string_append(beginning, " "); g_string_append(beginning, args[1]); g_string_append(beginning, " "); @@ -2975,7 +2975,7 @@ _join_autocomplete(const char * const input) } found = autocomplete_param_with_ac(input, beginning->str, join_property_ac, TRUE); g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } @@ -3002,14 +3002,14 @@ _account_autocomplete(const char * const input) g_string_append(beginning, args[2]); found = autocomplete_param_with_ac(input, beginning->str, otr_policy_ac, TRUE); g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } } else { found = autocomplete_param_with_ac(input, beginning->str, account_set_ac, TRUE); g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } @@ -3021,7 +3021,7 @@ _account_autocomplete(const char * const input) g_string_append(beginning, args[1]); found = autocomplete_param_with_ac(input, beginning->str, account_clear_ac, TRUE); g_string_free(beginning, TRUE); - if (found != NULL) { + if (found) { g_strfreev(args); return found; } @@ -3041,7 +3041,7 @@ _account_autocomplete(const char * const input) for (i = 0; i < ARRAY_SIZE(account_choice); i++) { found = autocomplete_param_with_func(input, account_choice[i], accounts_find_all); - if (found != NULL) { + if (found) { return found; } } @@ -3086,7 +3086,7 @@ command_docgen(void) fputs("<p>Details:</p>\n", main_fragment); fputs("<p><pre><code>", main_fragment); int i = 2; - while (pcmd->help.long_help[i] != NULL) { + while (pcmd->help.long_help[i]) { fprintf(main_fragment, "%s\n", pcmd->help.long_help[i++]); } fputs("</code></pre></p>\n<a href=\"#top\"><h5>back to top</h5></a><br><hr>\n", main_fragment); diff --git a/src/command/commands.c b/src/command/commands.c index a7e89724..f446ad59 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -407,7 +407,7 @@ cmd_account(gchar **args, struct cmd_help_t help) } else { accounts_set_jid(account_name, jid->barejid); cons_show("Updated jid for account %s: %s", account_name, jid->barejid); - if (jid->resourcepart != NULL) { + if (jid->resourcepart) { accounts_set_resource(account_name, jid->resourcepart); cons_show("Updated resource for account %s: %s", account_name, jid->resourcepart); } @@ -437,7 +437,7 @@ cmd_account(gchar **args, struct cmd_help_t help) cons_show("Updated resource for account %s: %s", account_name, value); cons_show(""); } else if (strcmp(property, "password") == 0) { - if(accounts_get_account(account_name)->eval_password != NULL) { + if(accounts_get_account(account_name)->eval_password) { cons_show("Cannot set password when eval_password is set."); } else { accounts_set_password(account_name, value); @@ -445,7 +445,7 @@ cmd_account(gchar **args, struct cmd_help_t help) cons_show(""); } } else if (strcmp(property, "eval_password") == 0) { - if(accounts_get_account(account_name)->password != NULL) { + if(accounts_get_account(account_name)->password) { cons_show("Cannot set eval_password when password is set."); } else { accounts_set_eval_password(account_name, value); @@ -766,7 +766,7 @@ cmd_help(gchar **args, struct cmd_help_t help) } GList *curr = ordered_commands; - while (curr != NULL) { + while (curr) { Command *cmd = curr->data; cons_show("%-12s: %s", cmd->cmd, cmd->help.short_help); curr = g_list_next(curr); @@ -828,12 +828,12 @@ cmd_help(gchar **args, struct cmd_help_t help) const gchar **help_text = NULL; Command *command = g_hash_table_lookup(commands, cmd_with_slash); - if (command != NULL) { + if (command) { help_text = command->help.long_help; } cons_show(""); - if (help_text != NULL) { + if (help_text) { ProfWin *console = wins_get_console(); ui_show_lines(console, help_text); } else { @@ -939,13 +939,13 @@ cmd_theme(gchar **args, struct cmd_help_t help) static void _who_room(gchar **args, struct cmd_help_t help) { - if ((g_strv_length(args) == 2) && (args[1] != NULL)) { + if ((g_strv_length(args) == 2) && args[1]) { cons_show("Argument group is not applicable to chat rooms."); return; } // bad arg - if (args[0] != NULL && + if (args[0] && (g_strcmp0(args[0], "online") != 0) && (g_strcmp0(args[0], "available") != 0) && (g_strcmp0(args[0], "unavailable") != 0) && @@ -989,7 +989,7 @@ _who_room(gchar **args, struct cmd_help_t help) } else if (strcmp("available", presence) == 0) { GList *filtered = NULL; - while (occupants != NULL) { + while (occupants) { Occupant *occupant = occupants->data; if (muc_occupant_available(occupant)) { filtered = g_list_append(filtered, occupant); @@ -1003,7 +1003,7 @@ _who_room(gchar **args, struct cmd_help_t help) } else if (strcmp("unavailable", presence) == 0) { GList *filtered = NULL; - while (occupants != NULL) { + while (occupants) { Occupant *occupant = occupants->data; if (!muc_occupant_available(occupant)) { filtered = g_list_append(filtered, occupant); @@ -1017,7 +1017,7 @@ _who_room(gchar **args, struct cmd_help_t help) } else { GList *filtered = NULL; - while (occupants != NULL) { + while (occupants) { Occupant *occupant = occupants->data; const char *presence_str = string_from_resource_presence(occupant->presence); if (strcmp(presence_str, presence) == 0) { @@ -1071,7 +1071,7 @@ _who_roster(gchar **args, struct cmd_help_t help) char *presence = args[0]; // bad arg - if ((presence != NULL) + if (presence && (strcmp(presence, "online") != 0) && (strcmp(presence, "available") != 0) && (strcmp(presence, "unavailable") != 0) @@ -1086,13 +1086,13 @@ _who_roster(gchar **args, struct cmd_help_t help) } char *group = NULL; - if ((g_strv_length(args) == 2) && (args[1] != NULL)) { + if ((g_strv_length(args) == 2) && args[1]) { group = args[1]; } cons_show(""); GSList *list = NULL; - if (group != NULL) { + if (group) { list = roster_get_group(group); if (list == NULL) { cons_show("No such group: %s.", group); @@ -1108,7 +1108,7 @@ _who_roster(gchar **args, struct cmd_help_t help) // no arg, show all contacts if ((presence == NULL) || (g_strcmp0(presence, "any") == 0)) { - if (group != NULL) { + if (group) { if (list == NULL) { cons_show("No contacts in group %s.", group); } else { @@ -1129,7 +1129,7 @@ _who_roster(gchar **args, struct cmd_help_t help) GSList *filtered = NULL; GSList *curr = list; - while (curr != NULL) { + while (curr) { PContact contact = curr->data; if (p_contact_is_available(contact)) { filtered = g_slist_append(filtered, contact); @@ -1137,7 +1137,7 @@ _who_roster(gchar **args, struct cmd_help_t help) curr = g_slist_next(curr); } - if (group != NULL) { + if (group) { if (filtered == NULL) { cons_show("No contacts in group %s are %s.", group, presence); } else { @@ -1159,7 +1159,7 @@ _who_roster(gchar **args, struct cmd_help_t help) GSList *filtered = NULL; GSList *curr = list; - while (curr != NULL) { + while (curr) { PContact contact = curr->data; if (!p_contact_is_available(contact)) { filtered = g_slist_append(filtered, contact); @@ -1167,7 +1167,7 @@ _who_roster(gchar **args, struct cmd_help_t help) curr = g_slist_next(curr); } - if (group != NULL) { + if (group) { if (filtered == NULL) { cons_show("No contacts in group %s are %s.", group, presence); } else { @@ -1189,7 +1189,7 @@ _who_roster(gchar **args, struct cmd_help_t help) GSList *filtered = NULL; GSList *curr = list; - while (curr != NULL) { + while (curr) { PContact contact = curr->data; if (p_contact_has_available_resource(contact)) { filtered = g_slist_append(filtered, contact); @@ -1197,7 +1197,7 @@ _who_roster(gchar **args, struct cmd_help_t help) curr = g_slist_next(curr); } - if (group != NULL) { + if (group) { if (filtered == NULL) { cons_show("No contacts in group %s are %s.", group, presence); } else { @@ -1219,7 +1219,7 @@ _who_roster(gchar **args, struct cmd_help_t help) GSList *filtered = NULL; GSList *curr = list; - while (curr != NULL) { + while (curr) { PContact contact = curr->data; if (!p_contact_has_available_resource(contact)) { filtered = g_slist_append(filtered, contact); @@ -1227,7 +1227,7 @@ _who_roster(gchar **args, struct cmd_help_t help) curr = g_slist_next(curr); } - if (group != NULL) { + if (group) { if (filtered == NULL) { cons_show("No contacts in group %s are %s.", group, presence); } else { @@ -1249,7 +1249,7 @@ _who_roster(gchar **args, struct cmd_help_t help) GSList *filtered = NULL; GSList *curr = list; - while (curr != NULL) { + while (curr) { PContact contact = curr->data; if (strcmp(p_contact_presence(contact), presence) == 0) { filtered = g_slist_append(filtered, contact); @@ -1257,7 +1257,7 @@ _who_roster(gchar **args, struct cmd_help_t help) curr = g_slist_next(curr); } - if (group != NULL) { + if (group) { if (filtered == NULL) { cons_show("No contacts in group %s are %s.", group, presence); } else { @@ -1380,9 +1380,9 @@ cmd_group(gchar **args, struct cmd_help_t help) if (args[0] == NULL) { GSList *groups = roster_get_groups(); GSList *curr = groups; - if (curr != NULL) { + if (curr) { cons_show("Groups:"); - while (curr != NULL) { + while (curr) { cons_show(" %s", curr->data); curr = g_slist_next(curr); } @@ -1750,7 +1750,7 @@ cmd_status(gchar **args, struct cmd_help_t help) switch (win_type) { case WIN_MUC: - if (usr != NULL) { + if (usr) { ProfMucWin *mucwin = wins_get_current_muc(); ProfWin *window = (ProfWin*) mucwin; Occupant *occupant = muc_roster_item(mucwin->roomjid, usr); @@ -1764,13 +1764,13 @@ cmd_status(gchar **args, struct cmd_help_t help) } break; case WIN_CHAT: - if (usr != NULL) { + if (usr) { ui_current_print_line("No parameter required when in chat."); } else { ProfChatWin *chatwin = wins_get_current_chat(); ProfWin *window = (ProfWin*) chatwin; PContact pcontact = roster_get_contact(chatwin->barejid); - if (pcontact != NULL) { + if (pcontact) { win_show_contact(window, pcontact); } else { win_println(window, "Error getting contact info."); @@ -1778,7 +1778,7 @@ cmd_status(gchar **args, struct cmd_help_t help) } break; case WIN_PRIVATE: - if (usr != NULL) { + if (usr) { ui_current_print_line("No parameter required when in chat."); } else { ProfPrivateWin *privatewin = wins_get_current_private(); @@ -1794,7 +1794,7 @@ cmd_status(gchar **args, struct cmd_help_t help) } break; case WIN_CONSOLE: - if (usr != NULL) { + if (usr) { char *usr_jid = roster_barejid_from_name(usr); if (usr_jid == NULL) { usr_jid = usr; @@ -1851,7 +1851,7 @@ cmd_info(gchar **args, struct cmd_help_t help) ProfChatWin *chatwin = wins_get_current_chat(); ProfWin *window = (ProfWin*) chatwin; PContact pcontact = roster_get_contact(chatwin->barejid); - if (pcontact != NULL) { + if (pcontact) { win_show_info(window, pcontact); } else { win_println(window, "Error getting contact info."); @@ -1881,7 +1881,7 @@ cmd_info(gchar **args, struct cmd_help_t help) usr_jid = usr; } pcontact = roster_get_contact(usr_jid); - if (pcontact != NULL) { + if (pcontact) { cons_show_info(pcontact); } else { cons_show("No such contact \"%s\" in roster.", usr); @@ -1913,7 +1913,7 @@ cmd_caps(gchar **args, struct cmd_help_t help) switch (win_type) { case WIN_MUC: - if (args[0] != NULL) { + if (args[0]) { ProfMucWin *mucwin = wins_get_current_muc(); occupant = muc_roster_item(mucwin->roomjid, args[0]); if (occupant) { @@ -1929,7 +1929,7 @@ cmd_caps(gchar **args, struct cmd_help_t help) break; case WIN_CHAT: case WIN_CONSOLE: - if (args[0] != NULL) { + if (args[0]) { Jid *jid = jid_create(args[0]); if (jid->fulljid == NULL) { @@ -1953,7 +1953,7 @@ cmd_caps(gchar **args, struct cmd_help_t help) } break; case WIN_PRIVATE: - if (args[0] != NULL) { + if (args[0]) { cons_show("No parameter needed to /caps when in private chat."); } else { ProfPrivateWin *privatewin = wins_get_current_private(); @@ -1988,7 +1988,7 @@ cmd_software(gchar **args, struct cmd_help_t help) switch (win_type) { case WIN_MUC: - if (args[0] != NULL) { + if (args[0]) { ProfMucWin *mucwin = wins_get_current_muc(); occupant = muc_roster_item(mucwin->roomjid, args[0]); if (occupant) { @@ -2004,7 +2004,7 @@ cmd_software(gchar **args, struct cmd_help_t help) break; case WIN_CHAT: case WIN_CONSOLE: - if (args[0] != NULL) { + if (args[0]) { Jid *jid = jid_create(args[0]); if (jid == NULL || jid->fulljid == NULL) { @@ -2018,7 +2018,7 @@ cmd_software(gchar **args, struct cmd_help_t help) } break; case WIN_PRIVATE: - if (args[0] != NULL) { + if (args[0]) { cons_show("No parameter needed to /software when in private chat."); } else { ProfPrivateWin *privatewin = wins_get_current_private(); @@ -2078,7 +2078,7 @@ cmd_join(gchar **args, struct cmd_help_t help) ProfAccount *account = accounts_get_account(account_name); // full room jid supplied (room@server) - if (room_arg->localpart != NULL) { + if (room_arg->localpart) { room = args[0]; // server not supplied (room), use account preference @@ -2153,7 +2153,7 @@ cmd_invite(gchar **args, struct cmd_help_t help) ProfMucWin *mucwin = wins_get_current_muc(); message_send_invite(mucwin->roomjid, usr_jid, reason); - if (reason != NULL) { + if (reason) { cons_show("Room invite sent, contact: %s, room: %s, reason: \"%s\".", contact, mucwin->roomjid, reason); } else { @@ -2438,7 +2438,7 @@ cmd_form(gchar **args, struct cmd_help_t help) if (g_strcmp0(args[0], "help") == 0) { char *tag = args[1]; - if (tag != NULL) { + if (tag) { ui_show_form_field_help(confwin, tag); } else { ui_show_form_help(confwin); @@ -2446,7 +2446,7 @@ cmd_form(gchar **args, struct cmd_help_t help) const gchar **help_text = NULL; Command *command = g_hash_table_lookup(commands, "/form"); - if (command != NULL) { + if (command) { help_text = command->help.long_help; } @@ -2612,7 +2612,7 @@ cmd_affiliation(gchar **args, struct cmd_help_t help) } char *affiliation = args[1]; - if ((affiliation != NULL) && + if (affiliation && (g_strcmp0(affiliation, "owner") != 0) && (g_strcmp0(affiliation, "admin") != 0) && (g_strcmp0(affiliation, "member") != 0) && @@ -2682,7 +2682,7 @@ cmd_role(gchar **args, struct cmd_help_t help) } char *role = args[1]; - if ((role != NULL ) && + if (role && (g_strcmp0(role, "visitor") != 0) && (g_strcmp0(role, "participant") != 0) && (g_strcmp0(role, "moderator") != 0) && @@ -2972,7 +2972,7 @@ cmd_bookmark(gchar **args, struct cmd_help_t help) char *password = g_hash_table_lookup(options, "password"); char *autojoin = g_hash_table_lookup(options, "autojoin"); - if (autojoin != NULL) { + if (autojoin) { if ((strcmp(autojoin, "on") != 0) && (strcmp(autojoin, "off") != 0)) { cons_show("Usage: %s", help.usage); cons_show(""); @@ -3020,7 +3020,7 @@ cmd_disco(gchar **args, struct cmd_help_t help) } GString *jid = g_string_new(""); - if (args[1] != NULL) { + if (args[1]) { jid = g_string_append(jid, args[1]); } else { Jid *jidp = jid_create(jabber_get_fulljid()); @@ -4230,7 +4230,7 @@ cmd_otr(gchar **args, struct cmd_help_t help) return TRUE; } else if (strcmp(args[0], "start") == 0) { - if (args[1] != NULL) { + if (args[1]) { char *contact = args[1]; char *barejid = roster_barejid_from_name(contact); if (barejid == NULL) { @@ -4449,7 +4449,7 @@ _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size) } GList *curr = ordered_commands; - while (curr != NULL) { + while (curr) { Command *cmd = curr->data; cons_show("%-12s: %s", cmd->cmd, cmd->help.short_help); curr = g_list_next(curr); |