}
#endif
-#ifdef HAVE_DIRENT_D_INO
+#if HAVE_DIRENT_D_INO
static int md_cmp_inode (struct maildir *a, struct maildir *b)
{
return a->inode - b->inode;
*md = maildir_sort (*md, (size_t) -1, md_cmp_path);
}
+#if HAVE_DIRENT_D_INO
static struct maildir *skip_duplicates (struct maildir *p, struct maildir **last)
{
/*
}
return p;
}
+#endif
/*
* This function does the second parsing pass
#if HAVE_DIRENT_D_INO
int sort = 0;
#endif
-
#if USE_HCACHE
header_cache_t *hc = NULL;
void *data;
struct timeval *when = NULL;
struct stat lastchanged;
int ret;
+#endif
+
+#if HAVE_DIRENT_D_INO
+#define DO_SORT() do { \
+ if (!sort) \
+ { \
+ dprint (4, (debugfile, "maildir: need to sort %s by inode\n", ctx->path)); \
+ p = maildir_sort (p, (size_t) -1, md_cmp_inode); \
+ if (!last) \
+ *md = p; \
+ else \
+ last->next = p; \
+ sort = 1; \
+ p = skip_duplicates (p, &last); \
+ snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); \
+ } \
+} while(0)
+#else
+#define DO_SORT() /* nothing */
+#endif
+#if USE_HCACHE
hc = mutt_hcache_open (HeaderCache, ctx->path, NULL);
#endif
#if USE_HCACHE
if (option(OPTHCACHEVERIFY))
- {
-#if HAVE_DIRENT_D_INO
- if (!sort)
- {
- dprint (4, (debugfile, "maildir: need to sort %s by inode\n", ctx->path));
- p = maildir_sort (p, (size_t) -1, md_cmp_inode);
- if (!last)
- *md = p;
- else
- last->next = p;
- sort = 1;
-
- p = skip_duplicates(p, &last);
-
- snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path);
- }
-#endif
+ {
+ DO_SORT();
ret = stat(fn, &lastchanged);
}
- else {
+ else
+ {
lastchanged.st_mtime = 0;
ret = 0;
}
-#if USE_HCACHE
if (ctx->magic == M_MH)
data = mutt_hcache_fetch (hc, p->h->path, strlen);
else
data = mutt_hcache_fetch (hc, p->h->path + 3, &maildir_hcache_keylen);
when = (struct timeval *) data;
-#endif
if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec)
{
p->h = mutt_hcache_restore ((unsigned char *)data, &p->h);
if (ctx->magic == M_MAILDIR)
maildir_parse_flags (p->h, fn);
- } else
- {
-#endif
-#if HAVE_DIRENT_D_INO
- if (!sort)
+ }
+ else
{
- dprint (4, (debugfile, "maildir: need to sort %s by inode\n", ctx->path));
- p = maildir_sort (p, (size_t) -1, md_cmp_inode);
- if (!last)
- *md = p;
- else
- last->next = p;
- sort = 1;
-
- p = skip_duplicates(p, &last);
+#endif /* USE_HCACHE */
- snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path);
- }
-#endif
+ DO_SORT();
if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h))
{
p->header_parsed = 1;
mutt_hcache_close (hc);
#endif
+#undef DO_SORT
+
mh_sort_natural (ctx, md);
}