changeset 4671:b3c59716e700 v7.3.1083

updated for version 7.3.1083 Problem: New regexp engine: Does not support \%^ and \%$. Solution: Support matching start and end of file.
author Bram Moolenaar <bram@vim.org>
date Fri, 31 May 2013 22:14:52 +0200
parents 053beb7bf8ba
children eada32f930a3
files src/regexp_nfa.c src/testdir/test64.in src/testdir/test64.ok src/version.c
diffstat 4 files changed, 61 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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:
 	    {
--- 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
 
--- 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
--- 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,