[SCM] Vim packaging branch, deb/langmap-escaped-comma, updated. upstream/7.2.079-79-ga84cd87

James Vega jamessan at debian.org
Tue Mar 3 00:57:56 UTC 2009


The following commit has been merged in the deb/langmap-escaped-comma branch:
commit a84cd87199e3690299b3f80b21e8810073e11a1e
Merge: ad32e5d6f62d8c5fdf4fcb8786283c7a2ee1e218 9cff935c8e77e1c183983d0b8af15b8ac836a028
Author: James Vega <jamessan at debian.org>
Date:   Mon Mar 2 19:43:17 2009 -0500

    Merge branch 'upstream' into deb/langmap-escaped-comma

diff --combined src/option.c
index 74c6419,87497ea..d3a5892
--- a/src/option.c
+++ b/src/option.c
@@@ -10153,25 -10153,110 +10153,110 @@@ wc_use_keyname(varp, wcp
  
  #ifdef FEAT_LANGMAP
  /*
-  * Any character has an equivalent character.  This is used for keyboards that
-  * have a special language mode that sends characters above 128 (although
-  * other characters can be translated too).
+  * Any character has an equivalent 'langmap' character.  This is used for
+  * keyboards that have a special language mode that sends characters above
+  * 128 (although other characters can be translated too).  The "to" field is a
+  * Vim command character.  This avoids having to switch the keyboard back to
+  * ASCII mode when leaving Insert mode.
+  *
+  * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
+  * commands.
+  * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
+  * langmap_entry_T.  This does the same as langmap_mapchar[] for characters >=
+  * 256.
   */
+ # ifdef FEAT_MBYTE
+ /*
+  * With multi-byte support use growarray for 'langmap' chars >= 256
+  */
+ typedef struct
+ {
+     int	    from;
+     int     to;
+ } langmap_entry_T;
+ 
+ static garray_T langmap_mapga;
+ static void langmap_set_entry __ARGS((int from, int to));
  
  /*
-  * char_u langmap_mapchar[256];
-  * Normally maps each of the 128 upper chars to an <128 ascii char; used to
-  * "translate" native lang chars in normal mode or some cases of
-  * insert mode without having to tediously switch lang mode back&forth.
+  * Search for an entry in "langmap_mapga" for "from".  If found set the "to"
+  * field.  If not found insert a new entry at the appropriate location.
   */
+     static void
+ langmap_set_entry(from, to)
+     int    from;
+     int    to;
+ {
+     langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
+     int             a = 0;
+     int             b = langmap_mapga.ga_len;
+ 
+     /* Do a binary search for an existing entry. */
+     while (a != b)
+     {
+ 	int i = (a + b) / 2;
+ 	int d = entries[i].from - from;
+ 
+ 	if (d == 0)
+ 	{
+ 	    entries[i].to = to;
+ 	    return;
+ 	}
+ 	if (d < 0)
+ 	    a = i + 1;
+ 	else
+ 	    b = i;
+     }
+ 
+     if (ga_grow(&langmap_mapga, 1) != OK)
+ 	return;  /* out of memory */
+ 
+     /* insert new entry at position "a" */
+     entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
+     mch_memmove(entries + 1, entries,
+ 			(langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
+     ++langmap_mapga.ga_len;
+     entries[0].from = from;
+     entries[0].to = to;
+ }
+ 
+ /*
+  * Apply 'langmap' to multi-byte character "c" and return the result.
+  */
+     int
+ langmap_adjust_mb(c)
+     int c;
+ {
+     langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
+     int a = 0;
+     int b = langmap_mapga.ga_len;
+ 
+     while (a != b)
+     {
+ 	int i = (a + b) / 2;
+ 	int d = entries[i].from - c;
+ 
+ 	if (d == 0)
+ 	    return entries[i].to;  /* found matching entry */
+ 	if (d < 0)
+ 	    a = i + 1;
+ 	else
+ 	    b = i;
+     }
+     return c;  /* no entry found, return "c" unmodified */
+ }
+ # endif
  
      static void
  langmap_init()
  {
      int i;
  
-     for (i = 0; i < 256; i++)		/* we init with a-one-to one map */
- 	langmap_mapchar[i] = i;
+     for (i = 0; i < 256; i++)
+ 	langmap_mapchar[i] = i;	 /* we init with a one-to-one map */
+ # ifdef FEAT_MBYTE
+     ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
+ # endif
  }
  
  /*
@@@ -10183,9 -10268,12 +10268,12 @@@ langmap_set(
  {
      char_u  *p;
      char_u  *p2;
 -    int	    from, to;
 +    int	    from=NUL, to=NUL;
  
-     langmap_init();			    /* back to one-to-one map first */
+ #ifdef FEAT_MBYTE
+     ga_clear(&langmap_mapga);		    /* clear the previous map first */
+ #endif
+     langmap_init();			    /* back to one-to-one map */
  
      for (p = p_langmap; p[0] != NUL; )
      {
@@@ -10201,11 -10289,6 +10289,11 @@@
  	    p2 = NULL;	    /* aAbBcCdD form, p2 is NULL */
  	while (p[0])
  	{
 +	    if (p[0] == ',')
 +	    {
 +		++p;
 +		break;
 +	    }
  	    if (p[0] == '\\' && p[1] != NUL)
  		++p;
  #ifdef FEAT_MBYTE
@@@ -10216,29 -10299,23 +10304,29 @@@
  	    if (p2 == NULL)
  	    {
  		mb_ptr_adv(p);
 -		if (p[0] == '\\')
 -		    ++p;
 +		if (p[0] != ',')
 +		{
 +		    if (p[0] == '\\')
 +			++p;
  #ifdef FEAT_MBYTE
 -		to = (*mb_ptr2char)(p);
 +		    to = (*mb_ptr2char)(p);
  #else
 -		to = p[0];
 +		    to = p[0];
  #endif
 +		}
  	    }
  	    else
  	    {
 -		if (p2[0] == '\\')
 -		    ++p2;
 +		if (p2[0] != ',')
 +		{
 +		    if (p2[0] == '\\')
 +			++p2;
  #ifdef FEAT_MBYTE
 -		to = (*mb_ptr2char)(p2);
 +		    to = (*mb_ptr2char)(p2);
  #else
 -		to = p2[0];
 +		    to = p2[0];
  #endif
 +		}
  	    }
  	    if (to == NUL)
  	    {
@@@ -10246,7 -10323,13 +10334,13 @@@
  							     transchar(from));
  		return;
  	    }
- 	    langmap_mapchar[from & 255] = to;
+ 
+ #ifdef FEAT_MBYTE
+ 	    if (from >= 256)
+ 		langmap_set_entry(from, to);
+ 	    else
+ #endif
+ 		langmap_mapchar[from & 255] = to;
  
  	    /* Advance to next pair */
  	    mb_ptr_adv(p);

-- 
Vim packaging



More information about the pkg-vim-maintainers mailing list