summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0050
blob: 914d8c818a83b0cbbed4f39e7c412672824e17be (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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0050
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.0050 (after 8.1.0049)
Problem:    $VIM_TERMINAL is also set when not in a terminal window.
Solution:   Pass a flag to indicate whether the job runs in a terminal.
Files:	    src/channel.c, src/proto/channel.pro, src/evalfunc.c,
            src/terminal.c, src/os_unix.c, src/proto/os_unix.pro,
            src/os_win32.c


*** ../vim-8.1.0049/src/channel.c	2018-06-03 14:42:17.840505115 +0200
--- src/channel.c	2018-06-12 20:13:06.460135822 +0200
***************
*** 5525,5531 ****
   * Returns NULL when out of memory.
   */
      job_T *
! job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg)
  {
      job_T	*job;
      char_u	*cmd = NULL;
--- 5525,5535 ----
   * Returns NULL when out of memory.
   */
      job_T *
! job_start(
! 	typval_T    *argvars,
! 	char	    **argv_arg,
! 	jobopt_T    *opt_arg,
! 	int	    is_terminal UNUSED)
  {
      job_T	*job;
      char_u	*cmd = NULL;
***************
*** 5679,5685 ****
  	ch_log(NULL, "Starting job: %s", (char *)ga.ga_data);
  	ga_clear(&ga);
      }
!     mch_job_start(argv, job, &opt);
  #else
      ch_log(NULL, "Starting job: %s", (char *)cmd);
      mch_job_start((char *)cmd, job, &opt);
--- 5683,5689 ----
  	ch_log(NULL, "Starting job: %s", (char *)ga.ga_data);
  	ga_clear(&ga);
      }
!     mch_job_start(argv, job, &opt, is_terminal);
  #else
      ch_log(NULL, "Starting job: %s", (char *)cmd);
      mch_job_start((char *)cmd, job, &opt);
*** ../vim-8.1.0049/src/proto/channel.pro	2018-06-03 14:42:17.848505102 +0200
--- src/proto/channel.pro	2018-06-12 20:08:25.045683595 +0200
***************
*** 66,72 ****
  void job_stop_on_exit(void);
  int has_pending_job(void);
  void job_check_ended(void);
! job_T *job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg);
  char *job_status(job_T *job);
  void job_info(job_T *job, dict_T *dict);
  void job_info_all(list_T *l);
--- 66,72 ----
  void job_stop_on_exit(void);
  int has_pending_job(void);
  void job_check_ended(void);
! job_T *job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg, int is_terminal);
  char *job_status(job_T *job);
  void job_info(job_T *job, dict_T *dict);
  void job_info_all(list_T *l);
*** ../vim-8.1.0049/src/evalfunc.c	2018-06-07 18:17:42.278227523 +0200
--- src/evalfunc.c	2018-06-12 20:05:33.630628161 +0200
***************
*** 7254,7260 ****
      rettv->v_type = VAR_JOB;
      if (check_restricted() || check_secure())
  	return;
!     rettv->vval.v_job = job_start(argvars, NULL, NULL);
  }
  
  /*
--- 7254,7260 ----
      rettv->v_type = VAR_JOB;
      if (check_restricted() || check_secure())
  	return;
!     rettv->vval.v_job = job_start(argvars, NULL, NULL, FALSE);
  }
  
  /*
*** ../vim-8.1.0049/src/terminal.c	2018-06-04 17:28:04.729961269 +0200
--- src/terminal.c	2018-06-12 20:06:16.926389419 +0200
***************
*** 5769,5775 ****
  #endif
  
      /* This may change a string in "argvar". */
!     term->tl_job = job_start(argvar, argv, opt);
      if (term->tl_job != NULL)
  	++term->tl_job->jv_refcount;
  
--- 5769,5775 ----
  #endif
  
      /* This may change a string in "argvar". */
!     term->tl_job = job_start(argvar, argv, opt, TRUE);
      if (term->tl_job != NULL)
  	++term->tl_job->jv_refcount;
  
*** ../vim-8.1.0049/src/os_unix.c	2018-06-12 18:04:28.038267855 +0200
--- src/os_unix.c	2018-06-12 20:11:20.272719511 +0200
***************
*** 4159,4165 ****
   * Set the environment for a child process.
   */
      static void
