X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fm_convert.c;fp=sbr%2Fm_convert.c;h=89da537d7202ebab34ba1497d38643d76d9ccc8e;hp=cd18406465f029fb8f480f5663eec73c5205ca89;hb=714b5c530ece27ea2835a313013f5b770163403c;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/sbr/m_convert.c b/sbr/m_convert.c index cd18406..89da537 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -29,19 +29,19 @@ static char *delimp; /* ** static prototypes */ -static int m_conv (struct msgs *, char *, int); -static int attr (struct msgs *, char *); +static int m_conv(struct msgs *, char *, int); +static int attr(struct msgs *, char *); int -m_convert (struct msgs *mp, char *name) +m_convert(struct msgs *mp, char *name) { int first, last, found, range, err; unsigned char *bp; char *cp; /* check if user defined sequence */ - err = attr (mp, cp = name); + err = attr(mp, cp = name); if (err == -1) return 0; @@ -59,57 +59,57 @@ m_convert (struct msgs *mp, char *name) ** Check for special "new" sequence, which ** is valid only if ALLOW_NEW is set. */ - if ((mp->msgflags & ALLOW_NEW) && !strcmp (cp, "new")) { - if ((err = first = getnew (mp)) <= 0) + if ((mp->msgflags & ALLOW_NEW) && !strcmp(cp, "new")) { + if ((err = first = getnew(mp)) <= 0) goto badmsg; else goto single; } - if (!strcmp (cp, "all")) + if (!strcmp(cp, "all")) cp = "first-last"; - if ((err = first = m_conv (mp, cp, FIRST)) <= 0) + if ((err = first = m_conv(mp, cp, FIRST)) <= 0) goto badmsg; cp = delimp; if (*cp != '\0' && *cp != '-' && *cp != ':') { badelim: - advise (NULL, "illegal argument delimiter: `%c'(0%o)", + advise(NULL, "illegal argument delimiter: `%c'(0%o)", *delimp, *delimp); return 0; } if (*cp == '-') { cp++; - if ((err = last = m_conv (mp, cp, LAST)) <= 0) { + if ((err = last = m_conv(mp, cp, LAST)) <= 0) { badmsg: switch (err) { case BADMSG: - advise (NULL, "no %s message", cp); + advise(NULL, "no %s message", cp); break; case BADNUM: - advise (NULL, "message %s doesn't exist", cp); + advise(NULL, "message %s doesn't exist", cp); break; case BADRNG: - advise (NULL, "message %s out of range 1-%d", + advise(NULL, "message %s out of range 1-%d", cp, mp->hghmsg); break; case BADLST: badlist: - advise (NULL, "bad message list %s", name); + advise(NULL, "bad message list %s", name); break; case BADNEW: - advise (NULL, "folder full, no %s message", + advise(NULL, "folder full, no %s message", name); break; default: - advise (NULL, "no messages match specification"); + advise(NULL, "no messages match specification"); } return 0; } @@ -120,7 +120,7 @@ badlist: goto badelim; if (first > mp->hghmsg || last < mp->lowmsg) { rangerr: - advise (NULL, "no messages in range %s", name); + advise(NULL, "no messages in range %s", name); return 0; } @@ -139,9 +139,9 @@ rangerr: convdir = 1; cp++; } - if ((range = atoi (bp = cp)) == 0) + if ((range = atoi(bp = cp)) == 0) goto badlist; - while (isdigit (*bp)) + while (isdigit(*bp)) bp++; if (*bp) goto badelim; @@ -157,7 +157,7 @@ rangerr: for (last = first; last >= mp->lowmsg && last <= mp->hghmsg; last += convdir) - if (does_exist (mp, last)) + if (does_exist(mp, last)) if (--range <= 0) break; if (last < mp->lowmsg) @@ -180,15 +180,15 @@ single: ** check if message is in-range and exists. */ if (mp->msgflags & ALLOW_NEW) { - set_select_empty (mp, first); + set_select_empty(mp, first); } else { if (first > mp->hghmsg || first < mp->lowmsg - || !(does_exist (mp, first))) { - if (!strcmp (name, "cur") || !strcmp (name, ".")) - advise (NULL, "no %s message", name); + || !(does_exist(mp, first))) { + if (!strcmp(name, "cur") || !strcmp(name, ".")) + advise(NULL, "no %s message", name); else - advise (NULL, "message %d doesn't exist", first); + advise(NULL, "message %d doesn't exist", first); return 0; } } @@ -201,10 +201,10 @@ single: ** if we are selecting an empty slot. */ for (; first <= last; first++) { - if (does_exist (mp, first) || - ((mp->msgflags & ALLOW_NEW) && is_select_empty (mp, first))) { - if (!is_selected (mp, first)) { - set_selected (mp, first); + if (does_exist(mp, first) || + ((mp->msgflags & ALLOW_NEW) && is_select_empty(mp, first))) { + if (!is_selected(mp, first)) { + set_selected(mp, first); mp->numsel++; if (mp->lowsel == 0 || first < mp->lowsel) mp->lowsel = first; @@ -235,7 +235,7 @@ single: */ static int -m_conv (struct msgs *mp, char *str, int call) +m_conv(struct msgs *mp, char *str, int call) { register int i; register unsigned char *cp, *bp; @@ -243,11 +243,11 @@ m_conv (struct msgs *mp, char *str, int call) convdir = 1; cp = bp = str; - if (isdigit (*cp)) { - while (isdigit (*bp)) + if (isdigit(*cp)) { + while (isdigit(*bp)) bp++; delimp = bp; - i = atoi (cp); + i = atoi(cp); if (i <= mp->hghmsg) return i; @@ -273,32 +273,32 @@ m_conv (struct msgs *mp, char *str, int call) *bp++ = '\0'; delimp = cp; - if (!strcmp (buf, "first")) + if (!strcmp(buf, "first")) return (mp->hghmsg || !(mp->msgflags & ALLOW_NEW) ? mp->lowmsg : BADMSG); - if (!strcmp (buf, "last")) { + if (!strcmp(buf, "last")) { convdir = -1; return (mp->hghmsg || !(mp->msgflags & ALLOW_NEW) ? mp->hghmsg : BADMSG); } - if (!strcmp (buf, "cur") || !strcmp (buf, ".")) + if (!strcmp(buf, "cur") || !strcmp(buf, ".")) return (mp->curmsg > 0 ? mp->curmsg : BADMSG); - if (!strcmp (buf, "prev")) { + if (!strcmp(buf, "prev")) { convdir = -1; for (i = (mp->curmsg <= mp->hghmsg) ? mp->curmsg - 1 : mp->hghmsg; i >= mp->lowmsg; i--) { - if (does_exist (mp, i)) + if (does_exist(mp, i)) return i; } return BADMSG; } - if (!strcmp (buf, "next")) { + if (!strcmp(buf, "next")) { for (i = (mp->curmsg >= mp->lowmsg) ? mp->curmsg + 1 : mp->lowmsg; i <= mp->hghmsg; i++) { - if (does_exist (mp, i)) + if (does_exist(mp, i)) return i; } return BADMSG; @@ -322,7 +322,7 @@ m_conv (struct msgs *mp, char *str, int call) */ static int -attr (struct msgs *mp, char *cp) +attr(struct msgs *mp, char *cp) { register unsigned char *dp; char *bp = NULL; @@ -333,15 +333,15 @@ attr (struct msgs *mp, char *cp) int first = 0; /* hack for "cur-name", "cur-n", etc. */ - if (!strcmp (cp, "cur")) + if (!strcmp(cp, "cur")) return 0; - if (ssequal ("cur:", cp)) /* this code need to be rewritten... */ + if (ssequal("cur:", cp)) /* this code need to be rewritten... */ return 0; /* Check for sequence negation */ - if ((dp = context_find (nsequence)) && *dp != '\0' && ssequal (dp, cp)) { + if ((dp = context_find(nsequence)) && *dp != '\0' && ssequal(dp, cp)) { inverted = 1; - cp += strlen (dp); + cp += strlen(dp); } convdir = 1; /* convert direction */ @@ -359,18 +359,18 @@ attr (struct msgs *mp, char *cp) ** seq:first (or) ** seq:last */ - if (isalpha (*dp)) { - if (!strcmp (dp, "prev")) { + if (isalpha(*dp)) { + if (!strcmp(dp, "prev")) { convdir = -1; first = (mp->curmsg > 0) && (mp->curmsg <= mp->hghmsg) ? mp->curmsg - 1 : mp->hghmsg; - } else if (!strcmp (dp, "next")) { + } else if (!strcmp(dp, "next")) { convdir = 1; first = (mp->curmsg >= mp->lowmsg) ? mp->curmsg + 1 : mp->lowmsg; - } else if (!strcmp (dp, "first")) { + } else if (!strcmp(dp, "first")) { convdir = 1; - } else if (!strcmp (dp, "last")) { + } else if (!strcmp(dp, "last")) { convdir = -1; } else return BADLST; @@ -388,7 +388,7 @@ attr (struct msgs *mp, char *cp) } if ((range = atoi(dp)) == 0) return BADLST; - while (isdigit (*dp)) + while (isdigit(*dp)) dp++; if (*dp) return BADLST; @@ -397,7 +397,7 @@ attr (struct msgs *mp, char *cp) *bp = '\0'; /* temporarily terminate sequence name */ } - i = seq_getnum (mp, cp); /* get index of sequence */ + i = seq_getnum(mp, cp); /* get index of sequence */ if (bp) *bp = ':'; /* restore sequence name */ @@ -408,10 +408,10 @@ attr (struct msgs *mp, char *cp) 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); + 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; @@ -434,6 +434,6 @@ attr (struct msgs *mp, char *cp) if (first) return BADMSG; - advise (NULL, "sequence %s %s", cp, inverted ? "full" : "empty"); + advise(NULL, "sequence %s %s", cp, inverted ? "full" : "empty"); return -1; }