Patch 7.4.2209
Problem:    Cannot map <M-">. (Stephen Riehm)
Solution:   Solve the memory access problem in another way. (Dominique Pelle)
            Allow for using <M-\"> in a string.
Files:      src/eval.c, src/gui_mac.c, src/misc2.c, src/option.c,
            src/proto/misc2.pro, src/syntax.c, src/term.c,
            src/testdir/test_mapping.vim


*** ../vim-7.4.2208/src/eval.c  2016-08-01 22:49:18.073145115 +0200
--- src/eval.c  2016-08-14 15:38:06.826200377 +0200
***************
*** 233,240 ****
  static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate);
  static int free_unref_items(int copyID);
  static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate);
- 
- 
  static int get_env_len(char_u **arg);
  static char_u * make_expanded_name(char_u *in_start, char_u *expr_start, 
char_u *expr_end, char_u *in_end);
  static void check_vars(char_u *name, int len);
--- 233,238 ----
***************
*** 4926,4932 ****
                          break;
  
                            /* Special key, e.g.: "\<C-W>" */
!               case '<': extra = trans_special(&p, name, TRUE);
                          if (extra != 0)
                          {
                              name += extra;
--- 4924,4930 ----
                          break;
  
                            /* Special key, e.g.: "\<C-W>" */
!               case '<': extra = trans_special(&p, name, TRUE, TRUE);
                          if (extra != 0)
                          {
                              name += extra;
***************
*** 4943,4948 ****
--- 4941,4951 ----
  
      }
      *name = NUL;
+     if (p == NUL)
+     {
+       EMSG2(_("E114: Missing quote: %s"), *arg);
+       return FAIL;
+     }
      *arg = p + 1;
  
      return OK;
*** ../vim-7.4.2208/src/gui_mac.c       2016-07-24 21:58:39.704057634 +0200
--- src/gui_mac.c       2016-08-14 15:38:06.826200377 +0200
***************
*** 4830,4836 ****
        char_u      *p_actext;
  
        p_actext = menu->actext;
!       key = find_special_key(&p_actext, &modifiers, FALSE, FALSE);
        if (*p_actext != 0)
            key = 0; /* error: trailing text */
        /* find_special_key() returns a keycode with as many of the
--- 4830,4836 ----
        char_u      *p_actext;
  
        p_actext = menu->actext;
!       key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE);
        if (*p_actext != 0)
            key = 0; /* error: trailing text */
        /* find_special_key() returns a keycode with as many of the
*** ../vim-7.4.2208/src/misc2.c 2016-08-01 15:40:24.183878405 +0200
--- src/misc2.c 2016-08-14 16:00:59.737464049 +0200
***************
*** 2674,2686 ****
  trans_special(
      char_u    **srcp,
      char_u    *dst,
!     int               keycode) /* prefer key code, e.g. K_DEL instead of DEL 
*/
  {
      int               modifiers = 0;
      int               key;
      int               dlen = 0;
  
!     key = find_special_key(srcp, &modifiers, keycode, FALSE);
      if (key == 0)
        return 0;
  
--- 2674,2687 ----
  trans_special(
      char_u    **srcp,
      char_u    *dst,
!     int               keycode, /* prefer key code, e.g. K_DEL instead of DEL 
*/
!     int               in_string) /* TRUE when inside a double quoted string */
  {
      int               modifiers = 0;
      int               key;
      int               dlen = 0;
  
!     key = find_special_key(srcp, &modifiers, keycode, FALSE, in_string);
      if (key == 0)
        return 0;
  
***************
*** 2720,2726 ****
      char_u    **srcp,
      int               *modp,
      int               keycode,     /* prefer key code, e.g. K_DEL instead of 
DEL */
!     int               keep_x_key)  /* don't translate xHome to Home key */
  {
      char_u    *last_dash;
      char_u    *end_of_name;
--- 2721,2728 ----
      char_u    **srcp,
      int               *modp,
      int               keycode,     /* prefer key code, e.g. K_DEL instead of 
DEL */
!     int               keep_x_key,  /* don't translate xHome to Home key */
!     int               in_string)   /* TRUE in string, double quote is escaped 
*/
  {
      char_u    *last_dash;
      char_u    *end_of_name;
***************
*** 2751,2760 ****
                else
  #endif
                    l = 1;
!               /* Anything accepted, like <C-?>, except <C-">, because the "
!                * ends the string. */
!               if (bp[l] != '"' && bp[l + 1] == '>')
                    bp += l;
            }
        }
        if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
--- 2753,2766 ----
                else
  #endif
                    l = 1;
!               /* Anything accepted, like <C-?>.
!                * <C-"> or <M-"> are not special in strings as " is
!                * the string delimiter. With a backslash it works: <M-\"> */
!               if (!(in_string && bp[1] == '"') && bp[2] == '>')
                    bp += l;
+               else if (in_string && bp[1] == '\\' && bp[2] == '"'
+                                                              && bp[3] == '>')
+                   bp += 2;
            }
        }
        if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
