To: vim-dev@vim.org Subject: Patch 6.2.393 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.393 Problem: When using very long lines the viminfo file can become very big. Solution: Add the "s" flag to 'viminfo': skip registers with more than the specified Kbyte of text. Files: runtime/doc/options.txt, src/ops.c, src/option.c *** ../vim-6.2.392/runtime/doc/options.txt Sun Feb 29 21:06:13 2004 --- runtime/doc/options.txt Mon Mar 22 20:47:20 2004 *************** *** 1,4 **** ! *options.txt* For Vim version 6.2. Last change: 2004 Feb 24 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *options.txt* For Vim version 6.2. Last change: 2004 Mar 22 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 6275,6283 **** *'viminfo'* *'vi'* *E526* *E527* *E528* 'viminfo' 'vi' string (Vi default: "", Vim default for MS-DOS, ! Windows and OS/2: '20,"50,h,rA:,rB:, ! for Amiga: '20,"50,h,rdf0:,rdf1:,rdf2: ! for others: '20,"50,h) global {not in Vi} {not available when compiled without the |+viminfo| --- 6325,6333 ---- *'viminfo'* *'vi'* *E526* *E527* *E528* 'viminfo' 'vi' string (Vi default: "", Vim default for MS-DOS, ! Windows and OS/2: '20,"50,s10,h,rA:,rB:, ! for Amiga: '20,"50,s10,h,rdf0:,rdf1:,rdf2: ! for others: '20,"50,s10,h) global {not in Vi} {not available when compiled without the |+viminfo| *************** *** 6299,6304 **** --- 6349,6355 ---- registers are not saved. When not included, all lines are saved. Dont forget to put a backslash before the ", otherwise it will be recognized as the start of a comment! + Also see the 's' item below: limit specified in Kbyte. % When included, save and restore the buffer list. If Vim is started with a file name argument, the buffer list is not restored. If Vim is started without a file name argument, the *************** *** 6308,6315 **** ' Maximum number of previously edited files for which the marks are remembered. This parameter must always be included when 'viminfo' is non-empty. ! Including this item also means that the |jumplist| is stored ! in the viminfo file. / Maximum number of items in the search pattern history to be saved. If non-zero, then the previous search and substitute patterns are also saved. When not included, the value of --- 6359,6366 ---- ' Maximum number of previously edited files for which the marks are remembered. This parameter must always be included when 'viminfo' is non-empty. ! Including this item also means that the |jumplist| and the ! |changelist| are stored in the viminfo file. / Maximum number of items in the search pattern history to be saved. If non-zero, then the previous search and substitute patterns are also saved. When not included, the value of *************** *** 6337,6353 **** ','). This parameter can be given several times. Each specifies the start of a path for which no marks will be stored. This is to avoid removable media. For MS-DOS you ! could use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:". Case is ignored. Maximum length of each 'r' argument is 50 characters. Example: > ! :set viminfo='50,\"1000,:0,n~/vim/viminfo < '50 Marks will be remembered for the last 50 files you edited. "1000 Contents of registers (up to 1000 lines each) will be remembered. :0 Command-line history will not be saved. n~/vim/viminfo The name of the file to use is "~/vim/viminfo". no / Since '/' is not specified, the default will be used, --- 6388,6410 ---- ','). This parameter can be given several times. Each specifies the start of a path for which no marks will be stored. This is to avoid removable media. For MS-DOS you ! could use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:". You can ! also use it for temp files, e.g., for Unix: "r/tmp". Case is ignored. Maximum length of each 'r' argument is 50 characters. + s Maximum size of an item in Kbyte. If zero then registers are + not saved. Currently only applies to registers. The default + "s10" will exclude registers with more than 10 Kbyte of text. + Also see the '"' item above: line count limit. Example: > ! :set viminfo='50,\"1000,s100,:0,n~/vim/viminfo < '50 Marks will be remembered for the last 50 files you edited. "1000 Contents of registers (up to 1000 lines each) will be remembered. + s100 Registers with more than 100 Kbyte text are skipped. :0 Command-line history will not be saved. n~/vim/viminfo The name of the file to use is "~/vim/viminfo". no / Since '/' is not specified, the default will be used, *** ../vim-6.2.392/src/ops.c Mon Mar 22 14:47:27 2004 --- src/ops.c Mon Mar 22 17:47:38 2004 *************** *** 5052,5063 **** --- 5052,5068 ---- char_u c; int num_lines; int max_num_lines; + int max_kbyte; + long len; fprintf(fp, _("\n# Registers:\n")); max_num_lines = get_viminfo_parameter('"'); if (max_num_lines == 0) return; + max_kbyte = get_viminfo_parameter('s'); + if (max_kbyte == 0) + return; for (i = 0; i < NUM_REGISTERS; i++) { if (y_regs[i].y_array == NULL) *************** *** 5072,5077 **** --- 5077,5093 ---- if (i == TILDE_REGISTER) continue; #endif + num_lines = y_regs[i].y_size; + if (max_kbyte > 0) + { + /* Skip register if there is more text than the maximum size. */ + len = 0; + for (j = 0; j < num_lines; j++) + len += STRLEN(y_regs[i].y_array[j]) + 1L; + if (len > (long)max_kbyte * 1024L) + continue; + } + switch (y_regs[i].y_type) { case MLINE: *************** *** 5102,5108 **** 0 #endif ); - num_lines = y_regs[i].y_size; /* If max_num_lines < 0, then we save ALL the lines in the register */ if (max_num_lines > 0 && num_lines > max_num_lines) --- 5118,5123 ---- *** ../vim-6.2.392/src/option.c Fri Mar 19 11:43:26 2004 --- src/option.c Mon Mar 22 20:29:18 2004 *************** *** 2177,2196 **** {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE, #ifdef FEAT_VIMINFO (char_u *)&p_viminfo, PV_NONE, - #else - (char_u *)NULL, PV_NONE, - #endif #if defined(MSDOS) || defined(MSWIN) || defined(OS2) ! {(char_u *)"", (char_u *)"'20,\"50,h,rA:,rB:"} #else # ifdef AMIGA {(char_u *)"", ! (char_u *)"'20,\"50,h,rdf0:,rdf1:,rdf2:"} # else ! {(char_u *)"", (char_u *)"'20,\"50,h"} # endif #endif ! }, {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM, #ifdef FEAT_VIRTUALEDIT (char_u *)&p_ve, PV_NONE, --- 2189,2209 ---- {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE, #ifdef FEAT_VIMINFO (char_u *)&p_viminfo, PV_NONE, #if defined(MSDOS) || defined(MSWIN) || defined(OS2) ! {(char_u *)"", (char_u *)"'20,\"50,s10,h,rA:,rB:"} #else # ifdef AMIGA {(char_u *)"", ! (char_u *)"'20,\"50,s10,h,rdf0:,rdf1:,rdf2:"} # else ! {(char_u *)"", (char_u *)"'20,\"50,s10,h"} # endif #endif ! #else ! (char_u *)NULL, PV_NONE, ! {(char_u *)0L, (char_u *)0L} ! #endif ! }, {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM, #ifdef FEAT_VIRTUALEDIT (char_u *)&p_ve, PV_NONE, *************** *** 4212,4219 **** } /* ! * Find the parameter represented by the given character (eg ', :, ", or /) in ! * the 'viminfo' option and return a pointer to the string after it. * Return NULL if the parameter is not specified in the string. */ char_u * --- 4225,4232 ---- } /* ! * Find the parameter represented by the given character (eg ''', ':', '"', or ! * '/') in the 'viminfo' option and return a pointer to the string after it. * Return NULL if the parameter is not specified in the string. */ char_u * *************** *** 5037,5043 **** for (s = p_viminfo; *s;) { /* Check it's a valid character */ ! if (vim_strchr((char_u *)"!\"%'/:@cfhnr", *s) == NULL) { errmsg = illegal_char(errbuf, *s); break; --- 5050,5056 ---- for (s = p_viminfo; *s;) { /* Check it's a valid character */ ! if (vim_strchr((char_u *)"!\"%'/:@cfhnrs", *s) == NULL) { errmsg = illegal_char(errbuf, *s); break; *** ../vim-6.2.392/src/version.c Mon Mar 22 20:54:36 2004 --- src/version.c Mon Mar 22 21:08:12 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 393, /**/ -- hundred-and-one symptoms of being an internet addict: 105. When someone asks you for your address, you tell them your URL. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///