X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fseq_setunseen.c;h=73bd83dccece86fe79b61aeab05ae6daabed984e;hp=2bb09b941d20ff98e4add2db2f319481baceca64;hb=d4c34b4439a9dbd89664de460ed37ecddc260fb1;hpb=c2360569e1d8d3678e294eb7c1354cb8bf7501c1 diff --git a/sbr/seq_setunseen.c b/sbr/seq_setunseen.c index 2bb09b9..73bd83d 100644 --- a/sbr/seq_setunseen.c +++ b/sbr/seq_setunseen.c @@ -8,17 +8,17 @@ */ #include +#include /* mh_free0() */ /* ** We scan through the folder and act upon all messages ** that are marked with the SELECT_UNSEEN bit. ** -** If seen == 1, delete messages from unseen sequence. -** If seen == 0, add messages to unseen sequence. +** Either add messages to or (if doadd is false) delete messages from +** the unseen sequence(s). */ - void -seq_setunseen(struct msgs *mp, int seen) +seq_setunseen(struct msgs *mp, int doadd) { int n; char **ap, *cp, *dp; @@ -35,7 +35,7 @@ seq_setunseen(struct msgs *mp, int seen) } if (!(ap = brkstring(dp, " ", "\n")) || !*ap) { /* contains no sequence name, i.e. we're finished */ - free(dp); + mh_free0(&dp); return; } @@ -44,7 +44,13 @@ seq_setunseen(struct msgs *mp, int seen) ** bit set to/from each of these sequences. */ for (; *ap; ap++) { - if (seen) { + if (doadd) { + for (n = mp->lowmsg; n <= mp->hghmsg; n++) { + if (is_unseen(mp, n)) { + seq_addmsg(mp, *ap, n, -1, 0); + } + } + } else { /* make sure sequence exists first */ if (seq_getnum(mp, *ap) != -1) { for (n = mp->lowsel; n <= mp->hghsel; n++) { @@ -53,14 +59,8 @@ seq_setunseen(struct msgs *mp, int seen) } } } - } else { - for (n = mp->lowmsg; n <= mp->hghmsg; n++) { - if (is_unseen(mp, n)) { - seq_addmsg(mp, *ap, n, -1, 0); - } - } } } - free(dp); + mh_free0(&dp); }