***************
*** 2798,2817 ****
            }
            else
            {
!               /*
!                * Modifier with single letter, or special key name.
!                */
  #ifdef FEAT_MBYTE
                if (has_mbyte)
!                   l = mb_ptr2len(last_dash + 1);
                else
  #endif
                    l = 1;
!               if (modifiers != 0 && last_dash[l + 1] == '>')
!                   key = PTR2CHAR(last_dash + 1);
                else
                {
!                   key = get_special_key_code(last_dash + 1);
                    if (!keep_x_key)
                        key = handle_x_keys(key);
                }
--- 2804,2825 ----
            }
            else
            {
!               int off = 1;
! 
!               /* Modifier with single letter, or special key name.  */
!               if (in_string && last_dash[1] == '\\' && last_dash[2] == '"')
!                   off = 2;
  #ifdef FEAT_MBYTE
                if (has_mbyte)
!                   l = mb_ptr2len(last_dash + off);
                else
  #endif
                    l = 1;
!               if (modifiers != 0 && last_dash[l + off] == '>')
!                   key = PTR2CHAR(last_dash + off);
                else
                {
!                   key = get_special_key_code(last_dash + off);
                    if (!keep_x_key)
                        key = handle_x_keys(key);
                }
*** ../vim-7.4.2208/src/option.c        2016-08-12 22:22:01.172781914 +0200
--- src/option.c        2016-08-14 15:38:06.830200340 +0200
***************
*** 9478,9484 ****
      {
        --arg;                      /* put arg at the '<' */
        modifiers = 0;
!       key = find_special_key(&arg, &modifiers, TRUE, TRUE);
        if (modifiers)              /* can't handle modifiers here */
            key = 0;
      }
--- 9478,9484 ----
      {
        --arg;                      /* put arg at the '<' */
        modifiers = 0;
!       key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
        if (modifiers)              /* can't handle modifiers here */
            key = 0;
      }
*** ../vim-7.4.2208/src/proto/misc2.pro 2016-06-26 16:44:19.519620863 +0200
--- src/proto/misc2.pro 2016-08-14 15:38:12.178150660 +0200
***************
*** 64,71 ****
  int simplify_key(int key, int *modifiers);
  int handle_x_keys(int key);
  char_u *get_special_key_name(int c, int modifiers);
! int trans_special(char_u **srcp, char_u *dst, int keycode);
! int find_special_key(char_u **srcp, int *modp, int keycode, int keep_x_key);
  int extract_modifiers(int key, int *modp);
  int find_special_key_in_table(int c);
  int get_special_key_code(char_u *name);
--- 64,71 ----
  int simplify_key(int key, int *modifiers);
  int handle_x_keys(int key);
  char_u *get_special_key_name(int c, int modifiers);
! int trans_special(char_u **srcp, char_u *dst, int keycode, int in_string);
! int find_special_key(char_u **srcp, int *modp, int keycode, int keep_x_key, 
int in_string);
  int extract_modifiers(int key, int *modp);
  int find_special_key_in_table(int c);
  int get_special_key_code(char_u *name);
*** ../vim-7.4.2208/src/syntax.c        2016-05-28 15:53:45.874534388 +0200
--- src/syntax.c        2016-08-14 15:38:12.186150585 +0200
***************
*** 7939,7945 ****
                 */
                for (p = arg, off = 0; off < 100 - 6 && *p; )
                {
!                   len = trans_special(&p, buf + off, FALSE);
                    if (len > 0)            /* recognized special char */
                        off += len;
                    else                    /* copy as normal char */
--- 7939,7945 ----
                 */
                for (p = arg, off = 0; off < 100 - 6 && *p; )
                {
!                   len = trans_special(&p, buf + off, FALSE, FALSE);
                    if (len > 0)            /* recognized special char */
                        off += len;
                    else                    /* copy as normal char */
*** ../vim-7.4.2208/src/term.c  2016-08-08 20:43:23.112463089 +0200
--- src/term.c  2016-08-14 15:38:12.186150585 +0200
***************
*** 5429,5435 ****
            }
  #endif
  
!           slen = trans_special(&src, result + dlen, TRUE);
            if (slen)
            {
                dlen += slen;
--- 5429,5435 ----
            }
  #endif
  
!           slen = trans_special(&src, result + dlen, TRUE, FALSE);
            if (slen)
            {
                dlen += slen;
*** ../vim-7.4.2208/src/testdir/test_mapping.vim        2016-08-14 
15:31:53.349671948 +0200
--- src/testdir/test_mapping.vim        2016-08-14 15:41:25.916351494 +0200
***************
*** 98,100 ****
--- 98,108 ----
    call assert_equal('new line here', getline(line('$') - 1))
    set nomodified
  endfunc
+ 
+ func Test_map_meta_quotes()
+   imap <M-"> foo
+   call feedkeys("Go-\<M-\">-\<Esc>", "xt")
+   call assert_equal("-foo-", getline('$'))
+   set nomodified
+   iunmap <M-">
+ endfunc
*** ../vim-7.4.2208/src/version.c       2016-08-14 15:31:53.357671874 +0200
--- src/version.c       2016-08-14 15:39:41.041325289 +0200
***************
*** 765,766 ****
--- 765,768 ----
  {   /* Add new patch number below this line */
+ /**/
+     2209,
  /**/

-- 
Q: What is the difference between open-source and commercial software?
A: If you have a problem with commercial software you can call a phone
   number and they will tell you it might be solved in a future version.
   For open-source software there isn't a phone number to call, but you
   get the solution within a day.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui