From: Aron Griffis Date: Tue, 21 Apr 2009 19:10:28 +0000 (-0400) Subject: Equivalent mutt_buffy, but readable code X-Git-Tag: mutt-1-5-20-rel~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3845987d516c8abdfbd55ee29593cdb5a3db6859;p=mutt Equivalent mutt_buffy, but readable code Signed-off-by: Aron Griffis --- 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'; }