summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.235
blob: 1f12ee7c1aa8e22b912a7bf5be02e8e166a82b15 (plain) (blame)
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
To: vim_dev@googlegroups.com
Subject: Patch 7.4.235
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.235
Problem:    It is not easy to get the full path of a command.
Solution:   Add the exepath() function.
Files:	    src/eval.c, src/misc1.c, src/os_amiga.c, src/os_msdos.c,
	    src/os_unix.c, src/os_vms.c, src/os_win32.c,
	    src/proto/os_amiga.pro, src/proto/os_msdos.pro,
	    src/proto/os_unix.pro, src/proto/os_win32.pro,
	    runtime/doc/eval.txt


*** ../vim-7.4.234/src/eval.c	2014-04-01 19:55:46.252787300 +0200
--- src/eval.c	2014-04-01 20:18:39.212768414 +0200
***************
*** 514,519 ****
--- 514,520 ----
  static void f_eval __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_eventhandler __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_executable __ARGS((typval_T *argvars, typval_T *rettv));
+ static void f_exepath __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_exists __ARGS((typval_T *argvars, typval_T *rettv));
  #ifdef FEAT_FLOAT
  static void f_exp __ARGS((typval_T *argvars, typval_T *rettv));
***************
*** 7920,7925 ****
--- 7921,7927 ----
      {"eval",		1, 1, f_eval},
      {"eventhandler",	0, 0, f_eventhandler},
      {"executable",	1, 1, f_executable},
+     {"exepath",		1, 1, f_exepath},
      {"exists",		1, 1, f_exists},
  #ifdef FEAT_FLOAT
      {"exp",		1, 1, f_exp},
***************
*** 10046,10052 ****
      typval_T	*argvars;
      typval_T	*rettv;
  {
!     rettv->vval.v_number = mch_can_exe(get_tv_string(&argvars[0]));
  }
  
  /*
--- 10048,10069 ----
      typval_T	*argvars;
      typval_T	*rettv;
  {
!     rettv->vval.v_number = mch_can_exe(get_tv_string(&argvars[0]), NULL);
! }
! 
! /*
!  * "exepath()" function
!  */
!     static void
! f_exepath(argvars, rettv)
!     typval_T	*argvars;
!     typval_T	*rettv;
! {
!     char_u *p = NULL;
! 
!     (void)mch_can_exe(get_tv_string(&argvars[0]), &p);
!     rettv->v_type = VAR_STRING;
!     rettv->vval.v_string = p;
  }
  
  /*
*** ../vim-7.4.234/src/misc1.c	2014-03-12 18:55:52.100906804 +0100
--- src/misc1.c	2014-04-01 20:01:08.752782864 +0200
***************
*** 10728,10734 ****
  	return;
  
      /* If the file isn't executable, may not add it.  Do accept directories. */
!     if (!isdir && (flags & EW_EXEC) && !mch_can_exe(f))
  	return;
  
      /* Make room for another item in the file list. */
--- 10728,10734 ----
  	return;
  
      /* If the file isn't executable, may not add it.  Do accept directories. */
!     if (!isdir && (flags & EW_EXEC) && !mch_can_exe(f, NULL))
  	return;
  
      /* Make room for another item in the file list. */
*** ../vim-7.4.234/src/os_amiga.c	2013-05-06 04:06:04.000000000 +0200
--- src/os_amiga.c	2014-04-01 20:19:50.804767429 +0200
***************
*** 884,891 ****
   * Return -1 if unknown.
   */
      int
