about summary refs log tree commit diff stats
path: root/src/tools/autocomplete.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-11-09 11:03:54 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-11-09 11:33:33 +0100
commit35aecd425fad6697e9cf72832cb287a156ec7942 (patch)
tree97d7a1c91bcb0e74e2133333302b54b6858d9f84 /src/tools/autocomplete.c
parent304f63f2041ce26788c327013b8b0c1b904f1044 (diff)
downloadprofani-tty-35aecd425fad6697e9cf72832cb287a156ec7942.tar.gz
Declare counter var inside loop
We require c99/gnu99 anyways.
Diffstat (limited to 'src/tools/autocomplete.c')
-rw-r--r--src/tools/autocomplete.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index a3763bfb..bd766e52 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -171,8 +171,7 @@ autocomplete_add(Autocomplete ac, const char* item)
 void
 autocomplete_add_all(Autocomplete ac, char** items)
 {
-    int i = 0;
-    for (i = 0; i < g_strv_length(items); i++) {
+    for (int i = 0; i < g_strv_length(items); i++) {
         autocomplete_add(ac, items[i]);
     }
 }
@@ -202,8 +201,7 @@ autocomplete_remove(Autocomplete ac, const char* const item)
 void
 autocomplete_remove_all(Autocomplete ac, char** items)
 {
-    int i = 0;
-    for (i = 0; i < g_strv_length(items); i++) {
+    for (int i = 0; i < g_strv_length(items); i++) {
         autocomplete_remove(ac, items[i]);
     }
 }
@@ -310,10 +308,9 @@ autocomplete_param_with_func(const char* const input, char* command, autocomplet
     int len = strlen(command_cpy);
 
     if (strncmp(input, command_cpy, len) == 0) {
-        int i;
         int inp_len = strlen(input);
         char prefix[inp_len];
-        for (i = len; i < inp_len; i++) {
+        for (int i = len; i < inp_len; i++) {
             prefix[i - len] = input[i];
         }
         prefix[inp_len - len] = '\0';
@@ -341,9 +338,8 @@ autocomplete_param_with_ac(const char* const input, char* command, Autocomplete
     int len = strlen(command_cpy);
     int inp_len = strlen(input);
     if (strncmp(input, command_cpy, len) == 0) {
-        int i;
         char prefix[inp_len];
-        for (i = len; i < inp_len; i++) {
+        for (int i = len; i < inp_len; i++) {
             prefix[i - len] = input[i];
         }
         prefix[inp_len - len] = '\0';