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

@@ -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;