-+ if (*de->d_name != '.' &&
-+ (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
-+ {
-+ tmp->msgcount++;
-+ if (p && strchr(p + 3, 'F')) {
-+ tmp->msg_flagged++;
-+ }
- }
- snprintf (path, sizeof (path), "%s/new/%s", tmp->path, de->d_name);
- if (!stat (path, &smd) && smd.st_mtime > tmp->mtime)
-@@ -403,8 +450,25 @@ int mutt_buffy_check (int force)
++ if (*de->d_name != '.') {
++ if ((p = strstr (de->d_name, ":2,"))) {
++ if (!strchr (p + 3, 'T')) {
++ tmp->msgcount++;
++ if ( !strchr (p + 3, 'S'))
++ tmp->msg_unread++;
++ if (strchr(p + 3, 'F'))
++ tmp->msg_flagged++;
++ }
++ } else
++ tmp->msgcount++;
+ }
+ }
+ closedir (dirp);