! mch_can_exe(name)
      char_u	*name;
  {
      /* TODO */
      return -1;
--- 884,892 ----
   * Return -1 if unknown.
   */
      int
! mch_can_exe(name, path)
      char_u	*name;
+     char_u	**path;
  {
      /* TODO */
      return -1;
*** ../vim-7.4.234/src/os_msdos.c	2014-03-23 15:12:29.931264336 +0100
--- src/os_msdos.c	2014-04-01 20:02:39.996781608 +0200
***************
*** 2945,2958 ****
   * Return -1 if unknown.
   */
      int
! mch_can_exe(name)
      char_u	*name;
  {
      char	*p;
  
      p = searchpath(name);
      if (p == NULL || mch_isdir(p))
  	return FALSE;
      return TRUE;
  }
  
--- 2945,2961 ----
   * Return -1 if unknown.
   */
      int
! mch_can_exe(name, path)
      char_u	*name;
+     char_u	**path;
  {
      char	*p;
  
      p = searchpath(name);
      if (p == NULL || mch_isdir(p))
  	return FALSE;
+     if (path != NULL)
+ 	*path = vim_strsave(p);
      return TRUE;
  }
  
*** ../vim-7.4.234/src/os_unix.c	2014-03-12 16:51:35.060792541 +0100
--- src/os_unix.c	2014-04-01 20:46:21.304745550 +0200
***************
*** 2992,2999 ****
   * Return -1 if unknown.
   */
      int
! mch_can_exe(name)
      char_u	*name;
  {
      char_u	*buf;
      char_u	*p, *e;
--- 2992,3000 ----
   * Return -1 if unknown.
   */
      int
! mch_can_exe(name, path)
      char_u	*name;
+     char_u	**path;
  {
      char_u	*buf;
      char_u	*p, *e;
***************
*** 3003,3009 ****
      if (mch_isFullName(name) || (name[0] == '.' && (name[1] == '/'
  				      || (name[1] == '.' && name[2] == '/'))))
      {
! 	return executable_file(name);
      }
  
      p = (char_u *)getenv("PATH");
--- 3004,3021 ----
      if (mch_isFullName(name) || (name[0] == '.' && (name[1] == '/'
  				      || (name[1] == '.' && name[2] == '/'))))
      {
! 	if (executable_file(name))
! 	{
! 	    if (path != NULL)
! 	    {
! 		if (name[0] == '.')
! 		    *path = FullName_save(name, TRUE);
! 		else
! 		    *path = vim_strsave(name);
! 	    }
! 	    return TRUE;
! 	}
! 	return FALSE;
      }
  
      p = (char_u *)getenv("PATH");
***************
*** 3032,3038 ****
--- 3044,3059 ----
  	STRCAT(buf, name);
  	retval = executable_file(buf);
  	if (retval == 1)
+ 	{
+ 	    if (path != NULL)
+ 	    {
+ 		if (buf[0] == '.')
+ 		    *path = FullName_save(buf, TRUE);
+ 		else
+ 		    *path = vim_strsave(buf);
+ 	    }
  	    break;
+ 	}
  
  	if (*e != ':')
  	    break;
***************
*** 5592,5598 ****
  		    continue;
  
  		/* Skip files that are not executable if we check for that. */
! 		if (!dir && (flags & EW_EXEC) && !mch_can_exe(p))
  		    continue;
  
  		if (--files_free == 0)
--- 5613,5619 ----
  		    continue;
  
  		/* Skip files that are not executable if we check for that. */
! 		if (!dir && (flags & EW_EXEC) && !mch_can_exe(p, NULL))
  		    continue;
  
  		if (--files_free == 0)
***************
*** 6090,6096 ****
  	    continue;
  
  	/* Skip files that are not executable if we check for that. */
! 	if (!dir && (flags & EW_EXEC) && !mch_can_exe((*file)[i]))
  	    continue;
  
  	p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
--- 6111,6117 ----
  	    continue;
  
  	/* Skip files that are not executable if we check for that. */
! 	if (!dir && (flags & EW_EXEC) && !mch_can_exe((*file)[i], NULL))
  	    continue;
  
  	p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
***************
*** 6317,6323 ****
  
  /* Reads gpm event and adds special keys to input buf. Returns length of
   * generated key sequence.
!  * This function is made after gui_send_mouse_event
   */
      static int
  mch_gpm_process()
--- 6338,6344 ----
  
  /* Reads gpm event and adds special keys to input buf. Returns length of
   * generated key sequence.
!  * This function is styled after gui_send_mouse_event().
   */
      static int
  mch_gpm_process()
*** ../vim-7.4.234/src/os_vms.c	2014-03-12 16:51:35.060792541 +0100
--- src/os_vms.c	2014-04-01 20:05:52.960778954 +0200
***************
*** 483,489 ****
  		continue;
  
  	    /* Skip files that are not executable if we check for that. */
! 	    if (!dir && (flags & EW_EXEC) && !mch_can_exe(vms_fmatch[i]))
  		continue;
  
  	    /* allocate memory for pointers */
--- 483,489 ----
  		continue;
  
  	    /* Skip files that are not executable if we check for that. */
! 	    if (!dir && (flags & EW_EXEC) && !mch_can_exe(vms_fmatch[i], NULL))
  		continue;
  
  	    /* allocate memory for pointers */
*** ../vim-7.4.234/src/os_win32.c	2014-02-11 17:05:57.282217857 +0100
--- src/os_win32.c	2014-04-01 20:26:07.432762248 +0200
***************
*** 1882,1888 ****
   * TODO: Should somehow check if it's really executable.
   */
      static int
! executable_exists(char *name)
  {
      char	*dum;
      char	fname[_MAX_PATH];
--- 1882,1888 ----
   * TODO: Should somehow check if it's really executable.
   */
      static int
! executable_exists(char *name, char_u **path)
  {
      char	*dum;
      char	fname[_MAX_PATH];
***************
*** 1905,1910 ****
--- 1905,1912 ----
  		    return FALSE;
  		if (GetFileAttributesW(fnamew) & FILE_ATTRIBUTE_DIRECTORY)
  		    return FALSE;
+ 		if (path != NULL)
+ 		    *path = utf16_to_enc(fnamew, NULL);
  		return TRUE;
  	    }
  	    /* Retry with non-wide function (for Windows 98). */
***************
*** 1915,1920 ****
--- 1917,1924 ----
  	return FALSE;
      if (mch_isdir(fname))
  	return FALSE;
+     if (path != NULL)
+ 	*path = vim_strsave(fname);
      return TRUE;
  }
  
***************
*** 1996,2002 ****
  	    vimrun_path = (char *)vim_strsave(vimrun_location);
  	    s_dont_use_vimrun = FALSE;
  	}
! 	else if (executable_exists("vimrun.exe"))
  	    s_dont_use_vimrun = FALSE;
  
  	/* Don't give the warning for a missing vimrun.exe right now, but only
--- 2000,2006 ----
  	    vimrun_path = (char *)vim_strsave(vimrun_location);
  	    s_dont_use_vimrun = FALSE;
  	}
! 	else if (executable_exists("vimrun.exe", NULL))
  	    s_dont_use_vimrun = FALSE;
  
  	/* Don't give the warning for a missing vimrun.exe right now, but only
***************
*** 2010,2016 ****
       * If "finstr.exe" doesn't exist, use "grep -n" for 'grepprg'.
       * Otherwise the default "findstr /n" is used.
       */
!     if (!executable_exists("findstr.exe"))
  	set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0);
  
  #ifdef FEAT_CLIPBOARD
--- 2014,2020 ----
       * If "finstr.exe" doesn't exist, use "grep -n" for 'grepprg'.
       * Otherwise the default "findstr /n" is used.
       */
!     if (!executable_exists("findstr.exe", NULL))
  	set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0);
  
  #ifdef FEAT_CLIPBOARD
***************
*** 3330,3336 ****
   * Return -1 if unknown.
   */
      int
! mch_can_exe(char_u *name)
  {
      char_u	buf[_MAX_PATH];
      int		len = (int)STRLEN(name);
--- 3334,3340 ----
   * Return -1 if unknown.
   */
      int
! mch_can_exe(char_u *name, char_u **path)
  {
      char_u	buf[_MAX_PATH];
      int		len = (int)STRLEN(name);
***************
*** 3343,3349 ****
       * this with a Unix-shell like 'shell'. */
      if (vim_strchr(gettail(name), '.') != NULL
  			       || strstr((char *)gettail(p_sh), "sh") != NULL)
! 	if (executable_exists((char *)name))
  	    return TRUE;
  
      /*
--- 3347,3353 ----
       * this with a Unix-shell like 'shell'. */
      if (vim_strchr(gettail(name), '.') != NULL
  			       || strstr((char *)gettail(p_sh), "sh") != NULL)
! 	if (executable_exists((char *)name, path))
  	    return TRUE;
  
      /*
***************
*** 3365,3371 ****
  	}
  	else
  	    copy_option_part(&p, buf + len, _MAX_PATH - len, ";");
! 	if (executable_exists((char *)buf))
  	    return TRUE;
      }
      return FALSE;
--- 3369,3375 ----
  	}
  	else
  	    copy_option_part(&p, buf + len, _MAX_PATH - len, ";");
! 	if (executable_exists((char *)buf, path))
  	    return TRUE;
      }
      return FALSE;
*** ../vim-7.4.234/src/proto/os_amiga.pro	2013-08-10 13:37:37.000000000 +0200
--- src/proto/os_amiga.pro	2014-04-01 20:41:23.672749644 +0200
***************
*** 26,32 ****
  void mch_hide __ARGS((char_u *name));
  int mch_isdir __ARGS((char_u *name));
  int mch_mkdir __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name));
  int mch_nodetype __ARGS((char_u *name));
  void mch_early_init __ARGS((void));
  void mch_exit __ARGS((int r));
--- 26,32 ----
  void mch_hide __ARGS((char_u *name));
  int mch_isdir __ARGS((char_u *name));
  int mch_mkdir __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name, char_u **path));
  int mch_nodetype __ARGS((char_u *name));
  void mch_early_init __ARGS((void));
  void mch_exit __ARGS((int r));
*** ../vim-7.4.234/src/proto/os_msdos.pro	2013-08-10 13:37:37.000000000 +0200
--- src/proto/os_msdos.pro	2014-04-01 20:41:32.432749524 +0200
***************
*** 38,44 ****
  int mch_setperm __ARGS((char_u *name, long perm));
  void mch_hide __ARGS((char_u *name));
  int mch_isdir __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name));
  int mch_nodetype __ARGS((char_u *name));
  int mch_dirname __ARGS((char_u *buf, int len));
  int mch_remove __ARGS((char_u *name));
--- 38,44 ----
  int mch_setperm __ARGS((char_u *name, long perm));
  void mch_hide __ARGS((char_u *name));
  int mch_isdir __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name, char_u **path));
  int mch_nodetype __ARGS((char_u *name));
  int mch_dirname __ARGS((char_u *buf, int len));
  int mch_remove __ARGS((char_u *name));
*** ../vim-7.4.234/src/proto/os_unix.pro	2013-08-10 13:37:23.000000000 +0200
--- src/proto/os_unix.pro	2014-04-01 20:41:58.712749162 +0200
***************
*** 42,48 ****
  void mch_free_acl __ARGS((vim_acl_T aclent));
  void mch_hide __ARGS((char_u *name));
  int mch_isdir __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name));
  int mch_nodetype __ARGS((char_u *name));
  void mch_early_init __ARGS((void));
  void mch_free_mem __ARGS((void));
--- 42,48 ----
  void mch_free_acl __ARGS((vim_acl_T aclent));
  void mch_hide __ARGS((char_u *name));
  int mch_isdir __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name, char_u **path));
  int mch_nodetype __ARGS((char_u *name));
  void mch_early_init __ARGS((void));
  void mch_free_mem __ARGS((void));
*** ../vim-7.4.234/src/proto/os_win32.pro	2013-08-10 13:37:38.000000000 +0200
--- src/proto/os_win32.pro	2014-04-01 20:42:16.992748911 +0200
***************
*** 26,32 ****
  int mch_is_linked __ARGS((char_u *fname));
  int win32_fileinfo __ARGS((char_u *fname, BY_HANDLE_FILE_INFORMATION *info));
  int mch_writable __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name));
  int mch_nodetype __ARGS((char_u *name));
  vim_acl_T mch_get_acl __ARGS((char_u *fname));
  void mch_set_acl __ARGS((char_u *fname, vim_acl_T acl));
--- 26,32 ----
  int mch_is_linked __ARGS((char_u *fname));
  int win32_fileinfo __ARGS((char_u *fname, BY_HANDLE_FILE_INFORMATION *info));
  int mch_writable __ARGS((char_u *name));
! int mch_can_exe __ARGS((char_u *name, char_u **path));
  int mch_nodetype __ARGS((char_u *name));
  vim_acl_T mch_get_acl __ARGS((char_u *fname));
  void mch_set_acl __ARGS((char_u *fname, vim_acl_T acl));
*** ../vim-7.4.234/runtime/doc/eval.txt	2014-04-01 19:55:46.244787300 +0200
--- runtime/doc/eval.txt	2014-04-01 20:54:37.832738720 +0200
***************
*** 1561,1566 ****
--- 1562,1571 ----
  v:progpath	Contains the command with which Vim was invoked, including the
  		path.  Useful if you want to message a Vim server using a
  		|--remote-expr|.
+ 		To get the full path use: >
+ 			echo exepath(v:progpath)
+ <		NOTE: This does not work when the command is a relative path
+ 		and the current directory has changed.
  		Read-only.
  
  					*v:register* *register-variable*
***************
*** 1761,1766 ****
--- 1766,1772 ----
  eval( {string})			any	evaluate {string} into its value
  eventhandler( )			Number	TRUE if inside an event handler
  executable( {expr})		Number	1 if executable {expr} exists
+ exepath( {expr})		String  full path of the command {expr}
  exists( {expr})			Number	TRUE if {expr} exists
  extend( {expr1}, {expr2} [, {expr3}])
  				List/Dict insert items of {expr2} into {expr1}
***************
*** 2705,2710 ****
--- 2711,2725 ----
  			0	does not exist
  			-1	not implemented on this system
  
+ exepath({expr})						*exepath()*
+ 		If {expr} is an executable and is either an absolute path, a
+ 		relative path or found in $PATH, return the full path.
+ 		Note that the current directory is used when {expr} starts
+ 		with "./", which may be a problem for Vim: >
+ 			echo exepath(v:progpath)
+ < 		If {expr} cannot be found in $PATH or is not executable then
+ 		an empty string is returned.
+ 
  							*exists()*
  exists({expr})	The result is a Number, which is non-zero if {expr} is
  		defined, zero otherwise.  The {expr} argument is a string,
*** ../vim-7.4.234/src/version.c	2014-04-01 19:55:46.252787300 +0200
--- src/version.c	2014-04-01 20:00:44.108783203 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     235,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
19. All of your friends have an @ in their names.

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