dovecot: Nowadays the SORT draft specifies that if Date: header ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 16 17:03:17 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/a53bc41fade4
changeset: 6546:a53bc41fade4
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 16 17:03:13 2007 +0300
description:
Nowadays the SORT draft specifies that if Date: header is missing or broken,
SORT should fallback to using INTERNALDATE.
diffstat:
1 file changed, 18 insertions(+), 7 deletions(-)
src/lib-storage/index/index-sort.c | 25 ++++++++++++++++++-------
diffs (52 lines):
diff -r 699c4c193ffc -r a53bc41fade4 src/lib-storage/index/index-sort.c
--- a/src/lib-storage/index/index-sort.c Tue Oct 16 17:02:50 2007 +0300
+++ b/src/lib-storage/index/index-sort.c Tue Oct 16 17:03:13 2007 +0300
@@ -196,6 +196,19 @@ sort_header_get(enum mail_sort_type sort
buf = t_str_new(128);
(void)uni_utf8_to_decomposed_titlecase(str, (size_t)-1, buf);
return str_c(buf);
+}
+
+static time_t sort_get_date(struct mail *mail)
+{
+ time_t t;
+
+ if (mail_get_date(mail, &t, NULL) < 0)
+ return 0;
+ if (t == 0) {
+ if (mail_get_received_date(mail, &t) < 0)
+ return 0;
+ }
+ return t;
}
static int sort_node_cmp_type(struct sort_cmp_context *ctx,
@@ -245,13 +258,11 @@ static int sort_node_cmp_type(struct sor
time1 = ctx->cache_time;
else {
mail_set_seq(ctx->mail, n1->seq);
- if (mail_get_date(ctx->mail, &time1, NULL) < 0)
- time1 = 0;
+ time1 = sort_get_date(ctx->mail);
}
mail_set_seq(ctx->mail, n2->seq);
- if (mail_get_date(ctx->mail, &time2, NULL) < 0)
- time2 = 0;
+ time2 = sort_get_date(ctx->mail);
ret = time1 < time2 ? -1 :
(time1 > time2 ? 1 : 0);
@@ -477,9 +488,9 @@ static uint32_t get_sort_id_date(struct
{
time_t time;
- if (mail_get_date(mail, &time, NULL) < 0)
- return 0;
- return time;
+ time = sort_get_date(mail);
+ /* FIXME: truncation is bad.. */
+ return time < 0 ? 0 : (time > (uint32_t)-1 ? (uint32_t)-1 : time);
}
static uint32_t get_sort_id_size(struct mail *mail)
More information about the dovecot-cvs
mailing list