Blame SOURCES/7.4.276

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.276
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.276
22c937
Problem:    The fish shell is not supported.
22c937
Solution:   Use begin/end instead of () for fish. (Andy Russell)
22c937
Files:	    src/ex_cmds.c, src/misc1.c, src/option.c, src/proto/misc1.pro
22c937
22c937
22c937
*** ../vim-7.4.275/src/ex_cmds.c	2014-05-07 14:38:41.129091709 +0200
22c937
--- src/ex_cmds.c	2014-05-07 15:09:57.797108136 +0200
22c937
***************
22c937
*** 1551,1558 ****
22c937
  {
22c937
      char_u	*buf;
22c937
      long_u	len;
22c937
  
22c937
!     len = (long_u)STRLEN(cmd) + 3;			/* "()" + NUL */
22c937
      if (itmp != NULL)
22c937
  	len += (long_u)STRLEN(itmp) + 9;		/* " { < " + " } " */
22c937
      if (otmp != NULL)
22c937
--- 1551,1566 ----
22c937
  {
22c937
      char_u	*buf;
22c937
      long_u	len;
22c937
+     int		is_fish_shell;
22c937
  
22c937
! #if (defined(UNIX) && !defined(ARCHIE)) || defined(OS2)
22c937
!     /* Account for fish's different syntax for subshells */
22c937
!     is_fish_shell = (fnamecmp(get_isolated_shell_name(), "fish") == 0);
22c937
!     if (is_fish_shell)
22c937
! 	len = (long_u)STRLEN(cmd) + 13;		/* "begin; " + "; end" + NUL */
22c937
!     else
22c937
! #endif
22c937
! 	len = (long_u)STRLEN(cmd) + 3;			/* "()" + NUL */
22c937
      if (itmp != NULL)
22c937
  	len += (long_u)STRLEN(itmp) + 9;		/* " { < " + " } " */
22c937
      if (otmp != NULL)
22c937
***************
22c937
*** 1567,1573 ****
22c937
       * redirecting input and/or output.
22c937
       */
22c937
      if (itmp != NULL || otmp != NULL)
22c937
! 	vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
22c937
      else
22c937
  	STRCPY(buf, cmd);
22c937
      if (itmp != NULL)
22c937
--- 1575,1586 ----
22c937
       * redirecting input and/or output.
22c937
       */
22c937
      if (itmp != NULL || otmp != NULL)
22c937
!     {
22c937
! 	if (is_fish_shell)
22c937
! 	    vim_snprintf((char *)buf, len, "begin; %s; end", (char *)cmd);
22c937
! 	else
22c937
! 	    vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
22c937
!     }
22c937
      else
22c937
  	STRCPY(buf, cmd);
22c937
      if (itmp != NULL)
22c937
***************
22c937
*** 1577,1583 ****
22c937
      }
22c937
  #else
22c937
      /*
22c937
!      * for shells that don't understand braces around commands, at least allow
22c937
       * the use of commands in a pipe.
22c937
       */
22c937
      STRCPY(buf, cmd);
22c937
--- 1590,1596 ----
22c937
      }
22c937
  #else
22c937
      /*
22c937
!      * For shells that don't understand braces around commands, at least allow
22c937
       * the use of commands in a pipe.
22c937
       */
22c937
      STRCPY(buf, cmd);
22c937
***************
22c937
*** 4315,4321 ****
22c937
      pos_T	old_cursor = curwin->w_cursor;
22c937
      int		start_nsubs;
22c937
  #ifdef FEAT_EVAL
22c937
!     int         save_ma = 0;
22c937
  #endif
22c937
  
22c937
      cmd = eap->arg;
22c937
--- 4328,4334 ----
22c937
      pos_T	old_cursor = curwin->w_cursor;
22c937
      int		start_nsubs;
22c937
  #ifdef FEAT_EVAL
22c937
!     int		save_ma = 0;
22c937
  #endif
22c937
  
22c937
      cmd = eap->arg;
22c937
***************
22c937
*** 5986,5992 ****
22c937
  			       "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
22c937
  			       "\\[count]", "\\[quotex]", "\\[range]",
22c937
  			       "\\[pattern]", "\\\\bar", "/\\\\%\\$",
22c937
!                                "s/\\\\\\~", "s/\\\\U", "s/\\\\L",
22c937
  			       "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};
