Patch 7.4.1131
Problem:    New lines in the viminfo file are dropped.
Solution:   Copy lines starting with "|".  Fix that when using :rviminfo in a
            function global variables were restored as function-local
            variables.
Files:      src/eval.c, src/structs.h, src/ex_cmds.c, src/misc2.c,
            src/proto/misc2.pro, src/testdir/test_viminfo.vim,
            src/testdir/Make_all.mak, src/testdir/test74.in,
            src/testdir/test74.ok


*** ../vim-7.4.1130/src/eval.c  2016-01-17 21:48:55.841086326 +0100
--- src/eval.c  2016-01-18 23:22:38.669842254 +0100
***************
*** 25054,25059 ****
--- 25054,25060 ----
      char_u    *tab;
      int               type = VAR_NUMBER;
      typval_T  tv;
+     funccall_T  *save_funccal;
  
      if (!writing && (find_viminfo_parameter('!') != NULL))
      {
***************
*** 25100,25106 ****
--- 25101,25111 ----
                    }
                }
  
+               /* when in a function use global variables */
+               save_funccal = current_funccal;
+               current_funccal = NULL;
                set_var(virp->vir_line + 1, &tv, FALSE);
+               current_funccal = save_funccal;
  
                if (tv.v_type == VAR_STRING)
                    vim_free(tv.vval.v_string);
*** ../vim-7.4.1130/src/structs.h       2015-11-24 18:45:52.641646980 +0100
--- src/structs.h       2016-01-18 22:11:39.893084664 +0100
***************
*** 1008,1013 ****
--- 1008,1014 ----
  #ifdef FEAT_MBYTE
      vimconv_T vir_conv;       /* encoding conversion */
  #endif
+     garray_T  vir_barlines;   /* lines starting with | */
  } vir_T;
  
  #define CONV_NONE             0
*** ../vim-7.4.1130/src/ex_cmds.c       2016-01-02 17:54:04.419793309 +0100
--- src/ex_cmds.c       2016-01-18 22:36:17.400631433 +0100
***************
*** 1707,1715 ****
                (char *)opt, (char *)fname);
  }
  
! #ifdef FEAT_VIMINFO
  
  static int no_viminfo __ARGS((void));
  static int  viminfo_errcnt;
  
      static int
--- 1707,1716 ----
                (char *)opt, (char *)fname);
  }
  
! #if defined(FEAT_VIMINFO) || defined(PROTO)
  
  static int no_viminfo __ARGS((void));
+ static void write_viminfo_barlines(vir_T *virp, FILE *fp_out);
  static int  viminfo_errcnt;
  
      static int
***************
*** 2123,2128 ****
--- 2124,2130 ----
  #ifdef FEAT_MBYTE
      vir.vir_conv.vc_type = CONV_NONE;
  #endif
+     ga_init2(&vir.vir_barlines, (int)sizeof(char_u *), 100);
  
      if (fp_in != NULL)
      {
***************
*** 2159,2164 ****
--- 2161,2167 ----
  #endif
        write_viminfo_filemarks(fp_out);
        write_viminfo_bufferlist(fp_out);
+       write_viminfo_barlines(&vir, fp_out);
        count = write_viminfo_marks(fp_out);
      }
      if (fp_in != NULL
***************
*** 2170,2175 ****
--- 2173,2179 ----
      if (vir.vir_conv.vc_type != CONV_NONE)
        convert_setup(&vir.vir_conv, NULL, NULL);
  #endif
+     ga_clear_strings(&vir.vir_barlines);
  }
  
  /*
***************
*** 2196,2202 ****
        {
                /* Characters reserved for future expansion, ignored now */
            case '+': /* "+40 /path/dir file", for running vim without args */
-           case '|': /* to be defined */
            case '^': /* to be defined */
            case '<': /* long line - ignored */
                /* A comment or empty line. */