! set_child_environment(long rows, long columns, char *term)
  {
  # ifdef HAVE_SETENV
      char	envbuf[50];
--- 4159,4169 ----
   * Set the environment for a child process.
   */
      static void
! set_child_environment(
! 	long	rows,
! 	long	columns,
! 	char	*term,
! 	int	is_terminal UNUSED)
  {
  # ifdef HAVE_SETENV
      char	envbuf[50];
***************
*** 4169,4175 ****
--- 4173,4181 ----
      static char	envbuf_Lines[20];
      static char	envbuf_Columns[20];
      static char	envbuf_Colors[20];
+ #  ifdef FEAT_TERMINAL
      static char	envbuf_Version[20];
+ #  endif
  #  ifdef FEAT_CLIENTSERVER
      static char	envbuf_Servername[60];
  #  endif
***************
*** 4190,4197 ****
      setenv("COLUMNS", (char *)envbuf, 1);
      sprintf((char *)envbuf, "%ld", colors);
      setenv("COLORS", (char *)envbuf, 1);
!     sprintf((char *)envbuf, "%ld",  get_vim_var_nr(VV_VERSION));
!     setenv("VIM_TERMINAL", (char *)envbuf, 1);
  #  ifdef FEAT_CLIENTSERVER
      setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1);
  #  endif
--- 4196,4208 ----
      setenv("COLUMNS", (char *)envbuf, 1);
      sprintf((char *)envbuf, "%ld", colors);
      setenv("COLORS", (char *)envbuf, 1);
! #  ifdef FEAT_TERMINAL
!     if (is_terminal)
!     {
! 	sprintf((char *)envbuf, "%ld",  get_vim_var_nr(VV_VERSION));
! 	setenv("VIM_TERMINAL", (char *)envbuf, 1);
!     }
! #  endif
  #  ifdef FEAT_CLIENTSERVER
      setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1);
  #  endif
***************
*** 4212,4220 ****
      putenv(envbuf_Columns);
      vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors);
      putenv(envbuf_Colors);
!     vim_snprintf(envbuf_Version, sizeof(envbuf_Version), "VIM_TERMINAL=%ld",
! 						   get_vim_var_nr(VV_VERSION));
!     putenv(envbuf_Version);
  #  ifdef FEAT_CLIENTSERVER
      vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername),
  	    "VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName);
--- 4223,4236 ----
      putenv(envbuf_Columns);
      vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors);
      putenv(envbuf_Colors);
! #  ifdef FEAT_TERMINAL
!     if (is_terminal)
!     {
! 	vim_snprintf(envbuf_Version, sizeof(envbuf_Version),
! 			       "VIM_TERMINAL=%ld", get_vim_var_nr(VV_VERSION));
! 	putenv(envbuf_Version);
!     }
! #  endif
  #  ifdef FEAT_CLIENTSERVER
      vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername),
  	    "VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName);
***************
*** 4224,4232 ****
  }
  
      static void
! set_default_child_environment(void)
  {
!     set_child_environment(Rows, Columns, "dumb");
  }
  #endif
  
--- 4240,4248 ----
  }
  
      static void
! set_default_child_environment(int is_terminal)
  {
!     set_child_environment(Rows, Columns, "dumb", is_terminal);
  }
  #endif
  
***************
*** 4689,4695 ****
  #  endif
  		}
  # endif
! 		set_default_child_environment();
  
  		/*
  		 * stderr is only redirected when using the GUI, so that a
--- 4705,4711 ----
  #  endif
  		}
  # endif
! 		set_default_child_environment(FALSE);
  
  		/*
  		 * stderr is only redirected when using the GUI, so that a
***************
*** 5367,5373 ****
  
  #if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
      void
! mch_job_start(char **argv, job_T *job, jobopt_T *options)
  {
      pid_t	pid;
      int		fd_in[2] = {-1, -1};	/* for stdin */
--- 5383,5389 ----
  
  #if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
      void
! mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
  {
      pid_t	pid;
      int		fd_in[2] = {-1, -1};	/* for stdin */
***************
*** 5515,5525 ****
  	    set_child_environment(
  		    (long)options->jo_term_rows,
  		    (long)options->jo_term_cols,
! 		    term);
  	}
  	else
  # endif
! 	    set_default_child_environment();
  
  	if (options->jo_env != NULL)
  	{
--- 5531,5542 ----
  	    set_child_environment(
  		    (long)options->jo_term_rows,
  		    (long)options->jo_term_cols,
! 		    term,
! 		    is_terminal);
  	}
  	else
  # endif
