diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-11-09 11:03:54 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-11-09 11:33:33 +0100 |
commit | 35aecd425fad6697e9cf72832cb287a156ec7942 (patch) | |
tree | 97d7a1c91bcb0e74e2133333302b54b6858d9f84 /src/command/cmd_defs.c | |
parent | 304f63f2041ce26788c327013b8b0c1b904f1044 (diff) | |
download | profani-tty-35aecd425fad6697e9cf72832cb287a156ec7942.tar.gz |
Declare counter var inside loop
We require c99/gnu99 anyways.
Diffstat (limited to 'src/command/cmd_defs.c')
-rw-r--r-- | src/command/cmd_defs.c | 25 |
1 files changed, 10 insertions, 15 deletions
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); } |