Karsten Hopp d89e9a
To: vim_dev@googlegroups.com
Karsten Hopp d89e9a
Subject: Patch 7.3.265
Karsten Hopp d89e9a
Fcc: outbox
Karsten Hopp d89e9a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp d89e9a
Mime-Version: 1.0
Karsten Hopp d89e9a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp d89e9a
Content-Transfer-Encoding: 8bit
Karsten Hopp d89e9a
------------
Karsten Hopp d89e9a
Karsten Hopp d89e9a
Patch 7.3.265
Karsten Hopp d89e9a
Problem:    When storing a pattern in search history there is no proper check
Karsten Hopp d89e9a
	    for the separator character.
Karsten Hopp d89e9a
Solution:   Pass the separator character to in_history(). (Muraoka Taro)
Karsten Hopp d89e9a
Files:	    src/ex_getln.c
Karsten Hopp d89e9a
Karsten Hopp d89e9a
Karsten Hopp d89e9a
*** ../vim-7.3.264/src/ex_getln.c	2011-07-07 16:44:33.000000000 +0200
Karsten Hopp d89e9a
--- src/ex_getln.c	2011-07-27 17:50:35.000000000 +0200
Karsten Hopp d89e9a
***************
Karsten Hopp d89e9a
*** 67,73 ****
Karsten Hopp d89e9a
  
Karsten Hopp d89e9a
  static int	hist_char2type __ARGS((int c));
Karsten Hopp d89e9a
  
Karsten Hopp d89e9a
! static int	in_history __ARGS((int, char_u *, int));
Karsten Hopp d89e9a
  # ifdef FEAT_EVAL
Karsten Hopp d89e9a
  static int	calc_hist_idx __ARGS((int histype, int num));
Karsten Hopp d89e9a
  # endif
Karsten Hopp d89e9a
--- 67,73 ----
Karsten Hopp d89e9a
  
Karsten Hopp d89e9a
  static int	hist_char2type __ARGS((int c));
Karsten Hopp d89e9a
  
Karsten Hopp d89e9a
! static int	in_history __ARGS((int, char_u *, int, int));
Karsten Hopp d89e9a
  # ifdef FEAT_EVAL
Karsten Hopp d89e9a
  static int	calc_hist_idx __ARGS((int histype, int num));
Karsten Hopp d89e9a
  # endif
Karsten Hopp d89e9a
***************
Karsten Hopp d89e9a
*** 5289,5301 ****
Karsten Hopp d89e9a
   * If 'move_to_front' is TRUE, matching entry is moved to end of history.
Karsten Hopp d89e9a
   */
Karsten Hopp d89e9a
      static int
Karsten Hopp d89e9a
! in_history(type, str, move_to_front)
Karsten Hopp d89e9a
      int	    type;
Karsten Hopp d89e9a
      char_u  *str;
Karsten Hopp d89e9a
      int	    move_to_front;	/* Move the entry to the front if it exists */
