summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.272
blob: e893a96257a69a990b0b160ccea3abb3ad75f095 (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
To: vim_dev@googlegroups.com
Subject: Patch 7.4.272
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.272
Problem:    Using just "$" does not cause an error message.
Solution:   Check for empty environment variable name. (Christian Brabandt)
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok


*** ../vim-7.4.271/src/eval.c	2014-04-29 14:02:42.543919791 +0200
--- src/eval.c	2014-04-29 17:33:40.575697949 +0200
***************
*** 7798,7804 ****
   * Get the value of an environment variable.
   * "arg" is pointing to the '$'.  It is advanced to after the name.
   * If the environment variable was not set, silently assume it is empty.
!  * Always return OK.
   */
      static int
  get_env_tv(arg, rettv, evaluate)
--- 7798,7804 ----
   * Get the value of an environment variable.
   * "arg" is pointing to the '$'.  It is advanced to after the name.
   * If the environment variable was not set, silently assume it is empty.
!  * Return FAIL if the name is invalid.
   */
      static int
  get_env_tv(arg, rettv, evaluate)
***************
*** 7817,7848 ****
      len = get_env_len(arg);
      if (evaluate)
      {
! 	if (len != 0)
  	{
! 	    cc = name[len];
! 	    name[len] = NUL;
! 	    /* first try vim_getenv(), fast for normal environment vars */
! 	    string = vim_getenv(name, &mustfree);
! 	    if (string != NULL && *string != NUL)
! 	    {
! 		if (!mustfree)
! 		    string = vim_strsave(string);
! 	    }
! 	    else
! 	    {
! 		if (mustfree)
! 		    vim_free(string);
  
! 		/* next try expanding things like $VIM and ${HOME} */
! 		string = expand_env_save(name - 1);
! 		if (string != NULL && *string == '$')
! 		{
! 		    vim_free(string);
! 		    string = NULL;
! 		}
  	    }
- 	    name[len] = cc;
  	}
  	rettv->v_type = VAR_STRING;
  	rettv->vval.v_string = string;
      }
--- 7817,7849 ----
      len = get_env_len(arg);
      if (evaluate)
      {
! 	if (len == 0)
!            return FAIL; /* can't be an environment variable */
! 
! 	cc = name[len];
! 	name[len] = NUL;
! 	/* first try vim_getenv(), fast for normal environment vars */
! 	string = vim_getenv(name, &mustfree);
! 	if (string != NULL && *string != NUL)
  	{
! 	    if (!mustfree)
! 		string = vim_strsave(string);
! 	}
! 	else
! 	{
! 	    if (mustfree)
! 		vim_free(string);
  
! 	    /* next try expanding things like $VIM and ${HOME} */
! 	    string = expand_env_save(name - 1);
! 	    if (string != NULL && *string == '$')
! 	    {
! 		vim_free(string);
! 		string = NULL;
  	    }
  	}
+ 	name[len] = cc;
+ 
  	rettv->v_type = VAR_STRING;
  	rettv->vval.v_string = string;
      }
*** ../vim-7.4.271/src/testdir/test_eval.in	2014-04-29 14:02:42.543919791 +0200
--- src/testdir/test_eval.in	2014-04-29 17:35:27.243696080 +0200
***************
*** 183,188 ****
--- 183,195 ----
  :" script-local function used in Funcref must exist.
  :so test_eval_func.vim
  :"
+ :" Using $ instead of '$' must give an error
+ :try
+ : call append($, 'foobar')
+ :catch
+ :$put =v:exception
+ :endtry
+ :"
  :/^start:/+1,$wq! test.out
  :" vim: et ts=4 isk-=\: fmr=???,???
  :call getchar()
*** ../vim-7.4.271/src/testdir/test_eval.ok	2014-04-29 14:02:42.543919791 +0200
--- src/testdir/test_eval.ok	2014-04-29 17:36:41.451694779 +0200
***************
*** 345,347 ****
--- 345,348 ----
  func s:Testje exists: 1
  Bar exists: 1
  func Bar exists: 1
+ Vim(call):E116: Invalid arguments for function append
*** ../vim-7.4.271/src/version.c	2014-04-29 15:55:39.443801021 +0200
--- src/version.c	2014-04-29 17:31:54.203699814 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     272,
  /**/

-- 
From "know your smileys":
 C=}>;*{)) Drunk, devilish chef with a toupee in an updraft,
	   a mustache, and a double chin

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