summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--headers.c3
-rw-r--r--muttlib.c29
-rw-r--r--protos.h1
-rw-r--r--send.c18
4 files changed, 34 insertions, 17 deletions
diff --git a/headers.c b/headers.c
index 1900c836..c3d23e57 100644
--- a/headers.c
+++ b/headers.c
@@ -70,7 +70,8 @@ void mutt_edit_headers (const char *editor,
return;
}
- mtime = st.st_mtime;
+ mtime = mutt_decrease_mtime (path, &st);
+
mutt_edit_file (editor, path);
stat (path, &st);
if (mtime == st.st_mtime)
diff --git a/muttlib.c b/muttlib.c
index 7f06f71a..a77c6c12 100644
--- a/muttlib.c
+++ b/muttlib.c
@@ -40,6 +40,9 @@
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <time.h>
+#include <sys/types.h>
+#include <utime.h>
BODY *mutt_new_body (void)
{
@@ -1255,3 +1258,29 @@ void mutt_buffer_add (BUFFER* buf, const char* s, size_t len)
buf->dptr += len;
*(buf->dptr) = '\0';
}
+
+/* Decrease a file's modification time by 1 second */
+
+time_t mutt_decrease_mtime (const char *f, struct stat *st)
+{
+ struct utimbuf utim;
+ struct stat _st;
+ time_t mtime;
+
+ if (!st)
+ {
+ if (stat (f, &_st) == -1)
+ return -1;
+ st = &_st;
+ }
+
+ if ((mtime = st->st_mtime) == time (NULL))
+ {
+ mtime -= 1;
+ utim.actime = mtime;
+ utim.modtime = mtime;
+ utime (f, &utim);
+ }
+
+ return mtime;
+}
diff --git a/protos.h b/protos.h
index 33eb4815..273594fc 100644
--- a/protos.h
+++ b/protos.h
@@ -106,6 +106,7 @@ HEADER *mutt_dup_header (HEADER *);
ATTACHPTR **mutt_gen_attach_list (BODY *, int, ATTACHPTR **, short *, short *, int, int);
+time_t mutt_decrease_mtime (const char *, struct stat *);
time_t mutt_local_tz (time_t);
time_t mutt_mktime (struct tm *, int);
time_t mutt_parse_date (const char *, HEADER *);
diff --git a/send.c b/send.c
index c9823b11..9a96ef2d 100644
--- a/send.c
+++ b/send.c
@@ -1276,22 +1276,8 @@ ci_send_message (int flags, /* send mode */
else if (! (flags & SENDBATCH))
{
struct stat st;
- time_t mtime;
- struct utimbuf utim;
-
- stat (msg->content->filename, &st);
- mtime = st.st_mtime;
- if (mtime == time (NULL))
- {
- /* Decrease the file's modification time by 1 second so we are sure
- * to find out if the `editor' program changes it in less than 1 second.
- */
- mtime -= 1;
- utim.actime = mtime;
- utim.modtime = mtime;
- utime (msg->content->filename, &utim);
- }
-
+ time_t mtime = mutt_decrease_mtime (msg->content->filename, NULL);
+
mutt_update_encoding (msg->content);
/* If the this isn't a text message, look for a mailcap edit command */