forked from aniani/vim
updated for version 7.3.124
Problem: When writing a file in binary mode it may be missing the final EOL if a file previously read was missing the EOL. (Kevin Goodsell) Solution: Move the write_no_eol_lnum into the buffer struct.
This commit is contained in:
23
src/fileio.c
23
src/fileio.c
@@ -317,7 +317,7 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
|
|||||||
int using_b_fname;
|
int using_b_fname;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_no_eol_lnum = 0; /* in case it was set by the previous read */
|
curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is no file name yet, use the one for the read file.
|
* If there is no file name yet, use the one for the read file.
|
||||||
@@ -2599,10 +2599,11 @@ failed:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Trick: We remember if the last line of the read didn't have
|
* Trick: We remember if the last line of the read didn't have
|
||||||
* an eol for when writing it again. This is required for
|
* an eol even when 'binary' is off, for when writing it again with
|
||||||
|
* 'binary' on. This is required for
|
||||||
* ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work.
|
* ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work.
|
||||||
*/
|
*/
|
||||||
write_no_eol_lnum = read_no_eol_lnum;
|
curbuf->b_no_eol_lnum = read_no_eol_lnum;
|
||||||
|
|
||||||
/* When reloading a buffer put the cursor at the first line that is
|
/* When reloading a buffer put the cursor at the first line that is
|
||||||
* different. */
|
* different. */
|
||||||
@@ -2650,13 +2651,17 @@ failed:
|
|||||||
FALSE, NULL, eap);
|
FALSE, NULL, eap);
|
||||||
if (msg_scrolled == n)
|
if (msg_scrolled == n)
|
||||||
msg_scroll = m;
|
msg_scroll = m;
|
||||||
#ifdef FEAT_EVAL
|
# ifdef FEAT_EVAL
|
||||||
if (aborting()) /* autocmds may abort script processing */
|
if (aborting()) /* autocmds may abort script processing */
|
||||||
return FAIL;
|
return FAIL;
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Reset now, following writes should not omit the EOL. Also, the line
|
||||||
|
* number will become invalid because of edits. */
|
||||||
|
curbuf->b_no_eol_lnum = 0;
|
||||||
|
|
||||||
if (recoverymode && error)
|
if (recoverymode && error)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
return OK;
|
return OK;
|
||||||
@@ -4560,7 +4565,7 @@ restore_backup:
|
|||||||
if (end == 0
|
if (end == 0
|
||||||
|| (lnum == end
|
|| (lnum == end
|
||||||
&& write_bin
|
&& write_bin
|
||||||
&& (lnum == write_no_eol_lnum
|
&& (lnum == buf->b_no_eol_lnum
|
||||||
|| (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol))))
|
|| (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol))))
|
||||||
{
|
{
|
||||||
++lnum; /* written the line, count it */
|
++lnum; /* written the line, count it */
|
||||||
@@ -5086,8 +5091,6 @@ nofail:
|
|||||||
{
|
{
|
||||||
aco_save_T aco;
|
aco_save_T aco;
|
||||||
|
|
||||||
write_no_eol_lnum = 0; /* in case it was set by the previous read */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apply POST autocommands.
|
* Apply POST autocommands.
|
||||||
* Careful: The autocommands may call buf_write() recursively!
|
* Careful: The autocommands may call buf_write() recursively!
|
||||||
@@ -7256,8 +7259,8 @@ buf_store_time(buf, st, fname)
|
|||||||
write_lnum_adjust(offset)
|
write_lnum_adjust(offset)
|
||||||
linenr_T offset;
|
linenr_T offset;
|
||||||
{
|
{
|
||||||
if (write_no_eol_lnum != 0) /* only if there is a missing eol */
|
if (curbuf->b_no_eol_lnum != 0) /* only if there is a missing eol */
|
||||||
write_no_eol_lnum += offset;
|
curbuf->b_no_eol_lnum += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TEMPDIRNAMES) || defined(PROTO)
|
#if defined(TEMPDIRNAMES) || defined(PROTO)
|
||||||
|
@@ -1057,10 +1057,6 @@ EXTERN pos_T last_cursormoved /* for CursorMoved event */
|
|||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN linenr_T write_no_eol_lnum INIT(= 0); /* non-zero lnum when last line
|
|
||||||
of next binary write should
|
|
||||||
not have an end-of-line */
|
|
||||||
|
|
||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */
|
EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */
|
||||||
EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */
|
EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */
|
||||||
|
@@ -4245,7 +4245,7 @@ mch_call_shell(cmd, options)
|
|||||||
* should not have one. */
|
* should not have one. */
|
||||||
if (lnum != curbuf->b_op_end.lnum
|
if (lnum != curbuf->b_op_end.lnum
|
||||||
|| !curbuf->b_p_bin
|
|| !curbuf->b_p_bin
|
||||||
|| (lnum != write_no_eol_lnum
|
|| (lnum != curbuf->b_no_eol_lnum
|
||||||
&& (lnum !=
|
&& (lnum !=
|
||||||
curbuf->b_ml.ml_line_count
|
curbuf->b_ml.ml_line_count
|
||||||
|| curbuf->b_p_eol)))
|
|| curbuf->b_p_eol)))
|
||||||
@@ -4588,10 +4588,10 @@ finished:
|
|||||||
{
|
{
|
||||||
append_ga_line(&ga);
|
append_ga_line(&ga);
|
||||||
/* remember that the NL was missing */
|
/* remember that the NL was missing */
|
||||||
write_no_eol_lnum = curwin->w_cursor.lnum;
|
curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
write_no_eol_lnum = 0;
|
curbuf->b_no_eol_lnum = 0;
|
||||||
ga_clear(&ga);
|
ga_clear(&ga);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1564,6 +1564,9 @@ struct file_buffer
|
|||||||
|
|
||||||
/* end of buffer options */
|
/* end of buffer options */
|
||||||
|
|
||||||
|
linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary
|
||||||
|
* write should not have an end-of-line */
|
||||||
|
|
||||||
int b_start_eol; /* last line had eol when it was read */
|
int b_start_eol; /* last line had eol when it was read */
|
||||||
int b_start_ffc; /* first char of 'ff' when edit started */
|
int b_start_ffc; /* first char of 'ff' when edit started */
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
|
@@ -714,6 +714,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 */
|
||||||
|
/**/
|
||||||
|
124,
|
||||||
/**/
|
/**/
|
||||||
123,
|
123,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user