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
112
113
114
115
116
117
118
119
120
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0552
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0552
Problem: Saved last search pattern may not be restored.
Solution: Call restore_last_search_pattern(). Add a check for balancing
saving and restoring the last search pattern.
Files: src/ex_getln.c, src/search.c
*** ../vim-8.1.0551/src/ex_getln.c 2018-11-24 14:27:36.988474753 +0100
--- src/ex_getln.c 2018-11-30 21:43:13.477019050 +0100
***************
*** 462,467 ****
--- 462,468 ----
int use_last_pat;
// Parsing range may already set the last search pattern.
+ // NOTE: must call restore_last_search_pattern() before returning!
save_last_search_pattern();
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
***************
*** 633,638 ****
--- 634,640 ----
int save;
// Parsing range may already set the last search pattern.
+ // NOTE: must call restore_last_search_pattern() before returning!
save_last_search_pattern();
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
***************
*** 735,740 ****
--- 737,743 ----
int skiplen, patlen;
// Parsing range may already set the last search pattern.
+ // NOTE: must call restore_last_search_pattern() before returning!
save_last_search_pattern();
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
***************
*** 742,747 ****
--- 745,751 ----
restore_last_search_pattern();
return FAIL;
}
+ restore_last_search_pattern();
// Add a character from under the cursor for 'incsearch'.
if (is_state->did_incsearch)
*** ../vim-8.1.0551/src/search.c 2018-11-16 16:21:01.633310065 +0100
--- src/search.c 2018-11-30 21:46:33.771924536 +0100
***************
*** 96,101 ****
--- 96,102 ----
/* copy of spats[RE_SEARCH], for keeping the search patterns while incremental
* searching */
static struct spat saved_last_search_spat;
+ static int did_save_last_search_spat = 0;
static int saved_last_idx = 0;
static int saved_no_hlsearch = 0;
# endif
***************
*** 364,369 ****
--- 365,375 ----
void
save_last_search_pattern(void)
{
+ if (did_save_last_search_spat != 0)
+ IEMSG("did_save_last_search_spat is not zero");
+ else
+ ++did_save_last_search_spat;
+
saved_last_search_spat = spats[RE_SEARCH];
if (spats[RE_SEARCH].pat != NULL)
saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat);
***************
*** 374,381 ****
--- 380,395 ----
void
restore_last_search_pattern(void)
{
+ if (did_save_last_search_spat != 1)
+ {
+ IEMSG("did_save_last_search_spat is not one");
+ return;
+ }
+ --did_save_last_search_spat;
+
vim_free(spats[RE_SEARCH].pat);
spats[RE_SEARCH] = saved_last_search_spat;
+ saved_last_search_spat.pat = NULL;
# if defined(FEAT_EVAL)
set_vv_searchforward();
# endif
*** ../vim-8.1.0551/src/version.c 2018-11-28 21:20:34.096221686 +0100
--- src/version.c 2018-11-30 21:47:47.412181458 +0100
***************
*** 794,795 ****
--- 794,797 ----
{ /* Add new patch number below this line */
+ /**/
+ 552,
/**/
--
SIGIRO -- irony detected (iron core dumped)
/// 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 ///
|