summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0211
blob: 3ce6e36440c886375deaba129372b0e9d89d6215 (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0211
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.0211
Problem:    Expanding a file name "~" results in $HOME. (Aidan Shafran)
Solution:   Change "~" to "./~" before expanding. (closes #3072)
Files:	    src/testdir/test_expand.vim, src/ex_docmd.c, src/eval.c,
            src/proto/eval.pro, src/evalfunc.c, src/if_cscope.c, src/misc1.c


*** ../vim-8.1.0210/src/testdir/test_expand.vim	Sun Jan 17 18:33:03 2016
--- src/testdir/test_expand.vim	Wed Jul 25 21:05:55 2018
***************
*** 39,41 ****
--- 39,49 ----
    call delete('Xdir ~ dir', 'd')
    call assert_false(isdirectory('Xdir ~ dir'))
  endfunc
+ 
+ func Test_expand_tilde_filename()
+   split ~
+   call assert_equal('~', expand('%')) 
+   call assert_notequal(expand('%:p'), expand('~/'))
+   call assert_match('\~', expand('%:p')) 
+   bwipe!
+ endfunc
*** ../vim-8.1.0210/src/ex_docmd.c	Sat Jul  7 16:41:10 2018
--- src/ex_docmd.c	Wed Jul 25 21:03:33 2018
***************
*** 10654,10659 ****
--- 10654,10660 ----
      int		resultlen;
      buf_T	*buf;
      int		valid = VALID_HEAD + VALID_PATH;    /* assume valid result */
+     int		tilde_file = FALSE;
      int		spec_idx;
  #ifdef FEAT_MODIFY_FNAME
      int		skip_mod = FALSE;
***************
*** 10720,10726 ****
--- 10721,10730 ----
  		    valid = 0;	    /* Must have ":p:h" to be valid */
  		}
  		else
+ 		{
  		    result = curbuf->b_fname;
+ 		    tilde_file = STRCMP(result, "~") == 0;
+ 		}
  		break;
  
  	case SPEC_HASH:		/* '#' or "#99": alternate file */
***************
*** 10784,10790 ****
--- 10788,10797 ----
  			valid = 0;	    /* Must have ":p:h" to be valid */
  		    }
  		    else
+ 		    {
  			result = buf->b_fname;
+ 			tilde_file = STRCMP(result, "~") == 0;
+ 		    }
  		}
  		break;
  
***************
*** 10877,10883 ****
  #ifdef FEAT_MODIFY_FNAME
  	else if (!skip_mod)
  	{
! 	    valid |= modify_fname(src, usedlen, &result, &resultbuf,
  								  &resultlen);
  	    if (result == NULL)
  	    {
--- 10884,10890 ----
  #ifdef FEAT_MODIFY_FNAME
  	else if (!skip_mod)
  	{
! 	    valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf,
  								  &resultlen);
  	    if (result == NULL)
  	    {
*** ../vim-8.1.0210/src/eval.c	Wed Jul 25 19:49:41 2018
--- src/eval.c	Wed Jul 25 21:05:06 2018
***************
*** 9690,9700 ****
   */
      int
  modify_fname(
!     char_u	*src,		/* string with modifiers */
!     int		*usedlen,	/* characters after src that are used */
!     char_u	**fnamep,	/* file name so far */
!     char_u	**bufp,		/* buffer for allocated file name or NULL */
!     int		*fnamelen)	/* length of fnamep */
  {
      int		valid = 0;
      char_u	*tail;
--- 9690,9701 ----
   */
      int
  modify_fname(
!     char_u	*src,		// string with modifiers
!     int		tilde_file,	// "~" is a file name, not $HOME
!     int		*usedlen,	// characters after src that are used
!     char_u	**fnamep,	// file name so far
!     char_u	**bufp,		// buffer for allocated file name or NULL
!     int		*fnamelen)	// length of fnamep
  {
      int		valid = 0;
      char_u	*tail;
***************
*** 9724,9731 ****
  		    || (*fnamep)[1] == '\\'
  # endif
  		    || (*fnamep)[1] == NUL)
- 
  #endif
  	   )
  	{
  	    *fnamep = expand_env_save(*fnamep);
--- 9725,9732 ----
  		    || (*fnamep)[1] == '\\'
  # endif
  		    || (*fnamep)[1] == NUL)
  #endif
+ 		&& !(tilde_file && (*fnamep)[1] == NUL)
  	   )
  	{
  	    *fnamep = expand_env_save(*fnamep);
*** ../vim-8.1.0210/src/proto/eval.pro	Tue Jun 12 22:05:10 2018
--- src/proto/eval.pro	Wed Jul 25 21:03:50 2018
***************
*** 136,142 ****
  int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int type_is, int ic);
  char_u *typval_tostring(typval_T *arg);
  int var_exists(char_u *var);
! int modify_fname(char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen);
  char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, char_u *flags);
  void filter_map(typval_T *argvars, typval_T *rettv, int map);
  /* vim: set ft=c : */
--- 136,142 ----
  int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int type_is, int ic);
  char_u *typval_tostring(typval_T *arg);
  int var_exists(char_u *var);
