X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fseq_msgstats.c;h=bfd7fb277b7a7af819b36d5922514b4f31ee3765;hb=c8e830d8fd222d69c9fca36d508a8d8a42fd4a46;hp=40b84746d42df5f26109024422e6a7168d11d650;hpb=0347722f5b69de06a867b73ddc23388d082ab219;p=mmh diff --git a/sbr/seq_msgstats.c b/sbr/seq_msgstats.c index 40b8474..bfd7fb2 100644 --- a/sbr/seq_msgstats.c +++ b/sbr/seq_msgstats.c @@ -4,13 +4,14 @@ ** (These functions had once been macros in h/mh.h) */ +#include #include static void assert_msg_range(struct msgs *mp, int msgnum) { if (msgnum < mp->lowoff || msgnum > mp->hghoff) { - adios(NULL, "Bug: message out of bounds"); + adios(EX_SOFTWARE, NULL, "Bug: message out of bounds"); } } @@ -26,6 +27,8 @@ void clear_msg_flags(struct msgs *mp, int msgnum) { assert_msg_range(mp, msgnum); + if (mp->msgstats[msgnum - mp->lowoff]) + mp->msgflags |= SEQMOD; mp->msgstats[msgnum - mp->lowoff] = 0; } @@ -97,7 +100,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 @@ -118,14 +133,15 @@ void unset_selected(struct msgs *mp, int msgnum) { assert_msg_range(mp, msgnum); - mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED; -} -void -unset_unseen(struct msgs *mp, int msgnum) -{ - assert_msg_range(mp, msgnum); - mp->msgstats[msgnum - mp->lowoff] &= ~SELECT_UNSEEN; + if (!is_selected(mp, msgnum)) { + return; + } + + mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED; + if (mp->numsel > 0) { + mp->numsel--; + } }