mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.0928: many type casts are used for vim_strnsave()
Problem: Many type casts are used for vim_strnsave(). Solution: Make the length argument size_t instead of int. (Ken Takata, closes vim/vim#5633) Remove some type casts.df44a27b53
N/A patches for version.c: vim-patch:8.2.0315: build failure on HP-UX system Problem: Build failure on HP-UX system. Solution: Use LONG_LONG_MIN instead of LLONG_MIN. Add type casts for switch statement. (John Marriott)c593bec412
vim-patch:8.2.1052: build failure with older compilers Problem: Build failure with older compilers. Solution: Move declaration to start of block.7acde51832
vim-patch:8.2.2229: build failure without the +eval feature Problem: build failure without the +eval feature. Solution: Add #ifdef.39cb2dab18
vim-patch:8.2.2232: compiler error for falling through into next case Problem: Compiler error for falling through into next case. Solution: Move FALLTHROUGH below the #endif9618a25b9c
This commit is contained in:
parent
ed0131e3d9
commit
883114e882
@ -1225,8 +1225,7 @@ void ex_diffpatch(exarg_T *eap)
|
|||||||
EMSG(_("E816: Cannot read patch output"));
|
EMSG(_("E816: Cannot read patch output"));
|
||||||
} else {
|
} else {
|
||||||
if (curbuf->b_fname != NULL) {
|
if (curbuf->b_fname != NULL) {
|
||||||
newname = vim_strnsave(curbuf->b_fname,
|
newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4);
|
||||||
(int)(STRLEN(curbuf->b_fname) + 4));
|
|
||||||
STRCAT(newname, ".new");
|
STRCAT(newname, ".new");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3423,7 +3423,7 @@ static void ins_compl_addleader(int c)
|
|||||||
|
|
||||||
xfree(compl_leader);
|
xfree(compl_leader);
|
||||||
compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
|
compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
|
||||||
(int)(curwin->w_cursor.col - compl_col));
|
curwin->w_cursor.col - compl_col);
|
||||||
ins_compl_new_leader();
|
ins_compl_new_leader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5422,7 +5422,7 @@ static int get_literal_key(char_u **arg, typval_T *tv)
|
|||||||
for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) {
|
for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) {
|
||||||
}
|
}
|
||||||
tv->v_type = VAR_STRING;
|
tv->v_type = VAR_STRING;
|
||||||
tv->vval.v_string = vim_strnsave(*arg, (int)(p - *arg));
|
tv->vval.v_string = vim_strnsave(*arg, p - *arg);
|
||||||
|
|
||||||
*arg = skipwhite(p);
|
*arg = skipwhite(p);
|
||||||
return OK;
|
return OK;
|
||||||
@ -10264,9 +10264,6 @@ repeat:
|
|||||||
if (src[*usedlen] == ':'
|
if (src[*usedlen] == ':'
|
||||||
&& (src[*usedlen + 1] == 's'
|
&& (src[*usedlen + 1] == 's'
|
||||||
|| (src[*usedlen + 1] == 'g' && src[*usedlen + 2] == 's'))) {
|
|| (src[*usedlen + 1] == 'g' && src[*usedlen + 2] == 's'))) {
|
||||||
char_u *str;
|
|
||||||
char_u *pat;
|
|
||||||
char_u *sub;
|
|
||||||
int sep;
|
int sep;
|
||||||
char_u *flags;
|
char_u *flags;
|
||||||
int didit = FALSE;
|
int didit = FALSE;
|
||||||
@ -10283,13 +10280,13 @@ repeat:
|
|||||||
// find end of pattern
|
// find end of pattern
|
||||||
p = vim_strchr(s, sep);
|
p = vim_strchr(s, sep);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
pat = vim_strnsave(s, (int)(p - s));
|
char_u *const pat = vim_strnsave(s, p - s);
|
||||||
s = p + 1;
|
s = p + 1;
|
||||||
// find end of substitution
|
// find end of substitution
|
||||||
p = vim_strchr(s, sep);
|
p = vim_strchr(s, sep);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
sub = vim_strnsave(s, (int)(p - s));
|
char_u *const sub = vim_strnsave(s, p - s);
|
||||||
str = vim_strnsave(*fnamep, *fnamelen);
|
char_u *const str = vim_strnsave(*fnamep, *fnamelen);
|
||||||
*usedlen = (size_t)(p + 1 - src);
|
*usedlen = (size_t)(p + 1 - src);
|
||||||
s = do_string_sub(str, pat, sub, NULL, flags);
|
s = do_string_sub(str, pat, sub, NULL, flags);
|
||||||
*fnamep = s;
|
*fnamep = s;
|
||||||
|
@ -6553,7 +6553,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
if (prevlen == 0) {
|
if (prevlen == 0) {
|
||||||
assert(len < INT_MAX);
|
assert(len < INT_MAX);
|
||||||
s = vim_strnsave(start, (int)len);
|
s = vim_strnsave(start, len);
|
||||||
} else {
|
} else {
|
||||||
/* Change "prev" buffer to be the right size. This way
|
/* Change "prev" buffer to be the right size. This way
|
||||||
* the bytes are only copied once, and very long lines are
|
* the bytes are only copied once, and very long lines are
|
||||||
@ -10855,7 +10855,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rettv->vval.v_string = vim_strnsave(head, (int)(tail - head));
|
rettv->vval.v_string = vim_strnsave(head, tail - head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2297,9 +2297,9 @@ void ex_function(exarg_T *eap)
|
|||||||
// Ignore leading white space.
|
// Ignore leading white space.
|
||||||
p = skipwhite(p + 4);
|
p = skipwhite(p + 4);
|
||||||
heredoc_trimmed =
|
heredoc_trimmed =
|
||||||
vim_strnsave(theline, (int)(skipwhite(theline) - theline));
|
vim_strnsave(theline, skipwhite(theline) - theline);
|
||||||
}
|
}
|
||||||
skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
|
skip_until = vim_strnsave(p, skiptowhite(p) - p);
|
||||||
do_concat = false;
|
do_concat = false;
|
||||||
is_heredoc = true;
|
is_heredoc = true;
|
||||||
}
|
}
|
||||||
|
@ -2796,9 +2796,10 @@ void ex_append(exarg_T *eap)
|
|||||||
p = vim_strchr(eap->nextcmd, NL);
|
p = vim_strchr(eap->nextcmd, NL);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
p = eap->nextcmd + STRLEN(eap->nextcmd);
|
p = eap->nextcmd + STRLEN(eap->nextcmd);
|
||||||
theline = vim_strnsave(eap->nextcmd, (int)(p - eap->nextcmd));
|
theline = vim_strnsave(eap->nextcmd, p - eap->nextcmd);
|
||||||
if (*p != NUL)
|
if (*p != NUL) {
|
||||||
++p;
|
p++;
|
||||||
|
}
|
||||||
eap->nextcmd = p;
|
eap->nextcmd = p;
|
||||||
} else {
|
} else {
|
||||||
// Set State to avoid the cursor shape to be set to INSERT mode
|
// Set State to avoid the cursor shape to be set to INSERT mode
|
||||||
|
@ -4988,7 +4988,6 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep,
|
|||||||
FUNC_ATTR_NONNULL_ARG(1, 3)
|
FUNC_ATTR_NONNULL_ARG(1, 3)
|
||||||
{
|
{
|
||||||
ucmd_T *cmd = NULL;
|
ucmd_T *cmd = NULL;
|
||||||
char_u *p;
|
|
||||||
int i;
|
int i;
|
||||||
int cmp = 1;
|
int cmp = 1;
|
||||||
char_u *rep_buf = NULL;
|
char_u *rep_buf = NULL;
|
||||||
@ -5048,7 +5047,7 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep,
|
|||||||
if (cmp != 0) {
|
if (cmp != 0) {
|
||||||
ga_grow(gap, 1);
|
ga_grow(gap, 1);
|
||||||
|
|
||||||
p = vim_strnsave(name, (int)name_len);
|
char_u *const p = vim_strnsave(name, name_len);
|
||||||
|
|
||||||
cmd = USER_CMD_GA(gap, i);
|
cmd = USER_CMD_GA(gap, i);
|
||||||
memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T));
|
memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T));
|
||||||
@ -6197,8 +6196,9 @@ int parse_compl_arg(const char_u *value, int vallen, int *complp,
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg != NULL)
|
if (arg != NULL) {
|
||||||
*compl_arg = vim_strnsave(arg, (int)arglen);
|
*compl_arg = vim_strnsave(arg, arglen);
|
||||||
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9292,7 +9292,7 @@ static void ex_match(exarg_T *eap)
|
|||||||
} else {
|
} else {
|
||||||
p = skiptowhite(eap->arg);
|
p = skiptowhite(eap->arg);
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
g = vim_strnsave(eap->arg, (int)(p - eap->arg));
|
g = vim_strnsave(eap->arg, p - eap->arg);
|
||||||
}
|
}
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
if (*p == NUL) {
|
if (*p == NUL) {
|
||||||
|
@ -2032,7 +2032,7 @@ static char_u *next_fenc(char_u **pp, bool *alloced)
|
|||||||
r = enc_canonize(*pp);
|
r = enc_canonize(*pp);
|
||||||
*pp += STRLEN(*pp);
|
*pp += STRLEN(*pp);
|
||||||
} else {
|
} else {
|
||||||
r = vim_strnsave(*pp, (int)(p - *pp));
|
r = vim_strnsave(*pp, p - *pp);
|
||||||
*pp = p + 1;
|
*pp = p + 1;
|
||||||
p = enc_canonize(r);
|
p = enc_canonize(r);
|
||||||
xfree(r);
|
xfree(r);
|
||||||
|
@ -975,9 +975,9 @@ void ml_recover(bool checkext)
|
|||||||
if (b0p->b0_flags & B0_HAS_FENC) {
|
if (b0p->b0_flags & B0_HAS_FENC) {
|
||||||
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
||||||
|
|
||||||
for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; --p)
|
for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {
|
||||||
;
|
}
|
||||||
b0_fenc = vim_strnsave(p, (int)(b0p->b0_fname + fnsize - p));
|
b0_fenc = vim_strnsave(p, b0p->b0_fname + fnsize - p);
|
||||||
}
|
}
|
||||||
|
|
||||||
mf_put(mfp, hp, false, false); /* release block 0 */
|
mf_put(mfp, hp, false, false); /* release block 0 */
|
||||||
|
@ -3724,8 +3724,7 @@ static long regtry(bt_regprog_T *prog,
|
|||||||
} else {
|
} else {
|
||||||
if (reg_startzp[i] != NULL && reg_endzp[i] != NULL)
|
if (reg_startzp[i] != NULL && reg_endzp[i] != NULL)
|
||||||
re_extmatch_out->matches[i] =
|
re_extmatch_out->matches[i] =
|
||||||
vim_strnsave(reg_startzp[i],
|
vim_strnsave(reg_startzp[i], reg_endzp[i] - reg_startzp[i]);
|
||||||
(int)(reg_endzp[i] - reg_startzp[i]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6565,7 +6564,7 @@ static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv,
|
|||||||
if (s == NULL || rsm.sm_match->endp[i] == NULL) {
|
if (s == NULL || rsm.sm_match->endp[i] == NULL) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
} else {
|
} else {
|
||||||
s = vim_strnsave(s, (int)(rsm.sm_match->endp[i] - s));
|
s = vim_strnsave(s, rsm.sm_match->endp[i] - s);
|
||||||
}
|
}
|
||||||
TV_LIST_ITEM_TV(li)->v_type = VAR_STRING;
|
TV_LIST_ITEM_TV(li)->v_type = VAR_STRING;
|
||||||
TV_LIST_ITEM_TV(li)->vval.v_string = s;
|
TV_LIST_ITEM_TV(li)->vval.v_string = s;
|
||||||
@ -7084,7 +7083,7 @@ char_u *reg_submatch(int no)
|
|||||||
if (s == NULL || rsm.sm_match->endp[no] == NULL) {
|
if (s == NULL || rsm.sm_match->endp[no] == NULL) {
|
||||||
retval = NULL;
|
retval = NULL;
|
||||||
} else {
|
} else {
|
||||||
retval = vim_strnsave(s, (int)(rsm.sm_match->endp[no] - s));
|
retval = vim_strnsave(s, rsm.sm_match->endp[no] - s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6480,8 +6480,7 @@ static long nfa_regtry(nfa_regprog_T *prog,
|
|||||||
|
|
||||||
if (lpos->start != NULL && lpos->end != NULL)
|
if (lpos->start != NULL && lpos->end != NULL)
|
||||||
re_extmatch_out->matches[i] =
|
re_extmatch_out->matches[i] =
|
||||||
vim_strnsave(lpos->start,
|
vim_strnsave(lpos->start, lpos->end - lpos->start);
|
||||||
(int)(lpos->end - lpos->start));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4186,10 +4186,10 @@ get_syn_options(
|
|||||||
arg = skiptowhite(arg);
|
arg = skiptowhite(arg);
|
||||||
if (gname_start == arg)
|
if (gname_start == arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
gname = vim_strnsave(gname_start, (int)(arg - gname_start));
|
gname = vim_strnsave(gname_start, arg - gname_start);
|
||||||
if (STRCMP(gname, "NONE") == 0)
|
if (STRCMP(gname, "NONE") == 0) {
|
||||||
*opt->sync_idx = NONE_IDX;
|
*opt->sync_idx = NONE_IDX;
|
||||||
else {
|
} else {
|
||||||
syn_id = syn_name2id(gname);
|
syn_id = syn_name2id(gname);
|
||||||
int i;
|
int i;
|
||||||
for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; )
|
for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; )
|
||||||
@ -4587,7 +4587,7 @@ syn_cmd_region(
|
|||||||
while (*key_end && !ascii_iswhite(*key_end) && *key_end != '=')
|
while (*key_end && !ascii_iswhite(*key_end) && *key_end != '=')
|
||||||
++key_end;
|
++key_end;
|
||||||
xfree(key);
|
xfree(key);
|
||||||
key = vim_strnsave_up(rest, (int)(key_end - rest));
|
key = vim_strnsave_up(rest, key_end - rest);
|
||||||
if (STRCMP(key, "MATCHGROUP") == 0) {
|
if (STRCMP(key, "MATCHGROUP") == 0) {
|
||||||
item = ITEM_MATCHGROUP;
|
item = ITEM_MATCHGROUP;
|
||||||
} else if (STRCMP(key, "START") == 0) {
|
} else if (STRCMP(key, "START") == 0) {
|
||||||
@ -5047,8 +5047,8 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
|
|||||||
EMSG2(_("E401: Pattern delimiter not found: %s"), arg);
|
EMSG2(_("E401: Pattern delimiter not found: %s"), arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* store the pattern and compiled regexp program */
|
// store the pattern and compiled regexp program
|
||||||
ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1));
|
ci->sp_pattern = vim_strnsave(arg + 1, end - arg - 1);
|
||||||
|
|
||||||
/* Make 'cpoptions' empty, to avoid the 'l' flag */
|
/* Make 'cpoptions' empty, to avoid the 'l' flag */
|
||||||
cpo_save = p_cpo;
|
cpo_save = p_cpo;
|
||||||
@ -5136,7 +5136,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|
|||||||
arg_end = skiptowhite(arg_start);
|
arg_end = skiptowhite(arg_start);
|
||||||
next_arg = skipwhite(arg_end);
|
next_arg = skipwhite(arg_end);
|
||||||
xfree(key);
|
xfree(key);
|
||||||
key = vim_strnsave_up(arg_start, (int)(arg_end - arg_start));
|
key = vim_strnsave_up(arg_start, arg_end - arg_start);
|
||||||
if (STRCMP(key, "CCOMMENT") == 0) {
|
if (STRCMP(key, "CCOMMENT") == 0) {
|
||||||
if (!eap->skip)
|
if (!eap->skip)
|
||||||
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
|
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
|
||||||
@ -5195,7 +5195,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|
|||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
/* store the pattern and compiled regexp program */
|
/* store the pattern and compiled regexp program */
|
||||||
curwin->w_s->b_syn_linecont_pat =
|
curwin->w_s->b_syn_linecont_pat =
|
||||||
vim_strnsave(next_arg + 1, (int)(arg_end - next_arg - 1));
|
vim_strnsave(next_arg + 1, arg_end - next_arg - 1);
|
||||||
curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic;
|
curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic;
|
||||||
|
|
||||||
/* Make 'cpoptions' empty, to avoid the 'l' flag */
|
/* Make 'cpoptions' empty, to avoid the 'l' flag */
|
||||||
@ -5555,18 +5555,17 @@ void ex_syntax(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
char_u *arg = eap->arg;
|
char_u *arg = eap->arg;
|
||||||
char_u *subcmd_end;
|
char_u *subcmd_end;
|
||||||
char_u *subcmd_name;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
syn_cmdlinep = eap->cmdlinep;
|
syn_cmdlinep = eap->cmdlinep;
|
||||||
|
|
||||||
/* isolate subcommand name */
|
// isolate subcommand name
|
||||||
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end)
|
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {
|
||||||
;
|
}
|
||||||
subcmd_name = vim_strnsave(arg, (int)(subcmd_end - arg));
|
char_u *const subcmd_name = vim_strnsave(arg, subcmd_end - arg);
|
||||||
if (eap->skip) /* skip error messages for all subcommands */
|
if (eap->skip) { // skip error messages for all subcommands
|
||||||
++emsg_skip;
|
emsg_skip++;
|
||||||
for (i = 0;; ++i) {
|
}
|
||||||
|
for (int i = 0;; i++) {
|
||||||
if (subcommands[i].name == NULL) {
|
if (subcommands[i].name == NULL) {
|
||||||
EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
|
EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
|
||||||
break;
|
break;
|
||||||
@ -6719,7 +6718,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
|||||||
}
|
}
|
||||||
xfree(key);
|
xfree(key);
|
||||||
key = (char *)vim_strnsave_up((const char_u *)key_start,
|
key = (char *)vim_strnsave_up((const char_u *)key_start,
|
||||||
(int)(linep - key_start));
|
linep - key_start);
|
||||||
linep = (const char *)skipwhite((const char_u *)linep);
|
linep = (const char *)skipwhite((const char_u *)linep);
|
||||||
|
|
||||||
if (strcmp(key, "NONE") == 0) {
|
if (strcmp(key, "NONE") == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user