astepano / rpms / vim

Forked from rpms/vim 6 years ago
Clone
a7ea2bd
To: vim_dev@googlegroups.com
a7ea2bd
Subject: Patch 7.3.091
a7ea2bd
Fcc: outbox
a7ea2bd
From: Bram Moolenaar <Bram@moolenaar.net>
a7ea2bd
Mime-Version: 1.0
a7ea2bd
Content-Type: text/plain; charset=UTF-8
a7ea2bd
Content-Transfer-Encoding: 8bit
a7ea2bd
------------
a7ea2bd
a7ea2bd
Patch 7.3.091
a7ea2bd
Problem:    "vim -w foo" writes special key codes for removed escape
a7ea2bd
	    sequences. (Josh Triplett)
a7ea2bd
Solution:   Don't write K_IGNORE codes.
a7ea2bd
Files:	    src/getchar.c, src/misc1.c, src/term.c, src/vim.h
a7ea2bd
a7ea2bd
a7ea2bd
*** ../vim-7.3.090/src/getchar.c	2010-10-27 17:39:00.000000000 +0200
a7ea2bd
--- src/getchar.c	2010-12-30 12:16:36.000000000 +0100
a7ea2bd
***************
a7ea2bd
*** 1506,1514 ****
a7ea2bd
      }
a7ea2bd
  }
a7ea2bd
  
a7ea2bd
- #define KL_PART_KEY -1		/* keylen value for incomplete key-code */
a7ea2bd
- #define KL_PART_MAP -2		/* keylen value for incomplete mapping */
a7ea2bd
- 
a7ea2bd
  /*
a7ea2bd
   * Get the next input character.
a7ea2bd
   * Can return a special key or a multi-byte character.
a7ea2bd
--- 1506,1511 ----
a7ea2bd
***************
a7ea2bd
*** 2171,2177 ****
a7ea2bd
  					if (!timedout)
a7ea2bd
  					{
a7ea2bd
  					    /* break at a partly match */
a7ea2bd
! 					    keylen = KL_PART_MAP;
a7ea2bd
  					    break;
a7ea2bd
  					}
a7ea2bd
  				    }
a7ea2bd
--- 2168,2174 ----
a7ea2bd
  					if (!timedout)
a7ea2bd
  					{
a7ea2bd
  					    /* break at a partly match */
a7ea2bd
! 					    keylen = KEYLEN_PART_MAP;
a7ea2bd
  					    break;
a7ea2bd
  					}
a7ea2bd
  				    }
a7ea2bd
***************
a7ea2bd
*** 2192,2198 ****
a7ea2bd
  
a7ea2bd
  			/* If no partly match found, use the longest full
a7ea2bd
  			 * match. */
a7ea2bd
! 			if (keylen != KL_PART_MAP)
a7ea2bd
  			{
a7ea2bd
  			    mp = mp_match;
a7ea2bd
  			    keylen = mp_match_len;
a7ea2bd
--- 2189,2195 ----
a7ea2bd
  
a7ea2bd
  			/* If no partly match found, use the longest full
a7ea2bd
  			 * match. */
a7ea2bd
! 			if (keylen != KEYLEN_PART_MAP)
a7ea2bd
  			{
a7ea2bd
  			    mp = mp_match;
a7ea2bd
  			    keylen = mp_match_len;
a7ea2bd
***************
a7ea2bd
*** 2230,2236 ****
a7ea2bd
  			}
a7ea2bd
  			/* Need more chars for partly match. */
a7ea2bd
  			if (mlen == typebuf.tb_len)
a7ea2bd
! 			    keylen = KL_PART_KEY;
a7ea2bd
  			else if (max_mlen < mlen)
a7ea2bd
  			    /* no match, may have to check for termcode at
a7ea2bd
  			     * next character */
a7ea2bd
--- 2227,2233 ----
a7ea2bd
  			}
a7ea2bd
  			/* Need more chars for partly match. */
a7ea2bd
  			if (mlen == typebuf.tb_len)
a7ea2bd
! 			    keylen = KEYLEN_PART_KEY;
a7ea2bd
  			else if (max_mlen < mlen)
a7ea2bd
  			    /* no match, may have to check for termcode at
a7ea2bd
  			     * next character */
a7ea2bd
***************
a7ea2bd
*** 2238,2244 ****
a7ea2bd
  		    }
