summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrendan Cully <brendan@kublai.com>2005-12-30 17:32:26 +0000
committerBrendan Cully <brendan@kublai.com>2005-12-30 17:32:26 +0000
commit7aee04c0ee5ba4073db3d4a93b249b6269e7bf17 (patch)
treeecf642aff759c74e7d7324f7c6792bb44c2b6af6
parent633c135ae64b34d48fb2dd1eb7b7951ebc7b6e5b (diff)
Only resort headers in imap_make_msg_set if order != SORT_ORDER.
Fix sync_helper to return 1 in case of +FLAGS but not -FLAGS.
-rw-r--r--imap/imap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/imap/imap.c b/imap/imap.c
index b2738e05..a8ee781d 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -857,18 +857,19 @@ int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed,
short oldsort; /* we clobber reverse, must restore it */
int started = 0;
- /* make copy of header pointers to sort in natural order */
- hdrs = safe_calloc (idata->ctx->msgcount, sizeof (HEADER*));
- memcpy (hdrs, idata->ctx->hdrs, idata->ctx->msgcount * sizeof (HEADER*));
-
if (Sort != SORT_ORDER)
{
+ hdrs = safe_calloc (idata->ctx->msgcount, sizeof (HEADER*));
+ memcpy (hdrs, idata->ctx->hdrs, idata->ctx->msgcount * sizeof (HEADER*));
+
oldsort = Sort;
Sort = SORT_ORDER;
qsort ((void*) hdrs, idata->ctx->msgcount, sizeof (HEADER*),
mutt_get_sort_func (SORT_ORDER));
Sort = oldsort;
}
+ else
+ hdrs = idata->ctx->hdrs;
for (n = 0; n < idata->ctx->msgcount; n++)
{
@@ -931,7 +932,8 @@ int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed,
}
}
- FREE (&hdrs);
+ if (Sort != SORT_ORDER)
+ FREE (&hdrs);
return count;
}
@@ -1037,7 +1039,7 @@ int imap_sync_message (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd,
static int sync_helper (IMAP_DATA* idata, BUFFER* buf, int right, int flag,
const char* name)
{
- int rc;
+ int rc = 0;
if (!mutt_bit_isset (idata->rights, right))
return 0;
@@ -1047,7 +1049,7 @@ static int sync_helper (IMAP_DATA* idata, BUFFER* buf, int right, int flag,
buf->dptr = buf->data;
mutt_buffer_addstr (buf, "UID STORE ");
- if ((rc = imap_make_msg_set (idata, buf, flag, 1, 0)))
+ if (imap_make_msg_set (idata, buf, flag, 1, 0))
{
rc++;
mutt_buffer_printf (buf, " +FLAGS.SILENT (%s)", name);
@@ -1055,7 +1057,7 @@ static int sync_helper (IMAP_DATA* idata, BUFFER* buf, int right, int flag,
}
buf->dptr = buf->data;
mutt_buffer_addstr (buf, "UID STORE ");
- if ((rc = imap_make_msg_set (idata, buf, flag, 1, 1)))
+ if (imap_make_msg_set (idata, buf, flag, 1, 1))
{
rc++;
mutt_buffer_printf (buf, " -FLAGS.SILENT (%s)", name);