From abd31aad6124471185143ae56b9f5546977258ac Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 19 Jun 2022 12:36:47 +0200 Subject: [PATCH] simplify assembly of IMAP APPEND commands treat the date string the same as the flag string. amends eb1f1076. --- src/drv_imap.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 1446f7a..8bae526 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -3233,6 +3233,14 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int to_trash, flagstr[d++] = ' '; } flagstr[d] = 0; + if (data->date) { +DIAG_PUSH +DIAG_DISABLE("-Wformat") // configure ensures that %z actually works. + strftime( datestr, sizeof(datestr), "\"%d-%b-%Y %H:%M:%S %z\" ", localtime( &data->date ) ); +DIAG_POP + } else { + datestr[0] = 0; + } INIT_IMAP_CMD(imap_cmd_out_uid_t, cmd, cb, aux) ctx->buffer_mem += data->len; @@ -3255,18 +3263,8 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int to_trash, return; } } - if (data->date) { - /* configure ensures that %z actually works. */ -DIAG_PUSH -DIAG_DISABLE("-Wformat") - strftime( datestr, sizeof(datestr), "%d-%b-%Y %H:%M:%S %z", localtime( &data->date ) ); -DIAG_POP - imap_exec( ctx, &cmd->gen, imap_store_msg_p2, - "APPEND \"%\\s\" %s\"%\\s\" ", buf, flagstr, datestr ); - } else { - imap_exec( ctx, &cmd->gen, imap_store_msg_p2, - "APPEND \"%\\s\" %s", buf, flagstr ); - } + imap_exec( ctx, &cmd->gen, imap_store_msg_p2, + "APPEND \"%\\s\" %s%s", buf, flagstr, datestr ); free( buf ); }