a7ea2bd
  
a7ea2bd
  		    if ((mp == NULL || max_mlen >= mp_match_len)
a7ea2bd
! 						     && keylen != KL_PART_MAP)
a7ea2bd
  		    {
a7ea2bd
  			int	save_keylen = keylen;
a7ea2bd
  
a7ea2bd
--- 2235,2241 ----
a7ea2bd
  		    }
a7ea2bd
  
a7ea2bd
  		    if ((mp == NULL || max_mlen >= mp_match_len)
a7ea2bd
! 						 && keylen != KEYLEN_PART_MAP)
a7ea2bd
  		    {
a7ea2bd
  			int	save_keylen = keylen;
a7ea2bd
  
a7ea2bd
***************
a7ea2bd
*** 2264,2271 ****
a7ea2bd
  			    /* If no termcode matched but 'pastetoggle'
a7ea2bd
  			     * matched partially it's like an incomplete key
a7ea2bd
  			     * sequence. */
a7ea2bd
! 			    if (keylen == 0 && save_keylen == KL_PART_KEY)
a7ea2bd
! 				keylen = KL_PART_KEY;
a7ea2bd
  
a7ea2bd
  			    /*
a7ea2bd
  			     * When getting a partial match, but the last
a7ea2bd
--- 2261,2268 ----
a7ea2bd
  			    /* If no termcode matched but 'pastetoggle'
a7ea2bd
  			     * matched partially it's like an incomplete key
a7ea2bd
  			     * sequence. */
a7ea2bd
! 			    if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
a7ea2bd
! 				keylen = KEYLEN_PART_KEY;
a7ea2bd
  
a7ea2bd
  			    /*
a7ea2bd
  			     * When getting a partial match, but the last
a7ea2bd
***************
a7ea2bd
*** 2302,2308 ****
a7ea2bd
  				    continue;
a7ea2bd
  				}
a7ea2bd
  				if (*s == NUL)	    /* need more characters */
a7ea2bd
! 				    keylen = KL_PART_KEY;
a7ea2bd
  			    }
a7ea2bd
  			    if (keylen >= 0)
a7ea2bd
  #endif
a7ea2bd
--- 2299,2305 ----
a7ea2bd
  				    continue;
a7ea2bd
  				}
a7ea2bd
  				if (*s == NUL)	    /* need more characters */
a7ea2bd
! 				    keylen = KEYLEN_PART_KEY;
a7ea2bd
  			    }
a7ea2bd
  			    if (keylen >= 0)
a7ea2bd
  #endif
a7ea2bd
***************
a7ea2bd
*** 2339,2345 ****
a7ea2bd
  			if (keylen > 0)	    /* full matching terminal code */
a7ea2bd
  			{
a7ea2bd
  #if defined(FEAT_GUI) && defined(FEAT_MENU)
a7ea2bd
! 			    if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
a7ea2bd
  					 && typebuf.tb_buf[typebuf.tb_off + 1]
a7ea2bd
  								   == KS_MENU)
a7ea2bd
  			    {
a7ea2bd
--- 2336,2343 ----
a7ea2bd
  			if (keylen > 0)	    /* full matching terminal code */
a7ea2bd
  			{
a7ea2bd
  #if defined(FEAT_GUI) && defined(FEAT_MENU)
a7ea2bd
! 			    if (typebuf.tb_len >= 2
a7ea2bd
! 				&& typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
a7ea2bd
  					 && typebuf.tb_buf[typebuf.tb_off + 1]
a7ea2bd
  								   == KS_MENU)
a7ea2bd
  			    {
a7ea2bd
***************
a7ea2bd
*** 2381,2387 ****
a7ea2bd
  			/* Partial match: get some more characters.  When a
a7ea2bd
  			 * matching mapping was found use that one. */
a7ea2bd
  			if (mp == NULL || keylen < 0)
a7ea2bd
! 			    keylen = KL_PART_KEY;
a7ea2bd
  			else
a7ea2bd
  			    keylen = mp_match_len;
a7ea2bd
  		    }
a7ea2bd
--- 2379,2385 ----
a7ea2bd
  			/* Partial match: get some more characters.  When a
a7ea2bd
  			 * matching mapping was found use that one. */
a7ea2bd
  			if (mp == NULL || keylen < 0)
a7ea2bd
! 			    keylen = KEYLEN_PART_KEY;
a7ea2bd
  			else
a7ea2bd
  			    keylen = mp_match_len;
a7ea2bd
  		    }
a7ea2bd
***************
a7ea2bd
*** 2553,2559 ****
a7ea2bd
  #endif
a7ea2bd
  			&& typebuf.tb_maplen == 0
a7ea2bd
  			&& (State & INSERT)
a7ea2bd
! 			&& (p_timeout || (keylen == KL_PART_KEY && p_ttimeout))
a7ea2bd
  			&& (c = inchar(typebuf.tb_buf + typebuf.tb_off
a7ea2bd
  						     + typebuf.tb_len, 3, 25L,
a7ea2bd
  						 typebuf.tb_change_cnt)) == 0)