! 	    set_default_child_environment(is_terminal);
  
  	if (options->jo_env != NULL)
  	{
*** ../vim-8.1.0049/src/proto/os_unix.pro	2018-05-17 13:52:48.000000000 +0200
--- src/proto/os_unix.pro	2018-06-12 20:08:29.497659084 +0200
***************
*** 62,68 ****
  void mch_new_shellsize(void);
  void may_send_sigint(int c, pid_t pid, pid_t wpid);
  int mch_call_shell(char_u *cmd, int options);
! void mch_job_start(char **argv, job_T *job, jobopt_T *options);
  char *mch_job_status(job_T *job);
  job_T *mch_detect_ended_job(job_T *job_list);
  int mch_signal_job(job_T *job, char_u *how);
--- 62,68 ----
  void mch_new_shellsize(void);
  void may_send_sigint(int c, pid_t pid, pid_t wpid);
  int mch_call_shell(char_u *cmd, int options);
! void mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal);
  char *mch_job_status(job_T *job);
  job_T *mch_detect_ended_job(job_T *job_list);
  int mch_signal_job(job_T *job, char_u *how);
*** ../vim-8.1.0049/src/os_win32.c	2018-06-12 18:04:28.038267855 +0200
--- src/os_win32.c	2018-06-12 20:18:53.770228655 +0200
***************
*** 5275,5300 ****
  	}
      }
  
!     if (is_terminal)
      {
! # ifdef FEAT_CLIENTSERVER
  	char_u	*servername = get_vim_var_str(VV_SEND_SERVER);
  	size_t	servername_len = STRLEN(servername);
! # endif
  	char_u	*version = get_vim_var_str(VV_VERSION);
  	size_t	version_len = STRLEN(version);
  	// size of "VIM_SERVERNAME=" and value,
  	// plus "VIM_TERMINAL=" and value,
  	// plus two terminating NULs
  	size_t	n = 0
! # ifdef FEAT_CLIENTSERVER
  		    + 15 + servername_len
! # endif
! 		    + 13 + version_len + 2;
  
  	if (ga_grow(gap, (int)n) == OK)
  	{
! # ifdef FEAT_CLIENTSERVER
  	    for (n = 0; n < 15; n++)
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)"VIM_SERVERNAME="[n];
--- 5275,5305 ----
  	}
      }
  
! # if defined(FEAT_CLIENTSERVER) || defined(FEAT_TERMINAL)
      {
! #  ifdef FEAT_CLIENTSERVER
  	char_u	*servername = get_vim_var_str(VV_SEND_SERVER);
  	size_t	servername_len = STRLEN(servername);
! #  endif
! #  ifdef FEAT_TERMINAL
  	char_u	*version = get_vim_var_str(VV_VERSION);
  	size_t	version_len = STRLEN(version);
+ #  endif
  	// size of "VIM_SERVERNAME=" and value,
  	// plus "VIM_TERMINAL=" and value,
  	// plus two terminating NULs
  	size_t	n = 0
! #  ifdef FEAT_CLIENTSERVER
  		    + 15 + servername_len
! #  endif
! #  ifdef FEAT_TERMINAL
! 		    + 13 + version_len + 2
! #  endif
! 		    ;
  
  	if (ga_grow(gap, (int)n) == OK)
  	{
! #  ifdef FEAT_CLIENTSERVER
  	    for (n = 0; n < 15; n++)
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)"VIM_SERVERNAME="[n];
***************
*** 5302,5315 ****
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)servername[n];
  	    *((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
! # endif
! 	    for (n = 0; n < 13; n++)
! 		*((WCHAR*)gap->ga_data + gap->ga_len++) =
! 		    (WCHAR)"VIM_TERMINAL="[n];
! 	    for (n = 0; n < version_len; n++)
! 		*((WCHAR*)gap->ga_data + gap->ga_len++) =
! 		    (WCHAR)version[n];
! 	    *((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
  	}
      }
  }
--- 5307,5325 ----
  		*((WCHAR*)gap->ga_data + gap->ga_len++) =
  		    (WCHAR)servername[n];
  	    *((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
! #  endif
! #  ifdef FEAT_TERMINAL
! 	    if (is_terminal)
! 	    {
! 		for (n = 0; n < 13; n++)
! 		    *((WCHAR*)gap->ga_data + gap->ga_len++) =
! 			(WCHAR)"VIM_TERMINAL="[n];
! 		for (n = 0; n < version_len; n++)
! 		    *((WCHAR*)gap->ga_data + gap->ga_len++) =
! 			(WCHAR)version[n];
! 		*((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
! 	    }
! #  endif
  	}
      }
  }
*** ../vim-8.1.0049/src/version.c	2018-06-12 18:04:28.042267834 +0200
--- src/version.c	2018-06-12 20:21:54.749235631 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     50,
  /**/

-- 
Change is inevitable, except from a vending machine.

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