vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 4c1dacde513a2c8ef9fbbb685fdfd2f7a34b6f40
parent 0c9cdc799afbe95e9c1994256713206aeadefb11
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 20 Nov 2015 15:21:49 +0100

text: get modification time after replacing file content in place

At the start of text_save_range we stat(2) the file to check whether
we have currently mmap(2)-ed it. Then we proceed to write the new
file content which changes modification time. Hence we have to
stat(2) again to retrieve it.

This should fix spurious warnings about file changes outside the
editor when editing e.g. symlinked files.

Diffstat:
Mtext.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/text.c b/text.c @@ -988,6 +988,8 @@ bool text_save_range(Text *txt, Filerange *range, const char *filename) { if (fsync(fd) == -1) goto err; + if (fstat(fd, &meta) == -1) + goto err; if (close(fd) == -1) return false; txt->info = meta;