- count = 0;
- while (count < 3) {
- if (mutt_strcmp (s, tmp->path) == 0)
- count++;
- else if (count && tmp->new > 0)
- break;
- tmp = tmp->next;
- if (!tmp) {
- tmp = Incoming;
- count++;
- }
- }
- if (count >= 3) {
- *s = '\0';
- mutt_buffy_check (1); /* buffy was wrong - resync things */
+ /*
+ * If buffy_lookup returns the index,
+ * or -1 if not found (-1..Incoming->length-1);
+ * plus one --> (0..Incoming->length).
+ * Modulo mapps it into the correct range.
+ */
+ i = 1 + buffy_lookup (s);
+ for (l=0; l < Incoming->length; l++) {
+ c = (l+i) % Incoming->length;
+ if ((!Context || !Context->path || !str_eq (((BUFFY*) Incoming->data[c])->path, Context->path)) &&
+ ((BUFFY*) Incoming->data[c])->new > 0)