Cleanup: Refactor variables: long --> int.

At 31c8440fee, some variables were changed
from int to long, to avoid -Wconversion errors. Long type was the
appropiate one because getdigits() was returning a long.
Now that we have get_int_digits() and get_long_digits(), we can revert
mentioned variables to int, and use get_int_digits() without having
-Wconversion warnings.
This commit is contained in:
Eliseo Martínez
2015-01-11 13:26:50 +01:00
parent 04c0658024
commit bb737b6f0e

View File

@@ -2819,13 +2819,13 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
char_u bytes[6]; char_u bytes[6];
int num_bytes; int num_bytes;
# endif # endif
long mouse_code = 0; /* init for GCC */ int mouse_code = 0; /* init for GCC */
int is_click, is_drag; int is_click, is_drag;
long wheel_code = 0; int wheel_code = 0;
long current_button; int current_button;
static long held_button = MOUSE_RELEASE; static int held_button = MOUSE_RELEASE;
static int orig_num_clicks = 1; static int orig_num_clicks = 1;
static long orig_mouse_code = 0x0; static int orig_mouse_code = 0x0;
int cpo_koffset; int cpo_koffset;
cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL);
@@ -3230,7 +3230,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
*/ */
p = tp + slen; p = tp + slen;
mouse_code = get_long_digits(&p); mouse_code = get_int_digits(&p);
if (*p++ != ';') if (*p++ != ';')
return -1; return -1;
@@ -3269,7 +3269,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
} }
} }
p += j; p += j;
if (cmd_complete && get_long_digits(&p) == mouse_code) { if (cmd_complete && get_int_digits(&p) == mouse_code) {
slen += j; /* skip the \033[ */ slen += j; /* skip the \033[ */
continue; continue;
} }
@@ -3308,24 +3308,22 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
} }
# endif /* !UNIX || FEAT_MOUSE_XTERM */ # endif /* !UNIX || FEAT_MOUSE_XTERM */
if (key_name[0] == (int)KS_NETTERM_MOUSE) { if (key_name[0] == (int)KS_NETTERM_MOUSE) {
long mc, mr; int mc, mr;
/* expect a rather limited sequence like: balancing { /* expect a rather limited sequence like: balancing {
* \033}6,45\r * \033}6,45\r
* '6' is the row, 45 is the column * '6' is the row, 45 is the column
*/ */
p = tp + slen; p = tp + slen;
mr = get_long_digits(&p); mr = get_int_digits(&p);
if (*p++ != ',') if (*p++ != ',')
return -1; return -1;
mc = get_long_digits(&p); mc = get_int_digits(&p);
if (*p++ != '\r') if (*p++ != '\r')
return -1; return -1;
assert(mc - 1 >= INT_MIN && mc - 1 <= INT_MAX); mouse_col = mc - 1;
mouse_col = (int)(mc - 1); mouse_row = mr - 1;
assert(mr - 1 >= INT_MIN && mr - 1 <= INT_MAX);
mouse_row = (int)(mr - 1);
mouse_code = MOUSE_LEFT; mouse_code = MOUSE_LEFT;
slen += (int)(p - (tp + slen)); slen += (int)(p - (tp + slen));
} }
@@ -3380,32 +3378,32 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
* The page coordinate may be omitted if the locator is on * The page coordinate may be omitted if the locator is on
* page one (the default). We ignore it anyway. * page one (the default). We ignore it anyway.
*/ */
long Pe, Pb, Pr, Pc; int Pe, Pb, Pr, Pc;
p = tp + slen; p = tp + slen;
/* get event status */ /* get event status */
Pe = get_long_digits(&p); Pe = get_int_digits(&p);
if (*p++ != ';') if (*p++ != ';')
return -1; return -1;
/* get button status */ /* get button status */
Pb = get_long_digits(&p); Pb = get_int_digits(&p);
if (*p++ != ';') if (*p++ != ';')
return -1; return -1;
/* get row status */ /* get row status */
Pr = get_long_digits(&p); Pr = get_int_digits(&p);
if (*p++ != ';') if (*p++ != ';')
return -1; return -1;
/* get column status */ /* get column status */
Pc = get_long_digits(&p); Pc = get_int_digits(&p);
/* the page parameter is optional */ /* the page parameter is optional */
if (*p == ';') { if (*p == ';') {
p++; p++;
(void)get_long_digits(&p); (void)get_int_digits(&p);
} }
if (*p++ != '&') if (*p++ != '&')
return -1; return -1;
@@ -3449,10 +3447,8 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
default: return -1; /* should never occur */ default: return -1; /* should never occur */
} }
assert(Pc - 1 >= INT_MIN && Pc - 1 <= INT_MAX); mouse_col = Pc - 1;
mouse_col = (int)(Pc - 1); mouse_row = Pr - 1;
assert(Pr - 1 >= INT_MIN && Pr - 1 <= INT_MAX);
mouse_row = (int)(Pr - 1);
slen += (int)(p - (tp + slen)); slen += (int)(p - (tp + slen));
} }
@@ -3540,8 +3536,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
key_name[1] = (wheel_code & 1) key_name[1] = (wheel_code & 1)
? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN; ? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN;
} else { } else {
assert(current_button >= INT_MIN && current_button <= INT_MAX); key_name[1] = (char_u)get_pseudo_mouse_code(current_button,
key_name[1] = (char_u)get_pseudo_mouse_code((int)current_button,
is_click, is_drag); is_click, is_drag);
} }
} }