Mercurial > vim
comparison src/search.c @ 25457:b95f9cc3d1b9 v8.2.3265
patch 8.2.3265: smartcase does not work correctly in very magic pattern
Commit: https://github.com/vim/vim/commit/78ba933d18439ff1a02f6be4c571e73ddceb3cd4
Author: Christian Brabandt <cb@256bit.org>
Date: Sun Aug 1 12:44:37 2021 +0200
patch 8.2.3265: smartcase does not work correctly in very magic pattern
Problem: Smartcase does not work correctly in very magic pattern.
Solution: Take the magicness into account when skipping over regexp items.
(Christian Brabandt, closes #8682, closes #7845)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Aug 2021 12:45:03 +0200 |
parents | d4a710f06f02 |
children | a6eea433586b |
comparison
equal
deleted
inserted
replaced
25456:b6b6400dee89 | 25457:b95f9cc3d1b9 |
---|---|
428 */ | 428 */ |
429 int | 429 int |
430 pat_has_uppercase(char_u *pat) | 430 pat_has_uppercase(char_u *pat) |
431 { | 431 { |
432 char_u *p = pat; | 432 char_u *p = pat; |
433 magic_T magic_val = MAGIC_ON; | |
434 | |
435 // get the magicness of the pattern | |
436 (void)skip_regexp_ex(pat, NUL, magic_isset(), NULL, NULL, &magic_val); | |
433 | 437 |
434 while (*p != NUL) | 438 while (*p != NUL) |
435 { | 439 { |
436 int l; | 440 int l; |
437 | 441 |
439 { | 443 { |
440 if (enc_utf8 && utf_isupper(utf_ptr2char(p))) | 444 if (enc_utf8 && utf_isupper(utf_ptr2char(p))) |
441 return TRUE; | 445 return TRUE; |
442 p += l; | 446 p += l; |
443 } | 447 } |
444 else if (*p == '\\') | 448 else if (*p == '\\' && magic_val == MAGIC_ON) |
445 { | 449 { |
446 if (p[1] == '_' && p[2] != NUL) // skip "\_X" | 450 if (p[1] == '_' && p[2] != NUL) // skip "\_X" |
447 p += 3; | 451 p += 3; |
448 else if (p[1] == '%' && p[2] != NUL) // skip "\%X" | 452 else if (p[1] == '%' && p[2] != NUL) // skip "\%X" |
449 p += 3; | 453 p += 3; |
450 else if (p[1] != NUL) // skip "\X" | 454 else if (p[1] != NUL) // skip "\X" |
451 p += 2; | 455 p += 2; |
452 else | 456 else |
453 p += 1; | 457 p += 1; |
458 } | |
459 else if ((*p == '%' || *p == '_') && magic_val == MAGIC_ALL) | |
460 { | |
461 if (p[1] != NUL) // skip "_X" and %X | |
462 p += 2; | |
454 } | 463 } |
455 else if (MB_ISUPPER(*p)) | 464 else if (MB_ISUPPER(*p)) |
456 return TRUE; | 465 return TRUE; |
457 else | 466 else |
458 ++p; | 467 ++p; |