--- 2200,2205 ----
***************
*** 2206,2211 ****
--- 2209,2219 ----
            case '#':
                eof = viminfo_readline(virp);
                break;
+           case '|': /* copy line (for future use) */
+               if (writing)
+                   ga_add_string(&virp->vir_barlines, virp->vir_line);
+               eof = viminfo_readline(virp);
+               break;
            case '*': /* "*encoding=value" */
                eof = viminfo_encoding(virp);
                break;
***************
*** 2427,2432 ****
--- 2435,2455 ----
      }
      putc('\n', fd);
  }
+ 
+     static void
+ write_viminfo_barlines(vir_T *virp, FILE *fp_out)
+ {
+     int               i;
+     garray_T  *gap = &virp->vir_barlines;
+ 
+     if (gap->ga_len > 0)
+     {
+       fputs(_("\n# Bar lines, copied verbatim:\n"), fp_out);
+ 
+       for (i = 0; i < gap->ga_len; ++i)
+           fputs(((char **)(gap->ga_data))[i], fp_out);
+     }
+ }
  #endif /* FEAT_VIMINFO */
  
  /*
*** ../vim-7.4.1130/src/misc2.c 2016-01-16 21:50:32.590161433 +0100
--- src/misc2.c 2016-01-18 23:27:58.950309444 +0100
***************
*** 2140,2145 ****
--- 2140,2165 ----
      return s;
  }
  
+ #if defined(FEAT_VIMINFO) || defined(PROTO)
+ /*
+  * Make a copy of string "p" and add it to "gap".
+  * When out of memory nothing changes.
+  */
+     void
+ ga_add_string(garray_T *gap, char_u *p)
+ {
+     char_u *cp = vim_strsave(p);
+ 
+     if (cp != NULL)
+     {
+       if (ga_grow(gap, 1) == OK)
+           ((char_u **)(gap->ga_data))[gap->ga_len++] = cp;
+       else
+           vim_free(cp);
+     }
+ }
+ #endif
+ 
  /*
   * Concatenate a string to a growarray which contains characters.
   * When "s" is NULL does not do anything.
*** ../vim-7.4.1130/src/proto/misc2.pro 2016-01-09 22:28:13.339790774 +0100
--- src/proto/misc2.pro 2016-01-18 22:26:25.979206608 +0100
***************
*** 56,61 ****
--- 56,62 ----
  void ga_init2 __ARGS((garray_T *gap, int itemsize, int growsize));
  int ga_grow __ARGS((garray_T *gap, int n));
  char_u *ga_concat_strings __ARGS((garray_T *gap, char *sep));
+ void ga_add_string __ARGS((garray_T *gap, char_u *p));
  void ga_concat __ARGS((garray_T *gap, char_u *s));
  void ga_append __ARGS((garray_T *gap, int c));
  void append_ga_line __ARGS((garray_T *gap));
*** ../vim-7.4.1130/src/testdir/test_viminfo.vim        2016-01-18 
23:25:44.879788318 +0100
--- src/testdir/test_viminfo.vim        2016-01-18 23:18:11.876784897 +0100
***************
*** 0 ****
--- 1,50 ----
+ " Test for reading and writing .viminfo
+ 
+ function Test_read_and_write()
+   let lines = [
+       \ '# comment line',
+       \ '*encoding=utf-8',
+       \ '~MSle0~/asdf',
+       \ '|copied as-is',
+       \ '|and one more',
+       \ ]
+   call writefile(lines, 'Xviminfo')
+   rviminfo Xviminfo
+   call assert_equal('asdf', @/)
+ 
+   wviminfo Xviminfo
+   let lines = readfile('Xviminfo')
+   let done = 0
+   for line in lines
+     if line[0] == '|'
+       if done == 0
+       call assert_equal('|copied as-is', line)
+       elseif done == 1
+       call assert_equal('|and one more', line)
+       endif
+       let done += 1
+     endif
+   endfor
+   call assert_equal(2, done)
+ 
+   call delete('Xviminfo')
+ endfunc
+ 
+ func Test_global_vars()
+   let test_dict = {'foo': 1, 'bar': 0, 'longvarible': 1000}
+   let g:MY_GLOBAL_DICT = test_dict
+   " store a really long list, so line wrapping will occur in viminfo file
+   let test_list = range(1,100)
+   let g:MY_GLOBAL_LIST = test_list
+   set viminfo='100,<50,s10,h,!
+   wv! Xviminfo
+   unlet g:MY_GLOBAL_DICT
+   unlet g:MY_GLOBAL_LIST
+ 
+   rv! Xviminfo
+   call assert_equal(test_dict, g:MY_GLOBAL_DICT)
+   call assert_equal(test_list, g:MY_GLOBAL_LIST)
+ 
+   call delete('Xviminfo')
+   set viminfo-=!
+ endfunc
*** ../vim-7.4.1130/src/testdir/Make_all.mak    2016-01-17 22:05:09.282375491 
+0100
--- src/testdir/Make_all.mak    2016-01-18 22:45:54.358223936 +0100
***************
*** 63,69 ****
        test70.out \
        test71.out \
        test73.out \
-       test74.out \
        test75.out \
        test76.out \
        test77.out \
--- 63,68 ----
***************
*** 176,185 ****
            test_cdo.res \
            test_hardcopy.res \
            test_increment.res \
            test_quickfix.res \
            test_viml.res \
!           test_alot.res \
!           test_perl.res
  
  
  # Explicit dependencies.
--- 175,185 ----
            test_cdo.res \
            test_hardcopy.res \
            test_increment.res \
+           test_perl.res \
            test_quickfix.res \
+           test_viminfo.res \
            test_viml.res \
!           test_alot.res
  
  
  # Explicit dependencies.
*** ../vim-7.4.1130/src/testdir/test74.in       2010-10-20 17:37:52.000000000 
+0200
--- src/testdir/test74.in       1970-01-01 01:00:00.000000000 +0100
***************
*** 1,36 ****
- " Tests for storing global variables in the .viminfo file vim: set ft=vim:
- 
- STARTTEST
- :so small.vim
- :" Do all test in a separate window to avoid E211 when we recursively
- :" delete the Xfind directory during cleanup
- :"
- :" This will cause a few errors, do it silently.
- :set visualbell
- :set nocp viminfo+=!,nviminfo
- :let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}
- :" store a really long list, so line wrapping will occur in viminfo file
- :let MY_GLOBAL_LIST=range(1,100)
- :wv! Xviminfo
- :unlet MY_GLOBAL_DICT
- :unlet MY_GLOBAL_LIST
- :rv! Xviminfo
- :call delete('Xviminfo')
- :if exists("MY_GLOBAL_DICT")
- :redir >> test.out
- :echo MY_GLOBAL_DICT
- :redir end
- :endif
- :if exists("MY_GLOBAL_LIST")
- :redir >> test.out
- :echo MY_GLOBAL_LIST
- :redir end
- :endif
- :redir >> test.out
- :echo "foobar"
- :redir end
- :endif
- :qa!
- ENDTEST
- 
- eof
--- 0 ----
*** ../vim-7.4.1130/src/testdir/test74.ok       2010-10-20 17:36:57.000000000 
+0200
--- src/testdir/test74.ok       1970-01-01 01:00:00.000000000 +0100
***************
*** 1,5 ****
- 
- {'foo': 1, 'longvarible': 1000, 'bar': 0}
- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 
62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 
82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
- 
- foobar
--- 0 ----
*** ../vim-7.4.1130/src/version.c       2016-01-18 20:30:10.120449505 +0100
--- src/version.c       2016-01-18 23:16:56.001621745 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     1131,
  /**/

-- 
A radioactive cat has eighteen half-lives.

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