aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp.c
diff options
context:
space:
mode:
authorDamián Silvani <munshkr@gmail.com>2014-07-20 13:15:21 -0300
committerDamián Silvani <munshkr@gmail.com>2014-08-14 23:06:52 -0300
commit9ea28e1903407e9d0b7674dca26163c7ff82600c (patch)
tree732834ba5b6902e60ea98a1acbee927126520e07 /src/nvim/regexp.c
parent6d4530979745aae216909f066c930893bbfbae81 (diff)
downloadrneovim-9ea28e1903407e9d0b7674dca26163c7ff82600c.tar.gz
rneovim-9ea28e1903407e9d0b7674dca26163c7ff82600c.tar.bz2
rneovim-9ea28e1903407e9d0b7674dca26163c7ff82600c.zip
vim-patch:7.4.293
Problem: It is not possible to ignore composing characters at a specific point in a pattern. Solution: Add the %C item. https://code.google.com/p/vim/source/detail?r=10fc95f48546f438648b8357062e93c9c2c0a377
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r--src/nvim/regexp.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index ba7e4eb2d3..193c68860d 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -258,6 +258,7 @@
#define RE_MARK 207 /* mark cmp Match mark position */
#define RE_VISUAL 208 /* Match Visual area */
+#define RE_COMPOSING 209 // any composing characters
/*
* Magic characters have a special meaning, they don't match literally.
@@ -2024,6 +2025,10 @@ static char_u *regatom(int *flagp)
ret = regnode(RE_VISUAL);
break;
+ case 'C':
+ ret = regnode(RE_COMPOSING);
+ break;
+
/* \%[abc]: Emit as a list of branches, all ending at the last
* branch which matches nothing. */
case '[':
@@ -4099,10 +4104,12 @@ regmatch (
status = RA_NOMATCH;
}
}
- // Check for following composing character.
+ // Check for following composing character, unless %C
+ // follows (skips over all composing chars).
if (status != RA_NOMATCH && enc_utf8
&& UTF_COMPOSINGLIKE(reginput, reginput + len)
- && !ireg_icombine) {
+ && !ireg_icombine
+ && OP(next) != RE_COMPOSING) {
// raaron: This code makes a composing character get
// ignored, which is the correct behavior (sometimes)
// for voweled Hebrew texts.
@@ -4167,6 +4174,15 @@ regmatch (
status = RA_NOMATCH;
break;
+ case RE_COMPOSING:
+ if (enc_utf8) {
+ // Skip composing characters.
+ while (utf_iscomposing(utf_ptr2char(reginput))) {
+ mb_cptr_adv(reginput);
+ }
+ }
+ break;
+
case NOTHING:
break;