mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #17538 from dundargoc/refactor/bugprone-signed-char-misuse
refactor: fix clang-tidy bugprone-signed-char-misuse warnings
This commit is contained in:
commit
d557a45571
@ -1110,7 +1110,7 @@ static int json_is_invalid_number(json_parse_t *json)
|
||||
|
||||
/* Reject numbers starting with 0x, or leading zeros */
|
||||
if (*p == '0') {
|
||||
int ch2 = *(p + 1);
|
||||
char ch2 = *(p + 1);
|
||||
|
||||
if ((ch2 | 0x20) == 'x' || /* Hex */
|
||||
('0' <= ch2 && ch2 <= '9')) /* Leading zero */
|
||||
|
@ -1500,7 +1500,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, cons
|
||||
} else if ((what & (STR2NR_HEX | STR2NR_OCT | STR2NR_OOCT | STR2NR_BIN))
|
||||
&& !STRING_ENDED(ptr + 1) && ptr[0] == '0' && ptr[1] != '8'
|
||||
&& ptr[1] != '9') {
|
||||
pre = ptr[1];
|
||||
pre = (char_u)ptr[1];
|
||||
// Detect hexadecimal: 0x or 0X followed by hex digit.
|
||||
if ((what & STR2NR_HEX)
|
||||
&& !STRING_ENDED(ptr + 2)
|
||||
|
@ -201,7 +201,7 @@ void do_debug(char_u *cmd)
|
||||
if (last_cmd != 0) {
|
||||
// Check that the tail matches.
|
||||
p++;
|
||||
while (*p != NUL && *p == *tail) {
|
||||
while (*p != NUL && *p == (char_u)(*tail)) {
|
||||
p++;
|
||||
tail++;
|
||||
}
|
||||
|
@ -7776,7 +7776,7 @@ int hkmap(int c)
|
||||
case ';':
|
||||
c = 't'; break;
|
||||
default: {
|
||||
static char str[] = "zqbcxlsjphmkwonu ydafe rig";
|
||||
static char_u str[] = "zqbcxlsjphmkwonu ydafe rig";
|
||||
|
||||
if (c < 'a' || c > 'z') {
|
||||
return c;
|
||||
|
@ -4858,7 +4858,6 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval
|
||||
long numval;
|
||||
char_u *stringval;
|
||||
int opt_type;
|
||||
int c;
|
||||
bool working = (**arg == '+'); // has("+option")
|
||||
int ret = OK;
|
||||
int opt_flags;
|
||||
@ -4877,7 +4876,7 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval
|
||||
return OK;
|
||||
}
|
||||
|
||||
c = *option_end;
|
||||
char c = *option_end;
|
||||
*option_end = NUL;
|
||||
opt_type = get_option_value(*arg, &numval,
|
||||
rettv == NULL ? NULL : &stringval, opt_flags);
|
||||
|
@ -9339,7 +9339,7 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
|
||||
{
|
||||
static char *e_invact = N_("E927: Invalid action: '%s'");
|
||||
const char *title = NULL;
|
||||
int action = ' ';
|
||||
char action = ' ';
|
||||
static int recursive = 0;
|
||||
rettv->vval.v_number = -1;
|
||||
dict_T *what = NULL;
|
||||
@ -9569,7 +9569,6 @@ static int get_yank_type(char_u **const pp, MotionType *const yank_type, long *c
|
||||
*/
|
||||
static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
int regname;
|
||||
bool append = false;
|
||||
MotionType yank_type;
|
||||
long block_len;
|
||||
@ -9583,13 +9582,13 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
if (strregname == NULL) {
|
||||
return; // Type error; errmsg already given.
|
||||
}
|
||||
regname = (uint8_t)(*strregname);
|
||||
char regname = (uint8_t)(*strregname);
|
||||
if (regname == 0 || regname == '@') {
|
||||
regname = '"';
|
||||
}
|
||||
|
||||
const typval_T *regcontents = NULL;
|
||||
int pointreg = 0;
|
||||
char pointreg = 0;
|
||||
if (argvars[1].v_type == VAR_DICT) {
|
||||
dict_T *const d = argvars[1].vval.v_dict;
|
||||
|
||||
@ -9759,7 +9758,7 @@ static void f_settagstack(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
static char *e_invact2 = N_("E962: Invalid action: '%s'");
|
||||
win_T *wp;
|
||||
dict_T *d;
|
||||
int action = 'r';
|
||||
char action = 'r';
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
|
@ -2835,7 +2835,7 @@ int modifier_len(char_u *cmd)
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) {
|
||||
int j;
|
||||
for (j = 0; p[j] != NUL; j++) {
|
||||
if (p[j] != cmdmods[i].name[j]) {
|
||||
if (p[j] != (char_u)cmdmods[i].name[j]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1602,7 +1602,7 @@ void ex_endtry(exarg_T *eap)
|
||||
{
|
||||
int idx;
|
||||
bool rethrow = false;
|
||||
int pending = CSTP_NONE;
|
||||
char pending = CSTP_NONE;
|
||||
void *rettv = NULL;
|
||||
cstack_T *const cstack = eap->cstack;
|
||||
|
||||
|
@ -1907,9 +1907,6 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
|
||||
// complete match
|
||||
if (keylen >= 0 && keylen <= typebuf.tb_len) {
|
||||
char_u *map_str = NULL;
|
||||
int save_m_expr;
|
||||
int save_m_noremap;
|
||||
int save_m_silent;
|
||||
|
||||
// Write chars to script file(s).
|
||||
// Note: :lmap mappings are written *after* being applied. #5658
|
||||
@ -1946,9 +1943,9 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
|
||||
// Copy the values from *mp that are used, because evaluating the
|
||||
// expression may invoke a function that redefines the mapping, thereby
|
||||
// making *mp invalid.
|
||||
save_m_expr = mp->m_expr;
|
||||
save_m_noremap = mp->m_noremap;
|
||||
save_m_silent = mp->m_silent;
|
||||
char save_m_expr = mp->m_expr;
|
||||
int save_m_noremap = mp->m_noremap;
|
||||
char save_m_silent = mp->m_silent;
|
||||
char_u *save_m_keys = NULL; // only saved when needed
|
||||
char_u *save_m_str = NULL; // only saved when needed
|
||||
LuaRef save_m_luaref = mp->m_luaref;
|
||||
@ -2661,9 +2658,9 @@ int fix_input_buffer(char_u *buf, int len)
|
||||
/// @param[in] orig_rhs_len `strlen` of orig_rhs.
|
||||
/// @param[in] cpo_flags See param docs for @ref replace_termcodes.
|
||||
/// @param[out] mapargs MapArguments struct holding the replaced strings.
|
||||
void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len,
|
||||
const char_u *orig_rhs, const size_t orig_rhs_len,
|
||||
LuaRef rhs_lua, int cpo_flags, MapArguments *mapargs)
|
||||
void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const char_u *orig_rhs,
|
||||
const size_t orig_rhs_len, LuaRef rhs_lua, int cpo_flags,
|
||||
MapArguments *mapargs)
|
||||
{
|
||||
char_u *lhs_buf = NULL;
|
||||
char_u *rhs_buf = NULL;
|
||||
|
@ -823,7 +823,6 @@ static void command_line_scan(mparm_T *parmp)
|
||||
bool had_stdin_file = false; // found explicit "-" argument
|
||||
bool had_minmin = false; // found "--" argument
|
||||
int want_argument; // option argument with argument
|
||||
int c;
|
||||
long n;
|
||||
|
||||
argc--;
|
||||
@ -845,7 +844,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
// Optional argument.
|
||||
} else if (argv[0][0] == '-' && !had_minmin) {
|
||||
want_argument = false;
|
||||
c = argv[0][argv_idx++];
|
||||
char c = argv[0][argv_idx++];
|
||||
switch (c) {
|
||||
case NUL: // "nvim -" read from stdin
|
||||
if (exmode_active) {
|
||||
|
@ -1071,7 +1071,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
|
||||
* Find out the direction of the search.
|
||||
*/
|
||||
if (dirc == 0) {
|
||||
dirc = spats[0].off.dir;
|
||||
dirc = (char_u)spats[0].off.dir;
|
||||
} else {
|
||||
spats[0].off.dir = dirc;
|
||||
set_vv_searchforward();
|
||||
|
@ -354,7 +354,7 @@ char *strcase_save(const char *const orig, bool upper)
|
||||
int l = utf_ptr2len((const char_u *)p);
|
||||
if (c == 0) {
|
||||
// overlong sequence, use only the first byte
|
||||
c = *p;
|
||||
c = (char_u)(*p);
|
||||
l = 1;
|
||||
}
|
||||
int uc = upper ? mb_toupper(c) : mb_tolower(c);
|
||||
|
@ -4208,7 +4208,7 @@ static char_u *get_syn_options(char_u *arg, syn_opt_arg_T *opt, int *conceal_cha
|
||||
p = flagtab[fidx].name;
|
||||
int i;
|
||||
for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) {
|
||||
if (arg[len] != p[i] && arg[len] != p[i + 1]) {
|
||||
if (arg[len] != (char_u)p[i] && arg[len] != (char_u)p[i + 1]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -138,3 +138,15 @@ describe('vim_strchr()', function()
|
||||
eq(nil, vim_strchr('«\237\175\191\237\188\128»', 0x10FF00))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('strcase_save()' , function()
|
||||
local strcase_save = function(input_string, upper)
|
||||
local res = strings.strcase_save(to_cstr(input_string), upper)
|
||||
return ffi.string(res)
|
||||
end
|
||||
|
||||
itp('decodes overlong encoded characters.', function()
|
||||
eq("A", strcase_save("\xc1\x81", true))
|
||||
eq("a", strcase_save("\xc1\x81", false))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user