To: vim-dev@vim.org Subject: Patch 6.2.287 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.287 (after 6.2.264) Problem: Duplicate lines are added to the viminfo file. Solution: Compare with existing entries without an offset. Also fixes reading very long history lines from viminfo. Files: src/ex_getln.c *** ../vim-6.2.286/src/ex_getln.c Tue Feb 17 20:22:36 2004 --- src/ex_getln.c Tue Feb 24 14:38:36 2004 *************** *** 4742,4783 **** vir_T *virp; { int type; ! int sep; ! int len; char_u *val; type = hist_char2type(virp->vir_line[0]); if (viminfo_hisidx[type] < viminfo_hislen[type]) { ! /* Use a zero offset, so that we have some extra space in the ! * allocated memory for the separator. */ ! val = viminfo_readstring(virp, 0, TRUE); ! if (val != NULL) { ! if (!in_history(type, val, viminfo_add_at_front)) { len = STRLEN(val); ! if (type == HIST_SEARCH) ! { ! /* Search entry: Move the separator from the second column ! * to after the NUL. */ ! sep = val[1]; ! --len; ! mch_memmove(val, val + 2, (size_t)len); ! val[len] = (sep == ' ' ? NUL : sep); ! } ! else { ! /* Not a search entry: No separator in the viminfo file, ! * add a NUL separator. */ ! mch_memmove(val, val + 1, (size_t)len); ! val[len] = NUL; } - viminfo_history[type][viminfo_hisidx[type]++] = val; } - else - vim_free(val); } } return viminfo_readline(virp); } --- 4781,4823 ---- vir_T *virp; { int type; ! long_u len; char_u *val; + char_u *p; type = hist_char2type(virp->vir_line[0]); if (viminfo_hisidx[type] < viminfo_hislen[type]) { ! val = viminfo_readstring(virp, 1, TRUE); ! if (val != NULL && *val != NUL) { ! if (!in_history(type, val + (type == HIST_SEARCH), ! viminfo_add_at_front)) { + /* Need to re-allocate to append the separator byte. */ len = STRLEN(val); ! p = lalloc(len + 2, TRUE); ! if (p != NULL) { ! if (type == HIST_SEARCH) ! { ! /* Search entry: Move the separator from the first ! * column to after the NUL. */ ! mch_memmove(p, val + 1, (size_t)len); ! p[len] = (*val == ' ' ? NUL : *val); ! } ! else ! { ! /* Not a search entry: No separator in the viminfo ! * file, add a NUL separator. */ ! mch_memmove(p, val, (size_t)len + 1); ! p[len + 1] = NUL; ! } ! viminfo_history[type][viminfo_hisidx[type]++] = p; } } } + vim_free(val); } return viminfo_readline(virp); } *** ../vim-6.2.286/src/version.c Tue Feb 24 15:19:00 2004 --- src/version.c Tue Feb 24 15:21:20 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 287, /**/ -- hundred-and-one symptoms of being an internet addict: 239. You think "surfing" is something you do on dry land. /// 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 /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///