diff options
Diffstat (limited to 'src/nvim/menu.c')
-rw-r--r-- | src/nvim/menu.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 2a18b08d8d..4fad926cb0 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -281,7 +281,6 @@ static int add_menu_path(const char *const menu_path, vimmenu_T *menuarg, const char *next_name; char c; char d; - int i; int pri_idx = 0; int old_modes = 0; int amenu; @@ -411,7 +410,7 @@ static int add_menu_path(const char *const menu_path, vimmenu_T *menuarg, const p = (call_data == NULL) ? NULL : xstrdup(call_data); // loop over all modes, may add more than one - for (i = 0; i < MENU_MODES; i++) { + for (int i = 0; i < MENU_MODES; i++) { if (modes & (1 << i)) { // free any old menu free_menu_string(menu, i); @@ -617,10 +616,7 @@ static int remove_menu(vimmenu_T **menup, char *name, int modes, bool silent) // Free the given menu structure and remove it from the linked list. static void free_menu(vimmenu_T **menup) { - int i; - vimmenu_T *menu; - - menu = *menup; + vimmenu_T *menu = *menup; // Don't change *menup until after calling gui_mch_destroy_menu(). The // MacOS code needs the original structure to properly delete the menu. @@ -630,7 +626,7 @@ static void free_menu(vimmenu_T **menup) xfree(menu->en_name); xfree(menu->en_dname); xfree(menu->actext); - for (i = 0; i < MENU_MODES; i++) { + for (int i = 0; i < MENU_MODES; i++) { free_menu_string(menu, i); } xfree(menu); @@ -640,9 +636,8 @@ static void free_menu(vimmenu_T **menup) static void free_menu_string(vimmenu_T *menu, int idx) { int count = 0; - int i; - for (i = 0; i < MENU_MODES; i++) { + for (int i = 0; i < MENU_MODES; i++) { if (menu->strings[i] == menu->strings[idx]) { count++; } @@ -662,13 +657,11 @@ static void free_menu_string(vimmenu_T *menu, int idx) /// @see menu_get static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) { - dict_T *dict; - if (!menu || (menu->modes & modes) == 0x0) { return NULL; } - dict = tv_dict_alloc(); + dict_T *dict = tv_dict_alloc(); tv_dict_add_str(dict, S_LEN("name"), menu->dname); tv_dict_add_nr(dict, S_LEN("priority"), (int)menu->priority); tv_dict_add_nr(dict, S_LEN("hidden"), menu_is_hidden(menu->dname)); @@ -815,7 +808,6 @@ static int show_menus(char *const path_name, int modes) static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) { int i; - int bit; if (menu != NULL && (menu->modes & modes) == 0x0) { return; @@ -838,7 +830,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) } if (menu != NULL && menu->children == NULL) { - for (bit = 0; bit < MENU_MODES; bit++) { + for (int bit = 0; bit < MENU_MODES; bit++) { if ((menu->modes & modes & (1 << bit)) != 0) { msg_putchar('\n'); if (got_int) { // "q" hit for "--more--" @@ -902,7 +894,6 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for char *after_dot; char *p; char *path_name = NULL; - char *name; int unmenu; vimmenu_T *menu; int expand_menus; @@ -963,7 +954,7 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for path_name = xmalloc(path_len); xstrlcpy(path_name, arg, path_len); } - name = path_name; + char *name = path_name; while (name != NULL && *name) { p = menu_name_skip(name); while (menu != NULL) { |