]>
Commit | Line | Data |
---|---|---|
d7160e4c ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.3.030 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.030 | |
11 | Problem: Cannot store Dict and List in viminfo file. | |
12 | Solution: Add support for this. (Christian Brabandt) | |
13 | Files: runtime/doc/options.txt, src/eval.c, src/testdir/Make_amiga.mak, | |
14 | src/testdir/Make_dos.mak, src/testdir/Make_ming.mak, | |
15 | src/testdir/Make_os2.mak, src/testdir/Make_vms.mms, | |
16 | src/testdir/Makefile, src/testdir/main.aap, src/testdir/test74.in, | |
17 | src/testdir/test74.ok | |
18 | ||
19 | ||
20 | *** ../vim-7.3.029/runtime/doc/options.txt 2010-08-15 21:57:17.000000000 +0200 | |
21 | --- runtime/doc/options.txt 2010-10-20 17:41:18.000000000 +0200 | |
22 | *************** | |
23 | *** 7530,7537 **** | |
24 | ! When included, save and restore global variables that start | |
25 | with an uppercase letter, and don't contain a lowercase | |
26 | letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" | |
27 | ! and "_K_L_M" are not. Only String and Number types are | |
28 | ! stored. | |
29 | " Maximum number of lines saved for each register. Old name of | |
30 | the '<' item, with the disadvantage that you need to put a | |
31 | backslash before the ", otherwise it will be recognized as the | |
32 | --- 7530,7538 ---- | |
33 | ! When included, save and restore global variables that start | |
34 | with an uppercase letter, and don't contain a lowercase | |
35 | letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis" | |
36 | ! and "_K_L_M" are not. Nested List and Dict items may not be | |
37 | ! read back correctly, you end up with a string representation | |
38 | ! instead. | |
39 | " Maximum number of lines saved for each register. Old name of | |
40 | the '<' item, with the disadvantage that you need to put a | |
41 | backslash before the ", otherwise it will be recognized as the | |
42 | *** ../vim-7.3.029/src/eval.c 2010-09-14 12:47:30.000000000 +0200 | |
43 | --- src/eval.c 2010-10-20 16:25:54.000000000 +0200 | |
44 | *************** | |
45 | *** 22520,22537 **** | |
46 | if (tab != NULL) | |
47 | { | |
48 | *tab++ = '\0'; /* isolate the variable name */ | |
49 | ! if (*tab == 'S') /* string var */ | |
50 | ! type = VAR_STRING; | |
51 | #ifdef FEAT_FLOAT | |
52 | ! else if (*tab == 'F') | |
53 | ! type = VAR_FLOAT; | |
54 | #endif | |
55 | ||
56 | tab = vim_strchr(tab, '\t'); | |
57 | if (tab != NULL) | |
58 | { | |
59 | tv.v_type = type; | |
60 | ! if (type == VAR_STRING) | |
61 | tv.vval.v_string = viminfo_readstring(virp, | |
62 | (int)(tab - virp->vir_line + 1), TRUE); | |
63 | #ifdef FEAT_FLOAT | |
64 | --- 22520,22540 ---- | |
65 | if (tab != NULL) | |
66 | { | |
67 | *tab++ = '\0'; /* isolate the variable name */ | |
68 | ! switch (*tab) | |
69 | ! { | |
70 | ! case 'S': type = VAR_STRING; break; | |
71 | #ifdef FEAT_FLOAT | |
72 | ! case 'F': type = VAR_FLOAT; break; | |
73 | #endif | |
74 | + case 'D': type = VAR_DICT; break; | |
75 | + case 'L': type = VAR_LIST; break; | |
76 | + } | |
77 | ||
78 | tab = vim_strchr(tab, '\t'); | |
79 | if (tab != NULL) | |
80 | { | |
81 | tv.v_type = type; | |
82 | ! if (type == VAR_STRING || type == VAR_DICT || type == VAR_LIST) | |
83 | tv.vval.v_string = viminfo_readstring(virp, | |
84 | (int)(tab - virp->vir_line + 1), TRUE); | |
85 | #ifdef FEAT_FLOAT | |
86 | *************** | |
87 | *** 22540,22548 **** | |
88 | #endif | |
89 | else | |
90 | tv.vval.v_number = atol((char *)tab + 1); | |
91 | set_var(virp->vir_line + 1, &tv, FALSE); | |
92 | ! if (type == VAR_STRING) | |
93 | vim_free(tv.vval.v_string); | |
94 | } | |
95 | } | |
96 | } | |
97 | --- 22543,22569 ---- | |
98 | #endif | |
99 | else | |
100 | tv.vval.v_number = atol((char *)tab + 1); | |
101 | + if (type == VAR_DICT || type == VAR_LIST) | |
102 | + { | |
103 | + typval_T *etv = eval_expr(tv.vval.v_string, NULL); | |
104 | + | |
105 | + if (etv == NULL) | |
106 | + /* Failed to parse back the dict or list, use it as a | |
107 | + * string. */ | |
108 | + tv.v_type = VAR_STRING; | |
109 | + else | |
110 | + { | |
111 | + vim_free(tv.vval.v_string); | |
112 | + tv = *etv; | |
113 | + } | |
114 | + } | |
115 | + | |
116 | set_var(virp->vir_line + 1, &tv, FALSE); | |
117 | ! | |
118 | ! if (tv.v_type == VAR_STRING) | |
119 | vim_free(tv.vval.v_string); | |
120 | + else if (tv.v_type == VAR_DICT || tv.v_type == VAR_LIST) | |
121 | + clear_tv(&tv); | |
122 | } | |
123 | } | |
124 | } | |
125 | *************** | |
126 | *** 22584,22591 **** | |
127 | case VAR_STRING: s = "STR"; break; | |
128 | case VAR_NUMBER: s = "NUM"; break; | |
129 | #ifdef FEAT_FLOAT | |
130 | ! case VAR_FLOAT: s = "FLO"; break; | |
131 | #endif | |
132 | default: continue; | |
133 | } | |
134 | fprintf(fp, "!%s\t%s\t", this_var->di_key, s); | |
135 | --- 22605,22614 ---- | |
136 | case VAR_STRING: s = "STR"; break; | |
137 | case VAR_NUMBER: s = "NUM"; break; | |
138 | #ifdef FEAT_FLOAT | |
139 | ! case VAR_FLOAT: s = "FLO"; break; | |
140 | #endif | |
141 | + case VAR_DICT: s = "DIC"; break; | |
142 | + case VAR_LIST: s = "LIS"; break; | |
143 | default: continue; | |
144 | } | |
145 | fprintf(fp, "!%s\t%s\t", this_var->di_key, s); | |
146 | *** ../vim-7.3.029/src/testdir/Make_amiga.mak 2010-08-15 21:57:29.000000000 +0200 | |
147 | --- src/testdir/Make_amiga.mak 2010-10-20 16:27:19.000000000 +0200 | |
148 | *************** | |
149 | *** 27,33 **** | |
150 | test56.out test57.out test58.out test59.out test60.out \ | |
151 | test61.out test62.out test63.out test64.out test65.out \ | |
152 | test66.out test67.out test68.out test69.out test70.out \ | |
153 | ! test71.out test72.out test73.out | |
154 | ||
155 | .SUFFIXES: .in .out | |
156 | ||
157 | --- 27,33 ---- | |
158 | test56.out test57.out test58.out test59.out test60.out \ | |
159 | test61.out test62.out test63.out test64.out test65.out \ | |
160 | test66.out test67.out test68.out test69.out test70.out \ | |
161 | ! test71.out test72.out test73.out test74.out | |
162 | ||
163 | .SUFFIXES: .in .out | |
164 | ||
165 | *************** | |
166 | *** 120,122 **** | |
167 | --- 120,123 ---- | |
168 | test71.out: test71.in | |
169 | test72.out: test72.in | |
170 | test73.out: test73.in | |
171 | + test74.out: test74.in | |
172 | *** ../vim-7.3.029/src/testdir/Make_dos.mak 2010-08-15 21:57:29.000000000 +0200 | |
173 | --- src/testdir/Make_dos.mak 2010-10-20 16:13:35.000000000 +0200 | |
174 | *************** | |
175 | *** 27,33 **** | |
176 | test30.out test31.out test32.out test33.out test34.out \ | |
177 | test37.out test38.out test39.out test40.out test41.out \ | |
178 | test42.out test52.out test65.out test66.out test67.out \ | |
179 | ! test68.out test69.out test71.out test72.out test73.out | |
180 | ||
181 | SCRIPTS32 = test50.out test70.out | |
182 | ||
183 | --- 27,34 ---- | |
184 | test30.out test31.out test32.out test33.out test34.out \ | |
185 | test37.out test38.out test39.out test40.out test41.out \ | |
186 | test42.out test52.out test65.out test66.out test67.out \ | |
187 | ! test68.out test69.out test71.out test72.out test73.out \ | |
188 | ! test74.out | |
189 | ||
190 | SCRIPTS32 = test50.out test70.out | |
191 | ||
192 | *** ../vim-7.3.029/src/testdir/Make_ming.mak 2010-08-15 21:57:29.000000000 +0200 | |
193 | --- src/testdir/Make_ming.mak 2010-10-20 16:26:54.000000000 +0200 | |
194 | *************** | |
195 | *** 47,53 **** | |
196 | test30.out test31.out test32.out test33.out test34.out \ | |
197 | test37.out test38.out test39.out test40.out test41.out \ | |
198 | test42.out test52.out test65.out test66.out test67.out \ | |
199 | ! test68.out test69.out test71.out test72.out test72.out | |
200 | ||
201 | SCRIPTS32 = test50.out test70.out | |
202 | ||
203 | --- 47,54 ---- | |
204 | test30.out test31.out test32.out test33.out test34.out \ | |
205 | test37.out test38.out test39.out test40.out test41.out \ | |
206 | test42.out test52.out test65.out test66.out test67.out \ | |
207 | ! test68.out test69.out test71.out test72.out test73.out \ | |
208 | ! test74.out | |
209 | ||
210 | SCRIPTS32 = test50.out test70.out | |
211 | ||
212 | *** ../vim-7.3.029/src/testdir/Make_os2.mak 2010-08-15 21:57:29.000000000 +0200 | |
213 | --- src/testdir/Make_os2.mak 2010-10-20 16:13:35.000000000 +0200 | |
214 | *************** | |
215 | *** 27,33 **** | |
216 | test56.out test57.out test58.out test59.out test60.out \ | |
217 | test61.out test62.out test63.out test64.out test65.out \ | |
218 | test66.out test67.out test68.out test69.out test70.out \ | |
219 | ! test71.out test72.out test73.out | |
220 | ||
221 | .SUFFIXES: .in .out | |
222 | ||
223 | --- 27,33 ---- | |
224 | test56.out test57.out test58.out test59.out test60.out \ | |
225 | test61.out test62.out test63.out test64.out test65.out \ | |
226 | test66.out test67.out test68.out test69.out test70.out \ | |
227 | ! test71.out test72.out test73.out test74.out | |
228 | ||
229 | .SUFFIXES: .in .out | |
230 | ||
231 | *** ../vim-7.3.029/src/testdir/Make_vms.mms 2010-08-15 21:57:29.000000000 +0200 | |
232 | --- src/testdir/Make_vms.mms 2010-10-20 16:13:35.000000000 +0200 | |
233 | *************** | |
234 | *** 74,80 **** | |
235 | test56.out test57.out test60.out \ | |
236 | test61.out test62.out test63.out test64.out test65.out \ | |
237 | test66.out test67.out test68.out test69.out \ | |
238 | ! test71.out test72.out | |
239 | ||
240 | # Known problems: | |
241 | # Test 30: a problem around mac format - unknown reason | |
242 | --- 74,80 ---- | |
243 | test56.out test57.out test60.out \ | |
244 | test61.out test62.out test63.out test64.out test65.out \ | |
245 | test66.out test67.out test68.out test69.out \ | |
246 | ! test71.out test72.out test74.out | |
247 | ||
248 | # Known problems: | |
249 | # Test 30: a problem around mac format - unknown reason | |
250 | *** ../vim-7.3.029/src/testdir/Makefile 2010-09-14 12:47:30.000000000 +0200 | |
251 | --- src/testdir/Makefile 2010-10-20 16:13:35.000000000 +0200 | |
252 | *************** | |
253 | *** 10,15 **** | |
254 | --- 10,16 ---- | |
255 | # This will make testing about 10 times as slow. | |
256 | # VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$* | |
257 | ||
258 | + | |
259 | SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \ | |
260 | test7.out test8.out test9.out test10.out test11.out \ | |
261 | test12.out test13.out test14.out test15.out test17.out \ | |
262 | *************** | |
263 | *** 23,29 **** | |
264 | test54.out test55.out test56.out test57.out test58.out \ | |
265 | test59.out test60.out test61.out test62.out test63.out \ | |
266 | test64.out test65.out test66.out test67.out test68.out \ | |
267 | ! test69.out test70.out test71.out test72.out test73.out | |
268 | ||
269 | SCRIPTS_GUI = test16.out | |
270 | ||
271 | --- 24,31 ---- | |
272 | test54.out test55.out test56.out test57.out test58.out \ | |
273 | test59.out test60.out test61.out test62.out test63.out \ | |
274 | test64.out test65.out test66.out test67.out test68.out \ | |
275 | ! test69.out test70.out test71.out test72.out test73.out \ | |
276 | ! test74.out | |
277 | ||
278 | SCRIPTS_GUI = test16.out | |
279 | ||
280 | *** ../vim-7.3.029/src/testdir/main.aap 2010-08-15 21:57:29.000000000 +0200 | |
281 | --- src/testdir/main.aap 2010-10-20 16:13:35.000000000 +0200 | |
282 | *************** | |
283 | *** 13,19 **** | |
284 | test33.out test34.out test35.out test36.out test37.out | |
285 | test38.out test39.out test40.out test41.out test42.out | |
286 | test43.out test44.out test45.out test46.out test47.out | |
287 | ! test48.out test49.out | |
288 | ||
289 | ScriptsGUI = test16.out | |
290 | ||
291 | --- 13,19 ---- | |
292 | test33.out test34.out test35.out test36.out test37.out | |
293 | test38.out test39.out test40.out test41.out test42.out | |
294 | test43.out test44.out test45.out test46.out test47.out | |
295 | ! test48.out test49.out test74.out | |
296 | ||
297 | ScriptsGUI = test16.out | |
298 | ||
299 | *** ../vim-7.3.029/src/testdir/test74.in 2010-10-20 17:41:30.000000000 +0200 | |
300 | --- src/testdir/test74.in 2010-10-20 17:37:52.000000000 +0200 | |
301 | *************** | |
302 | *** 0 **** | |
303 | --- 1,36 ---- | |
304 | + " Tests for storing global variables in the .viminfo file vim: set ft=vim: | |
305 | + | |
306 | + STARTTEST | |
307 | + :so small.vim | |
308 | + :" Do all test in a separate window to avoid E211 when we recursively | |
309 | + :" delete the Xfind directory during cleanup | |
310 | + :" | |
311 | + :" This will cause a few errors, do it silently. | |
312 | + :set visualbell | |
313 | + :set nocp viminfo+=!,nviminfo | |
314 | + :let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000} | |
315 | + :" store a really long list, so line wrapping will occur in viminfo file | |
316 | + :let MY_GLOBAL_LIST=range(1,100) | |
317 | + :wv! Xviminfo | |
318 | + :unlet MY_GLOBAL_DICT | |
319 | + :unlet MY_GLOBAL_LIST | |
320 | + :rv! Xviminfo | |
321 | + :call delete('Xviminfo') | |
322 | + :if exists("MY_GLOBAL_DICT") | |
323 | + :redir >> test.out | |
324 | + :echo MY_GLOBAL_DICT | |
325 | + :redir end | |
326 | + :endif | |
327 | + :if exists("MY_GLOBAL_LIST") | |
328 | + :redir >> test.out | |
329 | + :echo MY_GLOBAL_LIST | |
330 | + :redir end | |
331 | + :endif | |
332 | + :redir >> test.out | |
333 | + :echo "foobar" | |
334 | + :redir end | |
335 | + :endif | |
336 | + :qa! | |
337 | + ENDTEST | |
338 | + | |
339 | + eof | |
340 | *** ../vim-7.3.029/src/testdir/test74.ok 2010-10-20 17:41:30.000000000 +0200 | |
341 | --- src/testdir/test74.ok 2010-10-20 17:36:57.000000000 +0200 | |
342 | *************** | |
343 | *** 0 **** | |
344 | --- 1,5 ---- | |
345 | + | |
346 | + {'foo': 1, 'longvarible': 1000, 'bar': 0} | |
347 | + [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] | |
348 | + | |
349 | + foobar | |
350 | *** ../vim-7.3.029/src/version.c 2010-10-15 20:20:00.000000000 +0200 | |
351 | --- src/version.c 2010-10-20 17:23:54.000000000 +0200 | |
352 | *************** | |
353 | *** 716,717 **** | |
354 | --- 716,719 ---- | |
355 | { /* Add new patch number below this line */ | |
356 | + /**/ | |
357 | + 30, | |
358 | /**/ | |
359 | ||
360 | -- | |
361 | Not too long ago, cut and paste was done with scissors and glue... | |
362 | ||
363 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
364 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
365 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
366 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |