diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-05-31 22:14:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-05-31 22:14:52 +0200 |
commit | 4b78063368eca61c8c8991d3c9afc18d5a474b82 (patch) | |
tree | 43b7195c65e86e80fd5b6627a9b7a4ba99e2868e | |
parent | 14f55c6f67b55b693d0689beb66af90f53589a77 (diff) | |
download | vim-4b78063368eca61c8c8991d3c9afc18d5a474b82.zip |
updated for version 7.3.1083
Problem: New regexp engine: Does not support \%^ and \%$.
Solution: Support matching start and end of file.
-rw-r--r-- | src/regexp_nfa.c | 17 | ||||
-rw-r--r-- | src/testdir/test64.in | 18 | ||||
-rw-r--r-- | src/testdir/test64.ok | 28 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 61 insertions, 4 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 69370ace2..6a80bcc57 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -865,14 +865,10 @@ nfa_regatom() * pattern -- regardless of whether or not it makes sense. */ case '^': EMIT(NFA_BOF); - /* TODO: Not yet supported */ - return FAIL; break; case '$': EMIT(NFA_EOF); - /* TODO: Not yet supported */ - return FAIL; break; case '#': @@ -1780,6 +1776,8 @@ nfa_set_code(c) case NFA_BOL: STRCPY(code, "NFA_BOL "); break; case NFA_EOW: STRCPY(code, "NFA_EOW "); break; case NFA_BOW: STRCPY(code, "NFA_BOW "); break; + case NFA_EOF: STRCPY(code, "NFA_EOF "); break; + case NFA_BOF: STRCPY(code, "NFA_BOF "); break; case NFA_STAR: STRCPY(code, "NFA_STAR "); break; case NFA_PLUS: STRCPY(code, "NFA_PLUS "); break; case NFA_NOT: STRCPY(code, "NFA_NOT "); break; @@ -3705,6 +3703,17 @@ nfa_regmatch(start, submatch, m) break; } + case NFA_BOF: + if (reglnum == 0 && reginput == regline + && (!REG_MULTI || reg_firstlnum == 1)) + addstate_here(thislist, t->state->out, &t->sub, &listidx); + break; + + case NFA_EOF: + if (reglnum == reg_maxline && curc == NUL) + addstate_here(thislist, t->state->out, &t->sub, &listidx); + break; + #ifdef FEAT_MBYTE case NFA_COMPOSING: { diff --git a/src/testdir/test64.in b/src/testdir/test64.in index 45a71d261..dffcf52b3 100644 --- a/src/testdir/test64.in +++ b/src/testdir/test64.in @@ -267,6 +267,15 @@ STARTTEST :call add(tl, [2, '\_f', " \na ", "\n"]) :call add(tl, [2, '\_f\+', " \na ", "\na"]) :" +:"""" Test start/end of line, start/end of file +:call add(tl, [2, '^a.', "a_\nb ", "a_"]) +:call add(tl, [2, '^a.', "b a \na_"]) +:call add(tl, [2, '.a$', " a\n "]) +:call add(tl, [2, '.a$', " a b\n_a", "_a"]) +:call add(tl, [2, '\%^a.', "a a\na", "a "]) +:call add(tl, [2, '\%^a', " a \na "]) +:call add(tl, [2, '.a\%$', " a\n "]) +:call add(tl, [2, '.a\%$', " a\n_a", "_a"]) :" :"""" Test recognition of some character classes :call add(tl, [2, '[0-9]', '8', '8']) @@ -466,6 +475,15 @@ o-2-:set re=2 :call Postest() :put :" +:" start and end of buffer +/\%^ +yeGop:" +50%/\%^.. +yeGopA END:" +50%/\%$ +"ayb20gg/..\%$ +"bybGo"apo"bp:" +:" :/\%#=1^Results/,$wq! test.out ENDTEST diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok index 2f96073cf..5a13e060a 100644 --- a/src/testdir/test64.ok +++ b/src/testdir/test64.ok @@ -585,6 +585,30 @@ OK 2 - \_f OK 0 - \_f\+ OK 1 - \_f\+ OK 2 - \_f\+ +OK 0 - ^a. +OK 1 - ^a. +OK 2 - ^a. +OK 0 - ^a. +OK 1 - ^a. +OK 2 - ^a. +OK 0 - .a$ +OK 1 - .a$ +OK 2 - .a$ +OK 0 - .a$ +OK 1 - .a$ +OK 2 - .a$ +OK 0 - \%^a. +OK 1 - \%^a. +OK 2 - \%^a. +OK 0 - \%^a +OK 1 - \%^a +OK 2 - \%^a +OK 0 - .a\%$ +OK 1 - .a\%$ +OK 2 - .a\%$ +OK 0 - .a\%$ +OK 1 - .a\%$ +OK 2 - .a\%$ OK 0 - [0-9] OK 1 - [0-9] OK 2 - [0-9] @@ -818,3 +842,7 @@ moooooo ab!babababababfoo ba!ab##abab?bafoo **!*****_ +Test +Test END +EN +E diff --git a/src/version.c b/src/version.c index 8db4fb4ce..4038f0d44 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1083, +/**/ 1082, /**/ 1081, |