mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
vim-patch:8.1.0314: add swapinfo() "dirty" item
Problem: Build failure without the +eval feature. (Brenton Horne)
Solution: Add #ifdef. Also add the "dirty" item.
47ad5656e1
This commit is contained in:
@@ -7770,10 +7770,12 @@ swapinfo({fname}) swapinfo()
|
|||||||
file
|
file
|
||||||
mtime last modification time in seconds
|
mtime last modification time in seconds
|
||||||
inode Optional: INODE number of the file
|
inode Optional: INODE number of the file
|
||||||
|
dirty 1 if file was modified, 0 if not
|
||||||
In case of failure an "error" item is added with the reason:
|
In case of failure an "error" item is added with the reason:
|
||||||
Cannot open file: file not found or in accessible
|
Cannot open file: file not found or in accessible
|
||||||
Cannot read file: cannot read first block
|
Cannot read file: cannot read first block
|
||||||
magic number mismatch: info in first block is invalid
|
Not a swap file: does not contain correct block ID
|
||||||
|
Magic number mismatch: Info in first block is invalid
|
||||||
|
|
||||||
synID({lnum}, {col}, {trans}) *synID()*
|
synID({lnum}, {col}, {trans}) *synID()*
|
||||||
The result is a Number, which is the syntax ID at the position
|
The result is a Number, which is the syntax ID at the position
|
||||||
|
@@ -1466,8 +1466,10 @@ void get_b0_dict(const char *fname, dict_T *d)
|
|||||||
|
|
||||||
if ((fd = os_open(fname, O_RDONLY, 0)) >= 0) {
|
if ((fd = os_open(fname, O_RDONLY, 0)) >= 0) {
|
||||||
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
|
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
|
||||||
if (b0_magic_wrong(&b0)) {
|
if (ml_check_b0_id(&b0) == FAIL) {
|
||||||
tv_dict_add_str(d, S_LEN("error"), xstrdup("magic number mismatch"));
|
tv_dict_add_str(d, S_LEN("error"), xstrdup("Not a swap file"));
|
||||||
|
} else if (b0_magic_wrong(&b0)) {
|
||||||
|
tv_dict_add_str(d, S_LEN("error"), xstrdup("Magic number mismatch"));
|
||||||
} else {
|
} else {
|
||||||
// We have swap information.
|
// We have swap information.
|
||||||
tv_dict_add_str(d, S_LEN("version"), xstrdup((char *)b0.b0_version));
|
tv_dict_add_str(d, S_LEN("version"), xstrdup((char *)b0.b0_version));
|
||||||
@@ -1477,9 +1479,8 @@ void get_b0_dict(const char *fname, dict_T *d)
|
|||||||
|
|
||||||
tv_dict_add_nr(d, S_LEN("pid"), char_to_long(b0.b0_pid));
|
tv_dict_add_nr(d, S_LEN("pid"), char_to_long(b0.b0_pid));
|
||||||
tv_dict_add_nr(d, S_LEN("mtime"), char_to_long(b0.b0_mtime));
|
tv_dict_add_nr(d, S_LEN("mtime"), char_to_long(b0.b0_mtime));
|
||||||
#ifdef CHECK_INODE
|
tv_dict_add_nr(d, S_LEN("dirty"), b0.b0_dirty ? 1 : 0);
|
||||||
tv_dict_add_nr(d, S_LEN("inode"), char_to_long(b0.b0_ino));
|
tv_dict_add_nr(d, S_LEN("inode"), char_to_long(b0.b0_ino));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tv_dict_add_str(d, S_LEN("error"), xstrdup("Cannot read file"));
|
tv_dict_add_str(d, S_LEN("error"), xstrdup("Cannot read file"));
|
||||||
|
@@ -73,6 +73,7 @@ func Test_swapinfo()
|
|||||||
call assert_match('\w', info.user)
|
call assert_match('\w', info.user)
|
||||||
call assert_equal(hostname(), info.host)
|
call assert_equal(hostname(), info.host)
|
||||||
call assert_match('Xswapinfo', info.fname)
|
call assert_match('Xswapinfo', info.fname)
|
||||||
|
call assert_match(0, info.dirty)
|
||||||
call assert_equal(getpid(), info.pid)
|
call assert_equal(getpid(), info.pid)
|
||||||
call assert_match('^\d*$', info.mtime)
|
call assert_match('^\d*$', info.mtime)
|
||||||
if has_key(info, 'inode')
|
if has_key(info, 'inode')
|
||||||
@@ -92,6 +93,6 @@ func Test_swapinfo()
|
|||||||
|
|
||||||
call writefile([repeat('x', 10000)], 'Xnotaswapfile')
|
call writefile([repeat('x', 10000)], 'Xnotaswapfile')
|
||||||
let info = swapinfo('Xnotaswapfile')
|
let info = swapinfo('Xnotaswapfile')
|
||||||
call assert_equal('magic number mismatch', info.error)
|
call assert_equal('Not a swap file', info.error)
|
||||||
call delete('Xnotaswapfile')
|
call delete('Xnotaswapfile')
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user