Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.4.229
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.229
Problem:    Using ":let" for listing variables and the second one is a curly
	    braces expression may fail.
Solution:   Check for an "=" in a better way. (ZyX)
Files:	    src/eval.c, src/testdir/test104.in, src/testdir/test104.ok


*** ../vim-7.4.228/src/eval.c	2014-03-25 18:23:27.062087691 +0100
--- src/eval.c	2014-03-30 16:46:24.464562806 +0200
***************
*** 1856,1863 ****
  	return;
      if (argend > arg && argend[-1] == '.')  /* for var.='str' */
  	--argend;
!     expr = vim_strchr(argend, '=');
!     if (expr == NULL)
      {
  	/*
  	 * ":let" without "=": list variables
--- 1856,1864 ----
  	return;
      if (argend > arg && argend[-1] == '.')  /* for var.='str' */
  	--argend;
!     expr = skipwhite(argend);
!     if (*expr != '=' && !(vim_strchr((char_u *)"+-.", *expr) != NULL
! 			  && expr[1] == '='))
      {
  	/*
  	 * ":let" without "=": list variables
***************
*** 1886,1897 ****
      {
  	op[0] = '=';
  	op[1] = NUL;
! 	if (expr > argend)
  	{
! 	    if (vim_strchr((char_u *)"+-.", expr[-1]) != NULL)
! 		op[0] = expr[-1];   /* +=, -= or .= */
  	}
! 	expr = skipwhite(expr + 1);
  
  	if (eap->skip)
  	    ++emsg_skip;
--- 1887,1900 ----
      {
  	op[0] = '=';
  	op[1] = NUL;
! 	if (*expr != '=')
  	{
! 	    if (vim_strchr((char_u *)"+-.", *expr) != NULL)
! 		op[0] = *expr;   /* +=, -= or .= */
! 	    expr = skipwhite(expr + 2);
  	}
! 	else
! 	    expr = skipwhite(expr + 1);
  
  	if (eap->skip)
  	    ++emsg_skip;
*** ../vim-7.4.228/src/testdir/test104.in	2014-02-05 22:25:29.982568243 +0100
--- src/testdir/test104.in	2014-03-30 16:44:39.432561197 +0200
***************
*** 1,4 ****
! Tests for autoload.  vim: set ft=vim ts=8 :
  
  STARTTEST
  :so small.vim
--- 1,4 ----
! Tests for :let.  vim: set ft=vim ts=8 :
  
  STARTTEST
  :so small.vim
***************
*** 10,15 ****
--- 10,29 ----
  :catch
  :  $put ='FAIL: ' . v:exception
  :endtry
+ :let a = 1
+ :let b = 2
+ :for letargs in ['a b', '{0 == 1 ? "a" : "b"}', '{0 == 1 ? "a" : "b"} a', 'a {0 == 1 ? "a" : "b"}']
+ :  try
+ :    redir => messages
+ :    execute 'let' letargs
+ :    redir END
+ :    $put ='OK:'
+ :    $put =split(substitute(messages, '\n', '\0  ', 'g'), '\n')
+ :  catch
+ :    $put ='FAIL: ' . v:exception
+ :    redir END
+ :  endtry
+ :endfor
  :/^Results/,$wq! test.out
  ENDTEST
  
*** ../vim-7.4.228/src/testdir/test104.ok	2014-02-05 22:25:29.982568243 +0100
--- src/testdir/test104.ok	2014-03-30 16:44:39.432561197 +0200
***************
*** 1,2 ****
--- 1,13 ----
  Results of test104:
  OK: function('tr')
+ OK:
+   a                     #1
+   b                     #2
+ OK:
+   b                     #2
+ OK:
+   b                     #2
+   a                     #1
+ OK:
+   a                     #1
+   b                     #2
*** ../vim-7.4.228/src/version.c	2014-03-30 16:11:37.180530823 +0200
--- src/version.c	2014-03-30 16:46:39.660563039 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     229,
  /**/

-- 
You have heard the saying that if you put a thousand monkeys in a room with a
thousand typewriters and waited long enough, eventually you would have a room
full of dead monkeys.
				(Scott Adams - The Dilbert principle)

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