summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0445
blob: 41076aeebb12de94471f471968711d843a2eba37 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0445
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.0445
Problem:    Setting 'term' does not store location for termcap options.
Solution:   Set the script context for termcap options that are changed when
            'term' is set.
Files:	    src/option.c, src/proto/option.pro, src/term.c,
            src/testdir/test_options.vim


*** ../vim-8.1.0444/src/option.c	2018-09-30 21:43:17.199693265 +0200
--- src/option.c	2018-10-02 14:12:11.856267373 +0200
***************
*** 1755,1766 ****
      {"langmap",     "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
  #ifdef FEAT_LANGMAP
  			    (char_u *)&p_langmap, PV_NONE,
! 			    {(char_u *)"",	/* unmatched } */
  #else
  			    (char_u *)NULL, PV_NONE,
! 			    {(char_u *)NULL,
  #endif
! 				(char_u *)0L} SCTX_INIT},
      {"langmenu",    "lm",   P_STRING|P_VI_DEF|P_NFNAME,
  #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
  			    (char_u *)&p_lm, PV_NONE,
--- 1755,1766 ----
      {"langmap",     "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
  #ifdef FEAT_LANGMAP
  			    (char_u *)&p_langmap, PV_NONE,
! 			    {(char_u *)"", (char_u *)0L}
  #else
  			    (char_u *)NULL, PV_NONE,
! 			    {(char_u *)NULL, (char_u *)0L}
  #endif
! 			    SCTX_INIT},
      {"langmenu",    "lm",   P_STRING|P_VI_DEF|P_NFNAME,
  #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
  			    (char_u *)&p_lm, PV_NONE,
***************
*** 5790,5809 ****
  }
  
  /*
!  * Mark a terminal option as allocated, found by a pointer into term_strings[].
   */
!     void
! set_term_option_alloced(char_u **p)
  {
!     int		opt_idx;
  
      for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
  	if (options[opt_idx].var == (char_u *)p)
! 	{
! 	    options[opt_idx].flags |= P_ALLOCED;
! 	    return;
! 	}
!     return; /* cannot happen: didn't find it! */
  }
  
  #if defined(FEAT_EVAL) || defined(PROTO)
--- 5790,5821 ----
  }
  
  /*
!  * Return the option index found by a pointer into term_strings[].
!  * Return -1 if not found.
   */
!     int
! get_term_opt_idx(char_u **p)
  {
!     int opt_idx;
  
      for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
  	if (options[opt_idx].var == (char_u *)p)
! 	    return opt_idx;
!     return -1; // cannot happen: didn't find it!
! }
! 
! /*
!  * Mark a terminal option as allocated, found by a pointer into term_strings[].
!  * Return the option index or -1 if not found.
!  */
!     int
! set_term_option_alloced(char_u **p)
! {
!     int		opt_idx = get_term_opt_idx(p);
! 
!     if (opt_idx >= 0)
! 	options[opt_idx].flags |= P_ALLOCED;
!     return opt_idx;
  }
  
  #if defined(FEAT_EVAL) || defined(PROTO)
***************
*** 8237,8242 ****
--- 8249,8280 ----
  	    curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx;
      }
  }
+ 
+ /*
+  * Set the script_ctx for a termcap option.
+  * "name" must be the two character code, e.g. "RV".
+  * When "name" is NULL use "opt_idx".
+  */
+     void
+ set_term_option_sctx_idx(char *name, int opt_idx)
+ {
+     char_u  buf[5];
+     int	    idx;
+ 
+     if (name == NULL)
+ 	idx = opt_idx;
+     else
+     {
+ 	buf[0] = 't';
+ 	buf[1] = '_';
+ 	buf[2] = name[0];
+ 	buf[3] = name[1];
+ 	buf[4] = 0;
+ 	idx = findoption(buf);
+     }
+     if (idx >= 0)
+ 	set_option_sctx_idx(idx, OPT_GLOBAL, current_sctx);
+ }
  #endif
  
  /*
***************
*** 10445,10451 ****
  {
      struct vimoption   *p;
  
!     for (p = &options[0]; p->fullname != NULL; p++)
  	if (istermoption(p))
  	{
  	    if (p->flags & P_ALLOCED)
--- 10483,10489 ----
  {
      struct vimoption   *p;
  
!     for (p = options; p->fullname != NULL; p++)
  	if (istermoption(p))
  	{
  	    if (p->flags & P_ALLOCED)
***************
*** 10455,10460 ****
--- 10493,10502 ----
  	    *(char_u **)(p->var) = empty_option;
  	    p->def_val[VI_DEFAULT] = empty_option;
  	    p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
+ #ifdef FEAT_EVAL
+ 	    // remember where the option was cleared
+ 	    set_option_sctx_idx((int)(p - options), OPT_GLOBAL, current_sctx);
+ #endif
  	}
      clear_termcodes();
  }
*** ../vim-8.1.0444/src/proto/option.pro	2018-09-13 20:31:47.103018229 +0200
--- src/proto/option.pro	2018-10-02 14:12:15.040243605 +0200
***************
*** 17,27 ****
  void check_buf_options(buf_T *buf);
  void free_string_option(char_u *p);
  void clear_string_option(char_u **pp);
! void set_term_option_alloced(char_u **p);
  int was_set_insecurely(char_u *opt, int opt_flags);
  void set_string_option_direct(char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid);
  char_u *check_colorcolumn(win_T *wp);
  char_u *check_stl_option(char_u *s);
  int get_option_value(char_u *name, long *numval, char_u **stringval, int opt_flags);
  int get_option_value_strict(char_u *name, long *numval, char_u **stringval, int opt_type, void *from);
  char_u *option_iter_next(void **option, int opt_type);
--- 17,29 ----
  void check_buf_options(buf_T *buf);
  void free_string_option(char_u *p);
  void clear_string_option(char_u **pp);
! int get_term_opt_idx(char_u **p);
! int set_term_option_alloced(char_u **p);
  int was_set_insecurely(char_u *opt, int opt_flags);
  void set_string_option_direct(char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid);
  char_u *check_colorcolumn(win_T *wp);
  char_u *check_stl_option(char_u *s);
+ void set_term_option_sctx_idx(char *name, int opt_idx);
  int get_option_value(char_u *name, long *numval, char_u **stringval, int opt_flags);
  int get_option_value_strict(char_u *name, long *numval, char_u **stringval, int opt_type, void *from);
  char_u *option_iter_next(void **option, int opt_type);
*** ../vim-8.1.0444/src/term.c	2018-09-30 21:43:17.207693209 +0200
--- src/term.c	2018-10-02 14:44:51.335763377 +0200
***************
*** 1471,1476 ****
--- 1471,1479 ----
  	    if (term_strings[p->bt_entry] == NULL
  				 || term_strings[p->bt_entry] == empty_option)
  	    {
+ #ifdef FEAT_EVAL
+ 		int opt_idx = -1;
+ #endif
  		/* 8bit terminal: use CSI instead of <Esc>[ */
  		if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0)
  		{
***************
*** 1486,1496 ****
  				STRMOVE(t + 1, t + 2);
  			    }
  			term_strings[p->bt_entry] = s;
