- * create the sequence, if necessary
- */
- if (new_seq) {
- if (i >= NUMATTRS) {
- advise (NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
- return 0;
- }
- if (!(mp->msgattrs[i] = strdup (cp))) {
- advise (NULL, "strdup failed");
- return 0;
- }
- mp->msgattrs[i + 1] = NULL;
+ ** If the zero flag is set, first add all existing
+ ** messages in this folder to the sequence.
+ */
+ if (zero) {
+ /*
+ ** create the sequence, if necessary
+ */
+ if (new_seq) {
+ if (i >= NUMATTRS) {
+ advise(NULL, "only %d sequences allowed (no room for %s)!", NUMATTRS, cp);
+ return 0;
+ }
+ if (!(mp->msgattrs[i] = strdup(cp))) {
+ advise(NULL, "strdup failed");
+ return 0;
+ }
+ mp->msgattrs[i + 1] = NULL;
+ }
+ /*
+ ** now add sequence bit to all existing messages
+ */
+ for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) {
+ if (does_exist(mp, msgnum))
+ add_sequence(mp, i, msgnum);
+ else
+ clear_sequence(mp, i, msgnum);
+ }
+ } else {
+ if (new_seq) {
+ advise(NULL, "no such sequence as %s", cp);
+ return 0;
+ }