aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/regexp_bt.c4
-rw-r--r--src/nvim/regexp_nfa.c4
-rw-r--r--src/nvim/testdir/test_regexp_latin.vim15
3 files changed, 20 insertions, 3 deletions
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c
index bde2962d3b..f0efd06cc0 100644
--- a/src/nvim/regexp_bt.c
+++ b/src/nvim/regexp_bt.c
@@ -2091,6 +2091,7 @@ static char_u *regatom(int *flagp)
uint32_t n = 0;
int cmp;
bool cur = false;
+ bool got_digit = false;
cmp = c;
if (cmp == '<' || cmp == '>') {
@@ -2101,6 +2102,7 @@ static char_u *regatom(int *flagp)
c = getchr();
}
while (ascii_isdigit(c)) {
+ got_digit = true;
n = n * 10 + (uint32_t)(c - '0');
c = getchr();
}
@@ -2115,7 +2117,7 @@ static char_u *regatom(int *flagp)
*regcode++ = (char_u)cmp;
}
break;
- } else if (c == 'l' || c == 'c' || c == 'v') {
+ } else if ((c == 'l' || c == 'c' || c == 'v') && (cur || got_digit)) {
if (cur && n) {
semsg(_(e_regexp_number_after_dot_pos_search_chr), no_Magic(c));
rc_did_emsg = true;
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index a2f4e209f1..c93164ed7e 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -2141,6 +2141,7 @@ static int nfa_regatom(void)
int64_t n = 0;
const int cmp = c;
bool cur = false;
+ bool got_digit = false;
if (c == '<' || c == '>') {
c = getchr();
@@ -2161,11 +2162,12 @@ static int nfa_regatom(void)
}
n = n * 10 + (c - '0');
c = getchr();
+ got_digit = true;
}
if (c == 'l' || c == 'c' || c == 'v') {
int32_t limit = INT32_MAX;
- if (!cur && n == 0) {
+ if (!cur && !got_digit) {
semsg(_(e_nfa_regexp_missing_value_in_chr), no_Magic(c));
return FAIL;
}
diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim
index 2671313997..5312c6f26a 100644
--- a/src/nvim/testdir/test_regexp_latin.vim
+++ b/src/nvim/testdir/test_regexp_latin.vim
@@ -105,16 +105,29 @@ func Test_multi_failure()
set re=0
endfunc
-func Test_column_failure()
+func Test_column_success_failure()
+ new
+ call setline(1, 'xbar')
+
set re=1
+ %s/\%>0v./A/
+ call assert_equal('Abar', getline(1))
call assert_fails('/\%v', 'E71:')
+ call assert_fails('/\%>v', 'E71:')
call assert_fails('/\%c', 'E71:')
+ call assert_fails('/\%<c', 'E71:')
call assert_fails('/\%l', 'E71:')
set re=2
+ %s/\%>0v./B/
+ call assert_equal('Bbar', getline(1))
call assert_fails('/\%v', 'E1273:')
+ call assert_fails('/\%>v', 'E1273:')
call assert_fails('/\%c', 'E1273:')
+ call assert_fails('/\%<c', 'E1273:')
call assert_fails('/\%l', 'E1273:')
+
set re=0
+ bwipe!
endfunc
func Test_recursive_addstate()