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.
Files: src/ex_cmds.c
*** ../vim-7.4.1946/src/ex_cmds.c 2016-06-13 21:15:59.575470541 +0200
--- src/ex_cmds.c 2016-06-20 12:43:40.123948883 +0200
***************
*** 2559,2566 ****
/*
* Parse a viminfo line starting with '|'.
* Add each decoded value to "values".
*/
! static void
barline_parse(vir_T *virp, char_u *text, garray_T *values)
{
char_u *p = text;
--- 2559,2567 ----
/*
* 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 int
barline_parse(vir_T *virp, char_u *text, garray_T *values)
{
char_u *p = text;
***************
*** 2569,2574 ****
--- 2570,2576 ----
bval_T *value;
int i;
int allocated = FALSE;
+ int eof;
#ifdef FEAT_MBYTE
char_u *sconv;
int converted;
***************
*** 2611,2631 ****
* |{bartype},>{length of "{text}{text2}"}
* |<"{text1}
* |<{text2}",{value}
*/
++p;
len = getdigits(&p);
buf = alloc((int)(len + 1));
if (buf == NULL)
! return;
p = buf;
for (todo = len; todo > 0; todo -= n)
{
! if (viminfo_readline(virp) || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
{
! /* file was truncated or garbled */
vim_free(buf);
! return;
}
/* Get length of text, excluding |< and NL chars. */
n = STRLEN(virp->vir_line);
--- 2613,2636 ----
* |{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 TRUE;
p = buf;
for (todo = len; todo > 0; todo -= n)
{
! eof = viminfo_readline(virp);
! if (eof || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
{
! /* File was truncated or garbled. Read another line if
! * this one starts with '|'. */
vim_free(buf);
! return eof || virp->vir_line[0] == '|';
}
/* Get length of text, excluding |< and NL chars. */
n = STRLEN(virp->vir_line);
***************
*** 2651,2660 ****
* |{bartype},{lots of values},>
* |<{value},{value}
*/
! if (viminfo_readline(virp) || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
! /* file was truncated or garbled */
! return;
p = virp->vir_line + 2;
}
}
--- 2656,2667 ----
* |{bartype},{lots of values},>
* |<{value},{value}
*/
! eof = viminfo_readline(virp);
! if (eof || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
! /* 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,2681 ****
while (*p != '"')
{
if (*p == NL || *p == NUL)
! return; /* syntax error, drop the value */
if (*p == '\\')
{
++p;
--- 2682,2688 ----
while (*p != '"')
{
if (*p == NL || *p == NUL)
! return TRUE; /* syntax error, drop the value */
if (*p == '\\')
{
++p;
***************
*** 2734,2739 ****
--- 2741,2747 ----
else
break;
}
+ return TRUE;
}
static int
***************
*** 2744,2749 ****
--- 2752,2758 ----
garray_T values;
bval_T *vp;
int i;
+ int read_next = TRUE;
/* The format is: |{bartype},{value},...
* For a very long string:
***************
*** 2772,2778 ****
* doesn't understand the version. */
if (!got_encoding)
{
! 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;
--- 2781,2787 ----
* doesn't understand the version. */
if (!got_encoding)
{
! 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,2796 ****
break;
case BARTYPE_HISTORY:
! barline_parse(virp, p, &values);
handle_viminfo_history(&values, writing);
break;
case BARTYPE_REGISTER:
! barline_parse(virp, p, &values);
handle_viminfo_register(&values, force);
break;
case BARTYPE_MARK:
! barline_parse(virp, p, &values);
handle_viminfo_mark(&values, force);
break;
--- 2789,2805 ----
break;
case BARTYPE_HISTORY:
! read_next = barline_parse(virp, p, &values);
handle_viminfo_history(&values, writing);
break;
case BARTYPE_REGISTER:
! read_next = barline_parse(virp, p, &values);
handle_viminfo_register(&values, force);
break;
case BARTYPE_MARK:
! read_next = barline_parse(virp, p, &values);
handle_viminfo_mark(&values, force);
break;
***************
*** 2808,2814 ****
ga_clear(&values);
}
! return viminfo_readline(virp);
}
static void
--- 2817,2825 ----
ga_clear(&values);
}
! if (read_next)
! return viminfo_readline(virp);
! return FALSE;
}
static void
*** ../vim-7.4.1946/src/version.c 2016-06-20 11:28:11.788296416 +0200
--- src/version.c 2016-06-20 12:23:50.676650556 +0200
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 1947,
/**/
--
hundred-and-one symptoms of being an internet addict:
116. You are living with your boyfriend who networks your respective
computers so you can sit in separate rooms and email each other
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.