]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.030 v7.3.030
authorBram Moolenaar <Bram@vim.org>
Wed, 20 Oct 2010 15:44:42 +0000 (17:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 20 Oct 2010 15:44:42 +0000 (17:44 +0200)
Problem:    Cannot store Dict and List in viminfo file.
Solution:   Add support for this. (Christian Brabandt)

12 files changed:
runtime/doc/options.txt
src/eval.c
src/testdir/Make_amiga.mak
src/testdir/Make_dos.mak
src/testdir/Make_ming.mak
src/testdir/Make_os2.mak
src/testdir/Make_vms.mms
src/testdir/Makefile
src/testdir/main.aap
src/testdir/test74.in [new file with mode: 0644]
src/testdir/test74.ok [new file with mode: 0644]
src/version.c

index edd8f2df0a8ac8703c5b843aadb16610af8d4d18..b5283bb3d3c6cc1186506324909b82a50c23305b 100644 (file)
@@ -7530,8 +7530,9 @@ A jump table for the options with a short description can be found at |Q_op|.
        !       When included, save and restore global variables that start
                with an uppercase letter, and don't contain a lowercase
                letter.  Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis"
-               and "_K_L_M" are not.  Only String and Number types are
-               stored.
+               and "_K_L_M" are not.  Nested List and Dict items may not be
+               read back correctly, you end up with a string representation
+               instead.
        "       Maximum number of lines saved for each register.  Old name of
                the '<' item, with the disadvantage that you need to put a
                backslash before the ", otherwise it will be recognized as the
index 0f306d46ffd6070deae9b4a60a62ae7683fe0e7f..699598be087e200a6eeed370f969e93fab3dbf46 100644 (file)
@@ -22520,18 +22520,21 @@ read_viminfo_varlist(virp, writing)
        if (tab != NULL)
        {
            *tab++ = '\0';      /* isolate the variable name */
-           if (*tab == 'S')    /* string var */
-               type = VAR_STRING;
+           switch (*tab)
+           {
+               case 'S': type = VAR_STRING; break;
 #ifdef FEAT_FLOAT
-           else if (*tab == 'F')
-               type = VAR_FLOAT;
+               case 'F': type = VAR_FLOAT; break;
 #endif
+               case 'D': type = VAR_DICT; break;
+               case 'L': type = VAR_LIST; break;
+           }
 
            tab = vim_strchr(tab, '\t');
            if (tab != NULL)
            {
                tv.v_type = type;
-               if (type == VAR_STRING)
+               if (type == VAR_STRING || type == VAR_DICT || type == VAR_LIST)
                    tv.vval.v_string = viminfo_readstring(virp,
                                       (int)(tab - virp->vir_line + 1), TRUE);
 #ifdef FEAT_FLOAT
@@ -22540,9 +22543,27 @@ read_viminfo_varlist(virp, writing)
 #endif
                else
                    tv.vval.v_number = atol((char *)tab + 1);
+               if (type == VAR_DICT || type == VAR_LIST)
+               {
+                   typval_T *etv = eval_expr(tv.vval.v_string, NULL);
+
+                   if (etv == NULL)
+                       /* Failed to parse back the dict or list, use it as a
+                        * string. */
+                       tv.v_type = VAR_STRING;
+                   else
+                   {
+                       vim_free(tv.vval.v_string);
+                       tv = *etv;
+                   }
+               }
+
                set_var(virp->vir_line + 1, &tv, FALSE);
-               if (type == VAR_STRING)
+
+               if (tv.v_type == VAR_STRING)
                    vim_free(tv.vval.v_string);
+               else if (tv.v_type == VAR_DICT || tv.v_type == VAR_LIST)
+                   clear_tv(&tv);
            }
        }
     }
@@ -22584,8 +22605,10 @@ write_viminfo_varlist(fp)
                    case VAR_STRING: s = "STR"; break;
                    case VAR_NUMBER: s = "NUM"; break;
 #ifdef FEAT_FLOAT
-                   case VAR_FLOAT: s = "FLO"; break;
+                   case VAR_FLOAT:  s = "FLO"; break;
 #endif
+                   case VAR_DICT:   s = "DIC"; break;
+                   case VAR_LIST:   s = "LIS"; break;
                    default: continue;
                }
                fprintf(fp, "!%s\t%s\t", this_var->di_key, s);
index a2644cd950238db2287df8132bd26d967798c705..d026ca11262647169f52f158f1f449ba24d3d85e 100644 (file)
@@ -27,7 +27,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
                test56.out test57.out test58.out test59.out test60.out \
                test61.out test62.out test63.out test64.out test65.out \
                test66.out test67.out test68.out test69.out test70.out \
