handle hghsel lowsel and numsel in (un)set_selected
authorPhilipp Takacs <philipp@bureaucracy.de>
Thu, 5 Nov 2015 21:48:34 +0000 (22:48 +0100)
committermarkus schnalke <meillo@marmaro.de>
Tue, 10 Nov 2015 20:05:15 +0000 (21:05 +0100)
Now you can use this funkitions without taking care
of this values.

Thanks c_14 for reporting this bug.

sbr/folder_addmsg.c
sbr/folder_delmsgs.c
sbr/m_convert.c
sbr/seq_msgstats.c
uip/pick.c

index 4cc8d6c..e14c709 100644 (file)
@@ -87,20 +87,6 @@ folder_addmsg(struct msgs **mpp, char *msgfile, int selected,
                /* should we set the SELECTED bit? */
                if (selected) {
                        set_selected(mp, msgnum);
                /* should we set the SELECTED bit? */
                if (selected) {
                        set_selected(mp, msgnum);
-
-                       /* check if highest or lowest selected */
-                       if (mp->numsel == 0) {
-                               mp->lowsel = msgnum;
-                               mp->hghsel = msgnum;
-                       } else {
-                               if (msgnum < mp->lowsel)
-                                       mp->lowsel = msgnum;
-                               if (msgnum > mp->hghsel)
-                                       mp->hghsel = msgnum;
-                       }
-
-                       /* increment number selected */
-                       mp->numsel++;
                }
 
                /*
                }
 
                /*
index 8e5fd0a..3165883 100644 (file)
@@ -28,7 +28,6 @@ folder_delmsgs(struct msgs *mp, int hook)
 
                /* unselect message */
                unset_selected(mp, msgnum);
 
                /* unselect message */
                unset_selected(mp, msgnum);
-               mp->numsel--;
 
                snprintf(msgpath, sizeof (msgpath), "%s/%d",
                                mp->foldpath, msgnum);
 
                snprintf(msgpath, sizeof (msgpath), "%s/%d",
                                mp->foldpath, msgnum);
index f113366..0a47568 100644 (file)
@@ -44,13 +44,6 @@ addtosel(struct msgs *mp, int msg)
                return;  /* dont select twice */
        }
        set_selected(mp, msg);
                return;  /* dont select twice */
        }
        set_selected(mp, msg);
-       mp->numsel++;
-       if (mp->lowsel == 0 || msg < mp->lowsel) {
-               mp->lowsel = msg;
-       }
-       if (msg > mp->hghsel) {
-               mp->hghsel = msg;
-       }
 }
 
 int
 }
 
 int
index eb483b7..6b89d70 100644 (file)
@@ -99,6 +99,13 @@ set_selected(struct msgs *mp, int msgnum)
 {
        assert_msg_range(mp, msgnum);
        mp->msgstats[msgnum - mp->lowoff] |= SELECTED;
 {
        assert_msg_range(mp, msgnum);
        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
@@ -120,6 +127,9 @@ unset_selected(struct msgs *mp, int msgnum)
 {
        assert_msg_range(mp, msgnum);
        mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
 {
        assert_msg_range(mp, msgnum);
        mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
+       if (mp->numsel > 0) {
+               mp->numsel--;
+       }
 }
 
 void
 }
 
 void
index 3ac9e11..a1b5eff 100644 (file)
@@ -274,7 +274,6 @@ main(int argc, char **argv)
                        } else {
                                /* if it doesn't match, then unselect it */
                                unset_selected(mp, msgnum);
                        } else {
                                /* if it doesn't match, then unselect it */
                                unset_selected(mp, msgnum);
-                               mp->numsel--;
                        }
                        if (fp)
                                fclose(fp);
                        }
                        if (fp)
                                fclose(fp);