! int modify_fname(char_u *src, int tilde_file, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen);
  char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, typval_T *expr, char_u *flags);
  void filter_map(typval_T *argvars, typval_T *rettv, int map);
  /* vim: set ft=c : */
*** ../vim-8.1.0210/src/evalfunc.c	Wed Jul 25 19:49:41 2018
--- src/evalfunc.c	Wed Jul 25 21:01:17 2018
***************
*** 3801,3807 ****
      else
      {
  	len = (int)STRLEN(fname);
! 	(void)modify_fname(mods, &usedlen, &fname, &fbuf, &len);
      }
  
      rettv->v_type = VAR_STRING;
--- 3801,3807 ----
      else
      {
  	len = (int)STRLEN(fname);
! 	(void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len);
      }
  
      rettv->v_type = VAR_STRING;
*** ../vim-8.1.0210/src/if_cscope.c	Sun Mar  4 16:07:23 2018
--- src/if_cscope.c	Wed Jul 25 21:10:45 2018
***************
*** 519,525 ****
  #ifdef FEAT_MODIFY_FNAME
      len = (int)STRLEN(fname);
      fbuf = (char_u *)fname;
!     (void)modify_fname((char_u *)":p", &usedlen,
  					      (char_u **)&fname, &fbuf, &len);
      if (fname == NULL)
  	goto add_err;
--- 519,525 ----
  #ifdef FEAT_MODIFY_FNAME
      len = (int)STRLEN(fname);
      fbuf = (char_u *)fname;
!     (void)modify_fname((char_u *)":p", FALSE, &usedlen,
  					      (char_u **)&fname, &fbuf, &len);
      if (fname == NULL)
  	goto add_err;
*** ../vim-8.1.0210/src/misc1.c	Sat Jul  7 16:41:10 2018
--- src/misc1.c	Wed Jul 25 21:11:10 2018
***************
*** 4908,4914 ****
  	char_u	*fbuf = NULL;
  
  	flen = (int)STRLEN(homedir_env);
! 	(void)modify_fname((char_u *)":p", &usedlen,
  						  &homedir_env, &fbuf, &flen);
  	flen = (int)STRLEN(homedir_env);
  	if (flen > 0 && vim_ispathsep(homedir_env[flen - 1]))
--- 4908,4914 ----
  	char_u	*fbuf = NULL;
  
  	flen = (int)STRLEN(homedir_env);
! 	(void)modify_fname((char_u *)":p", FALSE, &usedlen,
  						  &homedir_env, &fbuf, &flen);
  	flen = (int)STRLEN(homedir_env);
  	if (flen > 0 && vim_ispathsep(homedir_env[flen - 1]))
*** ../vim-8.1.0210/src/version.c	Wed Jul 25 19:49:41 2018
--- src/version.c	Wed Jul 25 21:18:08 2018
***************
*** 795,796 ****
--- 795,798 ----
  {   /* Add new patch number below this line */
+ /**/
+     211,
  /**/

-- 
You were lucky to have a LAKE! There were a hundred and sixty of
us living in a small shoebox in the middle of the road.

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