From: Doug Kearns Date: Sun, 21 Jun 2026 13:31:40 +0000 (+0000) Subject: patch 9.2.0686: style: strcmp usage is inconsistent X-Git-Tag: v9.2.0686^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a155327d830ac2df751b1b59d0639a0c3cfbf1e;p=thirdparty%2Fvim.git patch 9.2.0686: style: strcmp usage is inconsistent Problem: style: strcmp usage is inconsistent. Solution: Always explicitly test the return value, matching the dominant style. closes: #19101 Signed-off-by: Doug Kearns Signed-off-by: Christian Brabandt --- diff --git a/src/channel.c b/src/channel.c index cfbfcb2bec..d7fa3bd2c7 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1308,7 +1308,7 @@ channel_parse_socketserver_address( if (*address == NUL) goto fail; - if (!STRNCMP(address, "unix:", 5)) + if (STRNCMP(address, "unix:", 5) == 0) { *unix_path = vim_strsave(address + 5); return OK; @@ -1361,7 +1361,7 @@ channel_open_func(typval_T *argvars) return NULL; } - if (!STRNCMP(address, "unix:", 5)) + if (STRNCMP(address, "unix:", 5) == 0) { is_unix = TRUE; address += 5; @@ -1458,7 +1458,7 @@ channel_listen_func(typval_T *argvars) return NULL; } - if (!STRNCMP(arg, "unix:", 5)) + if (STRNCMP(arg, "unix:", 5) == 0) { is_unix = TRUE; arg += 5; diff --git a/src/cindent.c b/src/cindent.c index fa8059509e..6bea836e2e 100644 --- a/src/cindent.c +++ b/src/cindent.c @@ -748,7 +748,7 @@ cin_is_compound_init(char_u *s) { if (*p == '=') p = r = cin_skipcomment(p + 1); - else if (!STRNCMP(p, "return", 6) && !vim_isIDc(p[6]) + else if (STRNCMP(p, "return", 6) == 0 && !vim_isIDc(p[6]) && (p == s || (p > s && !vim_isIDc(p[-1])))) p = r = cin_skipcomment(p + 6); else @@ -1424,19 +1424,19 @@ cin_is_if_for_while_before_offset(char_u *line, int *poffset) --offset; offset -= 1; - if (!STRNCMP(line + offset, "if", 2)) + if (STRNCMP(line + offset, "if", 2) == 0) goto probablyFound; if (offset >= 1) { offset -= 1; - if (!STRNCMP(line + offset, "for", 3)) + if (STRNCMP(line + offset, "for", 3) == 0) goto probablyFound; if (offset >= 2) { offset -= 2; - if (!STRNCMP(line + offset, "while", 5)) + if (STRNCMP(line + offset, "while", 5) == 0) goto probablyFound; } } diff --git a/src/gui_w32.c b/src/gui_w32.c index d84190091c..077ca9c1f7 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -9113,11 +9113,11 @@ gui_mch_register_sign(char_u *signfile) { int do_load = 1; - if (!STRICMP(ext, ".bmp")) + if (STRICMP(ext, ".bmp") == 0) sign.uType = IMAGE_BITMAP; - else if (!STRICMP(ext, ".ico")) + else if (STRICMP(ext, ".ico") == 0) sign.uType = IMAGE_ICON; - else if (!STRICMP(ext, ".cur") || !STRICMP(ext, ".ani")) + else if (STRICMP(ext, ".cur") == 0 || STRICMP(ext, ".ani") == 0) sign.uType = IMAGE_CURSOR; else do_load = 0; @@ -9127,7 +9127,7 @@ gui_mch_register_sign(char_u *signfile) gui.char_width * 2, gui.char_height, LR_LOADFROMFILE | LR_CREATEDIBSECTION); # ifdef FEAT_XPM_W32 - if (!STRICMP(ext, ".xpm")) + if (STRICMP(ext, ".xpm") == 0) { sign.uType = IMAGE_XPM; LoadXpmImage((char *)signfile, (HBITMAP *)&sign.hImage, diff --git a/src/hardcopy.c b/src/hardcopy.c index 2eb63ea588..10c3beb8f1 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -1959,7 +1959,7 @@ prt_open_resource(struct prt_ps_resource_S *resource) prt_check_resource(struct prt_ps_resource_S *resource, char_u *version) { // Version number m.n should match, the revision number does not matter - if (STRNCMP(resource->version, version, STRLEN(version))) + if (STRNCMP(resource->version, version, STRLEN(version)) != 0) { semsg(_(e_str_resource_file_has_wrong_version), resource->name); diff --git a/src/map.c b/src/map.c index 5970b3f5a5..b19f747d0c 100644 --- a/src/map.c +++ b/src/map.c @@ -1554,7 +1554,7 @@ ExpandMappings( while (ptr2 < ptr3) { - if (STRCMP(*ptr1, *ptr2)) + if (STRCMP(*ptr1, *ptr2) != 0) *++ptr1 = *ptr2++; else { @@ -1694,7 +1694,7 @@ check_abbr( // find entries with right mode and keys match = (mp->m_mode & State) && qlen == len - && !STRNCMP(q, ptr, (size_t)len); + && STRNCMP(q, ptr, (size_t)len) == 0; if (q != mp->m_keys) vim_free(q); if (match) diff --git a/src/message.c b/src/message.c index b0d09f6da6..de56ddcb93 100644 --- a/src/message.c +++ b/src/message.c @@ -174,7 +174,7 @@ msg_attr_keep( || (*s != '<' && last_msg_hist != NULL && last_msg_hist->msg != NULL - && STRCMP(s, last_msg_hist->msg))) + && STRCMP(s, last_msg_hist->msg) != 0)) add_msg_hist((char_u *)s, -1, attr); #ifdef FEAT_EVAL diff --git a/src/misc1.c b/src/misc1.c index 88e872d766..c09ae81275 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -316,7 +316,7 @@ get_last_leader_offset(char_u *line, char_u **flags) for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;) { --off; - if (!STRNCMP(string + off, com_leader, len2 - off)) + if (STRNCMP(string + off, com_leader, len2 - off) == 0) { if (i - off < lower_check_bound) lower_check_bound = i - off; diff --git a/src/search.c b/src/search.c index 12977dc8fa..e60f2d7b43 100644 --- a/src/search.c +++ b/src/search.c @@ -3816,9 +3816,9 @@ search_line: // compare the first "len" chars from "ptr" startp = skipwhite(p); if (p_ic) - matched = !MB_STRNICMP(startp, ptr, len); + matched = MB_STRNICMP(startp, ptr, len) == 0; else - matched = !STRNCMP(startp, ptr, len); + matched = STRNCMP(startp, ptr, len) == 0; if (matched && define_matched && whole && vim_iswordc(startp[len])) matched = FALSE; diff --git a/src/tag.c b/src/tag.c index 24d33bc11d..0e9d9344bf 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1535,23 +1535,23 @@ find_tagfunc_tags( continue; len += (int)STRLEN(tv->vval.v_string) + 1; // Space for "\tVALUE" - if (!STRCMP(dict_key, "name")) + if (STRCMP(dict_key, "name") == 0) { res_name = tv->vval.v_string; continue; } - if (!STRCMP(dict_key, "filename")) + if (STRCMP(dict_key, "filename") == 0) { res_fname = tv->vval.v_string; continue; } - if (!STRCMP(dict_key, "cmd")) + if (STRCMP(dict_key, "cmd") == 0) { res_cmd = tv->vval.v_string; continue; } has_extra = 1; - if (!STRCMP(dict_key, "kind")) + if (STRCMP(dict_key, "kind") == 0) { res_kind = tv->vval.v_string; continue; @@ -1617,13 +1617,13 @@ find_tagfunc_tags( if (tv->v_type != VAR_STRING || tv->vval.v_string == NULL) continue; - if (!STRCMP(dict_key, "name")) + if (STRCMP(dict_key, "name") == 0) continue; - if (!STRCMP(dict_key, "filename")) + if (STRCMP(dict_key, "filename") == 0) continue; - if (!STRCMP(dict_key, "cmd")) + if (STRCMP(dict_key, "cmd") == 0) continue; - if (!STRCMP(dict_key, "kind")) + if (STRCMP(dict_key, "kind") == 0) continue; *p++ = TAB; diff --git a/src/version.c b/src/version.c index 3f925d1475..c640b1c60c 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 686, /**/ 685, /**/