|
Karsten Hopp |
bd0f9e |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
bd0f9e |
Subject: Patch 7.3.880
|
|
Karsten Hopp |
bd0f9e |
Fcc: outbox
|
|
Karsten Hopp |
bd0f9e |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
bd0f9e |
Mime-Version: 1.0
|
|
Karsten Hopp |
bd0f9e |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
bd0f9e |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
bd0f9e |
------------
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
Patch 7.3.880
|
|
Karsten Hopp |
bd0f9e |
Problem: When writing viminfo, old history lines may replace lines written
|
|
Karsten Hopp |
bd0f9e |
more recently by another Vim instance.
|
|
Karsten Hopp |
bd0f9e |
Solution: Mark history entries that were read from viminfo and overwrite
|
|
Karsten Hopp |
bd0f9e |
them when merging with the current viminfo.
|
|
Karsten Hopp |
bd0f9e |
Files: src/ex_getln.c
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
*** ../vim-7.3.879/src/ex_getln.c 2013-03-19 16:46:59.000000000 +0100
|
|
Karsten Hopp |
bd0f9e |
--- src/ex_getln.c 2013-04-05 18:56:08.000000000 +0200
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 56,61 ****
|
|
Karsten Hopp |
bd0f9e |
--- 56,62 ----
|
|
Karsten Hopp |
bd0f9e |
typedef struct hist_entry
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
int hisnum; /* identifying number */
|
|
Karsten Hopp |
bd0f9e |
+ int viminfo; /* when TRUE hisstr comes from viminfo */
|
|
Karsten Hopp |
bd0f9e |
char_u *hisstr; /* actual entry, separator char after the NUL */
|
|
Karsten Hopp |
bd0f9e |
} histentry_T;
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 113,118 ****
|
|
Karsten Hopp |
bd0f9e |
--- 114,120 ----
|
|
Karsten Hopp |
bd0f9e |
static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[]));
|
|
Karsten Hopp |
bd0f9e |
# ifdef FEAT_CMDHIST
|
|
Karsten Hopp |
bd0f9e |
static char_u *get_history_arg __ARGS((expand_T *xp, int idx));
|
|
Karsten Hopp |
bd0f9e |
+ static void clear_hist_entry __ARGS((histentry_T *hisptr));
|
|
Karsten Hopp |
bd0f9e |
# endif
|
|
Karsten Hopp |
bd0f9e |
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
|
|
Karsten Hopp |
bd0f9e |
static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5343,5352 ****
|
|
Karsten Hopp |
bd0f9e |
if (hisidx[type] < 0) /* there are no entries yet */
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
for (i = 0; i < newlen; ++i)
|
|
Karsten Hopp |
bd0f9e |
! {
|
|
Karsten Hopp |
bd0f9e |
! temp[i].hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
! temp[i].hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
! }
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
else if (newlen > hislen) /* array becomes bigger */
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
--- 5345,5351 ----
|
|
Karsten Hopp |
bd0f9e |
if (hisidx[type] < 0) /* there are no entries yet */
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
for (i = 0; i < newlen; ++i)
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(&temp[i]);
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
else if (newlen > hislen) /* array becomes bigger */
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5354,5363 ****
|
|
Karsten Hopp |
bd0f9e |
temp[i] = history[type][i];
|
|
Karsten Hopp |
bd0f9e |
j = i;
|
|
Karsten Hopp |
bd0f9e |
for ( ; i <= newlen - (hislen - hisidx[type]); ++i)
|
|
Karsten Hopp |
bd0f9e |
! {
|
|
Karsten Hopp |
bd0f9e |
! temp[i].hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
! temp[i].hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
! }
|
|
Karsten Hopp |
bd0f9e |
for ( ; j < hislen; ++i, ++j)
|
|
Karsten Hopp |
bd0f9e |
temp[i] = history[type][j];
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
--- 5353,5359 ----
|
|
Karsten Hopp |
bd0f9e |
temp[i] = history[type][i];
|
|
Karsten Hopp |
bd0f9e |
j = i;
|
|
Karsten Hopp |
bd0f9e |
for ( ; i <= newlen - (hislen - hisidx[type]); ++i)
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(&temp[i]);
|
|
Karsten Hopp |
bd0f9e |
for ( ; j < hislen; ++i, ++j)
|
|
Karsten Hopp |
bd0f9e |
temp[i] = history[type][j];
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5385,5390 ****
|
|
Karsten Hopp |
bd0f9e |
--- 5381,5395 ----
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
+ static void
|
|
Karsten Hopp |
bd0f9e |
+ clear_hist_entry(hisptr)
|
|
Karsten Hopp |
bd0f9e |
+ histentry_T *hisptr;
|
|
Karsten Hopp |
bd0f9e |
+ {
|
|
Karsten Hopp |
bd0f9e |
+ hisptr->hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
+ hisptr->viminfo = FALSE;
|
|
Karsten Hopp |
bd0f9e |
+ hisptr->hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
+ }
|
|
Karsten Hopp |
bd0f9e |
+
|
|
Karsten Hopp |
bd0f9e |
/*
|
|
Karsten Hopp |
bd0f9e |
* Check if command line 'str' is already in history.
|
|
Karsten Hopp |
bd0f9e |
* If 'move_to_front' is TRUE, matching entry is moved to end of history.
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5433,5440 ****
|
|
Karsten Hopp |
bd0f9e |
history[type][last_i] = history[type][i];
|
|
Karsten Hopp |
bd0f9e |
last_i = i;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
- history[type][i].hisstr = str;
|
|
Karsten Hopp |
bd0f9e |
history[type][i].hisnum = ++hisnum[type];
|
|
Karsten Hopp |
bd0f9e |
return TRUE;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
return FALSE;
|
|
Karsten Hopp |
bd0f9e |
--- 5438,5446 ----
|
|
Karsten Hopp |
bd0f9e |
history[type][last_i] = history[type][i];
|
|
Karsten Hopp |
bd0f9e |
last_i = i;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
history[type][i].hisnum = ++hisnum[type];
|
|
Karsten Hopp |
bd0f9e |
+ history[type][i].viminfo = FALSE;
|
|
Karsten Hopp |
bd0f9e |
+ history[type][i].hisstr = str;
|
|
Karsten Hopp |
bd0f9e |
return TRUE;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
return FALSE;
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5498,5505 ****
|
|
Karsten Hopp |
bd0f9e |
/* Current line is from the same mapping, remove it */
|
|
Karsten Hopp |
bd0f9e |
hisptr = &history[HIST_SEARCH][hisidx[HIST_SEARCH]];
|
|
Karsten Hopp |
bd0f9e |
vim_free(hisptr->hisstr);
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
--hisnum[histype];
|
|
Karsten Hopp |
bd0f9e |
if (--hisidx[HIST_SEARCH] < 0)
|
|
Karsten Hopp |
bd0f9e |
hisidx[HIST_SEARCH] = hislen - 1;
|
|
Karsten Hopp |
bd0f9e |
--- 5504,5510 ----
|
|
Karsten Hopp |
bd0f9e |
/* Current line is from the same mapping, remove it */
|
|
Karsten Hopp |
bd0f9e |
hisptr = &history[HIST_SEARCH][hisidx[HIST_SEARCH]];
|
|
Karsten Hopp |
bd0f9e |
vim_free(hisptr->hisstr);
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(hisptr);
|
|
Karsten Hopp |
bd0f9e |
--hisnum[histype];
|
|
Karsten Hopp |
bd0f9e |
if (--hisidx[HIST_SEARCH] < 0)
|
|
Karsten Hopp |
bd0f9e |
hisidx[HIST_SEARCH] = hislen - 1;
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5520,5525 ****
|
|
Karsten Hopp |
bd0f9e |
--- 5525,5531 ----
|
|
Karsten Hopp |
bd0f9e |
hisptr->hisstr[len + 1] = sep;
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
hisptr->hisnum = ++hisnum[histype];
|
|
Karsten Hopp |
bd0f9e |
+ hisptr->viminfo = FALSE;
|
|
Karsten Hopp |
bd0f9e |
if (histype == HIST_SEARCH && in_map)
|
|
Karsten Hopp |
bd0f9e |
last_maptick = maptick;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5709,5716 ****
|
|
Karsten Hopp |
bd0f9e |
for (i = hislen; i--;)
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
vim_free(hisptr->hisstr);
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
! hisptr++->hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
hisidx[histype] = -1; /* mark history as cleared */
|
|
Karsten Hopp |
bd0f9e |
hisnum[histype] = 0; /* reset identifier counter */
|
|
Karsten Hopp |
bd0f9e |
--- 5715,5721 ----
|
|
Karsten Hopp |
bd0f9e |
for (i = hislen; i--;)
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
vim_free(hisptr->hisstr);
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(hisptr);
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
hisidx[histype] = -1; /* mark history as cleared */
|
|
Karsten Hopp |
bd0f9e |
hisnum[histype] = 0; /* reset identifier counter */
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5755,5770 ****
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
found = TRUE;
|
|
Karsten Hopp |
bd0f9e |
vim_free(hisptr->hisstr);
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
else
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
if (i != last)
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
history[histype][last] = *hisptr;
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
! hisptr->hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
if (--last < 0)
|
|
Karsten Hopp |
bd0f9e |
last += hislen;
|
|
Karsten Hopp |
bd0f9e |
--- 5760,5773 ----
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
found = TRUE;
|
|
Karsten Hopp |
bd0f9e |
vim_free(hisptr->hisstr);
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(hisptr);
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
else
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
if (i != last)
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
history[histype][last] = *hisptr;
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(hisptr);
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
if (--last < 0)
|
|
Karsten Hopp |
bd0f9e |
last += hislen;
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 5808,5815 ****
|
|
Karsten Hopp |
bd0f9e |
history[histype][i] = history[histype][j];
|
|
Karsten Hopp |
bd0f9e |
i = j;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
! history[histype][i].hisstr = NULL;
|
|
Karsten Hopp |
bd0f9e |
! history[histype][i].hisnum = 0;
|
|
Karsten Hopp |
bd0f9e |
if (--i < 0)
|
|
Karsten Hopp |
bd0f9e |
i += hislen;
|
|
Karsten Hopp |
bd0f9e |
hisidx[histype] = i;
|
|
Karsten Hopp |
bd0f9e |
--- 5811,5817 ----
|
|
Karsten Hopp |
bd0f9e |
history[histype][i] = history[histype][j];
|
|
Karsten Hopp |
bd0f9e |
i = j;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
! clear_hist_entry(&history[histype][i]);
|
|
Karsten Hopp |
bd0f9e |
if (--i < 0)
|
|
Karsten Hopp |
bd0f9e |
i += hislen;
|
|
Karsten Hopp |
bd0f9e |
hisidx[histype] = i;
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 6043,6054 ****
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
for (type = 0; type < HIST_COUNT; ++type)
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
! /*
|
|
Karsten Hopp |
bd0f9e |
! * Count the number of empty spaces in the history list. If there are
|
|
Karsten Hopp |
bd0f9e |
! * more spaces available than we request, then fill them up.
|
|
Karsten Hopp |
bd0f9e |
! */
|
|
Karsten Hopp |
bd0f9e |
for (i = 0, num = 0; i < hislen; i++)
|
|
Karsten Hopp |
bd0f9e |
! if (history[type][i].hisstr == NULL)
|
|
Karsten Hopp |
bd0f9e |
num++;
|
|
Karsten Hopp |
bd0f9e |
len = asklen;
|
|
Karsten Hopp |
bd0f9e |
if (num > len)
|
|
Karsten Hopp |
bd0f9e |
--- 6045,6055 ----
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
for (type = 0; type < HIST_COUNT; ++type)
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
! /* Count the number of empty spaces in the history list. Entries read
|
|
Karsten Hopp |
bd0f9e |
! * from viminfo previously are also considered empty. If there are
|
|
Karsten Hopp |
bd0f9e |
! * more spaces available than we request, then fill them up. */
|
|
Karsten Hopp |
bd0f9e |
for (i = 0, num = 0; i < hislen; i++)
|
|
Karsten Hopp |
bd0f9e |
! if (history[type][i].hisstr == NULL || history[type][i].viminfo)
|
|
Karsten Hopp |
bd0f9e |
num++;
|
|
Karsten Hopp |
bd0f9e |
len = asklen;
|
|
Karsten Hopp |
bd0f9e |
if (num > len)
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 6141,6147 ****
|
|
Karsten Hopp |
bd0f9e |
hisidx[type] = hislen - 1;
|
|
Karsten Hopp |
bd0f9e |
do
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
! if (history[type][idx].hisstr != NULL)
|
|
Karsten Hopp |
bd0f9e |
break;
|
|
Karsten Hopp |
bd0f9e |
if (++idx == hislen)
|
|
Karsten Hopp |
bd0f9e |
idx = 0;
|
|
Karsten Hopp |
bd0f9e |
--- 6142,6149 ----
|
|
Karsten Hopp |
bd0f9e |
hisidx[type] = hislen - 1;
|
|
Karsten Hopp |
bd0f9e |
do
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
! if (history[type][idx].hisstr != NULL
|
|
Karsten Hopp |
bd0f9e |
! || history[type][idx].viminfo)
|
|
Karsten Hopp |
bd0f9e |
break;
|
|
Karsten Hopp |
bd0f9e |
if (++idx == hislen)
|
|
Karsten Hopp |
bd0f9e |
idx = 0;
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 6153,6158 ****
|
|
Karsten Hopp |
bd0f9e |
--- 6155,6161 ----
|
|
Karsten Hopp |
bd0f9e |
{
|
|
Karsten Hopp |
bd0f9e |
vim_free(history[type][idx].hisstr);
|
|
Karsten Hopp |
bd0f9e |
history[type][idx].hisstr = viminfo_history[type][i];
|
|
Karsten Hopp |
bd0f9e |
+ history[type][idx].viminfo = TRUE;
|
|
Karsten Hopp |
bd0f9e |
if (--idx < 0)
|
|
Karsten Hopp |
bd0f9e |
idx = hislen - 1;
|
|
Karsten Hopp |
bd0f9e |
}
|
|
Karsten Hopp |
bd0f9e |
*** ../vim-7.3.879/src/version.c 2013-04-05 17:43:10.000000000 +0200
|
|
Karsten Hopp |
bd0f9e |
--- src/version.c 2013-04-05 18:54:11.000000000 +0200
|
|
Karsten Hopp |
bd0f9e |
***************
|
|
Karsten Hopp |
bd0f9e |
*** 730,731 ****
|
|
Karsten Hopp |
bd0f9e |
--- 730,733 ----
|
|
Karsten Hopp |
bd0f9e |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
bd0f9e |
+ /**/
|
|
Karsten Hopp |
bd0f9e |
+ 880,
|
|
Karsten Hopp |
bd0f9e |
/**/
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
--
|
|
Karsten Hopp |
bd0f9e |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
bd0f9e |
122. You ask if the Netaholics Anonymous t-shirt you ordered can be
|
|
Karsten Hopp |
bd0f9e |
sent to you via e-mail.
|
|
Karsten Hopp |
bd0f9e |
|
|
Karsten Hopp |
bd0f9e |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
bd0f9e |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
bd0f9e |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
bd0f9e |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|