Hi Bram!
On Fr, 12 Feb 2016, Bram Moolenaar wrote:
>
> Christian Brabandt wrote:
>
> > 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.
>
> When I include the test change, the test hangs.
I do not see this. Or is this a different test that hangs?
Hm, with a missing +eval, the test fails. Anyhow, here is the patch with
a test, that has the line numbers hardwired.
Best,
Christian
--
Letzte Worte des Bungee-Jumpers:
"Ist das Seil nicht zu lang?"
--
--
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
@@ -1501,6 +1501,10 @@ vim_regcomp_had_eol(void)
}
#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.
*
@@ -1919,6 +1923,7 @@ regatom(int *flagp)
int c;
char_u *p;
int extra = 0;
+ int prevprev_at_start = prev_at_start;
*flagp = WORST; /* Tentatively. */
@@ -2332,7 +2337,11 @@ regatom(int *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
@@ -2947,10 +2956,6 @@ regoptail(char_u *p, char_u *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
@@ -1129,6 +1129,7 @@ nfa_regatom(void)
int startc = -1;
int endc = -1;
int oldstartc = -1;
+ int prevprev_at_start = prev_at_start;
c = getchr();
switch (c)
@@ -1468,9 +1469,13 @@ nfa_regatom(void)
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\%204l^\t...//g
+p:s/\%#=1\%205l^\t...//g
+p:s/\%#=2\%206l^\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{|}~¦±¼ÇÓé