Fix missing va_end call in uip/mhmisc.c
[mmh] / sbr / seq_msgstats.c
index eb483b7..50ae7c6 100644 (file)
@@ -98,7 +98,19 @@ void
 set_selected(struct msgs *mp, int msgnum)
 {
        assert_msg_range(mp, msgnum);
+
+       if (is_selected(mp, msgnum)) {
+               return;
+       }
+
        mp->msgstats[msgnum - mp->lowoff] |= SELECTED;
+       if (mp->lowsel == 0 || msgnum < mp->lowsel) {
+               mp->lowsel = msgnum;
+       }
+       if (msgnum > mp->hghsel) {
+               mp->hghsel = msgnum;
+       }
+       mp->numsel++;
 }
 
 void
@@ -119,7 +131,15 @@ void
 unset_selected(struct msgs *mp, int msgnum)
 {
        assert_msg_range(mp, msgnum);
+
+       if (!is_selected(mp, msgnum)) {
+               return;
+       }
+
        mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
+       if (mp->numsel > 0) {
+               mp->numsel--;
+       }
 }
 
 void