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 #endif
9618a25b9c
This commit is contained in:
Jan Edmund Lazo 2020-12-27 12:14:32 -05:00
parent ed0131e3d9
commit 883114e882
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
12 changed files with 44 additions and 50 deletions

View File

@ -1225,8 +1225,7 @@ void ex_diffpatch(exarg_T *eap)
EMSG(_("E816: Cannot read patch output"));
} else {
if (curbuf->b_fname != NULL) {
newname = vim_strnsave(curbuf->b_fname,
(int)(STRLEN(curbuf->b_fname) + 4));
newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4);
STRCAT(newname, ".new");
}

View File

@ -3423,7 +3423,7 @@ static void ins_compl_addleader(int c)
xfree(compl_leader);
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();
}

View File

@ -5422,7 +5422,7 @@ static int get_literal_key(char_u **arg, typval_T *tv)
for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) {
}
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);
return OK;
@ -10264,9 +10264,6 @@ repeat:
if (src[*usedlen] == ':'
&& (src[*usedlen + 1] == 's'
|| (src[*usedlen + 1] == 'g' && src[*usedlen + 2] == 's'))) {
char_u *str;
char_u *pat;
char_u *sub;
int sep;
char_u *flags;
int didit = FALSE;
@ -10283,13 +10280,13 @@ repeat:
// find end of pattern
p = vim_strchr(s, sep);
if (p != NULL) {
pat = vim_strnsave(s, (int)(p - s));
char_u *const pat = vim_strnsave(s, p - s);
s = p + 1;
// find end of substitution
p = vim_strchr(s, sep);
if (p != NULL) {
sub = vim_strnsave(s, (int)(p - s));
str = vim_strnsave(*fnamep, *fnamelen);
char_u *const sub = vim_strnsave(s, p - s);
char_u *const str = vim_strnsave(*fnamep, *fnamelen);
*usedlen = (size_t)(p + 1 - src);
s = do_string_sub(str, pat, sub, NULL, flags);
*fnamep = s;

View File

@ -6553,7 +6553,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
if (prevlen == 0) {
assert(len < INT_MAX);
s = vim_strnsave(start, (int)len);
s = vim_strnsave(start, len);
} else {
/* Change "prev" buffer to be the right size. This way
* 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);
}
/*

View File

@ -2297,9 +2297,9 @@ void ex_function(exarg_T *eap)
// Ignore leading white space.
p = skipwhite(p + 4);
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;
is_heredoc = true;
}

View File

@ -2796,9 +2796,10 @@ void ex_append(exarg_T *eap)
p = vim_strchr(eap->nextcmd, NL);
if (p == NULL)
p = eap->nextcmd + STRLEN(eap->nextcmd);
theline = vim_strnsave(eap->nextcmd, (int)(p - eap->nextcmd));
if (*p != NUL)
++p;
theline = vim_strnsave(eap->nextcmd, p - eap->nextcmd);
if (*p != NUL) {
p++;
}
eap->nextcmd = p;
} else {
// Set State to avoid the cursor shape to be set to INSERT mode

View File

@ -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)
{
ucmd_T *cmd = NULL;
char_u *p;
int i;
int cmp = 1;
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) {
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);
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;
}
if (arg != NULL)
*compl_arg = vim_strnsave(arg, (int)arglen);
if (arg != NULL) {
*compl_arg = vim_strnsave(arg, arglen);
}
return OK;
}
@ -9292,7 +9292,7 @@ static void ex_match(exarg_T *eap)
} else {
p = skiptowhite(eap->arg);
if (!eap->skip) {
g = vim_strnsave(eap->arg, (int)(p - eap->arg));
g = vim_strnsave(eap->arg, p - eap->arg);
}
p = skipwhite(p);
if (*p == NUL) {

View File

@ -2032,7 +2032,7 @@ static char_u *next_fenc(char_u **pp, bool *alloced)
r = enc_canonize(*pp);
*pp += STRLEN(*pp);
} else {
r = vim_strnsave(*pp, (int)(p - *pp));
r = vim_strnsave(*pp, p - *pp);
*pp = p + 1;
p = enc_canonize(r);
xfree(r);

View File

@ -975,9 +975,9 @@ void ml_recover(bool checkext)
if (b0p->b0_flags & B0_HAS_FENC) {
int fnsize = B0_FNAME_SIZE_NOCRYPT;
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));
for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {
}
b0_fenc = vim_strnsave(p, b0p->b0_fname + fnsize - p);
}
mf_put(mfp, hp, false, false); /* release block 0 */

View File

@ -3724,8 +3724,7 @@ static long regtry(bt_regprog_T *prog,
} else {
if (reg_startzp[i] != NULL && reg_endzp[i] != NULL)
re_extmatch_out->matches[i] =
vim_strnsave(reg_startzp[i],
(int)(reg_endzp[i] - reg_startzp[i]));
vim_strnsave(reg_startzp[i], 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) {
s = NULL;
} 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)->vval.v_string = s;
@ -7084,7 +7083,7 @@ char_u *reg_submatch(int no)
if (s == NULL || rsm.sm_match->endp[no] == NULL) {
retval = NULL;
} else {
retval = vim_strnsave(s, (int)(rsm.sm_match->endp[no] - s));
retval = vim_strnsave(s, rsm.sm_match->endp[no] - s);
}
}

View File

@ -6480,8 +6480,7 @@ static long nfa_regtry(nfa_regprog_T *prog,
if (lpos->start != NULL && lpos->end != NULL)
re_extmatch_out->matches[i] =
vim_strnsave(lpos->start,
(int)(lpos->end - lpos->start));
vim_strnsave(lpos->start, lpos->end - lpos->start);
}
}
}

View File

@ -4186,10 +4186,10 @@ get_syn_options(
arg = skiptowhite(arg);
if (gname_start == arg)
return NULL;
gname = vim_strnsave(gname_start, (int)(arg - gname_start));
if (STRCMP(gname, "NONE") == 0)
gname = vim_strnsave(gname_start, arg - gname_start);
if (STRCMP(gname, "NONE") == 0) {
*opt->sync_idx = NONE_IDX;
else {
} else {
syn_id = syn_name2id(gname);
int i;
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 != '=')
++key_end;
xfree(key);
key = vim_strnsave_up(rest, (int)(key_end - rest));
key = vim_strnsave_up(rest, key_end - rest);
if (STRCMP(key, "MATCHGROUP") == 0) {
item = ITEM_MATCHGROUP;
} 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);
return NULL;
}
/* store the pattern and compiled regexp program */
ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1));
// store the pattern and compiled regexp program
ci->sp_pattern = vim_strnsave(arg + 1, end - arg - 1);
/* Make 'cpoptions' empty, to avoid the 'l' flag */
cpo_save = p_cpo;
@ -5136,7 +5136,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
arg_end = skiptowhite(arg_start);
next_arg = skipwhite(arg_end);
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 (!eap->skip)
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) {
/* store the pattern and compiled regexp program */
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;
/* 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 *subcmd_end;
char_u *subcmd_name;
int i;
syn_cmdlinep = eap->cmdlinep;
/* isolate subcommand name */
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end)
;
subcmd_name = vim_strnsave(arg, (int)(subcmd_end - arg));
if (eap->skip) /* skip error messages for all subcommands */
++emsg_skip;
for (i = 0;; ++i) {
// isolate subcommand name
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {
}
char_u *const subcmd_name = vim_strnsave(arg, subcmd_end - arg);
if (eap->skip) { // skip error messages for all subcommands
emsg_skip++;
}
for (int i = 0;; i++) {
if (subcommands[i].name == NULL) {
EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
break;
@ -6719,7 +6718,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
}
xfree(key);
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);
if (strcmp(key, "NONE") == 0) {