X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/71458b3b2492943349f7693a46792756d5013c69..4a56a28ac439137ba2b71fcb5952b4e4abd1e2fc:/sbr/m_convert.c?ds=sidebyside diff --git a/sbr/m_convert.c b/sbr/m_convert.c index d7080065..566b02a5 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -1,6 +1,4 @@ - -/* - * 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 @@ -8,6 +6,7 @@ */ #include +#include /* * error codes for sequence @@ -46,9 +45,9 @@ m_convert (struct msgs *mp, char *name) 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 @@ -64,8 +63,7 @@ m_convert (struct msgs *mp, char *name) 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")) @@ -77,7 +75,7 @@ m_convert (struct msgs *mp, char *name) 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; } @@ -87,28 +85,28 @@ badelim: 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; } @@ -119,7 +117,7 @@ badlist: 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; } @@ -179,7 +177,7 @@ rangerr: } } 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; @@ -204,8 +202,8 @@ single: * 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 { @@ -213,9 +211,9 @@ single: || 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; } } @@ -278,12 +276,11 @@ m_conv (struct msgs *mp, char *str, int call) 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 */ @@ -361,7 +358,7 @@ attr (struct msgs *mp, char *cp) /* 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; } @@ -506,6 +503,6 @@ attr (struct msgs *mp, char *cp) 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; }