projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace getcpy() and strdup() with mh_xstrdup()
[mmh]
/
sbr
/
seq_msgstats.c
diff --git
a/sbr/seq_msgstats.c
b/sbr/seq_msgstats.c
index
40b8474
..
50ae7c6
100644
(file)
--- a/
sbr/seq_msgstats.c
+++ b/
sbr/seq_msgstats.c
@@
-4,13
+4,14
@@
** (These functions had once been macros in h/mh.h)
*/
** (These functions had once been macros in h/mh.h)
*/
+#include <sysexits.h>
#include <h/mh.h>
static void
assert_msg_range(struct msgs *mp, int msgnum)
{
if (msgnum < mp->lowoff || msgnum > mp->hghoff) {
#include <h/mh.h>
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");
}
}
}
}
@@
-97,7
+98,19
@@
void
set_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
set_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
+
+ if (is_selected(mp, msgnum)) {
+ return;
+ }
+
mp->msgstats[msgnum - mp->lowoff] |= SELECTED;
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
}
void
@@
-118,7
+131,15
@@
void
unset_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
unset_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
+
+ if (!is_selected(mp, msgnum)) {
+ return;
+ }
+
mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
+ if (mp->numsel > 0) {
+ mp->numsel--;
+ }
}
void
}
void