Karsten Hopp bab1f4
To: vim_dev@googlegroups.com
Karsten Hopp bab1f4
Subject: Patch 7.4.831
Karsten Hopp bab1f4
Fcc: outbox
Karsten Hopp bab1f4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp bab1f4
Mime-Version: 1.0
Karsten Hopp bab1f4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp bab1f4
Content-Transfer-Encoding: 8bit
Karsten Hopp bab1f4
------------
Karsten Hopp bab1f4
Karsten Hopp bab1f4
Patch 7.4.831
Karsten Hopp bab1f4
Problem:    When expanding `=expr` on the command line and encountering an
Karsten Hopp bab1f4
            error, the command is executed anyway.
Karsten Hopp bab1f4
Solution:   Bail out when an error is detected.
Karsten Hopp bab1f4
Files:      src/misc1.c
Karsten Hopp bab1f4
Karsten Hopp bab1f4
Karsten Hopp bab1f4
*** ../vim-7.4.830/src/misc1.c	2015-07-28 21:17:31.522069387 +0200
Karsten Hopp bab1f4
--- src/misc1.c	2015-08-25 13:32:09.704105987 +0200
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 10875,10880 ****
Karsten Hopp bab1f4
--- 10875,10881 ----
Karsten Hopp bab1f4
      char_u		*p;
Karsten Hopp bab1f4
      static int		recursive = FALSE;
Karsten Hopp bab1f4
      int			add_pat;
Karsten Hopp bab1f4
+     int			retval = OK;
Karsten Hopp bab1f4
  #if defined(FEAT_SEARCHPATH)
Karsten Hopp bab1f4
      int			did_expand_in_path = FALSE;
Karsten Hopp bab1f4
  #endif
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 10924,10930 ****
Karsten Hopp bab1f4
--- 10925,10935 ----
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
  #ifdef VIM_BACKTICK
Karsten Hopp bab1f4
  	if (vim_backtick(p))
Karsten Hopp bab1f4
+ 	{
Karsten Hopp bab1f4
  	    add_pat = expand_backtick(&ga, p, flags);
Karsten Hopp bab1f4
+ 	    if (add_pat == -1)
Karsten Hopp bab1f4
+ 		retval = FAIL;
Karsten Hopp bab1f4
+ 	}
Karsten Hopp bab1f4
  	else
Karsten Hopp bab1f4
  #endif
Karsten Hopp bab1f4
  	{
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 11013,11019 ****
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
      recursive = FALSE;
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
!     return (ga.ga_data != NULL) ? OK : FAIL;
Karsten Hopp bab1f4
  }
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
  # ifdef VIM_BACKTICK
Karsten Hopp bab1f4
--- 11018,11024 ----
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
      recursive = FALSE;
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
!     return (ga.ga_data != NULL) ? retval : FAIL;
Karsten Hopp bab1f4
  }
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
  # ifdef VIM_BACKTICK
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 11031,11037 ****
Karsten Hopp bab1f4
  /*
Karsten Hopp bab1f4
   * Expand an item in `backticks` by executing it as a command.
Karsten Hopp bab1f4
   * Currently only works when pat[] starts and ends with a `.
Karsten Hopp bab1f4
!  * Returns number of file names found.
Karsten Hopp bab1f4
   */
Karsten Hopp bab1f4
      static int
Karsten Hopp bab1f4
  expand_backtick(gap, pat, flags)
Karsten Hopp bab1f4
--- 11036,11042 ----
Karsten Hopp bab1f4
  /*
Karsten Hopp bab1f4
   * Expand an item in `backticks` by executing it as a command.
Karsten Hopp bab1f4
   * Currently only works when pat[] starts and ends with a `.
Karsten Hopp bab1f4
!  * Returns number of file names found, -1 if an error is encountered.
Karsten Hopp bab1f4
   */
Karsten Hopp bab1f4
      static int
Karsten Hopp bab1f4
  expand_backtick(gap, pat, flags)
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 11048,11054 ****
Karsten Hopp bab1f4
      /* Create the command: lop off the backticks. */
Karsten Hopp bab1f4
      cmd = vim_strnsave(pat + 1, (int)STRLEN(pat) - 2);
Karsten Hopp bab1f4
      if (cmd == NULL)
Karsten Hopp bab1f4
! 	return 0;
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
  #ifdef FEAT_EVAL
Karsten Hopp bab1f4
      if (*cmd == '=')	    /* `={expr}`: Expand expression */
Karsten Hopp bab1f4
--- 11053,11059 ----
Karsten Hopp bab1f4
      /* Create the command: lop off the backticks. */
Karsten Hopp bab1f4
      cmd = vim_strnsave(pat + 1, (int)STRLEN(pat) - 2);
Karsten Hopp bab1f4
      if (cmd == NULL)
Karsten Hopp bab1f4
! 	return -1;
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
  #ifdef FEAT_EVAL
Karsten Hopp bab1f4
      if (*cmd == '=')	    /* `={expr}`: Expand expression */
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 11059,11065 ****
Karsten Hopp bab1f4
  				(flags & EW_SILENT) ? SHELL_SILENT : 0, NULL);
Karsten Hopp bab1f4
      vim_free(cmd);
Karsten Hopp bab1f4
      if (buffer == NULL)
Karsten Hopp bab1f4
! 	return 0;
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
      cmd = buffer;
Karsten Hopp bab1f4
      while (*cmd != NUL)
Karsten Hopp bab1f4
--- 11064,11070 ----
Karsten Hopp bab1f4
  				(flags & EW_SILENT) ? SHELL_SILENT : 0, NULL);
Karsten Hopp bab1f4
      vim_free(cmd);
Karsten Hopp bab1f4
      if (buffer == NULL)
Karsten Hopp bab1f4
! 	return -1;
Karsten Hopp bab1f4
  
Karsten Hopp bab1f4
      cmd = buffer;
Karsten Hopp bab1f4
      while (*cmd != NUL)
Karsten Hopp bab1f4
*** ../vim-7.4.830/src/version.c	2015-08-25 12:56:22.622312124 +0200
Karsten Hopp bab1f4
--- src/version.c	2015-08-25 13:55:45.693438779 +0200
Karsten Hopp bab1f4
***************
Karsten Hopp bab1f4
*** 743,744 ****
Karsten Hopp bab1f4
--- 743,746 ----
Karsten Hopp bab1f4
  {   /* Add new patch number below this line */
Karsten Hopp bab1f4
+ /**/
Karsten Hopp bab1f4
+     831,
Karsten Hopp bab1f4
  /**/
Karsten Hopp bab1f4
Karsten Hopp bab1f4
-- 
Karsten Hopp bab1f4
Every person is responsible for the choices he makes.
Karsten Hopp bab1f4
Karsten Hopp bab1f4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp bab1f4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp bab1f4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp bab1f4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///