aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-04-29 19:59:54 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-04-29 21:19:45 +0200
commit39e3783c697bad7ed16f5ce53910bb55f412626f (patch)
tree5b641dbc94d2fbf992976c28b32cfcff923a70e0 /src
parent24b7462b3cbf9a70f07f0a8e8da562a365cdc37a (diff)
downloadrneovim-39e3783c697bad7ed16f5ce53910bb55f412626f.tar.gz
rneovim-39e3783c697bad7ed16f5ce53910bb55f412626f.tar.bz2
rneovim-39e3783c697bad7ed16f5ce53910bb55f412626f.zip
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. https://github.com/vim/vim/commit/47ad5656e1e4285a74e7e8e5d0f1f71cd554e25c
Diffstat (limited to 'src')
-rw-r--r--src/nvim/memline.c9
-rw-r--r--src/nvim/testdir/test_swap.vim3
2 files changed, 7 insertions, 5 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 3e18c8559a..cbe4ce625a 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1466,8 +1466,10 @@ void get_b0_dict(const char *fname, dict_T *d)
if ((fd = os_open(fname, O_RDONLY, 0)) >= 0) {
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
- if (b0_magic_wrong(&b0)) {
- tv_dict_add_str(d, S_LEN("error"), xstrdup("magic number mismatch"));
+ if (ml_check_b0_id(&b0) == FAIL) {
+ 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 {
// We have swap information.
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("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));
-#endif
}
} else {
tv_dict_add_str(d, S_LEN("error"), xstrdup("Cannot read file"));
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim
index 28f995f6fb..241754aae0 100644
--- a/src/nvim/testdir/test_swap.vim
+++ b/src/nvim/testdir/test_swap.vim
@@ -73,6 +73,7 @@ func Test_swapinfo()
call assert_match('\w', info.user)
call assert_equal(hostname(), info.host)
call assert_match('Xswapinfo', info.fname)
+ call assert_match(0, info.dirty)
call assert_equal(getpid(), info.pid)
call assert_match('^\d*$', info.mtime)
if has_key(info, 'inode')
@@ -92,6 +93,6 @@ func Test_swapinfo()
call writefile([repeat('x', 10000)], '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')
endfunc