diff options
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 26 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 25 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 15 |
3 files changed, 26 insertions, 40 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 6e22e90e..3aeedc60 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1635,7 +1635,6 @@ cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean static char* _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previous) { - int i; char* result = NULL; jabber_conn_status_t conn_status = connection_get_status(); @@ -1644,7 +1643,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard" }; - for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { + for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) { result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL); if (result) { return result; @@ -1661,7 +1660,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ // Remove quote character before and after names when doing autocomplete char* unquoted = strip_arg_quotes(input); - for (i = 0; i < ARRAY_SIZE(nick_choices); i++) { + for (int i = 0; i < ARRAY_SIZE(nick_choices); i++) { result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE, previous); if (result) { free(unquoted); @@ -1676,7 +1675,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ gchar* contact_choices[] = { "/msg", "/info" }; // Remove quote character before and after names when doing autocomplete char* unquoted = strip_arg_quotes(input); - for (i = 0; i < ARRAY_SIZE(contact_choices); i++) { + for (int i = 0; i < ARRAY_SIZE(contact_choices); i++) { result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete, previous, NULL); if (result) { free(unquoted); @@ -1686,7 +1685,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ free(unquoted); gchar* resource_choices[] = { "/caps", "/ping" }; - for (i = 0; i < ARRAY_SIZE(resource_choices); i++) { + for (int i = 0; i < ARRAY_SIZE(resource_choices); i++) { result = autocomplete_param_with_func(input, resource_choices[i], roster_fulljid_autocomplete, previous, NULL); if (result) { return result; @@ -1695,7 +1694,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ } gchar* invite_choices[] = { "/join" }; - for (i = 0; i < ARRAY_SIZE(invite_choices); i++) { + for (int i = 0; i < ARRAY_SIZE(invite_choices); i++) { result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous, NULL); if (result) { return result; @@ -1705,7 +1704,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ gchar* cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/mainwin", "/inputwin" }; Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac }; - for (i = 0; i < ARRAY_SIZE(cmds); i++) { + for (int i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE, previous); if (result) { return result; @@ -1778,7 +1777,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ int len = strlen(input); char parsed[len + 1]; - i = 0; + int i = 0; while (i < len) { if (input[i] == ' ') { break; @@ -1856,12 +1855,11 @@ _who_autocomplete(ProfWin* window, const char* const input, gboolean previous) } else { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { - int i = 0; gchar* group_commands[] = { "/who any", "/who online", "/who offline", "/who chat", "/who away", "/who xa", "/who dnd", "/who available", "/who unavailable" }; - for (i = 0; i < ARRAY_SIZE(group_commands); i++) { + for (int i = 0; i < ARRAY_SIZE(group_commands); i++) { result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete, previous, NULL); if (result) { return result; @@ -2186,7 +2184,6 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo static char* _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous) { - int i = 0; char* result = NULL; result = autocomplete_param_with_func(input, "/notify room trigger remove", prefs_autocomplete_room_trigger, previous, NULL); @@ -2196,7 +2193,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous gchar* boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current", "/notify room text", "/notify chat text" }; - for (i = 0; i < ARRAY_SIZE(boolean_choices1); i++) { + for (int i = 0; i < ARRAY_SIZE(boolean_choices1); i++) { result = autocomplete_param_with_func(input, boolean_choices1[i], prefs_autocomplete_boolean_choice, previous, NULL); if (result) { return result; @@ -2229,7 +2226,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous } gchar* boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger" }; - for (i = 0; i < ARRAY_SIZE(boolean_choices2); i++) { + for (int i = 0; i < ARRAY_SIZE(boolean_choices2); i++) { result = autocomplete_param_with_func(input, boolean_choices2[i], prefs_autocomplete_boolean_choice, previous, NULL); if (result) { return result; @@ -3713,12 +3710,11 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou return found; } - int i = 0; gchar* account_choice[] = { "/account set", "/account show", "/account enable", "/account disable", "/account rename", "/account clear", "/account remove", "/account default set" }; - for (i = 0; i < ARRAY_SIZE(account_choice); i++) { + for (int i = 0; i < ARRAY_SIZE(account_choice); i++) { found = autocomplete_param_with_func(input, account_choice[i], accounts_find_all, previous, NULL); if (found) { return found; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 8bfd33d3..53c42bae 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2557,17 +2557,16 @@ _cmd_index(Command* cmd) index_source = g_string_append(index_source, " "); int len = g_strv_length(cmd->help.tags); - int i = 0; - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { index_source = g_string_append(index_source, cmd->help.tags[i]); index_source = g_string_append(index_source, " "); } len = g_strv_length(cmd->help.synopsis); - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { index_source = g_string_append(index_source, cmd->help.synopsis[i]); index_source = g_string_append(index_source, " "); } - for (i = 0; cmd->help.args[i][0] != NULL; i++) { + for (int i = 0; cmd->help.args[i][0] != NULL; i++) { index_source = g_string_append(index_source, cmd->help.args[i][0]); index_source = g_string_append(index_source, " "); index_source = g_string_append(index_source, cmd->help.args[i][1]); @@ -2578,7 +2577,7 @@ _cmd_index(Command* cmd) g_string_free(index_source, TRUE); GString* index = g_string_new(""); - for (i = 0; i < g_strv_length(tokens); i++) { + for (int i = 0; i < g_strv_length(tokens); i++) { index = g_string_append(index, tokens[i]); index = g_string_append(index, " "); } @@ -2598,8 +2597,7 @@ cmd_search_index_any(char* term) gchar** processed_terms = g_str_tokenize_and_fold(term, NULL, NULL); int terms_len = g_strv_length(processed_terms); - int i = 0; - for (i = 0; i < terms_len; i++) { + for (int i = 0; i < terms_len; i++) { GList* index_keys = g_hash_table_get_keys(search_index); GList* curr = index_keys; while (curr) { @@ -2630,8 +2628,7 @@ cmd_search_index_all(char* term) while (curr) { char* command = curr->data; int matches = 0; - int i = 0; - for (i = 0; i < terms_len; i++) { + for (int i = 0; i < terms_len; i++) { char* command_index = g_hash_table_lookup(search_index, command); if (g_str_match_string(terms[i], command_index, FALSE)) { matches++; @@ -2663,8 +2660,7 @@ cmd_init(void) // load command defs into hash table commands = g_hash_table_new(g_str_hash, g_str_equal); - unsigned int i; - for (i = 0; i < ARRAY_SIZE(command_defs); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(command_defs); i++) { Command* pcmd = command_defs + i; // add to hash @@ -2738,8 +2734,7 @@ cmd_get_ordered(const char* const tag) static gboolean _cmd_has_tag(Command* pcmd, const char* const tag) { - int i = 0; - for (i = 0; pcmd->help.tags[i] != NULL; i++) { + for (int i = 0; pcmd->help.tags[i] != NULL; i++) { if (g_strcmp0(tag, pcmd->help.tags[i]) == 0) { return TRUE; } @@ -2758,8 +2753,8 @@ void command_docgen(void) { GList* cmds = NULL; - unsigned int i; - for (i = 0; i < ARRAY_SIZE(command_defs); i++) { + + for (unsigned int i = 0; i < ARRAY_SIZE(command_defs); i++) { Command* pcmd = command_defs + i; cmds = g_list_insert_sorted(cmds, pcmd, (GCompareFunc)_cmp_command); } diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 56a68297..0837f630 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1086,8 +1086,7 @@ _writecsv(int fd, const char* const str) size_t len = strlen(str); char* s = malloc(2 * len * sizeof(char)); char* c = s; - int i = 0; - for (; i < strlen(str); i++) { + for (int i =0; i < strlen(str); i++) { if (str[i] != '"') *c++ = str[i]; else { @@ -1415,8 +1414,7 @@ cmd_close(ProfWin* window, const char* const command, gchar** args) gboolean is_num = TRUE; int index = 0; if (args[0] != NULL) { - int i = 0; - for (i = 0; i < strlen(args[0]); i++) { + for (int i = 0; i < strlen(args[0]); i++) { if (!isdigit((int)args[0][i])) { is_num = FALSE; break; @@ -1503,8 +1501,7 @@ gboolean cmd_win(ProfWin* window, const char* const command, gchar** args) { gboolean is_num = TRUE; - int i = 0; - for (i = 0; i < strlen(args[0]); i++) { + for (int i = 0; i < strlen(args[0]); i++) { if (!isdigit((int)args[0][i])) { is_num = FALSE; break; @@ -8567,14 +8564,13 @@ cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args) } GList* fingerprints = omemo_known_device_identities(jid->barejid); - GList* fingerprint; if (!fingerprints) { win_println(window, THEME_DEFAULT, "-", "There is no known fingerprints for %s", jid->barejid); return TRUE; } - for (fingerprint = fingerprints; fingerprint != NULL; fingerprint = fingerprint->next) { + for (GList* fingerprint = fingerprints; fingerprint != NULL; fingerprint = fingerprint->next) { char* formatted_fingerprint = omemo_format_fingerprint(fingerprint->data); gboolean trusted = omemo_is_trusted_identity(jid->barejid, fingerprint->data); @@ -8710,8 +8706,7 @@ cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args) omemo_untrust(barejid, fingerprint); char* unformatted_fingerprint = malloc(strlen(fingerprint)); - int i; - int j; + int i, j; for (i = 0, j = 0; fingerprint[i] != '\0'; i++) { if (!g_ascii_isxdigit(fingerprint[i])) { continue; |