mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make maildir_delayed_parsing() more readable

+34 -39
+34 -39
mh.c
··· 804 804 } 805 805 #endif 806 806 807 - #ifdef HAVE_DIRENT_D_INO 807 + #if HAVE_DIRENT_D_INO 808 808 static int md_cmp_inode (struct maildir *a, struct maildir *b) 809 809 { 810 810 return a->inode - b->inode; ··· 954 954 *md = maildir_sort (*md, (size_t) -1, md_cmp_path); 955 955 } 956 956 957 + #if HAVE_DIRENT_D_INO 957 958 static struct maildir *skip_duplicates (struct maildir *p, struct maildir **last) 958 959 { 959 960 /* ··· 972 973 } 973 974 return p; 974 975 } 976 + #endif 975 977 976 978 /* 977 979 * This function does the second parsing pass ··· 985 987 #if HAVE_DIRENT_D_INO 986 988 int sort = 0; 987 989 #endif 988 - 989 990 #if USE_HCACHE 990 991 header_cache_t *hc = NULL; 991 992 void *data; 992 993 struct timeval *when = NULL; 993 994 struct stat lastchanged; 994 995 int ret; 996 + #endif 995 997 998 + #if HAVE_DIRENT_D_INO 999 + #define DO_SORT() do { \ 1000 + if (!sort) \ 1001 + { \ 1002 + dprint (4, (debugfile, "maildir: need to sort %s by inode\n", ctx->path)); \ 1003 + p = maildir_sort (p, (size_t) -1, md_cmp_inode); \ 1004 + if (!last) \ 1005 + *md = p; \ 1006 + else \ 1007 + last->next = p; \ 1008 + sort = 1; \ 1009 + p = skip_duplicates (p, &last); \ 1010 + snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); \ 1011 + } \ 1012 + } while(0) 1013 + #else 1014 + #define DO_SORT() /* nothing */ 1015 + #endif 1016 + 1017 + #if USE_HCACHE 996 1018 hc = mutt_hcache_open (HeaderCache, ctx->path, NULL); 997 1019 #endif 998 1020 ··· 1011 1033 1012 1034 #if USE_HCACHE 1013 1035 if (option(OPTHCACHEVERIFY)) 1014 - { 1015 - #if HAVE_DIRENT_D_INO 1016 - if (!sort) 1017 - { 1018 - dprint (4, (debugfile, "maildir: need to sort %s by inode\n", ctx->path)); 1019 - p = maildir_sort (p, (size_t) -1, md_cmp_inode); 1020 - if (!last) 1021 - *md = p; 1022 - else 1023 - last->next = p; 1024 - sort = 1; 1025 - 1026 - p = skip_duplicates(p, &last); 1027 - 1028 - snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); 1029 - } 1030 - #endif 1036 + { 1037 + DO_SORT(); 1031 1038 ret = stat(fn, &lastchanged); 1032 1039 } 1033 - else { 1040 + else 1041 + { 1034 1042 lastchanged.st_mtime = 0; 1035 1043 ret = 0; 1036 1044 } 1037 1045 1038 - #if USE_HCACHE 1039 1046 if (ctx->magic == M_MH) 1040 1047 data = mutt_hcache_fetch (hc, p->h->path, strlen); 1041 1048 else 1042 1049 data = mutt_hcache_fetch (hc, p->h->path + 3, &maildir_hcache_keylen); 1043 1050 when = (struct timeval *) data; 1044 - #endif 1045 1051 1046 1052 if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec) 1047 1053 { 1048 1054 p->h = mutt_hcache_restore ((unsigned char *)data, &p->h); 1049 1055 if (ctx->magic == M_MAILDIR) 1050 1056 maildir_parse_flags (p->h, fn); 1051 - } else 1057 + } 1058 + else 1052 1059 { 1053 - #endif 1054 - #if HAVE_DIRENT_D_INO 1055 - if (!sort) 1056 - { 1057 - dprint (4, (debugfile, "maildir: need to sort %s by inode\n", ctx->path)); 1058 - p = maildir_sort (p, (size_t) -1, md_cmp_inode); 1059 - if (!last) 1060 - *md = p; 1061 - else 1062 - last->next = p; 1063 - sort = 1; 1060 + #endif /* USE_HCACHE */ 1064 1061 1065 - p = skip_duplicates(p, &last); 1066 - 1067 - snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); 1068 - } 1069 - #endif 1062 + DO_SORT(); 1070 1063 if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) 1071 1064 { 1072 1065 p->header_parsed = 1; ··· 1087 1080 #if USE_HCACHE 1088 1081 mutt_hcache_close (hc); 1089 1082 #endif 1083 + 1084 + #undef DO_SORT 1090 1085 1091 1086 mh_sort_natural (ctx, md); 1092 1087 }