! 			set_term_option_alloced(&term_strings[p->bt_entry]);
  		    }
  		}
  		else
  		    term_strings[p->bt_entry] = (char_u *)p->bt_string;
  	    }
  	}
  	else
--- 1489,1511 ----
  				STRMOVE(t + 1, t + 2);
  			    }
  			term_strings[p->bt_entry] = s;
! #ifdef FEAT_EVAL
! 			opt_idx =
! #endif
! 				  set_term_option_alloced(
! 						   &term_strings[p->bt_entry]);
  		    }
  		}
  		else
+ 		{
  		    term_strings[p->bt_entry] = (char_u *)p->bt_string;
+ #ifdef FEAT_EVAL
+ 		    opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]);
+ #endif
+ 		}
+ #ifdef FEAT_EVAL
+ 		set_term_option_sctx_idx(NULL, opt_idx);
+ #endif
  	    }
  	}
  	else
***************
*** 1616,1622 ****
--- 1631,1642 ----
      {
  	if (TERM_STR(string_names[i].dest) == NULL
  			     || TERM_STR(string_names[i].dest) == empty_option)
+ 	{
  	    TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp);
+ #ifdef FEAT_EVAL
+ 	    set_term_option_sctx_idx(string_names[i].name, -1);
+ #endif
+ 	}
      }
  
      /* tgetflag() returns 1 if the flag is present, 0 if not and
***************
*** 1658,1664 ****
--- 1678,1689 ----
       * Get number of colors (if not done already).
       */
      if (TERM_STR(KS_CCO) == NULL || TERM_STR(KS_CCO) == empty_option)
+     {
  	set_color_count(tgetnum("Co"));
+ #ifdef FEAT_EVAL
+ 	set_term_option_sctx_idx("Co", -1);
+ #endif
+     }
  
  # ifndef hpux
      BC = (char *)TGETSTR("bc", &tp);
*** ../vim-8.1.0444/src/testdir/test_options.vim	2018-08-23 22:20:31.449852029 +0200
--- src/testdir/test_options.vim	2018-10-02 14:42:18.764840113 +0200
***************
*** 270,275 ****
--- 270,287 ----
    call assert_fails('set t_foo=', 'E846:')
  endfunc
  
+ " Must be executed before other tests that set 'term'.
+ func Test_000_term_option_verbose()
+   let verb_cm = execute('verbose set t_cm')
+   call assert_notmatch('Last set from', verb_cm)
+ 
+   let term_save = &term
+   set term=ansi
+   let verb_cm = execute('verbose set t_cm')
+   call assert_match('Last set from.*test_options.vim', verb_cm)
+   let &term = term_save
+ endfunc
+ 
  func Test_set_ttytype()
    if !has('gui_running') && has('unix')
      " Setting 'ttytype' used to cause a double-free when exiting vim and
*** ../vim-8.1.0444/src/version.c	2018-10-02 14:15:08.991376909 +0200
--- src/version.c	2018-10-02 14:42:46.984641236 +0200
***************
*** 794,795 ****
--- 794,797 ----
  {   /* Add new patch number below this line */
+ /**/
+     445,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
132. You come back and check this list every half-hour.

 /// 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    ///