Skip to content

Commit 47ad565

Browse files
committed
patch 8.1.0314: build failure without the +eval feature
Problem: Build failure without the +eval feature. (Brenton Horne) Solution: Add #ifdef. Also add the "dirty" item.
1 parent 00f123a commit 47ad565

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

runtime/doc/eval.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8013,10 +8013,12 @@ swapinfo({fname}) swapinfo()
80138013
file
80148014
mtime last modification time in seconds
80158015
inode Optional: INODE number of the file
8016+
dirty 1 if file was modified, 0 if not
80168017
In case of failure an "error" item is added with the reason:
80178018
Cannot open file: file not found or in accessible
80188019
Cannot read file: cannot read first block
8019-
magic number mismatch: info in first block is invalid
8020+
Not a swap file: does not contain correct block ID
8021+
Magic number mismatch: Info in first block is invalid
80208022

80218023
synID({lnum}, {col}, {trans}) *synID()*
80228024
The result is a Number, which is the syntax ID at the position

src/memline.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,7 @@ make_percent_swname(char_u *dir, char_u *name)
20412041
static int process_still_running;
20422042
#endif
20432043

2044+
#if defined(FEAT_EVAL) || defined(PROTO)
20442045
/*
20452046
* Return information found in swapfile "fname" in dictionary "d".
20462047
* This is used by the swapinfo() function.
@@ -2055,11 +2056,12 @@ get_b0_dict(char_u *fname, dict_T *d)
20552056
{
20562057
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0))
20572058
{
2058-
if (b0_magic_wrong(&b0))
2059-
{
2059+
if (ml_check_b0_id(&b0) == FAIL)
20602060
dict_add_string(d, "error",
2061-
vim_strsave((char_u *)"magic number mismatch"));
2062-
}
2061+
vim_strsave((char_u *)"Not a swap file"));
2062+
else if (b0_magic_wrong(&b0))
2063+
dict_add_string(d, "error",
2064+
vim_strsave((char_u *)"Magic number mismatch"));
20632065
else
20642066
{
20652067
/* we have swap information */
@@ -2070,9 +2072,10 @@ get_b0_dict(char_u *fname, dict_T *d)
20702072

20712073
dict_add_number(d, "pid", char_to_long(b0.b0_pid));
20722074
dict_add_number(d, "mtime", char_to_long(b0.b0_mtime));
2073-
#ifdef CHECK_INODE
2075+
dict_add_number(d, "dirty", b0.b0_dirty ? 1 : 0);
2076+
# ifdef CHECK_INODE
20742077
dict_add_number(d, "inode", char_to_long(b0.b0_ino));
2075-
#endif
2078+
# endif
20762079
}
20772080
}
20782081
else
@@ -2083,6 +2086,7 @@ get_b0_dict(char_u *fname, dict_T *d)
20832086
else
20842087
dict_add_string(d, "error", vim_strsave((char_u *)"Cannot open file"));
20852088
}
2089+
#endif
20862090

20872091
/*
20882092
* Give information about an existing swap file.

src/testdir/test_swap.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func Test_swapinfo()
109109
call assert_match('\w', info.user)
110110
call assert_equal(hostname(), info.host)
111111
call assert_match('Xswapinfo', info.fname)
112+
call assert_match(0, info.dirty)
112113
call assert_equal(getpid(), info.pid)
113114
call assert_match('^\d*$', info.mtime)
114115
if has_key(info, 'inode')
@@ -128,6 +129,6 @@ func Test_swapinfo()
128129

129130
call writefile([repeat('x', 10000)], 'Xnotaswapfile')
130131
let info = swapinfo('Xnotaswapfile')
131-
call assert_equal('magic number mismatch', info.error)
132+
call assert_equal('Not a swap file', info.error)
132133
call delete('Xnotaswapfile')
133134
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static char *(features[]) =
794794

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
314,
797799
/**/
798800
313,
799801
/**/

0 commit comments

Comments
 (0)