From: Philipp Takacs Date: Fri, 6 Nov 2015 10:30:51 +0000 (+0100) Subject: check for (un)selection befor (un)set X-Git-Tag: mmh-0.3~39^2~21 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=056af7546464661f792d85308f119bf6c1554316 check for (un)selection befor (un)set If you select or unselect the same msgnum numsel won't be increased/decreased twice. --- diff --git a/sbr/m_convert.c b/sbr/m_convert.c index 0a47568..d187a34 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -36,16 +36,6 @@ static char *delimp; /* delimiter pointer */ static int m_conv(struct msgs *, char *, int); static int attr(struct msgs *, char *); - -static void -addtosel(struct msgs *mp, int msg) -{ - if (is_selected(mp, msg)) { - return; /* dont select twice */ - } - set_selected(mp, msg); -} - int m_convert(struct msgs *mp, char *name) { @@ -74,7 +64,7 @@ m_convert(struct msgs *mp, char *name) ** Also, it is available in any folder. */ if ((mp->msgflags & ALLOW_BEYOND) && strcmp(cp, seq_beyond)==0) { - addtosel(mp, getbeyond(mp)); + set_selected(mp, getbeyond(mp)); return 1; } @@ -219,7 +209,7 @@ badelim: /* Cycle through the range and select the messages that exist. */ for (found=0; first <= last; first++) { if (does_exist(mp, first)) { - addtosel(mp, first); + set_selected(mp, first); found++; } } @@ -420,7 +410,7 @@ attr(struct msgs *mp, char *cp) if (does_exist(mp, j) && inverted ? !in_sequence(mp, i, j) : in_sequence(mp, i, j)) { - addtosel(mp, j); + set_selected(mp, j); found++; /* diff --git a/sbr/seq_msgstats.c b/sbr/seq_msgstats.c index 6b89d70..50ae7c6 100644 --- a/sbr/seq_msgstats.c +++ b/sbr/seq_msgstats.c @@ -98,6 +98,11 @@ 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; @@ -126,6 +131,11 @@ 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--;