- *bp = '\0'; /* temporarily terminate sequence name */
- }
-
- i = seq_getnum (mp, cp); /* get index of sequence */
-
- if (bp)
- *bp = ':'; /* restore sequence name */
- if (i == -1)
- return 0;
-
- found = 0; /* count the number we select for this argument */
-
- for (j = first ? first : (convdir > 0) ? mp->lowmsg : mp->hghmsg;
- j >= mp->lowmsg && j <= mp->hghmsg; j += convdir) {
- if (does_exist (mp, j)
- && inverted ? !in_sequence (mp, i, j) : in_sequence (mp, i, j)) {
- if (!is_selected (mp, j)) {
- set_selected (mp, j);
- mp->numsel++;
- if (mp->lowsel == 0 || j < mp->lowsel)
- mp->lowsel = j;
- if (j > mp->hghsel)
- mp->hghsel = j;
- }
- found++;
-
- /*
- * If we have a range, then break out
- * once we've found enough.
- */
- if (range && found >= range)
- break;
+ convdir = 1; /* convert direction */
+
+ for (dp = cp; *dp && isalnum(*dp); dp++)
+ continue;
+
+ if (*dp == ':') {
+ bp = dp++;
+ range = 1;
+
+ /*
+ ** seq:p (or)
+ ** seq:n (or)
+ ** seq:f (or)
+ ** seq:l
+ */
+ if (isalpha(*dp)) {
+ if (!strcmp(dp, seq_prev)) {
+ convdir = -1;
+ first = (mp->curmsg > 0) && (mp->curmsg <= mp->hghmsg)
+ ? mp->curmsg - 1 : mp->hghmsg;
+ } else if (!strcmp(dp, seq_next)) {
+ convdir = 1;
+ first = (mp->curmsg >= mp->lowmsg)
+ ? mp->curmsg + 1 : mp->lowmsg;
+ } else if (!strcmp(dp, seq_first)) {
+ convdir = 1;
+ } else if (!strcmp(dp, seq_last)) {
+ convdir = -1;
+ } else
+ return BADLST;
+ } else {
+ /*
+ ** seq:42 (or)
+ ** seq:+42 (or)
+ ** seq:-42
+ */
+ if (*dp == '+')
+ dp++;
+ else if (*dp == '-') {
+ dp++;
+ convdir = -1;
+ }
+ if ((range = atoi(dp)) == 0)
+ return BADLST;
+ while (isdigit(*dp))
+ dp++;
+ if (*dp)
+ return BADLST;
+ }
+
+ *bp = '\0'; /* temporarily terminate sequence name */
+ }
+
+ i = seq_getnum(mp, cp); /* get index of sequence */
+
+ if (bp)
+ *bp = ':'; /* restore sequence name */
+ if (i == -1)
+ return 0;
+
+ found = 0; /* count the number we select for this argument */
+
+ for (j = first ? first : (convdir > 0) ? mp->lowmsg : mp->hghmsg;
+ j >= mp->lowmsg && j <= mp->hghmsg; j += convdir) {
+ if (does_exist(mp, j)
+ && inverted ? !in_sequence(mp, i, j) :
+ in_sequence(mp, i, j)) {
+ addtosel(mp, j);
+ found++;
+
+ /*
+ ** If we have a range, then break out
+ ** once we've found enough.
+ */
+ if (range && found >= range)
+ break;
+ }