Enable -Wconversion: menu.c #2885

This commit is contained in:
Ismail Badawi
2015-06-23 19:33:47 -04:00
committed by Justin M. Keyes
parent f78bf64771
commit 34a5efd7a9
5 changed files with 26 additions and 22 deletions

View File

@@ -66,7 +66,6 @@ set(CONV_SOURCES
if_cscope.c if_cscope.c
mbyte.c mbyte.c
memline.c memline.c
menu.c
message.c message.c
misc1.c misc1.c
ops.c ops.c

View File

@@ -7779,7 +7779,7 @@ static void ex_stopinsert(exarg_T *eap)
* Execute normal mode command "cmd". * Execute normal mode command "cmd".
* "remap" can be REMAP_NONE or REMAP_YES. * "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; oparg_T oa;

View File

@@ -848,11 +848,11 @@ static void init_typebuf(void)
* If nottyped is TRUE, the string does not return KeyTyped (don't use when * If nottyped is TRUE, the string does not return KeyTyped (don't use when
* offset is non-zero!). * 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 * 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; char_u *s1, *s2;
int newlen; int newlen;

View File

@@ -11,6 +11,7 @@
* Code for menus. Used for the GUI and 'wildmenu'. * Code for menus. Used for the GUI and 'wildmenu'.
*/ */
#include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <string.h> #include <string.h>
@@ -62,14 +63,14 @@ ex_menu (
int modes; int modes;
char_u *map_to; char_u *map_to;
int noremap; int noremap;
int silent = FALSE; bool silent = false;
int special = FALSE; int special = FALSE;
int unmenu; int unmenu;
char_u *map_buf; char_u *map_buf;
char_u *arg; char_u *arg;
char_u *p; char_u *p;
int i; int i;
int pri_tab[MENUDEPTH + 1]; long pri_tab[MENUDEPTH + 1];
int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu
* disable */ * disable */
vimmenu_T menuarg; vimmenu_T menuarg;
@@ -84,7 +85,7 @@ ex_menu (
continue; continue;
} }
if (STRNCMP(arg, "<silent>", 8) == 0) { if (STRNCMP(arg, "<silent>", 8) == 0) {
silent = TRUE; silent = true;
arg = skipwhite(arg + 8); arg = skipwhite(arg + 8);
continue; continue;
} }
@@ -119,7 +120,7 @@ ex_menu (
break; break;
if (ascii_iswhite(*p)) { if (ascii_iswhite(*p)) {
for (i = 0; i < MENUDEPTH && !ascii_iswhite(*arg); ++i) { 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) if (pri_tab[i] == 0)
pri_tab[i] = 500; pri_tab[i] = 500;
if (*arg == '.') if (*arg == '.')
@@ -261,7 +262,7 @@ add_menu_path (
char_u *menu_path, char_u *menu_path,
vimmenu_T *menuarg, /* passes modes, iconfile, iconidx, vimmenu_T *menuarg, /* passes modes, iconfile, iconidx,
icon_builtin, silent[0], noremap[0] */ icon_builtin, silent[0], noremap[0] */
int *pri_tab, long *pri_tab,
char_u *call_data char_u *call_data
) )
{ {
@@ -275,9 +276,9 @@ add_menu_path (
char_u *name; char_u *name;
char_u *dname; char_u *dname;
char_u *next_name; char_u *next_name;
char_u c;
char_u d;
int i; int i;
int c;
int d;
int pri_idx = 0; int pri_idx = 0;
int old_modes = 0; int old_modes = 0;
int amenu; int amenu;
@@ -548,7 +549,7 @@ remove_menu (
vimmenu_T **menup, vimmenu_T **menup,
char_u *name, char_u *name,
int modes, int modes,
int silent /* don't give error messages */ bool silent /* don't give error messages */
) )
{ {
vimmenu_T *menu; 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; expand_modes = MENU_ALL_MODES;
menu = root_menu; menu = root_menu;
if (after_dot != arg) { if (after_dot > arg) {
path_name = xmalloc(after_dot - arg); size_t path_len = (size_t) (after_dot - arg);
STRLCPY(path_name, arg, after_dot - arg); path_name = xmalloc(path_len);
STRLCPY(path_name, arg, path_len);
} }
name = path_name; name = path_name;
while (name != NULL && *name) { while (name != NULL && *name) {
@@ -1144,10 +1146,11 @@ get_menu_cmd_modes (
*/ */
static char_u *popup_mode_name(char_u *name, int idx) 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); 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]; p[5] = menu_mode_chars[idx];
return p; return p;
@@ -1177,7 +1180,8 @@ static char_u *menu_text(const char_u *str, int *mnemonic, char_u **actext)
if (p != NULL) { if (p != NULL) {
if (actext != NULL) if (actext != NULL)
*actext = vim_strsave(p + 1); *actext = vim_strsave(p + 1);
text = vim_strnsave(str, (int)(p - str)); assert(p >= str);
text = vim_strnsave(str, (size_t)(p - str));
} else } else
text = vim_strsave(str); text = vim_strsave(str);
@@ -1466,7 +1470,8 @@ void ex_menutranslate(exarg_T *eap)
else { else {
from = vim_strsave(from); from = vim_strsave(from);
from_noamp = menu_text(from, NULL, NULL); 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(from);
menu_translate_tab_and_shift(to); menu_translate_tab_and_shift(to);
menu_unescape_name(from); menu_unescape_name(from);
@@ -1508,7 +1513,7 @@ static char_u *menutrans_lookup(char_u *name, int len)
} }
/* Now try again while ignoring '&' characters. */ /* Now try again while ignoring '&' characters. */
char c = name[len]; char_u c = name[len];
name[len] = NUL; name[len] = NUL;
dname = menu_text(name, NULL, NULL); dname = menu_text(name, NULL, NULL);
name[len] = c; name[len] = c;

View File

@@ -39,10 +39,10 @@ struct VimMenu {
* was not translated */ * was not translated */
int mnemonic; /* mnemonic key (after '&') */ int mnemonic; /* mnemonic key (after '&') */
char_u *actext; /* accelerator text (after TAB) */ 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 */ char_u *strings[MENU_MODES]; /* Mapped string for each mode */
int noremap[MENU_MODES]; /* A REMAP_ flag 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 *children; /* Children of sub-menu */
vimmenu_T *parent; /* Parent of menu */ vimmenu_T *parent; /* Parent of menu */
vimmenu_T *next; /* Next item in menu */ vimmenu_T *next; /* Next item in menu */