diff options
-rw-r--r-- | src/nvim/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/nvim/getchar.c | 4 | ||||
-rw-r--r-- | src/nvim/menu.c | 37 | ||||
-rw-r--r-- | src/nvim/menu.h | 4 |
5 files changed, 26 insertions, 22 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 803ae4f911..2e45b5e9d6 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -66,7 +66,6 @@ set(CONV_SOURCES if_cscope.c mbyte.c memline.c - menu.c message.c misc1.c ops.c diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 2ca2c59b24..35b62cdd47 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7779,7 +7779,7 @@ static void ex_stopinsert(exarg_T *eap) * Execute normal mode command "cmd". * "remap" can be REMAP_NONE or REMAP_YES. */ -void exec_normal_cmd(char_u *cmd, int remap, int silent) +void exec_normal_cmd(char_u *cmd, int remap, bool silent) { oparg_T oa; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 1951cd6737..864aa6a622 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -848,11 +848,11 @@ static void init_typebuf(void) * If nottyped is TRUE, the string does not return KeyTyped (don't use when * offset is non-zero!). * - * If silent is TRUE, cmd_silent is set when the characters are obtained. + * If silent is true, cmd_silent is set when the characters are obtained. * * return FAIL for failure, OK otherwise */ -int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, int silent) +int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, bool silent) { char_u *s1, *s2; int newlen; diff --git a/src/nvim/menu.c b/src/nvim/menu.c index a5841c5d63..0db0ddffb8 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -11,6 +11,7 @@ * Code for menus. Used for the GUI and 'wildmenu'. */ +#include <assert.h> #include <inttypes.h> #include <string.h> @@ -62,14 +63,14 @@ ex_menu ( int modes; char_u *map_to; int noremap; - int silent = FALSE; + bool silent = false; int special = FALSE; int unmenu; char_u *map_buf; char_u *arg; char_u *p; int i; - int pri_tab[MENUDEPTH + 1]; + long pri_tab[MENUDEPTH + 1]; int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu * disable */ vimmenu_T menuarg; @@ -84,7 +85,7 @@ ex_menu ( continue; } if (STRNCMP(arg, "<silent>", 8) == 0) { - silent = TRUE; + silent = true; arg = skipwhite(arg + 8); continue; } @@ -119,7 +120,7 @@ ex_menu ( break; if (ascii_iswhite(*p)) { for (i = 0; i < MENUDEPTH && !ascii_iswhite(*arg); ++i) { - pri_tab[i] = getdigits_int(&arg); + pri_tab[i] = getdigits_long(&arg); if (pri_tab[i] == 0) pri_tab[i] = 500; if (*arg == '.') @@ -261,7 +262,7 @@ add_menu_path ( char_u *menu_path, vimmenu_T *menuarg, /* passes modes, iconfile, iconidx, icon_builtin, silent[0], noremap[0] */ - int *pri_tab, + long *pri_tab, char_u *call_data ) { @@ -275,9 +276,9 @@ add_menu_path ( char_u *name; char_u *dname; char_u *next_name; + char_u c; + char_u d; int i; - int c; - int d; int pri_idx = 0; int old_modes = 0; int amenu; @@ -548,7 +549,7 @@ remove_menu ( vimmenu_T **menup, char_u *name, int modes, - int silent /* don't give error messages */ + bool silent /* don't give error messages */ ) { vimmenu_T *menu; @@ -877,9 +878,10 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc expand_modes = MENU_ALL_MODES; menu = root_menu; - if (after_dot != arg) { - path_name = xmalloc(after_dot - arg); - STRLCPY(path_name, arg, after_dot - arg); + if (after_dot > arg) { + size_t path_len = (size_t) (after_dot - arg); + path_name = xmalloc(path_len); + STRLCPY(path_name, arg, path_len); } name = path_name; while (name != NULL && *name) { @@ -1144,10 +1146,11 @@ get_menu_cmd_modes ( */ static char_u *popup_mode_name(char_u *name, int idx) { - int len = (int)STRLEN(name); + size_t len = STRLEN(name); + assert(len >= 4); char_u *p = vim_strnsave(name, len + 1); - memmove(p + 6, p + 5, (size_t)(len - 4)); + memmove(p + 6, p + 5, len - 4); p[5] = menu_mode_chars[idx]; return p; @@ -1177,7 +1180,8 @@ static char_u *menu_text(const char_u *str, int *mnemonic, char_u **actext) if (p != NULL) { if (actext != NULL) *actext = vim_strsave(p + 1); - text = vim_strnsave(str, (int)(p - str)); + assert(p >= str); + text = vim_strnsave(str, (size_t)(p - str)); } else text = vim_strsave(str); @@ -1466,7 +1470,8 @@ void ex_menutranslate(exarg_T *eap) else { from = vim_strsave(from); from_noamp = menu_text(from, NULL, NULL); - to = vim_strnsave(to, (int)(arg - to)); + assert(arg >= to); + to = vim_strnsave(to, (size_t)(arg - to)); menu_translate_tab_and_shift(from); menu_translate_tab_and_shift(to); menu_unescape_name(from); @@ -1508,7 +1513,7 @@ static char_u *menutrans_lookup(char_u *name, int len) } /* Now try again while ignoring '&' characters. */ - char c = name[len]; + char_u c = name[len]; name[len] = NUL; dname = menu_text(name, NULL, NULL); name[len] = c; diff --git a/src/nvim/menu.h b/src/nvim/menu.h index 34965d3487..3266c511b4 100644 --- a/src/nvim/menu.h +++ b/src/nvim/menu.h @@ -39,10 +39,10 @@ struct VimMenu { * was not translated */ int mnemonic; /* mnemonic key (after '&') */ char_u *actext; /* accelerator text (after TAB) */ - int priority; /* Menu order priority */ + long priority; /* Menu order priority */ char_u *strings[MENU_MODES]; /* Mapped string for each mode */ int noremap[MENU_MODES]; /* A REMAP_ flag for each mode */ - char silent[MENU_MODES]; /* A silent flag for each mode */ + bool silent[MENU_MODES]; /* A silent flag for each mode */ vimmenu_T *children; /* Children of sub-menu */ vimmenu_T *parent; /* Parent of menu */ vimmenu_T *next; /* Next item in menu */ |