mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 7.4.1947
Problem: Viminfo continuation line with wrong length isn't skipped. (Marius Gedminas) Solution: Skip a line when encountering an error, but not two lines.
This commit is contained in:
@@ -2559,8 +2559,9 @@ barline_writestring(FILE *fd, char_u *s, int remaining_start)
|
|||||||
/*
|
/*
|
||||||
* Parse a viminfo line starting with '|'.
|
* Parse a viminfo line starting with '|'.
|
||||||
* Add each decoded value to "values".
|
* Add each decoded value to "values".
|
||||||
|
* Returns TRUE if the next line is to be read after using the parsed values.
|
||||||
*/
|
*/
|
||||||
static void
|
static int
|
||||||
barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
||||||
{
|
{
|
||||||
char_u *p = text;
|
char_u *p = text;
|
||||||
@@ -2569,6 +2570,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
|||||||
bval_T *value;
|
bval_T *value;
|
||||||
int i;
|
int i;
|
||||||
int allocated = FALSE;
|
int allocated = FALSE;
|
||||||
|
int eof;
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
char_u *sconv;
|
char_u *sconv;
|
||||||
int converted;
|
int converted;
|
||||||
@@ -2611,21 +2613,24 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
|||||||
* |{bartype},>{length of "{text}{text2}"}
|
* |{bartype},>{length of "{text}{text2}"}
|
||||||
* |<"{text1}
|
* |<"{text1}
|
||||||
* |<{text2}",{value}
|
* |<{text2}",{value}
|
||||||
|
* Length includes the quotes.
|
||||||
*/
|
*/
|
||||||
++p;
|
++p;
|
||||||
len = getdigits(&p);
|
len = getdigits(&p);
|
||||||
buf = alloc((int)(len + 1));
|
buf = alloc((int)(len + 1));
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return;
|
return TRUE;
|
||||||
p = buf;
|
p = buf;
|
||||||
for (todo = len; todo > 0; todo -= n)
|
for (todo = len; todo > 0; todo -= n)
|
||||||
{
|
{
|
||||||
if (viminfo_readline(virp) || virp->vir_line[0] != '|'
|
eof = viminfo_readline(virp);
|
||||||
|
if (eof || virp->vir_line[0] != '|'
|
||||||
|| virp->vir_line[1] != '<')
|
|| virp->vir_line[1] != '<')
|
||||||
{
|
{
|
||||||
/* file was truncated or garbled */
|
/* File was truncated or garbled. Read another line if
|
||||||
|
* this one starts with '|'. */
|
||||||
vim_free(buf);
|
vim_free(buf);
|
||||||
return;
|
return eof || virp->vir_line[0] == '|';
|
||||||
}
|
}
|
||||||
/* Get length of text, excluding |< and NL chars. */
|
/* Get length of text, excluding |< and NL chars. */
|
||||||
n = STRLEN(virp->vir_line);
|
n = STRLEN(virp->vir_line);
|
||||||
@@ -2651,10 +2656,12 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
|||||||
* |{bartype},{lots of values},>
|
* |{bartype},{lots of values},>
|
||||||
* |<{value},{value}
|
* |<{value},{value}
|
||||||
*/
|
*/
|
||||||
if (viminfo_readline(virp) || virp->vir_line[0] != '|'
|
eof = viminfo_readline(virp);
|
||||||
|
if (eof || virp->vir_line[0] != '|'
|
||||||
|| virp->vir_line[1] != '<')
|
|| virp->vir_line[1] != '<')
|
||||||
/* file was truncated or garbled */
|
/* File was truncated or garbled. Read another line if
|
||||||
return;
|
* this one starts with '|'. */
|
||||||
|
return eof || virp->vir_line[0] == '|';
|
||||||
p = virp->vir_line + 2;
|
p = virp->vir_line + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2675,7 +2682,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
|||||||
while (*p != '"')
|
while (*p != '"')
|
||||||
{
|
{
|
||||||
if (*p == NL || *p == NUL)
|
if (*p == NL || *p == NUL)
|
||||||
return; /* syntax error, drop the value */
|
return TRUE; /* syntax error, drop the value */
|
||||||
if (*p == '\\')
|
if (*p == '\\')
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
@@ -2734,6 +2741,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -2744,6 +2752,7 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
|
|||||||
garray_T values;
|
garray_T values;
|
||||||
bval_T *vp;
|
bval_T *vp;
|
||||||
int i;
|
int i;
|
||||||
|
int read_next = TRUE;
|
||||||
|
|
||||||
/* The format is: |{bartype},{value},...
|
/* The format is: |{bartype},{value},...
|
||||||
* For a very long string:
|
* For a very long string:
|
||||||
@@ -2772,7 +2781,7 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
|
|||||||
* doesn't understand the version. */
|
* doesn't understand the version. */
|
||||||
if (!got_encoding)
|
if (!got_encoding)
|
||||||
{
|
{
|
||||||
barline_parse(virp, p, &values);
|
read_next = barline_parse(virp, p, &values);
|
||||||
vp = (bval_T *)values.ga_data;
|
vp = (bval_T *)values.ga_data;
|
||||||
if (values.ga_len > 0 && vp->bv_type == BVAL_NR)
|
if (values.ga_len > 0 && vp->bv_type == BVAL_NR)
|
||||||
virp->vir_version = vp->bv_nr;
|
virp->vir_version = vp->bv_nr;
|
||||||
@@ -2780,17 +2789,17 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BARTYPE_HISTORY:
|
case BARTYPE_HISTORY:
|
||||||
barline_parse(virp, p, &values);
|
read_next = barline_parse(virp, p, &values);
|
||||||
handle_viminfo_history(&values, writing);
|
handle_viminfo_history(&values, writing);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BARTYPE_REGISTER:
|
case BARTYPE_REGISTER:
|
||||||
barline_parse(virp, p, &values);
|
read_next = barline_parse(virp, p, &values);
|
||||||
handle_viminfo_register(&values, force);
|
handle_viminfo_register(&values, force);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BARTYPE_MARK:
|
case BARTYPE_MARK:
|
||||||
barline_parse(virp, p, &values);
|
read_next = barline_parse(virp, p, &values);
|
||||||
handle_viminfo_mark(&values, force);
|
handle_viminfo_mark(&values, force);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2808,7 +2817,9 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
|
|||||||
ga_clear(&values);
|
ga_clear(&values);
|
||||||
}
|
}
|
||||||
|
|
||||||
return viminfo_readline(virp);
|
if (read_next)
|
||||||
|
return viminfo_readline(virp);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1947,
|
||||||
/**/
|
/**/
|
||||||
1946,
|
1946,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user