22c937
      int flags;
22c937
  
22c937
--- 5999,6005 ----
22c937
  			       "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
22c937
  			       "\\[count]", "\\[quotex]", "\\[range]",
22c937
  			       "\\[pattern]", "\\\\bar", "/\\\\%\\$",
22c937
! 			       "s/\\\\\\~", "s/\\\\U", "s/\\\\L",
22c937
  			       "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};
22c937
      int flags;
22c937
  
22c937
***************
22c937
*** 6026,6032 ****
22c937
  	  /* Replace:
22c937
  	   * "[:...:]" with "\[:...:]"
22c937
  	   * "[++...]" with "\[++...]"
22c937
! 	   * "\{" with "\\{"               -- matching "} \}"
22c937
  	   */
22c937
  	    if ((arg[0] == '[' && (arg[1] == ':'
22c937
  			 || (arg[1] == '+' && arg[2] == '+')))
22c937
--- 6039,6045 ----
22c937
  	  /* Replace:
22c937
  	   * "[:...:]" with "\[:...:]"
22c937
  	   * "[++...]" with "\[++...]"
22c937
! 	   * "\{" with "\\{"		   -- matching "} \}"
22c937
  	   */
22c937
  	    if ((arg[0] == '[' && (arg[1] == ':'
22c937
  			 || (arg[1] == '+' && arg[2] == '+')))
22c937
*** ../vim-7.4.275/src/misc1.c	2014-04-05 19:44:36.903160723 +0200
22c937
--- src/misc1.c	2014-05-07 15:04:25.921105231 +0200
22c937
***************
22c937
*** 1405,1411 ****
22c937
  #ifdef FEAT_SMARTINDENT
22c937
  	if (did_si)
22c937
  	{
22c937
! 	    int        sw = (int)get_sw_value(curbuf);
22c937
  
22c937
  	    if (p_sr)
22c937
  		newindent -= newindent % sw;
22c937
--- 1405,1411 ----
22c937
  #ifdef FEAT_SMARTINDENT
22c937
  	if (did_si)
22c937
  	{
22c937
! 	    int sw = (int)get_sw_value(curbuf);
22c937
  
22c937
  	    if (p_sr)
22c937
  		newindent -= newindent % sw;
22c937
***************
22c937
*** 10896,10898 ****
22c937
--- 10896,10936 ----
22c937
  {
22c937
      return (p_im && stuff_empty() && typebuf_typed());
22c937
  }
22c937
+ 
22c937
+ /*
22c937
+  * Returns the isolated name of the shell:
22c937
+  * - Skip beyond any path.  E.g., "/usr/bin/csh -f" -> "csh -f".
22c937
+  * - Remove any argument.  E.g., "csh -f" -> "csh".
22c937
+  * But don't allow a space in the path, so that this works:
22c937
+  *   "/usr/bin/csh --rcfile ~/.cshrc"
22c937
+  * But don't do that for Windows, it's common to have a space in the path.
22c937
+  */
22c937
+     char_u *
22c937
+ get_isolated_shell_name()
22c937
+ {
22c937
+     char_u *p;
22c937
+ 
22c937
+ #ifdef WIN3264
22c937
+     p = gettail(p_sh);
22c937
+     p = vim_strnsave(p, (int)(skiptowhite(p) - p));
22c937
+ #else
22c937
+     p = skiptowhite(p_sh);
22c937
+     if (*p == NUL)
22c937
+     {
22c937
+ 	/* No white space, use the tail. */
22c937
+ 	p = vim_strsave(gettail(p_sh));
22c937
+     }
22c937
+     else
22c937
+     {
22c937
+ 	char_u  *p1, *p2;
22c937
+ 
22c937
+ 	/* Find the last path separator before the space. */
22c937
+ 	p1 = p_sh;
22c937
+ 	for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
22c937
+ 	    if (vim_ispathsep(*p2))
22c937
+ 		p1 = p2 + 1;
22c937
+ 	p = vim_strnsave(p1, (int)(p - p1));
22c937
+     }
22c937
+ #endif
22c937
+     return p;
22c937
+ }
22c937
*** ../vim-7.4.275/src/option.c	2014-03-23 15:12:29.931264336 +0100
22c937
--- src/option.c	2014-05-07 15:05:14.117105653 +0200
22c937
***************
22c937
*** 3804,3840 ****
22c937
      else
22c937
  	do_sp = !(options[idx_sp].flags & P_WAS_SET);
22c937
  #endif
22c937
! 
22c937
!     /*
22c937
!      * Isolate the name of the shell:
22c937
!      * - Skip beyond any path.  E.g., "/usr/bin/csh -f" -> "csh -f".
22c937
!      * - Remove any argument.  E.g., "csh -f" -> "csh".
22c937
!      * But don't allow a space in the path, so that this works:
22c937
!      *   "/usr/bin/csh --rcfile ~/.cshrc"
22c937
!      * But don't do that for Windows, it's common to have a space in the path.
22c937
!      */
22c937
! #ifdef WIN3264
22c937
!     p = gettail(p_sh);
22c937
!     p = vim_strnsave(p, (int)(skiptowhite(p) - p));
22c937
! #else
22c937
!     p = skiptowhite(p_sh);
22c937
!     if (*p == NUL)
22c937
!     {
22c937
! 	/* No white space, use the tail. */
22c937
! 	p = vim_strsave(gettail(p_sh));
22c937
!     }
22c937
!     else
22c937
!     {
22c937
! 	char_u  *p1, *p2;
22c937
! 
22c937
! 	/* Find the last path separator before the space. */
22c937
! 	p1 = p_sh;
22c937
! 	for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
22c937
! 	    if (vim_ispathsep(*p2))
22c937
! 		p1 = p2 + 1;
22c937
! 	p = vim_strnsave(p1, (int)(p - p1));
22c937
!     }
22c937
! #endif
22c937
      if (p != NULL)
22c937
      {
22c937
  	/*
22c937
--- 3804,3810 ----
22c937
      else
22c937
  	do_sp = !(options[idx_sp].flags & P_WAS_SET);
22c937
  #endif
22c937
!     p = get_isolated_shell_name();
22c937
      if (p != NULL)
22c937
      {
22c937
  	/*
22c937
***************
22c937
*** 3875,3880 ****
22c937
--- 3845,3851 ----
22c937
  		    || fnamecmp(p, "zsh") == 0
22c937
  		    || fnamecmp(p, "zsh-beta") == 0
22c937
  		    || fnamecmp(p, "bash") == 0
22c937
+ 		    || fnamecmp(p, "fish") == 0
22c937
  #  ifdef WIN3264
22c937
  		    || fnamecmp(p, "cmd") == 0
22c937
  		    || fnamecmp(p, "sh.exe") == 0
22c937
***************
22c937
*** 8858,8865 ****
22c937
   * opt_type). Uses
22c937
   *
22c937
   * Returned flags:
22c937
!  *       0 hidden or unknown option, also option that does not have requested 
22c937
!  *         type (see SREQ_* in vim.h)
22c937
   *  see SOPT_* in vim.h for other flags
22c937
   *
22c937
   * Possible opt_type values: see SREQ_* in vim.h
22c937
--- 8829,8836 ----
22c937
   * opt_type). Uses
22c937
   *
22c937
   * Returned flags:
22c937
!  *       0 hidden or unknown option, also option that does not have requested
22c937
!  *	   type (see SREQ_* in vim.h)
22c937
   *  see SOPT_* in vim.h for other flags
22c937
   *
22c937
   * Possible opt_type values: see SREQ_* in vim.h
22c937
*** ../vim-7.4.275/src/proto/misc1.pro	2014-04-05 19:44:36.903160723 +0200
22c937
--- src/proto/misc1.pro	2014-05-07 14:57:04.605101368 +0200
22c937
***************
22c937
*** 103,106 ****
22c937
--- 103,107 ----
22c937
  char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int *ret_len));
22c937
  void FreeWild __ARGS((int count, char_u **files));
22c937
  int goto_im __ARGS((void));
22c937
+ char_u *get_isolated_shell_name __ARGS((void));
22c937
  /* vim: set ft=c : */
22c937
*** ../vim-7.4.275/src/version.c	2014-05-07 14:38:41.129091709 +0200
22c937
--- src/version.c	2014-05-07 14:58:59.769102376 +0200
22c937
***************
22c937
*** 736,737 ****
22c937
--- 736,739 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     276,
22c937
  /**/
22c937
22c937
-- 
22c937
Support your right to bare arms!  Wear short sleeves!
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///