summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0453
blob: cdd9e7d30d233bec2efcfe826fa8893858c37e16 (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0453
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.0453
Problem:    MS-Windows: executable() is not reliable.
Solution:   Use $PATHEXT properly. (Yasuhiro Matsumoto, closes #3412)
Files:	    src/os_win32.c, src/testdir/test_functions.vim


*** ../vim-8.1.0452/src/os_win32.c	2018-10-06 15:02:53.797052261 +0200
--- src/os_win32.c	2018-10-06 15:18:33.140733117 +0200
***************
*** 3535,3555 ****
  {
      char_u	buf[_MAX_PATH];
      int		len = (int)STRLEN(name);
!     char_u	*p;
  
      if (len >= _MAX_PATH)	/* safety check */
  	return FALSE;
  
!     /* If there already is an extension try using the name directly.  Also do
!      * 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, use_path))
  	    return TRUE;
  
      /*
       * Loop over all extensions in $PATHEXT.
       */
      vim_strncpy(buf, name, _MAX_PATH - 1);
      p = mch_getenv("PATHEXT");
      if (p == NULL)
--- 3535,3578 ----
  {
      char_u	buf[_MAX_PATH];
      int		len = (int)STRLEN(name);
!     char_u	*p, *saved;
  
      if (len >= _MAX_PATH)	/* safety check */
  	return FALSE;
  
!     /* Ty using the name directly when a Unix-shell like 'shell'. */
!     if (strstr((char *)gettail(p_sh), "sh") != NULL)
  	if (executable_exists((char *)name, path, use_path))
  	    return TRUE;
  
      /*
       * Loop over all extensions in $PATHEXT.
       */
+     p = mch_getenv("PATHEXT");
+     if (p == NULL)
+ 	p = (char_u *)".com;.exe;.bat;.cmd";
+     saved = vim_strsave(p);
+     if (saved == NULL)
+ 	return FALSE;
+     p = saved;
+     while (*p)
+     {
+ 	char_u	*tmp = vim_strchr(p, ';');
+ 
+ 	if (tmp != NULL)
+ 	    *tmp = NUL;
+ 	if (_stricoll((char *)name + len - STRLEN(p), (char *)p) == 0
+ 			    && executable_exists((char *)name, path, use_path))
+ 	{
+ 	    vim_free(saved);
+ 	    return TRUE;
+ 	}
+ 	if (tmp == NULL)
+ 	    break;
+ 	p = tmp + 1;
+     }
+     vim_free(saved);
+ 
      vim_strncpy(buf, name, _MAX_PATH - 1);
      p = mch_getenv("PATHEXT");
      if (p == NULL)
*** ../vim-8.1.0452/src/testdir/test_functions.vim	2018-09-03 22:08:05.676736128 +0200
--- src/testdir/test_functions.vim	2018-10-06 15:14:28.462908180 +0200
***************
*** 800,805 ****
--- 800,818 ----
    bw!
  endfunc
  
+ func Test_Executable()
+   if has('win32')
+     call assert_equal(1, executable('notepad'))
+     call assert_equal(1, executable('notepad.exe'))
+     call assert_equal(0, executable('notepad.exe.exe'))
+     call assert_equal(0, executable('shell32.dll'))
+     call assert_equal(0, executable('win.ini'))
+   elseif has('unix')
+     call assert_equal(1, executable('cat'))
+     call assert_equal(0, executable('dog'))
+   endif
+ endfunc
+ 
  func Test_hostname()
    let hostname_vim = hostname()
    if has('unix')
*** ../vim-8.1.0452/src/version.c	2018-10-06 15:02:53.797052261 +0200
--- src/version.c	2018-10-06 15:15:48.630198494 +0200
***************
*** 794,795 ****
--- 794,797 ----
  {   /* Add new patch number below this line */
+ /**/
+     453,
  /**/

-- 
Send $25.00 for handy leaflet on how to make money by selling leaflets

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