Hi there,

Here is a patch I received from Harald Dunkel; it ensured the backup
file has the same timestamp as the original file. This behaviour
comforms with emacs' behaviour. I think this patch is also useful for
upstream mg so I post it here.


Index: fileio.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/fileio.c,v
retrieving revision 1.99
diff -u -p -u -r1.99 fileio.c
--- fileio.c    19 Mar 2015 21:22:15 -0000      1.99
+++ fileio.c    15 Jan 2016 10:59:36 -0000
@@ -266,6 +266,13 @@ fbackupfile(const char *fn)
        }
        serrno = errno;
        (void) fchmod(to, (sb.st_mode & 0777));
+       /* copy the mtime to the backupfile */
+       {
+               struct timespec new_times[2];
+               new_times[0] = sb.st_atim;
+               new_times[1] = sb.st_mtim;
+               futimens(to, new_times);
+       }
        close(from);
        close(to);
        if (nread == -1) {



# Han

Reply via email to