add mbox_commit_message function
authorDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Jun 2016 20:36:22 +0000 (13:36 -0700)
committerDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Jun 2016 20:36:22 +0000 (13:36 -0700)
Move mbox operations that were done in mx_commit_message to a dedicated
mbox_commit_message function.

mbox.c
mx.c
mx.h

diff --git a/mbox.c b/mbox.c
index e0b79a1ae5ee22c1fc02e71bcda9f17116473036..748249d6d9b0abe6af63075ac3d52259d3408ca9 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -461,6 +461,16 @@ static int mbox_close_message (CONTEXT *ctx, MESSAGE *msg)
   return 0;
 }
 
+int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg)
+{
+  int r = fputc ('\n', msg->fp);
+
+  if (r == EOF)
+    return -1;
+
+  return 0;
+}
+
 static int mbox_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr)
 {
   msg->fp = dest->fp;
diff --git a/mx.c b/mx.c
index 441e6a8456456487506ebe48fc6843868985ebf2..f712f5e53ac8c13e7a513acc5354e325e2602a5f 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1349,8 +1349,7 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
     
     case MUTT_MBOX:
     {
-      if (fputc ('\n', msg->fp) == EOF)
-       r = -1;
+      r = mbox_commit_message (ctx, msg);
       break;
     }
 
diff --git a/mx.h b/mx.h
index e335d2068059569a174933260706af8c80588a53..c5885f6e9426ac143646e4ce56c7ab97f09f9ed4 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -51,6 +51,7 @@ int mmdf_parse_mailbox (CONTEXT *);
 void mbox_unlock_mailbox (CONTEXT *);
 int mbox_check_empty (const char *);
 void mbox_reset_atime (CONTEXT *, struct stat *);
+int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg);
 
 int mh_sync_mailbox (CONTEXT *, int *);
 int mh_check_empty (const char *);