1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
To: vim_dev@googlegroups.com
Subject: Patch 7.4.045
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.4.045
Problem: substitute() does not work properly when the pattern starts with
"\ze".
Solution: Detect an empty match. (Christian Brabandt)
Files: src/eval.c, src/testdir/test80.in, src/testdir/test80.ok
*** ../vim-7.4.044/src/eval.c 2013-09-25 21:00:24.000000000 +0200
--- src/eval.c 2013-09-29 21:03:22.000000000 +0200
***************
*** 24301,24306 ****
--- 24301,24307 ----
garray_T ga;
char_u *ret;
char_u *save_cpo;
+ int zero_width;
/* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
save_cpo = p_cpo;
***************
*** 24339,24358 ****
(void)vim_regsub(®match, sub, (char_u *)ga.ga_data
+ ga.ga_len + i, TRUE, TRUE, FALSE);
ga.ga_len += i + sublen - 1;
! /* avoid getting stuck on a match with an empty string */
! if (tail == regmatch.endp[0])
{
! if (*tail == NUL)
! break;
*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
++ga.ga_len;
}
- else
- {
- tail = regmatch.endp[0];
- if (*tail == NUL)
- break;
- }
if (!do_all)
break;
}
--- 24340,24356 ----
(void)vim_regsub(®match, sub, (char_u *)ga.ga_data
+ ga.ga_len + i, TRUE, TRUE, FALSE);
ga.ga_len += i + sublen - 1;
! zero_width = (tail == regmatch.endp[0]
! || regmatch.startp[0] == regmatch.endp[0]);
! tail = regmatch.endp[0];
! if (*tail == NUL)
! break;
! if (zero_width)
{
! /* avoid getting stuck on a match with an empty string */
*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
++ga.ga_len;
}
if (!do_all)
break;
}
*** ../vim-7.4.044/src/testdir/test80.in 2013-03-19 17:30:51.000000000 +0100
--- src/testdir/test80.in 2013-09-29 20:59:00.000000000 +0200
***************
*** 142,147 ****
--- 142,149 ----
:$put =\"\n\nTEST_7:\"
:$put =substitute('A
A', 'A.', '\=submatch(0)', '')
:$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
+ :$put =substitute('-bb', '\zeb', 'a', 'g')
+ :$put =substitute('-bb', '\ze', 'c', 'g')
/^TEST_8
ENDTEST
*** ../vim-7.4.044/src/testdir/test80.ok 2013-03-19 17:31:45.000000000 +0100
--- src/testdir/test80.ok 2013-09-29 20:59:35.000000000 +0200
***************
*** 103,108 ****
--- 103,110 ----
A
A
B
B
+ -abab
+ c-cbcbc
TEST_8:
*** ../vim-7.4.044/src/version.c 2013-09-29 19:05:17.000000000 +0200
--- src/version.c 2013-09-29 21:04:50.000000000 +0200
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 45,
/**/
--
Just think of all the things we haven't thought of yet.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|