Patch 7.4.1917
Problem:    History lines read from viminfo in different encoding than when
            writing are not converted.
Solution:   Convert the history lines.
Files:      src/ex_cmds.c, src/testdir/test_viminfo.vim


*** ../vim-7.4.1916/src/ex_cmds.c       2016-06-09 22:52:56.207926413 +0200
--- src/ex_cmds.c       2016-06-11 14:41:06.496706476 +0200
***************
*** 2543,2548 ****
--- 2543,2552 ----
      int           count = 0;
      int           i;
      int           allocated = FALSE;
+ #ifdef FEAT_MBYTE
+     char_u  *sconv;
+     int           converted;
+ #endif
  
      while (*p == ',')
      {
***************
*** 2560,2566 ****
            if (!allocated)
            {
                for (i = 0; i < count; ++i)
!                   if (values[i].bv_type == BVAL_STRING)
                    {
                        values[i].bv_string = vim_strnsave(
                                       values[i].bv_string, values[i].bv_len);
--- 2564,2571 ----
            if (!allocated)
            {
                for (i = 0; i < count; ++i)
!                   if (values[i].bv_type == BVAL_STRING
!                                                  && !values[i].bv_allocated)
                    {
                        values[i].bv_string = vim_strnsave(
                                       values[i].bv_string, values[i].bv_len);
***************
*** 2654,2665 ****
            }
            s[len] = NUL;
  
            if (s != buf && allocated)
                s = vim_strsave(s);
            values[count].bv_string = s;
            values[count].bv_type = BVAL_STRING;
            values[count].bv_len = len;
!           values[count].bv_allocated = allocated;
            ++count;
            if (nextp != NULL)
            {
--- 2659,2691 ----
            }
            s[len] = NUL;
  
+ #ifdef FEAT_MBYTE
+           converted = FALSE;
+           if (virp->vir_conv.vc_type != CONV_NONE && *s != NUL)
+           {
+               sconv = string_convert(&virp->vir_conv, s, NULL);
+               if (sconv != NULL)
+               {
+                   if (s == buf)
+                       vim_free(s);
+                   s = sconv;
+                   buf = s;
+                   converted = TRUE;
+               }
+           }
+ #endif
+           /* Need to copy in allocated memory if the string wasn't allocated
+            * above and we did allocate before, thus vir_line may change. */
            if (s != buf && allocated)
                s = vim_strsave(s);
            values[count].bv_string = s;
            values[count].bv_type = BVAL_STRING;
            values[count].bv_len = len;
!           values[count].bv_allocated = allocated
! #ifdef FEAT_MBYTE
!                                           || converted
! #endif
!                                               ;
            ++count;
            if (nextp != NULL)
            {
*** ../vim-7.4.1916/src/testdir/test_viminfo.vim        2016-06-09 
20:24:24.312049004 +0200
--- src/testdir/test_viminfo.vim        2016-06-11 14:40:03.693361738 +0200
***************
*** 179,181 ****
--- 179,203 ----
  
    call delete('Xviminfo')
  endfunc
+ 
+ func Test_viminfo_encoding()
+   if !has('multi_byte')
+     return
+   endif
+   set enc=latin1
+   call histdel(':')
+   call histadd(':', "echo '\xe9'")
+   wviminfo Xviminfo
+ 
+   set fencs=utf-8,latin1
+   set enc=utf-8
+   sp Xviminfo
+   call assert_equal('latin1', &fenc)
+   close
+   
+   call histdel(':')
+   rviminfo Xviminfo
+   call assert_equal("echo 'é'", histget(':', -1))
+ 
+   call delete('Xviminfo')
+ endfunc
*** ../vim-7.4.1916/src/version.c       2016-06-10 23:02:52.950729704 +0200
--- src/version.c       2016-06-11 14:26:37.709620079 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     1917,
  /**/

-- 
>From "know your smileys":
 !-|    I-am-a-Cylon-Centurian-with-one-red-eye-bouncing-back-and-forth

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