Mercurial > vim
diff src/regexp_bt.c @ 34084:90063f44c99a v9.1.0011
patch 9.1.0011: regexp cannot match combining chars in collection
Commit: https://github.com/vim/vim/commit/d2cc51f9a1a5a30ef5d2e732f49d7f495cae24cf
Author: Christian Brabandt <cb@256bit.org>
Date: Thu Jan 4 22:54:08 2024 +0100
patch 9.1.0011: regexp cannot match combining chars in collection
Problem: regexp cannot match combining chars in collection
Solution: Check for combining characters in regex collections for the
NFA and BT Regex Engine
Also, while at it, make debug mode work again.
fixes #10286
closes: #12871
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 04 Jan 2024 23:00:04 +0100 |
parents | d415dfae6977 |
children | df52075b12cd |
line wrap: on
line diff
--- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -3743,13 +3743,38 @@ regmatch( case ANYOF: case ANYBUT: - if (c == NUL) - status = RA_NOMATCH; - else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF)) - status = RA_NOMATCH; - else - ADVANCE_REGINPUT(); - break; + { + char_u *q = OPERAND(scan); + + if (c == NUL) + status = RA_NOMATCH; + else if ((cstrchr(q, c) == NULL) == (op == ANYOF)) + status = RA_NOMATCH; + else + { + // Check following combining characters + int len = 0; + int i; + + if (enc_utf8) + len = utfc_ptr2len(q) - utf_ptr2len(q); + + MB_CPTR_ADV(rex.input); + MB_CPTR_ADV(q); + + if (!enc_utf8 || len == 0) + break; + + for (i = 0; i < len; ++i) + if (q[i] != rex.input[i]) + { + status = RA_NOMATCH; + break; + } + rex.input += len; + } + break; + } case MULTIBYTECODE: if (has_mbyte)