Mercurial > vim
comparison src/regexp.c @ 23505:bb29b09902d5 v8.2.2295
patch 8.2.2295: incsearch does not detect empty pattern properly
Commit: https://github.com/vim/vim/commit/d93a7fc1a98a58f8101ee780d4735079ad99ae35
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 4 12:42:13 2021 +0100
patch 8.2.2295: incsearch does not detect empty pattern properly
Problem: Incsearch does not detect empty pattern properly.
Solution: Return magic state when skipping over a pattern. (Christian
Brabandt, closes #7612, closes #6420)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 04 Jan 2021 12:45:05 +0100 |
parents | a7cdfc8e4b6e |
children | f293bb501b30 |
comparison
equal
deleted
inserted
replaced
23504:25d5c354a83e | 23505:bb29b09902d5 |
---|---|
302 static unsigned regflags; // RF_ flags for prog | 302 static unsigned regflags; // RF_ flags for prog |
303 #if defined(FEAT_SYN_HL) || defined(PROTO) | 303 #if defined(FEAT_SYN_HL) || defined(PROTO) |
304 static int had_eol; // TRUE when EOL found by vim_regcomp() | 304 static int had_eol; // TRUE when EOL found by vim_regcomp() |
305 #endif | 305 #endif |
306 | 306 |
307 static int reg_magic; // magicness of the pattern: | 307 static magic_T reg_magic; // magicness of the pattern |
308 #define MAGIC_NONE 1 // "\V" very unmagic | |
309 #define MAGIC_OFF 2 // "\M" or 'magic' off | |
310 #define MAGIC_ON 3 // "\m" or 'magic' | |
311 #define MAGIC_ALL 4 // "\v" very magic | |
312 | 308 |
313 static int reg_string; // matching with a string instead of a buffer | 309 static int reg_string; // matching with a string instead of a buffer |
314 // line | 310 // line |
315 static int reg_strict; // "[abc" is illegal | 311 static int reg_strict; // "[abc" is illegal |
316 | 312 |
546 skip_regexp( | 542 skip_regexp( |
547 char_u *startp, | 543 char_u *startp, |
548 int delim, | 544 int delim, |
549 int magic) | 545 int magic) |
550 { | 546 { |
551 return skip_regexp_ex(startp, delim, magic, NULL, NULL); | 547 return skip_regexp_ex(startp, delim, magic, NULL, NULL, NULL); |
552 } | 548 } |
553 | 549 |
554 /* | 550 /* |
555 * Call skip_regexp() and when the delimiter does not match give an error and | 551 * Call skip_regexp() and when the delimiter does not match give an error and |
556 * return NULL. | 552 * return NULL. |
575 * skip_regexp() with extra arguments: | 571 * skip_regexp() with extra arguments: |
576 * When "newp" is not NULL and "dirc" is '?', make an allocated copy of the | 572 * When "newp" is not NULL and "dirc" is '?', make an allocated copy of the |
577 * expression and change "\?" to "?". If "*newp" is not NULL the expression | 573 * expression and change "\?" to "?". If "*newp" is not NULL the expression |
578 * is changed in-place. | 574 * is changed in-place. |
579 * If a "\?" is changed to "?" then "dropped" is incremented, unless NULL. | 575 * If a "\?" is changed to "?" then "dropped" is incremented, unless NULL. |
576 * If "magic_val" is not NULL, returns the effective magicness of the pattern | |
580 */ | 577 */ |
581 char_u * | 578 char_u * |
582 skip_regexp_ex( | 579 skip_regexp_ex( |
583 char_u *startp, | 580 char_u *startp, |
584 int dirc, | 581 int dirc, |
585 int magic, | 582 int magic, |
586 char_u **newp, | 583 char_u **newp, |
587 int *dropped) | 584 int *dropped, |
588 { | 585 magic_T *magic_val) |
589 int mymagic; | 586 { |
587 magic_T mymagic; | |
590 char_u *p = startp; | 588 char_u *p = startp; |
591 | 589 |
592 if (magic) | 590 if (magic) |
593 mymagic = MAGIC_ON; | 591 mymagic = MAGIC_ON; |
594 else | 592 else |
630 mymagic = MAGIC_ALL; | 628 mymagic = MAGIC_ALL; |
631 else if (*p == 'V') | 629 else if (*p == 'V') |
632 mymagic = MAGIC_NONE; | 630 mymagic = MAGIC_NONE; |
633 } | 631 } |
634 } | 632 } |
633 if (magic_val != NULL) | |
634 *magic_val = mymagic; | |
635 return p; | 635 return p; |
636 } | 636 } |
637 | 637 |
638 /* | 638 /* |
639 * Functions for getting characters from the regexp input. | 639 * Functions for getting characters from the regexp input. |