Mercurial > vim
diff src/memfile.c @ 32503:5d07e7e9580f v9.0.1583
patch 9.0.1583: get E304 when using 'cryptmethod' "xchacha20v2"
Commit: https://github.com/vim/vim/commit/3a2a60ce4a8e73594bca16814672fcc243d093ac
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 27 18:02:55 2023 +0100
patch 9.0.1583: get E304 when using 'cryptmethod' "xchacha20v2"
Problem: Get E304 when using 'cryptmethod' "xchacha20v2". (Steve Mynott)
Solution: Add 4th crypt method to block zero ID check. Avoid syncing a swap
file before reading the file. (closes #12433)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 May 2023 19:15:04 +0200 |
parents | 9b0c304500cc |
children | bb5458706799 |
line wrap: on
line diff
--- a/src/memfile.c +++ b/src/memfile.c @@ -150,7 +150,7 @@ mf_open(char_u *fname, int flags) mfp->mf_free_first = NULL; // free list is empty mfp->mf_used_first = NULL; // used list is empty mfp->mf_used_last = NULL; - mfp->mf_dirty = FALSE; + mfp->mf_dirty = MF_DIRTY_NO; mfp->mf_used_count = 0; mf_hash_init(&mfp->mf_hash); mf_hash_init(&mfp->mf_trans); @@ -224,7 +224,7 @@ mf_open_file(memfile_T *mfp, char_u *fna if (mfp->mf_fd < 0) return FAIL; - mfp->mf_dirty = TRUE; + mfp->mf_dirty = MF_DIRTY_YES; return OK; } @@ -386,7 +386,7 @@ mf_new(memfile_T *mfp, int negative, int } } hp->bh_flags = BH_LOCKED | BH_DIRTY; // new block is always dirty - mfp->mf_dirty = TRUE; + mfp->mf_dirty = MF_DIRTY_YES; hp->bh_page_count = page_count; mf_ins_used(mfp, hp); mf_ins_hash(mfp, hp); @@ -483,7 +483,8 @@ mf_put( if (dirty) { flags |= BH_DIRTY; - mfp->mf_dirty = TRUE; + if (mfp->mf_dirty != MF_DIRTY_YES_NOSYNC) + mfp->mf_dirty = MF_DIRTY_YES; } hp->bh_flags = flags; if (infile) @@ -528,9 +529,10 @@ mf_sync(memfile_T *mfp, int flags) bhdr_T *hp; int got_int_save = got_int; - if (mfp->mf_fd < 0) // there is no file, nothing to do + if (mfp->mf_fd < 0) { - mfp->mf_dirty = FALSE; + // there is no file, nothing to do + mfp->mf_dirty = MF_DIRTY_NO; return FAIL; } @@ -576,7 +578,7 @@ mf_sync(memfile_T *mfp, int flags) * In case of an error this flag is also set, to avoid trying all the time. */ if (hp == NULL || status == FAIL) - mfp->mf_dirty = FALSE; + mfp->mf_dirty = MF_DIRTY_NO; if ((flags & MFS_FLUSH) && *p_sws != NUL) { @@ -675,7 +677,7 @@ mf_set_dirty(memfile_T *mfp) for (hp = mfp->mf_used_last; hp != NULL; hp = hp->bh_prev) if (hp->bh_bnum > 0) hp->bh_flags |= BH_DIRTY; - mfp->mf_dirty = TRUE; + mfp->mf_dirty = MF_DIRTY_YES; } /*