X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fseq_list.c;h=23bd54425648662d57ca4605aa11d578fefd0545;hp=b64e8cd8d03d4363e8fcccb186d1fc2f6a6ca88b;hb=a485ed478abbd599d8c9aab48934e7a26733ecb1;hpb=f480c03187724e54e5391ee61b810827da319a6c diff --git a/sbr/seq_list.c b/sbr/seq_list.c index b64e8cd..23bd544 100644 --- a/sbr/seq_list.c +++ b/sbr/seq_list.c @@ -1,4 +1,3 @@ - /* * seq_list.c -- Get all messages in a sequence and return them * -- as a space separated list of message ranges. @@ -22,84 +21,84 @@ static int len = 0; char * seq_list(struct msgs *mp, char *seqname) { - int i, j, seqnum; - char *bp; - - /* On first invocation, allocate initial buffer space */ - if (!buffer) { - len = MAXBUFFER; - buffer = mh_xmalloc ((size_t) len); - } - - /* - * Special processing for "cur" sequence. We assume that the - * "cur" sequence and mp->curmsg are in sync (see seq_add.c). - * This is returned, even if message doesn't exist or the - * folder is empty. - */ - if (!strcmp (current, seqname)) { - if (mp->curmsg) { - sprintf(buffer, "%s", m_name(mp->curmsg)); - return (buffer); - } else - return (NULL); - } - - /* If the folder is empty, just return NULL */ - if (mp->nummsg == 0) - return NULL; - - /* Get the index of the sequence */ - if ((seqnum = seq_getnum (mp, seqname)) == -1) - return NULL; - - bp = buffer; - - for (i = mp->lowmsg; i <= mp->hghmsg; ++i) { - /* - * If message doesn't exist, or isn't in - * the sequence, then continue. - */ - if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i)) - continue; - - /* - * See if we need to enlarge buffer. Since we don't know - * exactly how many character this particular message range - * will need, we enlarge the buffer if we are within - * 50 characters of the end. - */ - if (bp - buffer > len - 50) { - char *newbuf; + int i, j, seqnum; + char *bp; - len += MAXBUFFER; - newbuf = mh_xrealloc (buffer, (size_t) len); - bp = newbuf + (bp - buffer); - buffer = newbuf; + /* On first invocation, allocate initial buffer space */ + if (!buffer) { + len = MAXBUFFER; + buffer = mh_xmalloc ((size_t) len); } /* - * If this is not the first message range in - * the list, first add a space. + * Special processing for "cur" sequence. We assume that the + * "cur" sequence and mp->curmsg are in sync (see seq_add.c). + * This is returned, even if message doesn't exist or the + * folder is empty. */ - if (bp > buffer) - *bp++ = ' '; - - sprintf(bp, "%s", m_name(i)); - bp += strlen(bp); - j = i; /* Remember beginning of message range */ - - /* - * Scan to the end of this message range - */ - for (++i; i <= mp->hghmsg && does_exist(mp, i) && in_sequence(mp, seqnum, i); - ++i) - ; + if (!strcmp (current, seqname)) { + if (mp->curmsg) { + sprintf(buffer, "%s", m_name(mp->curmsg)); + return (buffer); + } else + return (NULL); + } - if (i - j > 1) { - sprintf(bp, "-%s", m_name(i - 1)); - bp += strlen(bp); + /* If the folder is empty, just return NULL */ + if (mp->nummsg == 0) + return NULL; + + /* Get the index of the sequence */ + if ((seqnum = seq_getnum (mp, seqname)) == -1) + return NULL; + + bp = buffer; + + for (i = mp->lowmsg; i <= mp->hghmsg; ++i) { + /* + * If message doesn't exist, or isn't in + * the sequence, then continue. + */ + if (!does_exist(mp, i) || !in_sequence(mp, seqnum, i)) + continue; + + /* + * See if we need to enlarge buffer. Since we don't know + * exactly how many character this particular message range + * will need, we enlarge the buffer if we are within + * 50 characters of the end. + */ + if (bp - buffer > len - 50) { + char *newbuf; + + len += MAXBUFFER; + newbuf = mh_xrealloc (buffer, (size_t) len); + bp = newbuf + (bp - buffer); + buffer = newbuf; + } + + /* + * If this is not the first message range in + * the list, first add a space. + */ + if (bp > buffer) + *bp++ = ' '; + + sprintf(bp, "%s", m_name(i)); + bp += strlen(bp); + j = i; /* Remember beginning of message range */ + + /* + * Scan to the end of this message range + */ + for (++i; i <= mp->hghmsg && does_exist(mp, i) && in_sequence(mp, seqnum, i); + ++i) + ; + + if (i - j > 1) { + sprintf(bp, "-%s", m_name(i - 1)); + bp += strlen(bp); + } } - } - return (bp > buffer? buffer : NULL); + return (bp > buffer? buffer : NULL); }