vim-patch:9.1.1700: Multiline ignorecase specific pattern does not match with 'ignorecase' (#35520)

Problem:  a pattern that involves a backref on a different line does not
          match when 'ignorecase' is set (QiWei, after v9.1.0645)
Solution: Use MB_STRNICMP when ignorecase is set, fix tests to close
          swapfiles

related: vim/vim#14756
fixes: vim/vim#17470
closes: vim/vim#18104

bf82e58a70

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 24020ef2dd)
This commit is contained in:
zeertzjq
2025-08-28 07:35:22 +08:00
committed by github-actions[bot]
parent 4c5cb950c6
commit 99817471d7
2 changed files with 23 additions and 5 deletions

View File

@@ -1582,6 +1582,7 @@ static void reg_nextline(void)
// Returns RA_FAIL, RA_NOMATCH or RA_MATCH.
// If "bytelen" is not NULL, it is set to the byte length of the match in the
// last line.
// Optional: ignore case if rex.reg_ic is set.
static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T end_lnum,
colnr_T end_col, int *bytelen)
{
@@ -1619,7 +1620,8 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
len = reg_getline_len(clnum) - ccol;
}
if (cstrncmp(p + ccol, (char *)rex.input, &len) != 0) {
if ((!rex.reg_ic && cstrncmp(p + ccol, (char *)rex.input, &len) != 0)
|| (rex.reg_ic && mb_strnicmp(p + ccol, (char *)rex.input, (size_t)len) != 0)) {
return RA_NOMATCH; // doesn't match
}
if (bytelen != NULL) {