Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.4.485
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.485 (after 7.4.484)
Problem:    Abbreviations don't work. (Toothpik)
Solution:   Move the length computation inside the for loop.  Compare against
	    the unescaped key.
Files:	    src/getchar.c


*** ../vim-7.4.484/src/getchar.c	2014-10-21 18:17:05.638274024 +0200
--- src/getchar.c	2014-10-21 19:30:46.262283680 +0200
***************
*** 4443,4449 ****
  #endif
      int		is_id = TRUE;
      int		vim_abbr;
-     int		qlen;		/* length of q, CSI/K_SPECIAL unescaped */
  
      if (typebuf.tb_no_abbr_cnt)	/* abbrev. are not recursive */
  	return FALSE;
--- 4443,4448 ----
***************
*** 4521,4549 ****
  #else
  	mp = first_abbr;
  #endif
- 	qlen = mp->m_keylen;
- 	if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL)
- 	{
- 	    char_u	*q = vim_strsave(mp->m_keys);
- 
- 	    /* might have CSI escaped mp->m_keys */
- 	    if (q != NULL)
- 	    {
- 		vim_unescape_csi(q);
- 		qlen = (int)STRLEN(q);
- 		vim_free(q);
- 	    }
- 	}
  	for ( ; mp;
  #ifdef FEAT_LOCALMAP
  		mp->m_next == NULL ? (mp = mp2, mp2 = NULL) :
  #endif
  		(mp = mp->m_next))
  	{
  	    /* find entries with right mode and keys */
! 	    if (       (mp->m_mode & State)
  		    && qlen == len
! 		    && !STRNCMP(mp->m_keys, ptr, (size_t)len))
  		break;
  	}
  	if (mp != NULL)
--- 4520,4553 ----
  #else
  	mp = first_abbr;
  #endif
  	for ( ; mp;
  #ifdef FEAT_LOCALMAP
  		mp->m_next == NULL ? (mp = mp2, mp2 = NULL) :
  #endif
  		(mp = mp->m_next))
  	{
+ 	    int		qlen = mp->m_keylen;
+ 	    char_u	*q = mp->m_keys;
+ 	    int		match;
+ 
+ 	    if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL)
+ 	    {
+ 		/* might have CSI escaped mp->m_keys */
+ 		q = vim_strsave(mp->m_keys);
+ 		if (q != NULL)
+ 		{
+ 		    vim_unescape_csi(q);
+ 		    qlen = (int)STRLEN(q);
+ 		}
+ 	    }
+ 
  	    /* find entries with right mode and keys */
! 	    match =    (mp->m_mode & State)
  		    && qlen == len
! 		    && !STRNCMP(q, ptr, (size_t)len);
! 	    if (q != mp->m_keys)
! 		vim_free(q);
! 	    if (match)
  		break;
  	}
  	if (mp != NULL)
*** ../vim-7.4.484/src/version.c	2014-10-21 18:17:05.638274024 +0200
--- src/version.c	2014-10-21 19:34:55.338284224 +0200
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     485,
  /**/

-- 
TALL KNIGHT: We shall say Ni! again to you if you do not appease us.
ARTHUR:      All right!  What do you want?
TALL KNIGHT: We want ... a shrubbery!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

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