Karsten Hopp d89e9a
  {
Karsten Hopp d89e9a
      int	    i;
Karsten Hopp d89e9a
      int	    last_i = -1;
Karsten Hopp d89e9a
  
Karsten Hopp d89e9a
      if (hisidx[type] < 0)
Karsten Hopp d89e9a
  	return FALSE;
Karsten Hopp d89e9a
--- 5289,5303 ----
Karsten Hopp d89e9a
   * If 'move_to_front' is TRUE, matching entry is moved to end of history.
Karsten Hopp d89e9a
   */
Karsten Hopp d89e9a
      static int
Karsten Hopp d89e9a
! in_history(type, str, move_to_front, sep)
Karsten Hopp d89e9a
      int	    type;
Karsten Hopp d89e9a
      char_u  *str;
Karsten Hopp d89e9a
      int	    move_to_front;	/* Move the entry to the front if it exists */
Karsten Hopp d89e9a
+     int	    sep;
Karsten Hopp d89e9a
  {
Karsten Hopp d89e9a
      int	    i;
Karsten Hopp d89e9a
      int	    last_i = -1;
Karsten Hopp d89e9a
+     char_u  *p;
Karsten Hopp d89e9a
  
Karsten Hopp d89e9a
      if (hisidx[type] < 0)
Karsten Hopp d89e9a
  	return FALSE;
Karsten Hopp d89e9a
***************
Karsten Hopp d89e9a
*** 5304,5310 ****
Karsten Hopp d89e9a
      {
Karsten Hopp d89e9a
  	if (history[type][i].hisstr == NULL)
Karsten Hopp d89e9a
  	    return FALSE;
Karsten Hopp d89e9a
! 	if (STRCMP(str, history[type][i].hisstr) == 0)
Karsten Hopp d89e9a
  	{
Karsten Hopp d89e9a
  	    if (!move_to_front)
Karsten Hopp d89e9a
  		return TRUE;
Karsten Hopp d89e9a
--- 5306,5317 ----
Karsten Hopp d89e9a
      {
Karsten Hopp d89e9a
  	if (history[type][i].hisstr == NULL)
Karsten Hopp d89e9a
  	    return FALSE;
Karsten Hopp d89e9a
! 
Karsten Hopp d89e9a
! 	/* For search history, check that the separator character matches as
Karsten Hopp d89e9a
! 	 * well. */
Karsten Hopp d89e9a
! 	p = history[type][i].hisstr;
Karsten Hopp d89e9a
! 	if (STRCMP(str, p) == 0
Karsten Hopp d89e9a
! 		&& (type != HIST_SEARCH || sep == p[STRLEN(p) + 1]))
Karsten Hopp d89e9a
  	{
Karsten Hopp d89e9a
  	    if (!move_to_front)
Karsten Hopp d89e9a
  		return TRUE;
Karsten Hopp d89e9a
***************
Karsten Hopp d89e9a
*** 5398,5404 ****
Karsten Hopp d89e9a
  	}
Karsten Hopp d89e9a
  	last_maptick = -1;
Karsten Hopp d89e9a
      }
Karsten Hopp d89e9a
!     if (!in_history(histype, new_entry, TRUE))
Karsten Hopp d89e9a
      {
Karsten Hopp d89e9a
  	if (++hisidx[histype] == hislen)
Karsten Hopp d89e9a
  	    hisidx[histype] = 0;
Karsten Hopp d89e9a
--- 5405,5411 ----
Karsten Hopp d89e9a
  	}
Karsten Hopp d89e9a
  	last_maptick = -1;
Karsten Hopp d89e9a
      }
Karsten Hopp d89e9a
!     if (!in_history(histype, new_entry, TRUE, sep))
Karsten Hopp d89e9a
      {
Karsten Hopp d89e9a
  	if (++hisidx[histype] == hislen)
Karsten Hopp d89e9a
  	    hisidx[histype] = 0;
Karsten Hopp d89e9a
***************
Karsten Hopp d89e9a
*** 5977,5983 ****
Karsten Hopp d89e9a
  	if (val != NULL && *val != NUL)
Karsten Hopp d89e9a
  	{
Karsten Hopp d89e9a
  	    if (!in_history(type, val + (type == HIST_SEARCH),
Karsten Hopp d89e9a
! 							viminfo_add_at_front))
Karsten Hopp d89e9a
  	    {
Karsten Hopp d89e9a
  		/* Need to re-allocate to append the separator byte. */
Karsten Hopp d89e9a
  		len = STRLEN(val);
Karsten Hopp d89e9a
--- 5984,5990 ----
Karsten Hopp d89e9a
  	if (val != NULL && *val != NUL)
Karsten Hopp d89e9a
  	{
Karsten Hopp d89e9a
  	    if (!in_history(type, val + (type == HIST_SEARCH),
Karsten Hopp d89e9a
! 						  viminfo_add_at_front, *val))
Karsten Hopp d89e9a
  	    {
Karsten Hopp d89e9a
  		/* Need to re-allocate to append the separator byte. */
Karsten Hopp d89e9a
  		len = STRLEN(val);
Karsten Hopp d89e9a
*** ../vim-7.3.264/src/version.c	2011-07-27 17:31:42.000000000 +0200
Karsten Hopp d89e9a
--- src/version.c	2011-07-27 17:58:22.000000000 +0200
Karsten Hopp d89e9a
***************
Karsten Hopp d89e9a
*** 711,712 ****
Karsten Hopp d89e9a
--- 711,714 ----
Karsten Hopp d89e9a
  {   /* Add new patch number below this line */
Karsten Hopp d89e9a
+ /**/
Karsten Hopp d89e9a
+     265,
Karsten Hopp d89e9a
  /**/
Karsten Hopp d89e9a
Karsten Hopp d89e9a
-- 
Karsten Hopp d89e9a
    [clop clop]
Karsten Hopp d89e9a
MORTICIAN:  Who's that then?
Karsten Hopp d89e9a
CUSTOMER:   I don't know.
Karsten Hopp d89e9a
MORTICIAN:  Must be a king.
Karsten Hopp d89e9a
CUSTOMER:   Why?
Karsten Hopp d89e9a
MORTICIAN:  He hasn't got shit all over him.
Karsten Hopp d89e9a
                                  The Quest for the Holy Grail (Monty Python)
Karsten Hopp d89e9a
Karsten Hopp d89e9a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp d89e9a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp d89e9a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp d89e9a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///