a7ea2bd
--- 2551,2558 ----
a7ea2bd
  #endif
a7ea2bd
  			&& typebuf.tb_maplen == 0
a7ea2bd
  			&& (State & INSERT)
a7ea2bd
! 			&& (p_timeout
a7ea2bd
! 			    || (keylen == KEYLEN_PART_KEY && p_ttimeout))
a7ea2bd
  			&& (c = inchar(typebuf.tb_buf + typebuf.tb_off
a7ea2bd
  						     + typebuf.tb_len, 3, 25L,
a7ea2bd
  						 typebuf.tb_change_cnt)) == 0)
a7ea2bd
***************
a7ea2bd
*** 2783,2791 ****
a7ea2bd
  			    ? 0
a7ea2bd
  			    : ((typebuf.tb_len == 0
a7ea2bd
  				    || !(p_timeout || (p_ttimeout
a7ea2bd
! 						   && keylen == KL_PART_KEY)))
a7ea2bd
  				    ? -1L
a7ea2bd
! 				    : ((keylen == KL_PART_KEY && p_ttm >= 0)
a7ea2bd
  					    ? p_ttm
a7ea2bd
  					    : p_tm)), typebuf.tb_change_cnt);
a7ea2bd
  
a7ea2bd
--- 2782,2790 ----
a7ea2bd
  			    ? 0
a7ea2bd
  			    : ((typebuf.tb_len == 0
a7ea2bd
  				    || !(p_timeout || (p_ttimeout
a7ea2bd
! 					       && keylen == KEYLEN_PART_KEY)))
a7ea2bd
  				    ? -1L
a7ea2bd
! 				    : ((keylen == KEYLEN_PART_KEY && p_ttm >= 0)
a7ea2bd
  					    ? p_ttm
a7ea2bd
  					    : p_tm)), typebuf.tb_change_cnt);
a7ea2bd
  
a7ea2bd
*** ../vim-7.3.090/src/misc1.c	2010-12-02 16:01:23.000000000 +0100
a7ea2bd
--- src/misc1.c	2010-12-30 12:28:59.000000000 +0100
a7ea2bd
***************
a7ea2bd
*** 3114,3123 ****
a7ea2bd
  	       && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
a7ea2bd
  	    continue;
a7ea2bd
  
a7ea2bd
! 	/* found a termcode: adjust length */
a7ea2bd
! 	if (n > 0)
a7ea2bd
  	    len = n;
a7ea2bd
! 	if (len == 0)	    /* nothing typed yet */
a7ea2bd
  	    continue;
a7ea2bd
  
a7ea2bd
  	/* Handle modifier and/or special key code. */
a7ea2bd
--- 3114,3124 ----
a7ea2bd
  	       && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
a7ea2bd
  	    continue;
a7ea2bd
  
a7ea2bd
! 	if (n == KEYLEN_REMOVED)  /* key code removed */
a7ea2bd
! 	    continue;
a7ea2bd
! 	if (n > 0)		/* found a termcode: adjust length */
a7ea2bd
  	    len = n;
a7ea2bd
! 	if (len == 0)		/* nothing typed yet */
a7ea2bd
  	    continue;
a7ea2bd
  
a7ea2bd
  	/* Handle modifier and/or special key code. */
a7ea2bd
*** ../vim-7.3.090/src/term.c	2010-08-15 21:57:32.000000000 +0200
a7ea2bd
--- src/term.c	2010-12-30 12:14:48.000000000 +0100
a7ea2bd
***************
a7ea2bd
*** 3828,3833 ****
a7ea2bd
--- 3831,3837 ----
a7ea2bd
   * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off
