aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
authorJames <89495599+IAKOBVS@users.noreply.github.com>2024-06-11 22:40:24 +0700
committerGitHub <noreply@github.com>2024-06-11 16:40:24 +0100
commitc37695a5d5f2e8914fff86f3581bed70b4c85d3c (patch)
tree89c5f523768f3fe31a938e497fb7ff9657049e4b /src/nvim
parent44410d063ad23544f87d1c8a553de336ae7939d8 (diff)
downloadrneovim-c37695a5d5f2e8914fff86f3581bed70b4c85d3c.tar.gz
rneovim-c37695a5d5f2e8914fff86f3581bed70b4c85d3c.tar.bz2
rneovim-c37695a5d5f2e8914fff86f3581bed70b4c85d3c.zip
refactor: use S_LEN(s) instead of s, n (#29219)
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/autocmd.c10
-rw-r--r--src/nvim/buffer.c10
-rw-r--r--src/nvim/channel.c2
-rw-r--r--src/nvim/cmdexpand.c8
-rw-r--r--src/nvim/context.c4
-rw-r--r--src/nvim/debugger.c10
-rw-r--r--src/nvim/diff.c60
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c14
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/ex_cmds.c4
-rw-r--r--src/nvim/ex_docmd.c34
-rw-r--r--src/nvim/ex_eval.c4
-rw-r--r--src/nvim/ex_getln.c8
-rw-r--r--src/nvim/file_search.c8
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/getchar.c4
-rw-r--r--src/nvim/help.c6
-rw-r--r--src/nvim/highlight_group.c2
-rw-r--r--src/nvim/indent.c10
-rw-r--r--src/nvim/keycodes.c2
-rw-r--r--src/nvim/mapping.c28
-rw-r--r--src/nvim/mbyte.c43
-rw-r--r--src/nvim/memline.c4
-rw-r--r--src/nvim/menu.c24
-rw-r--r--src/nvim/message.c4
-rw-r--r--src/nvim/option.c28
-rw-r--r--src/nvim/optionstr.c14
-rw-r--r--src/nvim/profile.c8
-rw-r--r--src/nvim/regexp.c4
-rw-r--r--src/nvim/runtime.c10
-rw-r--r--src/nvim/search.c26
-rw-r--r--src/nvim/sign.c46
-rw-r--r--src/nvim/spellfile.c6
-rw-r--r--src/nvim/spellsuggest.c14
-rw-r--r--src/nvim/statusline.c2
-rw-r--r--src/nvim/syntax.c12
-rw-r--r--src/nvim/tag.c28
-rw-r--r--src/nvim/terminal.c4
-rw-r--r--src/nvim/textformat.c2
-rw-r--r--src/nvim/usercmd.c6
-rw-r--r--src/nvim/window.c2
42 files changed, 263 insertions, 258 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index e5872fcc76..37aa946aaf 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -824,11 +824,11 @@ void do_autocmd(exarg_T *eap, char *arg_in, int forceit)
continue;
}
- invalid_flags |= arg_autocmd_flag_get(&once, &cmd, "++once", 6);
- invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, "++nested", 8);
+ invalid_flags |= arg_autocmd_flag_get(&once, &cmd, S_LEN("++once"));
+ invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, S_LEN("++nested"));
// Check the deprecated "nested" flag.
- invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, "nested", 6);
+ invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, S_LEN("nested"));
}
if (invalid_flags) {
@@ -1245,7 +1245,7 @@ void ex_doautoall(exarg_T *eap)
bool check_nomodeline(char **argp)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
- if (strncmp(*argp, "<nomodeline>", 12) == 0) {
+ if (strncmp(*argp, S_LEN("<nomodeline>")) == 0) {
*argp = skipwhite(*argp + 12);
return false;
}
@@ -2359,7 +2359,7 @@ theend:
bool aupat_is_buflocal(const char *pat, int patlen)
FUNC_ATTR_PURE
{
- return patlen >= 8 && strncmp(pat, "<buffer", 7) == 0 && (pat)[patlen - 1] == '>';
+ return patlen >= 8 && strncmp(pat, S_LEN("<buffer")) == 0 && (pat)[patlen - 1] == '>';
}
int aupat_get_buflocal_nr(const char *pat, int patlen)
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 57245ce3f5..3f4e7047f9 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3850,8 +3850,8 @@ static int chk_modeline(linenr_T lnum, int flags)
int prev = -1;
for (s = ml_get(lnum); *s != NUL; s++) {
if (prev == -1 || ascii_isspace(prev)) {
- if ((prev != -1 && strncmp(s, "ex:", 3) == 0)
- || strncmp(s, "vi:", 3) == 0) {
+ if ((prev != -1 && strncmp(s, S_LEN("ex:")) == 0)
+ || strncmp(s, S_LEN("vi:")) == 0) {
break;
}
// Accept both "vim" and "Vim".
@@ -3867,7 +3867,7 @@ static int chk_modeline(linenr_T lnum, int flags)
if (*e == ':'
&& (s[0] != 'V'
- || strncmp(skipwhite(e + 1), "set", 3) == 0)
+ || strncmp(skipwhite(e + 1), S_LEN("set")) == 0)
&& (s[3] == ':'
|| (VIM_VERSION_100 >= vers && isdigit((uint8_t)s[3]))
|| (VIM_VERSION_100 < vers && s[3] == '<')
@@ -3916,8 +3916,8 @@ static int chk_modeline(linenr_T lnum, int flags)
// "vi:set opt opt opt: foo" -- foo not interpreted
// "vi:opt opt opt: foo" -- foo interpreted
// Accept "se" for compatibility with Elvis.
- if (strncmp(s, "set ", 4) == 0
- || strncmp(s, "se ", 3) == 0) {
+ if (strncmp(s, S_LEN("set ")) == 0
+ || strncmp(s, S_LEN("se ")) == 0) {
if (*e != ':') { // no terminating ':'?
break;
}
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 5f9bfc3a73..e3df12abbe 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -639,7 +639,7 @@ static inline list_T *buffer_to_tv_list(const char *const buf, const size_t len)
list_T *const l = tv_list_alloc(kListLenMayKnow);
// Empty buffer should be represented by [''], encode_list_write() thinks
// empty list is fine for the case.
- tv_list_append_string(l, "", 0);
+ tv_list_append_string(l, S_LEN(""));
if (len > 0) {
encode_list_write(l, buf, len);
}
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 0b88e2be11..d8081ddfac 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -2247,7 +2247,7 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff)
// Does command allow "++argopt" argument?
if (ea.argt & EX_ARGOPT) {
- while (*arg != NUL && strncmp(arg, "++", 2) == 0) {
+ while (*arg != NUL && strncmp(arg, S_LEN("++")) == 0) {
p = arg + 2;
while (*p && !ascii_isspace(*p)) {
MB_PTR_ADV(p);
@@ -2774,7 +2774,7 @@ static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numM
// When expanding a function name starting with s:, match the <SNR>nr_
// prefix.
char *tofree = NULL;
- if (xp->xp_context == EXPAND_USER_FUNC && strncmp(pat, "^s:", 3) == 0) {
+ if (xp->xp_context == EXPAND_USER_FUNC && strncmp(pat, S_LEN("^s:")) == 0) {
const size_t len = strlen(pat) + 20;
tofree = xmalloc(len);
@@ -3564,7 +3564,7 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (xpc.xp_context == EXPAND_USER_DEFINED) {
// Must be "custom,funcname" pattern
- if (strncmp(type, "custom,", 7) != 0) {
+ if (strncmp(type, S_LEN("custom,")) != 0) {
semsg(_(e_invarg2), type);
return;
}
@@ -3574,7 +3574,7 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (xpc.xp_context == EXPAND_USER_LIST) {
// Must be "customlist,funcname" pattern
- if (strncmp(type, "customlist,", 11) != 0) {
+ if (strncmp(type, S_LEN("customlist,")) != 0) {
semsg(_(e_invarg2), type);
return;
}
diff --git a/src/nvim/context.c b/src/nvim/context.c
index 95e2618f62..b8eecfbb16 100644
--- a/src/nvim/context.c
+++ b/src/nvim/context.c
@@ -261,7 +261,7 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly)
HASHTAB_ITER(func_tbl_get(), hi, {
const char *const name = hi->hi_key;
- bool islambda = (strncmp(name, "<lambda>", 8) == 0);
+ bool islambda = (strncmp(name, S_LEN("<lambda>")) == 0);
bool isscript = ((uint8_t)name[0] == K_SPECIAL);
if (!islambda && (!scriptonly || isscript)) {
@@ -299,7 +299,7 @@ static inline void ctx_restore_funcs(Context *ctx)
static inline Array sbuf_to_array(msgpack_sbuffer sbuf, Arena *arena)
{
list_T *const list = tv_list_alloc(kListLenMayKnow);
- tv_list_append_string(list, "", 0);
+ tv_list_append_string(list, S_LEN(""));
if (sbuf.size > 0) {
encode_list_write(list, sbuf.data, sbuf.size);
}
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index b71ff23f57..ffbeee7f7a 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -521,18 +521,18 @@ static int dbg_parsearg(char *arg, garray_T *gap)
struct debuggy *bp = &DEBUGGY(gap, gap->ga_len);
// Find "func" or "file".
- if (strncmp(p, "func", 4) == 0) {
+ if (strncmp(p, S_LEN("func")) == 0) {
bp->dbg_type = DBG_FUNC;
- } else if (strncmp(p, "file", 4) == 0) {
+ } else if (strncmp(p, S_LEN("file")) == 0) {
bp->dbg_type = DBG_FILE;
- } else if (gap != &prof_ga && strncmp(p, "here", 4) == 0) {
+ } else if (gap != &prof_ga && strncmp(p, S_LEN("here")) == 0) {
if (curbuf->b_ffname == NULL) {
emsg(_(e_noname));
return FAIL;
}
bp->dbg_type = DBG_FILE;
here = true;
- } else if (gap != &prof_ga && strncmp(p, "expr", 4) == 0) {
+ } else if (gap != &prof_ga && strncmp(p, S_LEN("expr")) == 0) {
bp->dbg_type = DBG_EXPR;
} else {
semsg(_(e_invarg2), p);
@@ -559,7 +559,7 @@ static int dbg_parsearg(char *arg, garray_T *gap)
}
if (bp->dbg_type == DBG_FUNC) {
- bp->dbg_name = xstrdup(strncmp(p, "g:", 2) == 0 ? p + 2 : p);
+ bp->dbg_name = xstrdup(strncmp(p, S_LEN("g:")) == 0 ? p + 2 : p);
} else if (here) {
bp->dbg_name = xstrdup(curbuf->b_ffname);
} else if (bp->dbg_type == DBG_EXPR) {
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 54335fc93e..e24c39e60c 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1020,7 +1020,7 @@ static int check_external_diff(diffio_T *diffio)
if (fd == NULL) {
io_error = true;
} else {
- if (fwrite("line1\n", 6, 1, fd) != 1) {
+ if (fwrite(S_LEN("line1\n"), 1, fd) != 1) {
io_error = true;
}
fclose(fd);
@@ -1029,7 +1029,7 @@ static int check_external_diff(diffio_T *diffio)
if (fd == NULL) {
io_error = true;
} else {
- if (fwrite("line2\n", 6, 1, fd) != 1) {
+ if (fwrite(S_LEN("line2\n"), 1, fd) != 1) {
io_error = true;
}
fclose(fd);
@@ -1050,8 +1050,8 @@ static int check_external_diff(diffio_T *diffio)
break;
}
- if (strncmp(linebuf, "1c1", 3) == 0
- || strncmp(linebuf, "@@ -1 +1 @@", 11) == 0) {
+ if (strncmp(linebuf, S_LEN("1c1")) == 0
+ || strncmp(linebuf, S_LEN("@@ -1 +1 @@")) == 0) {
ok = kTrue;
}
}
@@ -1583,13 +1583,13 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle)
// @@ -1,3 +1,5 @@
if (isdigit((uint8_t)(*line))) {
*diffstyle = DIFF_ED;
- } else if ((strncmp(line, "@@ ", 3) == 0)) {
+ } else if ((strncmp(line, S_LEN("@@ ")) == 0)) {
*diffstyle = DIFF_UNIFIED;
- } else if ((strncmp(line, "--- ", 4) == 0)
+ } else if ((strncmp(line, S_LEN("--- ")) == 0)
&& (vim_fgets(line, LBUFLEN, fd) == 0)
- && (strncmp(line, "+++ ", 4) == 0)
+ && (strncmp(line, S_LEN("+++ ")) == 0)
&& (vim_fgets(line, LBUFLEN, fd) == 0)
- && (strncmp(line, "@@ ", 3) == 0)) {
+ && (strncmp(line, S_LEN("@@ ")) == 0)) {
*diffstyle = DIFF_UNIFIED;
} else {
// Format not recognized yet, skip over this line. Cygwin diff
@@ -1607,7 +1607,7 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle)
}
} else {
assert(*diffstyle == DIFF_UNIFIED);
- if (strncmp(line, "@@ ", 3) != 0) {
+ if (strncmp(line, S_LEN("@@ ")) != 0) {
continue; // not the start of a diff block
}
if (parse_diff_unified(line, hunk) == FAIL) {
@@ -2473,70 +2473,70 @@ int diffopt_changed(void)
char *p = p_dip;
while (*p != NUL) {
// Note: Keep this in sync with p_dip_values
- if (strncmp(p, "filler", 6) == 0) {
+ if (strncmp(p, S_LEN("filler")) == 0) {
p += 6;
diff_flags_new |= DIFF_FILLER;
- } else if ((strncmp(p, "context:", 8) == 0) && ascii_isdigit(p[8])) {
+ } else if ((strncmp(p, S_LEN("context:")) == 0) && ascii_isdigit(p[8])) {
p += 8;
diff_context_new = getdigits_int(&p, false, diff_context_new);
- } else if (strncmp(p, "iblank", 6) == 0) {
+ } else if (strncmp(p, S_LEN("iblank")) == 0) {
p += 6;
diff_flags_new |= DIFF_IBLANK;
- } else if (strncmp(p, "icase", 5) == 0) {
+ } else if (strncmp(p, S_LEN("icase")) == 0) {
p += 5;
diff_flags_new |= DIFF_ICASE;
- } else if (strncmp(p, "iwhiteall", 9) == 0) {
+ } else if (strncmp(p, S_LEN("iwhiteall")) == 0) {
p += 9;
diff_flags_new |= DIFF_IWHITEALL;
- } else if (strncmp(p, "iwhiteeol", 9) == 0) {
+ } else if (strncmp(p, S_LEN("iwhiteeol")) == 0) {
p += 9;
diff_flags_new |= DIFF_IWHITEEOL;
- } else if (strncmp(p, "iwhite", 6) == 0) {
+ } else if (strncmp(p, S_LEN("iwhite")) == 0) {
p += 6;
diff_flags_new |= DIFF_IWHITE;
- } else if (strncmp(p, "horizontal", 10) == 0) {
+ } else if (strncmp(p, S_LEN("horizontal")) == 0) {
p += 10;
diff_flags_new |= DIFF_HORIZONTAL;
- } else if (strncmp(p, "vertical", 8) == 0) {
+ } else if (strncmp(p, S_LEN("vertical")) == 0) {
p += 8;
diff_flags_new |= DIFF_VERTICAL;
- } else if ((strncmp(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) {
+ } else if ((strncmp(p, S_LEN("foldcolumn:")) == 0) && ascii_isdigit(p[11])) {
p += 11;
diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new);
- } else if (strncmp(p, "hiddenoff", 9) == 0) {
+ } else if (strncmp(p, S_LEN("hiddenoff")) == 0) {
p += 9;
diff_flags_new |= DIFF_HIDDEN_OFF;
- } else if (strncmp(p, "closeoff", 8) == 0) {
+ } else if (strncmp(p, S_LEN("closeoff")) == 0) {
p += 8;
diff_flags_new |= DIFF_CLOSE_OFF;
- } else if (strncmp(p, "followwrap", 10) == 0) {
+ } else if (strncmp(p, S_LEN("followwrap")) == 0) {
p += 10;
diff_flags_new |= DIFF_FOLLOWWRAP;
- } else if (strncmp(p, "indent-heuristic", 16) == 0) {
+ } else if (strncmp(p, S_LEN("indent-heuristic")) == 0) {
p += 16;
diff_indent_heuristic = XDF_INDENT_HEURISTIC;
- } else if (strncmp(p, "internal", 8) == 0) {
+ } else if (strncmp(p, S_LEN("internal")) == 0) {
p += 8;
diff_flags_new |= DIFF_INTERNAL;
- } else if (strncmp(p, "algorithm:", 10) == 0) {
+ } else if (strncmp(p, S_LEN("algorithm:")) == 0) {
// Note: Keep this in sync with p_dip_algorithm_values.
p += 10;
- if (strncmp(p, "myers", 5) == 0) {
+ if (strncmp(p, S_LEN("myers")) == 0) {
p += 5;
diff_algorithm_new = 0;
- } else if (strncmp(p, "minimal", 7) == 0) {
+ } else if (strncmp(p, S_LEN("minimal")) == 0) {
p += 7;
diff_algorithm_new = XDF_NEED_MINIMAL;
- } else if (strncmp(p, "patience", 8) == 0) {
+ } else if (strncmp(p, S_LEN("patience")) == 0) {
p += 8;
diff_algorithm_new = XDF_PATIENCE_DIFF;
- } else if (strncmp(p, "histogram", 9) == 0) {
+ } else if (strncmp(p, S_LEN("histogram")) == 0) {
p += 9;
diff_algorithm_new = XDF_HISTOGRAM_DIFF;
} else {
return FAIL;
}
- } else if ((strncmp(p, "linematch:", 10) == 0) && ascii_isdigit(p[10])) {
+ } else if ((strncmp(p, S_LEN("linematch:")) == 0) && ascii_isdigit(p[10])) {
p += 10;
linematch_lines_new = getdigits_int(&p, false, linematch_lines_new);
diff_flags_new |= DIFF_LINEMATCH;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index f6e2dbfa4e..889f445c3d 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3095,7 +3095,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
p = get_cursor_line_ptr();
if (skipwhite(p) == p + curwin->w_cursor.col - 4
- && strncmp(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
+ && strncmp(p + curwin->w_cursor.col - 4, S_LEN("else")) == 0) {
return true;
}
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a4680b62ab..df5d336cbd 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1219,7 +1219,7 @@ int call_vim_function(const char *func, int argc, typval_T *argv, typval_T *rett
int len = (int)strlen(func);
partial_T *pt = NULL;
- if (len >= 6 && !memcmp(func, "v:lua.", 6)) {
+ if (len >= 6 && !memcmp(func, S_LEN("v:lua."))) {
func += 6;
len = check_luafunc_name(func, false);
if (len == 0) {
@@ -2161,7 +2161,7 @@ void del_menutrans_vars(void)
{
hash_lock(&globvarht);
HASHTAB_ITER(&globvarht, hi, {
- if (strncmp(hi->hi_key, "menutrans_", 10) == 0) {
+ if (strncmp(hi->hi_key, S_LEN("menutrans_")) == 0) {
delete_var(&globvarht, hi);
}
});
@@ -3274,7 +3274,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
check_vars(s, (size_t)len);
// If evaluate is false rettv->v_type was not set, but it's needed
// in handle_subscript() to parse v:lua, so set it here.
- if (rettv->v_type == VAR_UNKNOWN && !evaluate && strnequal(s, "v:lua.", 6)) {
+ if (rettv->v_type == VAR_UNKNOWN && !evaluate && strnequal(s, S_LEN("v:lua."))) {
rettv->v_type = VAR_PARTIAL;
rettv->vval.v_partial = vvlua_partial;
rettv->vval.v_partial->pt_refcount++;
@@ -3483,7 +3483,7 @@ static int eval_method(char **const arg, typval_T *const rettv, evalarg_T *const
int len;
char *name = *arg;
char *lua_funcname = NULL;
- if (strnequal(name, "v:lua.", 6)) {
+ if (strnequal(name, S_LEN("v:lua."))) {
lua_funcname = name + 6;
*arg = (char *)skip_luafunc_name(lua_funcname);
*arg = skipwhite(*arg); // to detect trailing whitespace later
@@ -5618,7 +5618,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref)
int dict_idx = 0;
int arg_idx = 0;
list_T *list = NULL;
- if (strncmp(s, "s:", 2) == 0 || strncmp(s, "<SID>", 5) == 0) {
+ if (strncmp(s, S_LEN("s:")) == 0 || strncmp(s, S_LEN("<SID>")) == 0) {
// Expand s: and <SID> into <SNR>nr_, so that the function can
// also be called from another script. Using trans_function_name()
// would also work, but some plugins depend on the name being
@@ -6192,7 +6192,7 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co
case kCallbackFuncref:
name = callback->data.funcref;
int len = (int)strlen(name);
- if (len >= 6 && !memcmp(name, "v:lua.", 6)) {
+ if (len >= 6 && !memcmp(name, S_LEN("v:lua."))) {
name += 6;
len = check_luafunc_name(name, false);
if (len == 0) {
@@ -6460,7 +6460,7 @@ bool write_list(FileDescriptor *const fp, const list_T *const list, const bool b
}
}
if (!binary || TV_LIST_ITEM_NEXT(list, li) != NULL) {
- const ptrdiff_t written = file_write(fp, "\n", 1);
+ const ptrdiff_t written = file_write(fp, S_LEN("\n"));
if (written < 0) {
error = (int)written;
goto write_list_error;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 666d46cdad..9a1ed7dea9 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -5095,7 +5095,7 @@ static void get_matches_in_str(const char *str, regmatch_T *rmp, list_T *mlist,
// return a list with the submatches
for (int i = 1; i < NSUBEXP; i++) {
if (rmp->endp[i] == NULL) {
- tv_list_append_string(sml, "", 0);
+ tv_list_append_string(sml, S_LEN(""));
} else {
tv_list_append_string(sml, rmp->startp[i], rmp->endp[i] - rmp->startp[i]);
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 2f7673a6f4..234ab59844 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1360,11 +1360,11 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
{
bool is_fish_shell =
#if defined(UNIX)
- strncmp(invocation_path_tail(p_sh, NULL), "fish", 4) == 0;
+ strncmp(invocation_path_tail(p_sh, NULL), S_LEN("fish")) == 0;
#else
false;
#endif
- bool is_pwsh = strncmp(invocation_path_tail(p_sh, NULL), "pwsh", 4) == 0
+ bool is_pwsh = strncmp(invocation_path_tail(p_sh, NULL), S_LEN("pwsh")) == 0
|| strncmp(invocation_path_tail(p_sh, NULL), "powershell",
10) == 0;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 1e2c515195..a38ff6333a 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4191,7 +4191,7 @@ static int getargopt(exarg_T *eap)
// Note: Keep this in sync with get_argopt_name.
// ":edit ++[no]bin[ary] file"
- if (strncmp(arg, "bin", 3) == 0 || strncmp(arg, "nobin", 5) == 0) {
+ if (strncmp(arg, S_LEN("bin")) == 0 || strncmp(arg, S_LEN("nobin")) == 0) {
if (*arg == 'n') {
arg += 2;
eap->force_bin = FORCE_NOBIN;
@@ -4206,33 +4206,33 @@ static int getargopt(exarg_T *eap)
}
// ":read ++edit file"
- if (strncmp(arg, "edit", 4) == 0) {
+ if (strncmp(arg, S_LEN("edit")) == 0) {
eap->read_edit = true;
eap->arg = skipwhite(arg + 4);
return OK;
}
// ":write ++p foo/bar/file
- if (strncmp(arg, "p", 1) == 0) {
+ if (strncmp(arg, S_LEN("p")) == 0) {
eap->mkdir_p = true;
eap->arg = skipwhite(arg + 1);
return OK;
}
- if (strncmp(arg, "ff", 2) == 0) {
+ if (strncmp(arg, S_LEN("ff")) == 0) {
arg += 2;
pp = &eap->force_ff;
- } else if (strncmp(arg, "fileformat", 10) == 0) {
+ } else if (strncmp(arg, S_LEN("fileformat")) == 0) {
arg += 10;
pp = &eap->force_ff;
- } else if (strncmp(arg, "enc", 3) == 0) {
- if (strncmp(arg, "encoding", 8) == 0) {
+ } else if (strncmp(arg, S_LEN("enc")) == 0) {
+ if (strncmp(arg, S_LEN("encoding")) == 0) {
arg += 8;
} else {
arg += 3;
}
pp = &eap->force_enc;
- } else if (strncmp(arg, "bad", 3) == 0) {
+ } else if (strncmp(arg, S_LEN("bad")) == 0) {
arg += 3;
pp = &bad_char_idx;
}
@@ -4296,19 +4296,19 @@ int expand_argopt(char *pat, expand_T *xp, regmatch_T *rmp, char ***matches, int
char *name_end = xp->xp_pattern - 1;
if (name_end - xp->xp_line >= 2
- && strncmp(name_end - 2, "ff", 2) == 0) {
+ && strncmp(name_end - 2, S_LEN("ff")) == 0) {
cb = get_fileformat_name;
} else if (name_end - xp->xp_line >= 10
- && strncmp(name_end - 10, "fileformat", 10) == 0) {
+ && strncmp(name_end - 10, S_LEN("fileformat")) == 0) {
cb = get_fileformat_name;
} else if (name_end - xp->xp_line >= 3
- && strncmp(name_end - 3, "enc", 3) == 0) {
+ && strncmp(name_end - 3, S_LEN("enc")) == 0) {
cb = get_encoding_name;
} else if (name_end - xp->xp_line >= 8
- && strncmp(name_end - 8, "encoding", 8) == 0) {
+ && strncmp(name_end - 8, S_LEN("encoding")) == 0) {
cb = get_encoding_name;
} else if (name_end - xp->xp_line >= 3
- && strncmp(name_end - 3, "bad", 3) == 0) {
+ && strncmp(name_end - 3, S_LEN("bad")) == 0) {
cb = get_bad_name;
}
@@ -7213,7 +7213,7 @@ char *expand_sfile(char *arg)
char *result = xstrdup(arg);
for (char *p = result; *p;) {
- if (strncmp(p, "<sfile>", 7) != 0) {
+ if (strncmp(p, S_LEN("<sfile>")) != 0) {
p++;
} else {
// replace "<sfile>" with the sourced file name, and do ":" stuff
@@ -7300,12 +7300,12 @@ static void ex_filetype(exarg_T *eap)
// Accept "plugin" and "indent" in any order.
while (true) {
- if (strncmp(arg, "plugin", 6) == 0) {
+ if (strncmp(arg, S_LEN("plugin")) == 0) {
plugin = true;
arg = skipwhite(arg + 6);
continue;
}
- if (strncmp(arg, "indent", 6) == 0) {
+ if (strncmp(arg, S_LEN("indent")) == 0) {
indent = true;
arg = skipwhite(arg + 6);
continue;
@@ -7384,7 +7384,7 @@ static void ex_setfiletype(exarg_T *eap)
}
char *arg = eap->arg;
- if (strncmp(arg, "FALLBACK ", 9) == 0) {
+ if (strncmp(arg, S_LEN("FALLBACK ")) == 0) {
arg += 9;
}
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 2681beb228..0b2e1f9294 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -254,7 +254,7 @@ bool cause_errthrow(const char *mesg, bool multiline, bool severe, bool *ignore)
if (plist == msg_list || severe) {
// Skip the extra "Vim " prefix for message "E458".
char *tmsg = elem->msg;
- if (strncmp(tmsg, "Vim E", 5) == 0
+ if (strncmp(tmsg, S_LEN("Vim E")) == 0
&& ascii_isdigit(tmsg[5])
&& ascii_isdigit(tmsg[6])
&& ascii_isdigit(tmsg[7])
@@ -443,7 +443,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
// would be treated differently from real interrupt or error exceptions
// when no active try block is found, see do_cmdline().
if (type == ET_USER) {
- if (strncmp(value, "Vim", 3) == 0
+ if (strncmp(value, S_LEN("Vim")) == 0
&& (((char *)value)[3] == NUL || ((char *)value)[3] == ':'
|| ((char *)value)[3] == '(')) {
emsg(_("E608: Cannot :throw exceptions with 'Vim' prefix"));
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index cef1868fc8..74e6e3422e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2799,13 +2799,13 @@ int check_opt_wim(void)
if (p[i] != NUL && p[i] != ',' && p[i] != ':') {
return FAIL;
}
- if (i == 7 && strncmp(p, "longest", 7) == 0) {
+ if (i == 7 && strncmp(p, S_LEN("longest")) == 0) {
new_wim_flags[idx] |= WIM_LONGEST;
- } else if (i == 4 && strncmp(p, "full", 4) == 0) {
+ } else if (i == 4 && strncmp(p, S_LEN("full")) == 0) {
new_wim_flags[idx] |= WIM_FULL;
- } else if (i == 4 && strncmp(p, "list", 4) == 0) {
+ } else if (i == 4 && strncmp(p, S_LEN("list")) == 0) {
new_wim_flags[idx] |= WIM_LIST;
- } else if (i == 8 && strncmp(p, "lastused", 8) == 0) {
+ } else if (i == 8 && strncmp(p, S_LEN("lastused")) == 0) {
new_wim_flags[idx] |= WIM_BUFLASTUSED;
} else {
return FAIL;
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 30a80773e3..ef936abab5 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -399,7 +399,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
emsg(_(e_path_too_long_for_completion));
break;
}
- if (strncmp(wc_part, "**", 2) == 0) {
+ if (strncmp(wc_part, S_LEN("**")) == 0) {
ff_expand_buffer[len++] = *wc_part++;
ff_expand_buffer[len++] = *wc_part++;
@@