vim-patch:9.1.1395: search_stat not reset when pattern differs in case (#34058)

Problem:  search_stat not reset when pattern differs in case
          (tahzibijafar)
Solution: use STRNCMP instead of MB_STRNICMP macro

There was a long standing todo comment, that using MB_STRNICMP is wrong.
So let's change it to STRNCMP() instead. Even if it not handle
multi-byte characters correctly, then Vim will rather recompute the
search stat, instead of re-using the old (and possibly wrong) value.

fixes: vim/vim#17312
closes: vim/vim#17314

670d0c1468

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-05-17 07:47:20 +08:00
committed by GitHub
parent 6af1b7e5e8
commit ec5f054dc9
3 changed files with 44 additions and 4 deletions

View File

@@ -2724,12 +2724,9 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst
|| (dirc == '/' && lt(p, lastpos)));
// If anything relevant changed the count has to be recomputed.
// STRNICMP ignores case, but we should not ignore case.
// Unfortunately, there is no STRNICMP function.
// XXX: above comment should be "no MB_STRCMP function" ?
if (!(chgtick == buf_get_changedtick(curbuf)
&& (lastpat != NULL // suppress clang/NULL passed as nonnull parameter
&& mb_strnicmp(lastpat, spats[last_idx].pat, lastpatlen) == 0
&& strncmp(lastpat, spats[last_idx].pat, lastpatlen) == 0
&& lastpatlen == spats[last_idx].patlen)
&& equalpos(lastpos, *cursor_pos)
&& lbuf == curbuf)