Mercurial > vim
comparison src/ex_cmds.c @ 7664:1fded31d9e04 v7.4.1131
commit https://github.com/vim/vim/commit/b20e334859334be35de4b295023a2b49bdabbfa9
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 18 23:29:01 2016 +0100
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 18 Jan 2016 23:30:05 +0100 |
parents | ad432f8f68fb |
children | 20dc2763a3b9 |
comparison
equal
deleted
inserted
replaced
7663:c4b2ec5485e5 | 7664:1fded31d9e04 |
---|---|
1705 " %s%s", /* " > %s" causes problems on Amiga */ | 1705 " %s%s", /* " > %s" causes problems on Amiga */ |
1706 #endif | 1706 #endif |
1707 (char *)opt, (char *)fname); | 1707 (char *)opt, (char *)fname); |
1708 } | 1708 } |
1709 | 1709 |
1710 #ifdef FEAT_VIMINFO | 1710 #if defined(FEAT_VIMINFO) || defined(PROTO) |
1711 | 1711 |
1712 static int no_viminfo __ARGS((void)); | 1712 static int no_viminfo __ARGS((void)); |
1713 static void write_viminfo_barlines(vir_T *virp, FILE *fp_out); | |
1713 static int viminfo_errcnt; | 1714 static int viminfo_errcnt; |
1714 | 1715 |
1715 static int | 1716 static int |
1716 no_viminfo() | 1717 no_viminfo() |
1717 { | 1718 { |
2121 return; | 2122 return; |
2122 vir.vir_fd = fp_in; | 2123 vir.vir_fd = fp_in; |
2123 #ifdef FEAT_MBYTE | 2124 #ifdef FEAT_MBYTE |
2124 vir.vir_conv.vc_type = CONV_NONE; | 2125 vir.vir_conv.vc_type = CONV_NONE; |
2125 #endif | 2126 #endif |
2127 ga_init2(&vir.vir_barlines, (int)sizeof(char_u *), 100); | |
2126 | 2128 |
2127 if (fp_in != NULL) | 2129 if (fp_in != NULL) |
2128 { | 2130 { |
2129 if (flags & VIF_WANT_INFO) | 2131 if (flags & VIF_WANT_INFO) |
2130 { | 2132 { |
2157 #ifdef FEAT_EVAL | 2159 #ifdef FEAT_EVAL |
2158 write_viminfo_varlist(fp_out); | 2160 write_viminfo_varlist(fp_out); |
2159 #endif | 2161 #endif |
2160 write_viminfo_filemarks(fp_out); | 2162 write_viminfo_filemarks(fp_out); |
2161 write_viminfo_bufferlist(fp_out); | 2163 write_viminfo_bufferlist(fp_out); |
2164 write_viminfo_barlines(&vir, fp_out); | |
2162 count = write_viminfo_marks(fp_out); | 2165 count = write_viminfo_marks(fp_out); |
2163 } | 2166 } |
2164 if (fp_in != NULL | 2167 if (fp_in != NULL |
2165 && (flags & (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT))) | 2168 && (flags & (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT))) |
2166 copy_viminfo_marks(&vir, fp_out, count, eof, flags); | 2169 copy_viminfo_marks(&vir, fp_out, count, eof, flags); |
2168 vim_free(vir.vir_line); | 2171 vim_free(vir.vir_line); |
2169 #ifdef FEAT_MBYTE | 2172 #ifdef FEAT_MBYTE |
2170 if (vir.vir_conv.vc_type != CONV_NONE) | 2173 if (vir.vir_conv.vc_type != CONV_NONE) |
2171 convert_setup(&vir.vir_conv, NULL, NULL); | 2174 convert_setup(&vir.vir_conv, NULL, NULL); |
2172 #endif | 2175 #endif |
2176 ga_clear_strings(&vir.vir_barlines); | |
2173 } | 2177 } |
2174 | 2178 |
2175 /* | 2179 /* |
2176 * read_viminfo_up_to_marks() -- Only called from do_viminfo(). Reads in the | 2180 * read_viminfo_up_to_marks() -- Only called from do_viminfo(). Reads in the |
2177 * first part of the viminfo file which contains everything but the marks that | 2181 * first part of the viminfo file which contains everything but the marks that |
2194 { | 2198 { |
2195 switch (virp->vir_line[0]) | 2199 switch (virp->vir_line[0]) |
2196 { | 2200 { |
2197 /* Characters reserved for future expansion, ignored now */ | 2201 /* Characters reserved for future expansion, ignored now */ |
2198 case '+': /* "+40 /path/dir file", for running vim without args */ | 2202 case '+': /* "+40 /path/dir file", for running vim without args */ |
2199 case '|': /* to be defined */ | |
2200 case '^': /* to be defined */ | 2203 case '^': /* to be defined */ |
2201 case '<': /* long line - ignored */ | 2204 case '<': /* long line - ignored */ |
2202 /* A comment or empty line. */ | 2205 /* A comment or empty line. */ |
2203 case NUL: | 2206 case NUL: |
2204 case '\r': | 2207 case '\r': |
2205 case '\n': | 2208 case '\n': |
2206 case '#': | 2209 case '#': |
2210 eof = viminfo_readline(virp); | |
2211 break; | |
2212 case '|': /* copy line (for future use) */ | |
2213 if (writing) | |
2214 ga_add_string(&virp->vir_barlines, virp->vir_line); | |
2207 eof = viminfo_readline(virp); | 2215 eof = viminfo_readline(virp); |
2208 break; | 2216 break; |
2209 case '*': /* "*encoding=value" */ | 2217 case '*': /* "*encoding=value" */ |
2210 eof = viminfo_encoding(virp); | 2218 eof = viminfo_encoding(virp); |
2211 break; | 2219 break; |
2424 c = 'n'; | 2432 c = 'n'; |
2425 } | 2433 } |
2426 putc(c, fd); | 2434 putc(c, fd); |
2427 } | 2435 } |
2428 putc('\n', fd); | 2436 putc('\n', fd); |
2437 } | |
2438 | |
2439 static void | |
2440 write_viminfo_barlines(vir_T *virp, FILE *fp_out) | |
2441 { | |
2442 int i; | |
2443 garray_T *gap = &virp->vir_barlines; | |
2444 | |
2445 if (gap->ga_len > 0) | |
2446 { | |
2447 fputs(_("\n# Bar lines, copied verbatim:\n"), fp_out); | |
2448 | |
2449 for (i = 0; i < gap->ga_len; ++i) | |
2450 fputs(((char **)(gap->ga_data))[i], fp_out); | |
2451 } | |
2429 } | 2452 } |
2430 #endif /* FEAT_VIMINFO */ | 2453 #endif /* FEAT_VIMINFO */ |
2431 | 2454 |
2432 /* | 2455 /* |
2433 * Implementation of ":fixdel", also used by get_stty(). | 2456 * Implementation of ":fixdel", also used by get_stty(). |