Skip to content

Commit 7c29f38

Browse files
committed
patch 7.4.1305
Problem: "\%1l^#.*" does not match on a line starting with "#". Solution: Do not clear the start-of-line flag. (Christian Brabandt)
1 parent 7823a3b commit 7c29f38

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/regexp.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,10 @@ vim_regcomp_had_eol(void)
15001500
}
15011501
#endif
15021502

1503+
/* variables for parsing reginput */
1504+
static int at_start; /* True when on the first character */
1505+
static int prev_at_start; /* True when on the second character */
1506+
15031507
/*
15041508
* Parse regular expression, i.e. main body or parenthesized thing.
15051509
*
@@ -1918,6 +1922,7 @@ regatom(int *flagp)
19181922
int c;
19191923
char_u *p;
19201924
int extra = 0;
1925+
int save_prev_at_start = prev_at_start;
19211926

19221927
*flagp = WORST; /* Tentatively. */
19231928

@@ -2331,7 +2336,11 @@ regatom(int *flagp)
23312336
else if (c == 'l' || c == 'c' || c == 'v')
23322337
{
23332338
if (c == 'l')
2339+
{
23342340
ret = regnode(RE_LNUM);
2341+
if (save_prev_at_start)
2342+
at_start = TRUE;
2343+
}
23352344
else if (c == 'c')
23362345
ret = regnode(RE_COL);
23372346
else
@@ -2946,10 +2955,6 @@ regoptail(char_u *p, char_u *val)
29462955
/*
29472956
* Functions for getting characters from the regexp input.
29482957
*/
2949-
2950-
static int at_start; /* True when on the first character */
2951-
static int prev_at_start; /* True when on the second character */
2952-
29532958
/*
29542959
* Start parsing at "str".
29552960
*/

src/regexp_nfa.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ nfa_regatom(void)
11281128
int startc = -1;
11291129
int endc = -1;
11301130
int oldstartc = -1;
1131+
int save_prev_at_start = prev_at_start;
11311132

11321133
c = getchr();
11331134
switch (c)
@@ -1467,9 +1468,13 @@ nfa_regatom(void)
14671468
if (c == 'l' || c == 'c' || c == 'v')
14681469
{
14691470
if (c == 'l')
1471+
{
14701472
/* \%{n}l \%{n}<l \%{n}>l */
14711473
EMIT(cmp == '<' ? NFA_LNUM_LT :
14721474
cmp == '>' ? NFA_LNUM_GT : NFA_LNUM);
1475+
if (save_prev_at_start)
1476+
at_start = TRUE;
1477+
}
14731478
else if (c == 'c')
14741479
/* \%{n}c \%{n}<c \%{n}>c */
14751480
EMIT(cmp == '<' ? NFA_COL_LT :

src/testdir/test36.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ p:s/\%#=2\U//g
9898
p:s/\%#=0[^A-Z]//g
9999
p:s/\%#=1[^A-Z]//g
100100
p:s/\%#=2[^A-Z]//g
101+
p:s/\%#=0\%204l^\t...//g
102+
p:s/\%#=1\%205l^\t...//g
103+
p:s/\%#=2\%206l^\t...//g
101104
:/^start-here/+1,$wq! test.out
102105
ENDTEST
103106

src/testdir/test36.ok

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ ABCDEFGHIXYZ
9494
ABCDEFGHIXYZ
9595
ABCDEFGHIXYZ
9696
ABCDEFGHIXYZ
97+
!"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~����������
98+
!"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~����������
99+
!"#$%&'()#+'-./0123456789:;<=>?@ABCDEFGHIXYZ[\]^_`abcdefghiwxyz{|}~����������

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@ static char *(features[]) =
747747

748748
static int included_patches[] =
749749
{ /* Add new patch number below this line */
750+
/**/
751+
1305,
750752
/**/
751753
1304,
752754
/**/

0 commit comments

Comments
 (0)