Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
updated for version 7.3.103
Problem:    Changing 'fileformat' and then using ":w" in an empty file sets
	    the 'modified' option.
Solution:   In unchanged() don't ignore 'ff' for an empty file.
  • Loading branch information
brammool committed Jan 21, 2011
1 parent b8e6593 commit 9285b88
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .hgignore
Expand Up @@ -42,3 +42,11 @@ gvimext.lib
*.mo *.mo
*.swp *.swp
*~ *~

# Generated by "make test"
src/po/*.ck
src/testdir/mbyte.vim
src/testdir/mzscheme.vim
src/testdir/small.vim
src/testdir/tiny.vim
src/testdir/test*.out
2 changes: 1 addition & 1 deletion src/misc1.c
Expand Up @@ -2919,7 +2919,7 @@ unchanged(buf, ff)
buf_T *buf; buf_T *buf;
int ff; /* also reset 'fileformat' */ int ff; /* also reset 'fileformat' */
{ {
if (buf->b_changed || (ff && file_ff_differs(buf))) if (buf->b_changed || (ff && file_ff_differs(buf, FALSE)))
{ {
buf->b_changed = 0; buf->b_changed = 0;
ml_setflags(buf); ml_setflags(buf);
Expand Down
9 changes: 6 additions & 3 deletions src/option.c
Expand Up @@ -11296,16 +11296,19 @@ save_file_ff(buf)
* from when editing started (save_file_ff() called). * from when editing started (save_file_ff() called).
* Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
* changed and 'binary' is not set. * changed and 'binary' is not set.
* Don't consider a new, empty buffer to be changed. * When "ignore_empty" is true don't consider a new, empty buffer to be
* changed.
*/ */
int int
file_ff_differs(buf) file_ff_differs(buf, ignore_empty)
buf_T *buf; buf_T *buf;
int ignore_empty;
{ {
/* In a buffer that was never loaded the options are not valid. */ /* In a buffer that was never loaded the options are not valid. */
if (buf->b_flags & BF_NEVERLOADED) if (buf->b_flags & BF_NEVERLOADED)
return FALSE; return FALSE;
if ((buf->b_flags & BF_NEW) if (ignore_empty
&& (buf->b_flags & BF_NEW)
&& buf->b_ml.ml_line_count == 1 && buf->b_ml.ml_line_count == 1
&& *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
return FALSE; return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/proto/option.pro
Expand Up @@ -54,6 +54,6 @@ void change_compatible __ARGS((int on));
int option_was_set __ARGS((char_u *name)); int option_was_set __ARGS((char_u *name));
int can_bs __ARGS((int what)); int can_bs __ARGS((int what));
void save_file_ff __ARGS((buf_T *buf)); void save_file_ff __ARGS((buf_T *buf));
int file_ff_differs __ARGS((buf_T *buf)); int file_ff_differs __ARGS((buf_T *buf, int ignore_empty));
int check_ff_value __ARGS((char_u *p)); int check_ff_value __ARGS((char_u *p));
/* vim: set ft=c : */ /* vim: set ft=c : */
4 changes: 2 additions & 2 deletions src/undo.c
Expand Up @@ -3304,7 +3304,7 @@ bufIsChanged(buf)
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
!bt_dontwrite(buf) && !bt_dontwrite(buf) &&
#endif #endif
(buf->b_changed || file_ff_differs(buf)); (buf->b_changed || file_ff_differs(buf, TRUE));
} }


int int
Expand All @@ -3314,7 +3314,7 @@ curbufIsChanged()
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
!bt_dontwrite(curbuf) && !bt_dontwrite(curbuf) &&
#endif #endif
(curbuf->b_changed || file_ff_differs(curbuf)); (curbuf->b_changed || file_ff_differs(curbuf, TRUE));
} }


#if defined(FEAT_EVAL) || defined(PROTO) #if defined(FEAT_EVAL) || defined(PROTO)
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -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 */
/**/
103,
/**/ /**/
102, 102,
/**/ /**/
Expand Down

0 comments on commit 9285b88

Please sign in to comment.