-
-/*
- * m_convert.c -- parse a message range or sequence and set SELECTED
+/* m_convert.c -- parse a message range or sequence and set SELECTED
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
* error codes for sequence
if (err == -1)
return 0;
- else if (err < 0)
+ if (err < 0)
goto badmsg;
- else if (err > 0)
+ if (err > 0)
return 1;
/*
* else err == 0, so continue
if ((mp->msgflags & ALLOW_NEW) && !strcmp (cp, "new")) {
if ((err = first = getnew (mp)) <= 0)
goto badmsg;
- else
- goto single;
+ goto single;
}
if (!strcmp (cp, "all"))
cp = delimp;
if (*cp != '\0' && *cp != '-' && *cp != ':' && *cp != '=') {
badelim:
- advise (NULL, "illegal argument delimiter: `%c'(0%o)", *delimp, *delimp);
+ inform("illegal argument delimiter: `%c'(0%o)", *delimp, *delimp);
return 0;
}
badmsg:
switch (err) {
case BADMSG:
- advise (NULL, "no %s message", cp);
+ inform("no %s message", cp);
break;
case BADNUM:
- advise (NULL, "message %s doesn't exist", cp);
+ inform("message %s doesn't exist", cp);
break;
case BADRNG:
- advise (NULL, "message %s out of range 1-%d", cp, mp->hghmsg);
+ inform("message %s out of range 1-%d", cp, mp->hghmsg);
break;
case BADLST:
badlist:
- advise (NULL, "bad message list %s", name);
+ inform("bad message list %s", name);
break;
case BADNEW:
- advise (NULL, "folder full, no %s message", name);
+ inform("folder full, no %s message", name);
break;
default:
- advise (NULL, "no messages match specification");
+ inform("no messages match specification");
}
return 0;
}
goto badelim;
if (first > mp->hghmsg || last < mp->lowmsg) {
rangerr:
- advise (NULL, "no messages in range %s", name);
+ inform("no messages in range %s", name);
return 0;
}
}
} else { /* looking for the nth message. if not enough, fail. */
if (last < mp->lowmsg || last > mp->hghmsg) {
- advise (NULL, "no such message");
+ inform("no such message");
return 0;
}
first = last;
* limits simply reallocate the folder so it's within range.
*/
if (first < mp->lowoff || first > mp->hghoff)
- mp = folder_realloc(mp, first < mp->lowoff ? first : mp->lowoff,
- first > mp->hghoff ? first : mp->hghoff);
+ mp = folder_realloc(mp, min(first, mp->lowoff),
+ max(first, mp->hghoff));
set_select_empty (mp, first);
} else {
|| first < mp->lowmsg
|| !(does_exist (mp, first))) {
if (!strcmp (name, "cur") || !strcmp (name, "."))
- advise (NULL, "no %s message", name);
+ inform("no %s message", name);
else
- advise (NULL, "message %d doesn't exist", first);
+ inform("message %d doesn't exist", first);
return 0;
}
}
if (i <= mp->hghmsg)
return i;
- else if (*delimp || call == LAST)
+ if (*delimp || call == LAST)
return mp->hghmsg + 1;
- else if (mp->msgflags & ALLOW_NEW)
+ if (mp->msgflags & ALLOW_NEW)
return BADRNG;
- else
- return BADNUM;
+ return BADNUM;
}
/* doesn't enforce lower case */
/* hack for "cur-name", "cur-n", etc. */
if (!strcmp (cp, "cur"))
return 0;
- if (strncmp ("cur", cp, 3) == 0) {
+ if (has_prefix(cp, "cur")) {
if (cp[3] == ':' || cp[3] == '=')
return 0;
}
if (first || just_one)
return BADMSG;
- advise (NULL, "sequence %s %s", cp, inverted ? "full" : "empty");
+ inform("sequence %s %s", cp, inverted ? "full" : "empty");
return -1;
}