a7ea2bd
   * + max_offset].
a7ea2bd
   * Return 0 for no match, -1 for partial match, > 0 for full match.
a7ea2bd
+  * Return KEYLEN_REMOVED when a key code was deleted.
a7ea2bd
   * With a match, the match is removed, the replacement code is inserted in
a7ea2bd
   * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
a7ea2bd
   * returned.
a7ea2bd
***************
a7ea2bd
*** 3845,3850 ****
a7ea2bd
--- 3849,3855 ----
a7ea2bd
      int		slen = 0;	/* init for GCC */
a7ea2bd
      int		modslen;
a7ea2bd
      int		len;
a7ea2bd
+     int		retval = 0;
a7ea2bd
      int		offset;
a7ea2bd
      char_u	key_name[2];
a7ea2bd
      int		modifiers;
a7ea2bd
***************
a7ea2bd
*** 4940,4945 ****
a7ea2bd
--- 4945,4957 ----
a7ea2bd
  #endif
a7ea2bd
  		string[new_slen++] = key_name[1];
a7ea2bd
  	}
a7ea2bd
+ 	else if (new_slen == 0 && key_name[0] == KS_EXTRA
a7ea2bd
+ 						  && key_name[1] == KE_IGNORE)
a7ea2bd
+ 	{
a7ea2bd
+ 	    /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED
a7ea2bd
+ 	     * to indicate what happened. */
a7ea2bd
+ 	    retval = KEYLEN_REMOVED;
a7ea2bd
+ 	}
a7ea2bd
  	else
a7ea2bd
  	{
a7ea2bd
  	    string[new_slen++] = K_SPECIAL;
a7ea2bd
***************
a7ea2bd
*** 4976,4982 ****
a7ea2bd
  						   (size_t)(buflen - offset));
a7ea2bd
  	    mch_memmove(buf + offset, string, (size_t)new_slen);
a7ea2bd
  	}
a7ea2bd
! 	return (len + extra + offset);
a7ea2bd
      }
a7ea2bd
  
a7ea2bd
      return 0;			    /* no match found */
a7ea2bd
--- 4988,4994 ----
a7ea2bd
  						   (size_t)(buflen - offset));
a7ea2bd
  	    mch_memmove(buf + offset, string, (size_t)new_slen);
a7ea2bd
  	}
a7ea2bd
! 	return retval == 0 ? (len + extra + offset) : retval;
a7ea2bd
      }
a7ea2bd
  
a7ea2bd
      return 0;			    /* no match found */
a7ea2bd
*** ../vim-7.3.090/src/vim.h	2010-12-17 20:23:56.000000000 +0100
a7ea2bd
--- src/vim.h	2010-12-30 12:06:45.000000000 +0100
a7ea2bd
***************
a7ea2bd
*** 2211,2214 ****
a7ea2bd
--- 2211,2218 ----
a7ea2bd
  #define MSCR_LEFT	-1
a7ea2bd
  #define MSCR_RIGHT	-2
a7ea2bd
  
a7ea2bd
+ #define KEYLEN_PART_KEY -1	/* keylen value for incomplete key-code */
a7ea2bd
+ #define KEYLEN_PART_MAP -2	/* keylen value for incomplete mapping */
a7ea2bd
+ #define KEYLEN_REMOVED  9999	/* keylen value for removed sequence */
a7ea2bd
+ 
a7ea2bd
  #endif /* VIM__H */
a7ea2bd
*** ../vim-7.3.090/src/version.c	2010-12-30 11:41:05.000000000 +0100
a7ea2bd
--- src/version.c	2010-12-30 12:24:56.000000000 +0100
a7ea2bd
***************
a7ea2bd
*** 716,717 ****
a7ea2bd
--- 716,719 ----
a7ea2bd
  {   /* Add new patch number below this line */
a7ea2bd
+ /**/
a7ea2bd
+     91,
a7ea2bd
  /**/
a7ea2bd
a7ea2bd
-- 
a7ea2bd
hundred-and-one symptoms of being an internet addict:
a7ea2bd
56. You leave the modem speaker on after connecting because you think it
a7ea2bd
    sounds like the ocean wind...the perfect soundtrack for "surfing the net".
a7ea2bd
a7ea2bd
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
a7ea2bd
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
a7ea2bd
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
a7ea2bd
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///