On Di, 19 Jan 2016, Bram Moolenaar wrote:

> Christian Brabandt wrote:
> 
> > Hi,
> > consider this file:
> > 
> > #v+
> > ~$ cat file
> > # first comment line
> > # second comment line
> > ~$ vim -u NONE -N file
> > :set hls
> > /^\%1l#.*
> > (this matches the first line)
> > /\%1l^#.*
> > (this does not match the first line)
> > /^#.*\%1l
> > (this matches the first line)
> > #v-
> > 
> > The 'regexpengine' setting does not matter, both engines seem to behave 
> > the same, however I find it kind of unexpected, that the second search 
> > term does not match.
> 
> It looks like the zero-width match clears the flag that the current
> position is at the start of the line.  I would call that a bug.

Yes you are right and I wouldn't bet the problem only occurs here.
However here is a patch.

Best,
Christian
-- 
"Blasen ist nicht flöten; ihr müsst die Finger bewegen."
                -- Goethe, Maximen und Reflektionen, Nr. 44

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/regexp.c b/src/regexp.c
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -1515,6 +1515,10 @@ vim_regcomp_had_eol()
 }
 #endif
 
+/* variables for parsing reginput */
+static int	at_start;	/* True when on the first character */
+static int	prev_at_start;  /* True when on the second character */
+
 /*
  * Parse regular expression, i.e. main body or parenthesized thing.
  *
@@ -1937,6 +1941,7 @@ regatom(flagp)
     int		    c;
     char_u	    *p;
     int		    extra = 0;
+    int		    prevprev_at_start = prev_at_start;
 
     *flagp = WORST;		/* Tentatively. */
 
@@ -2350,7 +2355,11 @@ regatom(flagp)
 			      else if (c == 'l' || c == 'c' || c == 'v')
 			      {
 				  if (c == 'l')
+				  {
 				      ret = regnode(RE_LNUM);
+				      if (prevprev_at_start)
+					  at_start = TRUE;
+				  }
 				  else if (c == 'c')
 				      ret = regnode(RE_COL);
 				  else
@@ -2980,10 +2989,6 @@ regoptail(p, val)
 /*
  * Functions for getting characters from the regexp input.
  */
-
-static int	at_start;	/* True when on the first character */
-static int	prev_at_start;  /* True when on the second character */
-
 /*
  * Start parsing at "str".
  */
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -1138,6 +1138,7 @@ nfa_regatom()
     int		startc = -1;
     int		endc = -1;
     int		oldstartc = -1;
+    int		prevprev_at_start = prev_at_start;
 
     c = getchr();
     switch (c)
@@ -1477,9 +1478,13 @@ nfa_regatom()
 			if (c == 'l' || c == 'c' || c == 'v')
 			{
 			    if (c == 'l')
+			    {
 				/* \%{n}l  \%{n}<l  \%{n}>l  */
 				EMIT(cmp == '<' ? NFA_LNUM_LT :
 				     cmp == '>' ? NFA_LNUM_GT : NFA_LNUM);
+				if (prevprev_at_start)
+				    at_start = TRUE;
+			    }
 			    else if (c == 'c')
 				/* \%{n}c  \%{n}<c  \%{n}>c  */
 				EMIT(cmp == '<' ? NFA_COL_LT :
diff --git a/src/testdir/test36.in b/src/testdir/test36.in
--- a/src/testdir/test36.in
+++ b/src/testdir/test36.in
@@ -98,6 +98,9 @@ p:s/\%#=2\U//g
 p:s/\%#=0[^A-Z]//g
 p:s/\%#=1[^A-Z]//g
 p:s/\%#=2[^A-Z]//g
+p:s/\%#=0\%=line('.')
l^\t...//g
+p:s/\%#=1\%=line('.')
l^\t...//g
+p:s/\%#=2\%=line('.')
l^\t...//g
 :/^start-here/+1,$wq! test.out
 ENDTEST
 
diff --git a/src/testdir/test36.ok b/src/testdir/test36.ok
--- a/src/testdir/test36.ok
+++ b/src/testdir/test36.ok
@@ -94,3 +94,6 @@ ABCDEFGHIXYZ
 ABCDEFGHIXYZ
 ABCDEFGHIXYZ
 ABCDEFGHIXYZ
+!"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~€‚›¦±¼ÇÓé
+!"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~€‚›¦±¼ÇÓé
+!"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~€‚›¦±¼ÇÓé

Raspunde prin e-mail lui