jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.272

073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.272
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.272
073263
Problem:    Using just "$" does not cause an error message.
073263
Solution:   Check for empty environment variable name. (Christian Brabandt)
073263
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok
073263
073263
073263
*** ../vim-7.4.271/src/eval.c	2014-04-29 14:02:42.543919791 +0200
073263
--- src/eval.c	2014-04-29 17:33:40.575697949 +0200
073263
***************
073263
*** 7798,7804 ****
073263
   * Get the value of an environment variable.
073263
   * "arg" is pointing to the '$'.  It is advanced to after the name.
073263
   * If the environment variable was not set, silently assume it is empty.
073263
!  * Always return OK.
073263
   */
073263
      static int
073263
  get_env_tv(arg, rettv, evaluate)
073263
--- 7798,7804 ----
073263
   * Get the value of an environment variable.
073263
   * "arg" is pointing to the '$'.  It is advanced to after the name.
073263
   * If the environment variable was not set, silently assume it is empty.
073263
!  * Return FAIL if the name is invalid.
073263
   */
073263
      static int
073263
  get_env_tv(arg, rettv, evaluate)
073263
***************
073263
*** 7817,7848 ****
073263
      len = get_env_len(arg);
073263
      if (evaluate)
073263
      {
073263
! 	if (len != 0)
073263
  	{
073263
! 	    cc = name[len];
073263
! 	    name[len] = NUL;
073263
! 	    /* first try vim_getenv(), fast for normal environment vars */
073263
! 	    string = vim_getenv(name, &mustfree);
073263
! 	    if (string != NULL && *string != NUL)
073263
! 	    {
073263
! 		if (!mustfree)
073263
! 		    string = vim_strsave(string);
073263
! 	    }
073263
! 	    else
073263
! 	    {
073263
! 		if (mustfree)
073263
! 		    vim_free(string);
073263
  
073263
! 		/* next try expanding things like $VIM and ${HOME} */
073263
! 		string = expand_env_save(name - 1);
073263
! 		if (string != NULL && *string == '$')
073263
! 		{
073263
! 		    vim_free(string);
073263
! 		    string = NULL;
073263
! 		}
073263
  	    }
073263
- 	    name[len] = cc;
073263
  	}
073263
  	rettv->v_type = VAR_STRING;
073263
  	rettv->vval.v_string = string;
073263
      }
073263
--- 7817,7849 ----
073263
      len = get_env_len(arg);
073263
      if (evaluate)
073263
      {
073263
! 	if (len == 0)
073263
!            return FAIL; /* can't be an environment variable */
073263
! 
073263
! 	cc = name[len];
073263
! 	name[len] = NUL;
073263
! 	/* first try vim_getenv(), fast for normal environment vars */
073263
! 	string = vim_getenv(name, &mustfree);
073263
! 	if (string != NULL && *string != NUL)
073263
  	{
073263
! 	    if (!mustfree)
073263
! 		string = vim_strsave(string);
073263
! 	}
073263
! 	else
073263
! 	{
073263
! 	    if (mustfree)
073263
! 		vim_free(string);
073263
  
073263
! 	    /* next try expanding things like $VIM and ${HOME} */
073263
! 	    string = expand_env_save(name - 1);
073263
! 	    if (string != NULL && *string == '$')
073263
! 	    {
073263
! 		vim_free(string);
073263
! 		string = NULL;
073263
  	    }
073263
  	}
073263
+ 	name[len] = cc;
073263
+ 
073263
  	rettv->v_type = VAR_STRING;
073263
  	rettv->vval.v_string = string;
073263
      }
073263
*** ../vim-7.4.271/src/testdir/test_eval.in	2014-04-29 14:02:42.543919791 +0200
073263
--- src/testdir/test_eval.in	2014-04-29 17:35:27.243696080 +0200
073263
***************
073263
*** 183,188 ****
073263
--- 183,195 ----
073263
  :" script-local function used in Funcref must exist.
073263
  :so test_eval_func.vim
073263
  :"
073263
+ :" Using $ instead of '$' must give an error
073263
+ :try
073263
+ : call append($, 'foobar')
073263
+ :catch
073263
+ :$put =v:exception
073263
+ :endtry
073263
+ :"
073263
  :/^start:/+1,$wq! test.out
073263
  :" vim: et ts=4 isk-=\: fmr=???,???
073263
  :call getchar()
073263
*** ../vim-7.4.271/src/testdir/test_eval.ok	2014-04-29 14:02:42.543919791 +0200
073263
--- src/testdir/test_eval.ok	2014-04-29 17:36:41.451694779 +0200
073263
***************
073263
*** 345,347 ****
073263
--- 345,348 ----
073263
  func s:Testje exists: 1
073263
  Bar exists: 1
073263
  func Bar exists: 1
073263
+ Vim(call):E116: Invalid arguments for function append
073263
*** ../vim-7.4.271/src/version.c	2014-04-29 15:55:39.443801021 +0200
073263
--- src/version.c	2014-04-29 17:31:54.203699814 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     272,
073263
  /**/
073263
073263
-- 
073263
From "know your smileys":
073263
 C=}>;*{)) Drunk, devilish chef with a toupee in an updraft,
073263
	   a mustache, and a double chin
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///