diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index ebed3e6f03..c32d33080e 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, S_LEN("++once")); - invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, S_LEN("++nested")); + invalid_flags |= arg_autocmd_flag_get(&once, &cmd, "++once", 6); + invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, "++nested", 8); // Check the deprecated "nested" flag. - invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, S_LEN("nested")); + invalid_flags |= arg_autocmd_flag_get(&nested, &cmd, "nested", 6); } 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, S_LEN("")) == 0) { + if (strncmp(*argp, "", 12) == 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, S_LEN("'; + return patlen >= 8 && strncmp(pat, "'; } int aupat_get_buflocal_nr(const char *pat, int patlen) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 3f4e7047f9..57245ce3f5 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, S_LEN("ex:")) == 0) - || strncmp(s, S_LEN("vi:")) == 0) { + if ((prev != -1 && strncmp(s, "ex:", 3) == 0) + || strncmp(s, "vi:", 3) == 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), S_LEN("set")) == 0) + || strncmp(skipwhite(e + 1), "set", 3) == 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, S_LEN("set ")) == 0 - || strncmp(s, S_LEN("se ")) == 0) { + if (strncmp(s, "set ", 4) == 0 + || strncmp(s, "se ", 3) == 0) { if (*e != ':') { // no terminating ':'? break; } diff --git a/src/nvim/channel.c b/src/nvim/channel.c index e3df12abbe..5f9bfc3a73 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, S_LEN("")); + tv_list_append_string(l, "", 0); if (len > 0) { encode_list_write(l, buf, len); } diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index fdb452aee4..f75b84c77b 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, S_LEN("++")) == 0) { + while (*arg != NUL && strncmp(arg, "++", 2) == 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 nr_ // prefix. char *tofree = NULL; - if (xp->xp_context == EXPAND_USER_FUNC && strncmp(pat, S_LEN("^s:")) == 0) { + if (xp->xp_context == EXPAND_USER_FUNC && strncmp(pat, "^s:", 3) == 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, S_LEN("custom,")) != 0) { + if (strncmp(type, "custom,", 7) != 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, S_LEN("customlist,")) != 0) { + if (strncmp(type, "customlist,", 11) != 0) { semsg(_(e_invarg2), type); return; } diff --git a/src/nvim/context.c b/src/nvim/context.c index b8eecfbb16..95e2618f62 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, S_LEN("")) == 0); + bool islambda = (strncmp(name, "", 8) == 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, S_LEN("")); + tv_list_append_string(list, "", 0); 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 ffbeee7f7a..b71ff23f57 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, S_LEN("func")) == 0) { + if (strncmp(p, "func", 4) == 0) { bp->dbg_type = DBG_FUNC; - } else if (strncmp(p, S_LEN("file")) == 0) { + } else if (strncmp(p, "file", 4) == 0) { bp->dbg_type = DBG_FILE; - } else if (gap != &prof_ga && strncmp(p, S_LEN("here")) == 0) { + } else if (gap != &prof_ga && strncmp(p, "here", 4) == 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, S_LEN("expr")) == 0) { + } else if (gap != &prof_ga && strncmp(p, "expr", 4) == 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, S_LEN("g:")) == 0 ? p + 2 : p); + bp->dbg_name = xstrdup(strncmp(p, "g:", 2) == 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 750f0c3525..0fe1729029 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(S_LEN("line1\n"), 1, fd) != 1) { + if (fwrite("line1\n", 6, 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(S_LEN("line2\n"), 1, fd) != 1) { + if (fwrite("line2\n", 6, 1, fd) != 1) { io_error = true; } fclose(fd); @@ -1050,8 +1050,8 @@ static int check_external_diff(diffio_T *diffio) break; } - if (strncmp(linebuf, S_LEN("1c1")) == 0 - || strncmp(linebuf, S_LEN("@@ -1 +1 @@")) == 0) { + if (strncmp(linebuf, "1c1", 3) == 0 + || strncmp(linebuf, "@@ -1 +1 @@", 11) == 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, S_LEN("@@ ")) == 0)) { + } else if ((strncmp(line, "@@ ", 3) == 0)) { *diffstyle = DIFF_UNIFIED; - } else if ((strncmp(line, S_LEN("--- ")) == 0) + } else if ((strncmp(line, "--- ", 4) == 0) && (vim_fgets(line, LBUFLEN, fd) == 0) - && (strncmp(line, S_LEN("+++ ")) == 0) + && (strncmp(line, "+++ ", 4) == 0) && (vim_fgets(line, LBUFLEN, fd) == 0) - && (strncmp(line, S_LEN("@@ ")) == 0)) { + && (strncmp(line, "@@ ", 3) == 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, S_LEN("@@ ")) != 0) { + if (strncmp(line, "@@ ", 3) != 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, S_LEN("filler")) == 0) { + if (strncmp(p, "filler", 6) == 0) { p += 6; diff_flags_new |= DIFF_FILLER; - } else if ((strncmp(p, S_LEN("context:")) == 0) && ascii_isdigit(p[8])) { + } else if ((strncmp(p, "context:", 8) == 0) && ascii_isdigit(p[8])) { p += 8; diff_context_new = getdigits_int(&p, false, diff_context_new); - } else if (strncmp(p, S_LEN("iblank")) == 0) { + } else if (strncmp(p, "iblank", 6) == 0) { p += 6; diff_flags_new |= DIFF_IBLANK; - } else if (strncmp(p, S_LEN("icase")) == 0) { + } else if (strncmp(p, "icase", 5) == 0) { p += 5; diff_flags_new |= DIFF_ICASE; - } else if (strncmp(p, S_LEN("iwhiteall")) == 0) { + } else if (strncmp(p, "iwhiteall", 9) == 0) { p += 9; diff_flags_new |= DIFF_IWHITEALL; - } else if (strncmp(p, S_LEN("iwhiteeol")) == 0) { + } else if (strncmp(p, "iwhiteeol", 9) == 0) { p += 9; diff_flags_new |= DIFF_IWHITEEOL; - } else if (strncmp(p, S_LEN("iwhite")) == 0) { + } else if (strncmp(p, "iwhite", 6) == 0) { p += 6; diff_flags_new |= DIFF_IWHITE; - } else if (strncmp(p, S_LEN("horizontal")) == 0) { + } else if (strncmp(p, "horizontal", 10) == 0) { p += 10; diff_flags_new |= DIFF_HORIZONTAL; - } else if (strncmp(p, S_LEN("vertical")) == 0) { + } else if (strncmp(p, "vertical", 8) == 0) { p += 8; diff_flags_new |= DIFF_VERTICAL; - } else if ((strncmp(p, S_LEN("foldcolumn:")) == 0) && ascii_isdigit(p[11])) { + } else if ((strncmp(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) { p += 11; diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new); - } else if (strncmp(p, S_LEN("hiddenoff")) == 0) { + } else if (strncmp(p, "hiddenoff", 9) == 0) { p += 9; diff_flags_new |= DIFF_HIDDEN_OFF; - } else if (strncmp(p, S_LEN("closeoff")) == 0) { + } else if (strncmp(p, "closeoff", 8) == 0) { p += 8; diff_flags_new |= DIFF_CLOSE_OFF; - } else if (strncmp(p, S_LEN("followwrap")) == 0) { + } else if (strncmp(p, "followwrap", 10) == 0) { p += 10; diff_flags_new |= DIFF_FOLLOWWRAP; - } else if (strncmp(p, S_LEN("indent-heuristic")) == 0) { + } else if (strncmp(p, "indent-heuristic", 16) == 0) { p += 16; diff_indent_heuristic = XDF_INDENT_HEURISTIC; - } else if (strncmp(p, S_LEN("internal")) == 0) { + } else if (strncmp(p, "internal", 8) == 0) { p += 8; diff_flags_new |= DIFF_INTERNAL; - } else if (strncmp(p, S_LEN("algorithm:")) == 0) { + } else if (strncmp(p, "algorithm:", 10) == 0) { // Note: Keep this in sync with p_dip_algorithm_values. p += 10; - if (strncmp(p, S_LEN("myers")) == 0) { + if (strncmp(p, "myers", 5) == 0) { p += 5; diff_algorithm_new = 0; - } else if (strncmp(p, S_LEN("minimal")) == 0) { + } else if (strncmp(p, "minimal", 7) == 0) { p += 7; diff_algorithm_new = XDF_NEED_MINIMAL; - } else if (strncmp(p, S_LEN("patience")) == 0) { + } else if (strncmp(p, "patience", 8) == 0) { p += 8; diff_algorithm_new = XDF_PATIENCE_DIFF; - } else if (strncmp(p, S_LEN("histogram")) == 0) { + } else if (strncmp(p, "histogram", 9) == 0) { p += 9; diff_algorithm_new = XDF_HISTOGRAM_DIFF; } else { return FAIL; } - } else if ((strncmp(p, S_LEN("linematch:")) == 0) && ascii_isdigit(p[10])) { + } else if ((strncmp(p, "linematch:", 10) == 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 889f445c3d..f6e2dbfa4e 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, S_LEN("else")) == 0) { + && strncmp(p + curwin->w_cursor.col - 4, "else", 4) == 0) { return true; } } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4cff5e1582..d52e10f61b 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, S_LEN("v:lua."))) { + if (len >= 6 && !memcmp(func, "v:lua.", 6)) { 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, S_LEN("menutrans_")) == 0) { + if (strncmp(hi->hi_key, "menutrans_", 10) == 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, S_LEN("v:lua."))) { + if (rettv->v_type == VAR_UNKNOWN && !evaluate && strnequal(s, "v:lua.", 6)) { 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, S_LEN("v:lua."))) { + if (strnequal(name, "v:lua.", 6)) { 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_LEN("s:")) == 0 || strncmp(s, S_LEN("")) == 0) { + if (strncmp(s, "s:", 2) == 0 || strncmp(s, "", 5) == 0) { // Expand s: and into 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, S_LEN("v:lua."))) { + if (len >= 6 && !memcmp(name, "v:lua.", 6)) { 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, S_LEN("\n")); + const ptrdiff_t written = file_write(fp, "\n", 1); 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 9a1ed7dea9..666d46cdad 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, S_LEN("")); + tv_list_append_string(sml, "", 0); } 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 7858e44f17..0aa897105e 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), S_LEN("fish")) == 0; + strncmp(invocation_path_tail(p_sh, NULL), "fish", 4) == 0; #else false; #endif - bool is_pwsh = strncmp(invocation_path_tail(p_sh, NULL), S_LEN("pwsh")) == 0 + bool is_pwsh = strncmp(invocation_path_tail(p_sh, NULL), "pwsh", 4) == 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 9a6a845958..a6246afb41 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, S_LEN("bin")) == 0 || strncmp(arg, S_LEN("nobin")) == 0) { + if (strncmp(arg, "bin", 3) == 0 || strncmp(arg, "nobin", 5) == 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, S_LEN("edit")) == 0) { + if (strncmp(arg, "edit", 4) == 0) { eap->read_edit = true; eap->arg = skipwhite(arg + 4); return OK; } // ":write ++p foo/bar/file - if (strncmp(arg, S_LEN("p")) == 0) { + if (strncmp(arg, "p", 1) == 0) { eap->mkdir_p = true; eap->arg = skipwhite(arg + 1); return OK; } - if (strncmp(arg, S_LEN("ff")) == 0) { + if (strncmp(arg, "ff", 2) == 0) { arg += 2; pp = &eap->force_ff; - } else if (strncmp(arg, S_LEN("fileformat")) == 0) { + } else if (strncmp(arg, "fileformat", 10) == 0) { arg += 10; pp = &eap->force_ff; - } else if (strncmp(arg, S_LEN("enc")) == 0) { - if (strncmp(arg, S_LEN("encoding")) == 0) { + } else if (strncmp(arg, "enc", 3) == 0) { + if (strncmp(arg, "encoding", 8) == 0) { arg += 8; } else { arg += 3; } pp = &eap->force_enc; - } else if (strncmp(arg, S_LEN("bad")) == 0) { + } else if (strncmp(arg, "bad", 3) == 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, S_LEN("ff")) == 0) { + && strncmp(name_end - 2, "ff", 2) == 0) { cb = get_fileformat_name; } else if (name_end - xp->xp_line >= 10 - && strncmp(name_end - 10, S_LEN("fileformat")) == 0) { + && strncmp(name_end - 10, "fileformat", 10) == 0) { cb = get_fileformat_name; } else if (name_end - xp->xp_line >= 3 - && strncmp(name_end - 3, S_LEN("enc")) == 0) { + && strncmp(name_end - 3, "enc", 3) == 0) { cb = get_encoding_name; } else if (name_end - xp->xp_line >= 8 - && strncmp(name_end - 8, S_LEN("encoding")) == 0) { + && strncmp(name_end - 8, "encoding", 8) == 0) { cb = get_encoding_name; } else if (name_end - xp->xp_line >= 3 - && strncmp(name_end - 3, S_LEN("bad")) == 0) { + && strncmp(name_end - 3, "bad", 3) == 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, S_LEN("")) != 0) { + if (strncmp(p, "", 7) != 0) { p++; } else { // replace "" 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, S_LEN("plugin")) == 0) { + if (strncmp(arg, "plugin", 6) == 0) { plugin = true; arg = skipwhite(arg + 6); continue; } - if (strncmp(arg, S_LEN("indent")) == 0) { + if (strncmp(arg, "indent", 6) == 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, S_LEN("FALLBACK ")) == 0) { + if (strncmp(arg, "FALLBACK ", 9) == 0) { arg += 9; } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 0f4f31df02..6e7c1ff21c 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, S_LEN("Vim E")) == 0 + if (strncmp(tmsg, "Vim E", 5) == 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, S_LEN("Vim")) == 0 + if (strncmp(value, "Vim", 3) == 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 74e6e3422e..cef1868fc8 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, S_LEN("longest")) == 0) { + if (i == 7 && strncmp(p, "longest", 7) == 0) { new_wim_flags[idx] |= WIM_LONGEST; - } else if (i == 4 && strncmp(p, S_LEN("full")) == 0) { + } else if (i == 4 && strncmp(p, "full", 4) == 0) { new_wim_flags[idx] |= WIM_FULL; - } else if (i == 4 && strncmp(p, S_LEN("list")) == 0) { + } else if (i == 4 && strncmp(p, "list", 4) == 0) { new_wim_flags[idx] |= WIM_LIST; - } else if (i == 8 && strncmp(p, S_LEN("lastused")) == 0) { + } else if (i == 8 && strncmp(p, "lastused", 8) == 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 50031eedee..b6a039af5e 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, S_LEN("**")) == 0) { + if (strncmp(wc_part, "**", 2) == 0) { ff_expand_buffer[len++] = *wc_part++; ff_expand_buffer[len++] = *wc_part++; @@ -462,7 +462,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i if (p > search_ctx->ffsc_fix_path) { // do not add '..' to the path and start upwards searching len = (int)(p - search_ctx->ffsc_fix_path) - 1; - if ((len >= 2 && strncmp(search_ctx->ffsc_fix_path, S_LEN("..")) == 0) + if ((len >= 2 && strncmp(search_ctx->ffsc_fix_path, "..", 2) == 0) && (len == 2 || search_ctx->ffsc_fix_path[2] == PATHSEP)) { xfree(buf); goto error_return; @@ -690,7 +690,7 @@ char *vim_findfile(void *search_ctx_arg) rest_of_wildcards = stackp->ffs_wc_path; if (*rest_of_wildcards != NUL) { len = strlen(file_path); - if (strncmp(rest_of_wildcards, S_LEN("**")) == 0) { + if (strncmp(rest_of_wildcards, "**", 2) == 0) { // pointer to the restrict byte // The restrict byte is not a character! p = rest_of_wildcards + 2; @@ -867,7 +867,7 @@ char *vim_findfile(void *search_ctx_arg) // if wildcards contains '**' we have to descent till we reach the // leaves of the directory tree. - if (strncmp(stackp->ffs_wc_path, S_LEN("**")) == 0) { + if (strncmp(stackp->ffs_wc_path, "**", 2) == 0) { for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; i++) { if (path_fnamecmp(stackp->ffs_filearray[i], diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 4b8121b423..3078f00fbb 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1896,7 +1896,7 @@ theend: bool is_dev_fd_file(char *fname) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { - return strncmp(fname, S_LEN("/dev/fd/")) == 0 + return strncmp(fname, "/dev/fd/", 8) == 0 && ascii_isdigit((uint8_t)fname[8]) && *skipdigits(fname + 9) == NUL && (fname[9] != NUL diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 6167418052..ce2c85f174 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -566,7 +566,7 @@ void AppendToRedobuffLit(const char *str, int len) // CTRL-V '0' must be inserted as CTRL-V 048. if (*s == NUL && c == '0') { - add_buff(&redobuff, S_LEN("048")); + add_buff(&redobuff, "048", 3); } else { add_char_buff(&redobuff, c); } @@ -777,7 +777,7 @@ int start_redo(int count, bool old_redo) // copy the buffer name, if present if (c == '"') { - add_buff(&readbuf2, S_LEN("\"")); + add_buff(&readbuf2, "\"", 1); c = read_redo(false, old_redo); // if a numbered buffer is used, increment the number diff --git a/src/nvim/help.c b/src/nvim/help.c index 6ba3e17e0b..0da846bb9f 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -655,7 +655,7 @@ void get_local_additions(void) // files. This uses the very first line in the help file. char *const fname = path_tail(curbuf->b_fname); if (path_fnamecmp(fname, "help.txt") == 0 - || (path_fnamencmp(fname, S_LEN("help.")) == 0 + || (path_fnamencmp(fname, "help.", 5) == 0 && ASCII_ISALPHA(fname[5]) && ASCII_ISALPHA(fname[6]) && TOLOWER_ASC(fname[7]) == 'x' @@ -1015,7 +1015,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool // Write the tags into the file. for (int i = 0; i < ga.ga_len; i++) { s = ((char **)ga.ga_data)[i]; - if (strncmp(s, S_LEN("help-tags\t")) == 0) { + if (strncmp(s, "help-tags\t", 10) == 0) { // help-tags entry was added in formatted form fputs(s, fd_tags); } else { @@ -1149,7 +1149,7 @@ void ex_helptags(exarg_T *eap) bool add_help_tags = false; // Check for ":helptags ++t {dir}". - if (strncmp(eap->arg, S_LEN("++t")) == 0 && ascii_iswhite(eap->arg[3])) { + if (strncmp(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) { add_help_tags = true; eap->arg = skipwhite(eap->arg + 3); } diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index cc9e606d1d..aa98983b63 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -1059,7 +1059,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } int from_id = syn_check_group(from_start, (size_t)(from_end - from_start)); - if (strncmp(to_start, S_LEN("NONE")) == 0) { + if (strncmp(to_start, "NONE", 4) == 0) { to_id = 0; } else { to_id = syn_check_group(to_start, (size_t)(to_end - to_start)); diff --git a/src/nvim/indent.c b/src/nvim/indent.c index a4964db465..66cb443e4d 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -782,20 +782,20 @@ bool briopt_check(win_T *wp) char *p = wp->w_p_briopt; while (*p != NUL) { // Note: Keep this in sync with p_briopt_values - if (strncmp(p, S_LEN("shift:")) == 0 + if (strncmp(p, "shift:", 6) == 0 && ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6]))) { p += 6; bri_shift = getdigits_int(&p, true, 0); - } else if (strncmp(p, S_LEN("min:")) == 0 && ascii_isdigit(p[4])) { + } else if (strncmp(p, "min:", 4) == 0 && ascii_isdigit(p[4])) { p += 4; bri_min = getdigits_int(&p, true, 0); - } else if (strncmp(p, S_LEN("sbr")) == 0) { + } else if (strncmp(p, "sbr", 3) == 0) { p += 3; bri_sbr = true; - } else if (strncmp(p, S_LEN("list:")) == 0) { + } else if (strncmp(p, "list:", 5) == 0) { p += 5; bri_list = (int)getdigits(&p, false, 0); - } else if (strncmp(p, S_LEN("column:")) == 0) { + } else if (strncmp(p, "column:", 7) == 0) { p += 7; bri_vcol = (int)getdigits(&p, false, 0); } diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index a2dffa4602..f7215d3d12 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -904,7 +904,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co } // Check for special <> keycodes, like "" if (do_special && ((flags & REPTERM_DO_LT) || ((end - src) >= 3 - && strncmp(src, S_LEN("")) != 0))) { + && strncmp(src, "", 4) != 0))) { // Change Func to K_SNR _Func. This name is used // for script-local user functions. // (room: 5 * 6 = 30 bytes; needed: 3 + + 1 <= 14) diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index d02c865328..167111f3ae 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -403,43 +403,43 @@ static int str_to_mapargs(const char *strargs, bool is_unmap, MapArguments *mapa // Accept , , , ,