summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-06-20 12:50:17 +0200
committerBram Moolenaar <Bram@vim.org>2016-06-20 12:50:17 +0200
commitecefe71704850b94df44f65fc756c1551ec68388 (patch)
tree6761cced1b20029da8a9ec6e74bd20620e2c5490
parentcf2d77987ca2af092dad5d4cbca9eda621fe5567 (diff)
patch 7.4.1947v7.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.
-rw-r--r--src/ex_cmds.c39
-rw-r--r--src/version.c2
2 files changed, 27 insertions, 14 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index ec405cb432..aff2bddcae 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2559,8 +2559,9 @@ barline_writestring(FILE *fd, char_u *s, int remaining_start)
/*
* Parse a viminfo line starting with '|'.
* 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)
{
char_u *p = text;
@@ -2569,6 +2570,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
bval_T *value;
int i;
int allocated = FALSE;
+ int eof;
#ifdef FEAT_MBYTE
char_u *sconv;
int converted;
@@ -2611,21 +2613,24 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
* |{bartype},>{length of "{text}{text2}"}
* |<"{text1}
* |<{text2}",{value}
+ * Length includes the quotes.
*/
++p;
len = getdigits(&p);
buf = alloc((int)(len + 1));
if (buf == NULL)
- return;
+ return TRUE;
p = buf;
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] != '<')
{
- /* file was truncated or garbled */
+ /* File was truncated or garbled. Read another line if
+ * this one starts with '|'. */
vim_free(buf);
- return;
+ return eof || virp->vir_line[0] == '|';
}
/* Get length of text, excluding |< and NL chars. */
n = STRLEN(virp->vir_line);
@@ -2651,10 +2656,12 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
* |{bartype},{lots of values},>
* |<{value},{value}
*/
- if (viminfo_readline(virp) || virp->vir_line[0] != '|'
+ eof = viminfo_readline(virp);
+ if (eof || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
- /* file was truncated or garbled */
- return;
+ /* File was truncated or garbled. Read another line if
+ * this one starts with '|'. */
+ return eof || virp->vir_line[0] == '|';
p = virp->vir_line + 2;
}
}
@@ -2675,7 +2682,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
while (*p != '"')
{
if (*p == NL || *p == NUL)
- return; /* syntax error, drop the value */
+ return TRUE; /* syntax error, drop the value */
if (*p == '\\')
{
++p;
@@ -2734,6 +2741,7 @@ barline_parse(vir_T *virp, char_u *text, garray_T *values)
else
break;
}
+ return TRUE;
}
static int
@@ -2744,6 +2752,7 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
garray_T values;
bval_T *vp;
int i;
+ int read_next = TRUE;
/* The format is: |{bartype},{value},...
* 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. */
if (!got_encoding)
{
- barline_parse(virp, p, &values);
+ read_next = barline_parse(virp, p, &values);
vp = (bval_T *)values.ga_data;
if (values.ga_len > 0 && vp->bv_type == BVAL_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;
case BARTYPE_HISTORY:
- barline_parse(virp, p, &values);
+ read_next = barline_parse(virp, p, &values);
handle_viminfo_history(&values, writing);
break;
case BARTYPE_REGISTER:
- barline_parse(virp, p, &values);
+ read_next = barline_parse(virp, p, &values);
handle_viminfo_register(&values, force);
break;
case BARTYPE_MARK:
- barline_parse(virp, p, &values);
+ read_next = barline_parse(virp, p, &values);
handle_viminfo_mark(&values, force);
break;
@@ -2808,7 +2817,9 @@ read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
ga_clear(&values);
}
- return viminfo_readline(virp);
+ if (read_next)
+ return viminfo_readline(virp);
+ return FALSE;
}
static void
diff --git a/src/version.c b/src/version.c
index bda068bca8..e51402039a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1947,
+/**/
1946,
/**/
1945,