/*
** Buffer size for content part of header fields. We want this
** to be large enough so that we don't do a lot of extra FLDPLUS
-** calls on m_getfld but small enough so that we don't snarf
-** the entire message body when we're only going to display 30
-** characters of it.
+** calls on m_getfld.
*/
#define SBUFSIZ 512
scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg,
int unseen)
{
+ static int slwidth;
int i, compnum, state;
unsigned char *cp, *tmpbuf;
char **nxtbuf;
char *scnmsg = NULL;
FILE *scnout = NULL;
char name[NAMESZ];
- static int slwidth;
char returnpath[BUFSIZ];
char deliverydate[BUFSIZ];
int incing = (outnum > 0);
}
dat[3] = slwidth = width;
scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
- (slwidth + 2) );
+ (slwidth + 2)); /* probably for \n and \0 */
if (incing)
umask(~m_gmprot());
FINDCOMP(datecomp, "date");
nxtbuf = compbuffers = (char **) calloc((size_t) ncomps,
sizeof(char *));
- if (nxtbuf == NULL)
+ if (!nxtbuf)
adios(NULL, "unable to allocate component buffers");
used_buf = (struct comp **) calloc((size_t) (ncomps+1),
- sizeof(struct comp *));
- if (used_buf == NULL)
+ sizeof(struct comp *));
+ if (!used_buf)
adios(NULL, "unable to allocate component buffer stack");
- used_buf += ncomps+1; *--used_buf = 0;
+ /* NULL-terminate array */
+ used_buf += ncomps;
+ *used_buf = NULL;
+ /* allocate space for the items */
for (i = ncomps; i--; )
*nxtbuf++ = mh_xmalloc(SBUFSIZ);
}
scnmsg = m_name(outnum);
if (*scnmsg == '?') /* msg num out of range */
return SCNNUM;
- if ((scnout = fopen(scnmsg, "w")) == NULL)
+ if (!(scnout = fopen(scnmsg, "w")))
adios(scnmsg, "unable to write");
/*
** Add the Return-Path and Delivery-Date
dat[2] = st.st_size;
if (datecomp) {
if (!datecomp->c_text) {
- if (datecomp->c_tws == NULL)
+ if (!datecomp->c_tws)
datecomp->c_tws = (struct tws *) calloc((size_t) 1, sizeof(*datecomp->c_tws));
- if (datecomp->c_tws == NULL)
+ if (!datecomp->c_tws)
adios(NULL, "unable to allocate tws buffer");
*datecomp->c_tws = *dlocaltime((time_t *) &st.st_mtime);
datecomp->c_flags |= CF_DATEFAB|CF_TRUE;