summaryrefslogtreecommitdiffstats
path: root/buffy.c
diff options
context:
space:
mode:
authorAron Griffis <agriffis@n01se.net>2009-04-21 15:10:28 -0400
committerAron Griffis <agriffis@n01se.net>2009-04-21 15:10:28 -0400
commit3845987d516c8abdfbd55ee29593cdb5a3db6859 (patch)
tree6fec4e0dcdba7c7a2e67af3f9a45bd643a470dcf /buffy.c
parentaec838aa40000b20dc1f84dd19381e76da81f639 (diff)
Equivalent mutt_buffy, but readable code
Signed-off-by: Aron Griffis <agriffis@n01se.net>
Diffstat (limited to 'buffy.c')
-rw-r--r--buffy.c65
1 files changed, 19 insertions, 46 deletions
diff --git a/buffy.c b/buffy.c
index 0e100e8d..0c851b5f 100644
--- a/buffy.c
+++ b/buffy.c
@@ -508,57 +508,30 @@ int mutt_buffy_notify (void)
*/
void mutt_buffy (char *s, size_t slen)
{
- int count;
BUFFY *tmp = Incoming;
+ int pass, found = 0;
mutt_expand_path (s, slen);
- switch (mutt_buffy_check (0))
- {
- case 0:
-
- *s = '\0';
- break;
-
- case 1:
-
- while (tmp && !tmp->new)
- tmp = tmp->next;
- if (!tmp)
- {
- *s = '\0';
- mutt_buffy_check (1); /* buffy was wrong - resync things */
- break;
- }
- mutt_expand_path (tmp->path, sizeof (tmp->path));
- strfcpy (s, tmp->path, slen);
- mutt_pretty_mailbox (s, slen);
- break;
- default:
-
- count = 0;
- while (count < 3)
- {
- mutt_expand_path (tmp->path, sizeof (tmp->path));
- if (mutt_strcmp (s, tmp->path) == 0)
- count++;
- else if (count && tmp->new)
- break;
- tmp = tmp->next;
- if (!tmp)
+ if (mutt_buffy_check (0))
+ {
+ for (pass = 0; pass < 2; pass++)
+ for (tmp = Incoming; tmp; tmp = tmp->next)
{
- tmp = Incoming;
- count++;
+ mutt_expand_path (tmp->path, sizeof (tmp->path));
+ if ((found || pass) && tmp->new)
+ {
+ strfcpy (s, tmp->path, slen);
+ mutt_pretty_mailbox (s, slen);
+ return;
+ }
+ if (mutt_strcmp (s, tmp->path) == 0)
+ found = 1;
}
- }
- if (count >= 3)
- {
- *s = '\0';
- mutt_buffy_check (1); /* buffy was wrong - resync things */
- break;
- }
- strfcpy (s, tmp->path, slen);
- mutt_pretty_mailbox (s, slen);
- break;
+
+ mutt_buffy_check (1); /* buffy was wrong - resync things */
}
+
+ /* no folders with new mail */
+ *s = '\0';
}