-               test71.out test72.out test73.out
+               test71.out test72.out test73.out test74.out
 
 .SUFFIXES: .in .out
 
@@ -120,3 +120,4 @@ test70.out: test70.in
 test71.out: test71.in
 test72.out: test72.in
 test73.out: test73.in
+test74.out: test74.in
index 900a6375440a2215fdea87749e5652de6a6361aa..455f899484c06346d581adece2a276c583cb2f1c 100644 (file)
@@ -27,7 +27,8 @@ SCRIPTS =     test3.out test4.out test5.out test6.out test7.out \
                test30.out test31.out test32.out test33.out test34.out \
                test37.out test38.out test39.out test40.out test41.out \
                test42.out test52.out test65.out test66.out test67.out \
-               test68.out test69.out test71.out test72.out test73.out
+               test68.out test69.out test71.out test72.out test73.out \
+               test74.out
 
 SCRIPTS32 =    test50.out test70.out
 
index 2d40ab5c7cd17c091dcdd5a0545e4b13f21335a9..b1436bbefe9f104129d378a214c9a790c0b292b5 100644 (file)
@@ -47,7 +47,8 @@ SCRIPTS =     test3.out test4.out test5.out test6.out test7.out \
                test30.out test31.out test32.out test33.out test34.out \
                test37.out test38.out test39.out test40.out test41.out \
                test42.out test52.out test65.out test66.out test67.out \
-               test68.out test69.out test71.out test72.out test72.out
+               test68.out test69.out test71.out test72.out test73.out \
+               test74.out
 
 SCRIPTS32 =    test50.out test70.out
 
index 46e9b6c164ae2e73d194f1813335abab05a5122b..f1a2ece2e9d10cc48601b811ad415feb252f9781 100644 (file)
@@ -27,7 +27,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
                test56.out test57.out test58.out test59.out test60.out \
                test61.out test62.out test63.out test64.out test65.out \
                test66.out test67.out test68.out test69.out test70.out \
-               test71.out test72.out test73.out
+               test71.out test72.out test73.out test74.out
 
 .SUFFIXES: .in .out
 
index 4e2c096e0034d228e1f7b1f036ba4cfbcbc888e3..031ee91db048a28a70ae78a6bc968a1fd1aa9b9f 100644 (file)
@@ -74,7 +74,7 @@ SCRIPT = test1.out  test2.out  test3.out  test4.out  test5.out  \
         test56.out test57.out test60.out \
         test61.out test62.out test63.out test64.out test65.out \
         test66.out test67.out test68.out test69.out \
-        test71.out test72.out
+        test71.out test72.out test74.out
 
 # Known problems:
 # Test 30: a problem around mac format - unknown reason
index bdc2c28cbddfd3fb9f677b745fba75a5c2f8d9a9..87c805088d45cfbab9bf6cfb63891c5f1c7f55f4 100644 (file)
@@ -10,6 +10,7 @@ VIMPROG = ../vim
 #   This will make testing about 10 times as slow.
 # VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$*
 
+
 SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
                test7.out test8.out test9.out test10.out test11.out \
                test12.out  test13.out test14.out test15.out test17.out \
@@ -23,7 +24,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
                test54.out test55.out test56.out test57.out test58.out \
                test59.out test60.out test61.out test62.out test63.out \
                test64.out test65.out test66.out test67.out test68.out \
-               test69.out test70.out test71.out test72.out test73.out
+               test69.out test70.out test71.out test72.out test73.out \
+               test74.out
 
 SCRIPTS_GUI = test16.out
 
index 78ef7e00ea6cf6f62e39acc47eea66195c1a5788..ef2d93cacb73086775a1fc9cad1b99f2b539b60f 100644 (file)
@@ -13,7 +13,7 @@ Scripts = test1.out test2.out test3.out test4.out test5.out test6.out
                test33.out test34.out test35.out test36.out test37.out
                test38.out test39.out test40.out test41.out test42.out
                test43.out test44.out test45.out test46.out test47.out
-               test48.out test49.out
+               test48.out test49.out test74.out
 
 ScriptsGUI = test16.out
 
diff --git a/src/testdir/test74.in b/src/testdir/test74.in
new file mode 100644 (file)
index 0000000..4fbe5e4
--- /dev/null
@@ -0,0 +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
diff --git a/src/testdir/test74.ok b/src/testdir/test74.ok
new file mode 100644 (file)
index 0000000..b026c33
--- /dev/null
@@ -0,0 +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
index 9584550ba5751248da3ee0c305112906bf146df5..e776e1d52fb5a3c8c8ba84e1b4fe159c7ce655aa 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    30,
 /**/
     29,
 /**/