aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/diff.c3
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c11
-rw-r--r--src/nvim/eval/funcs.c4
-rw-r--r--src/nvim/eval/userfunc.c4
-rw-r--r--src/nvim/ex_cmds.c7
-rw-r--r--src/nvim/ex_docmd.c10
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/memline.c6
-rw-r--r--src/nvim/regexp.c7
-rw-r--r--src/nvim/regexp_nfa.c3
-rw-r--r--src/nvim/syntax.c35
12 files changed, 44 insertions, 50 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 1cdf84f9d0..4d72117fed 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -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");
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index ebbb6e803a..36acc10f98 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -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();
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 10a382ec4e..7916e3a66a 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index ed01e8a8b0..16eb6f8898 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -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);
}
/*
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 4e8b98d723..70c998ef39 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -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;
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 6e08378ad4..c0f08139ec 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -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
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 8828e781b6..3fc02e0693 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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) {
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 936a9d1397..1568bf3fbb 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -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);
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 70225484ec..31dc6b3649 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -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 */
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index fb08cd2727..a2589ac431 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -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);
}
}
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index d38719f396..8b5ee59d40 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -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);
}
}
}
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index e91d560284..4d88df5a3a 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -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) {