From c6615b2fbf66e8c99a00330e23747787fb6c35cc Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 22 Mar 2012 19:54:12 +0100 Subject: [PATCH] Remove remainings from scan format `body' pseudo-component. Also, folded constant rlwidth var. --- uip/scansbr.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/uip/scansbr.c b/uip/scansbr.c index 9f4143e..b15c908 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -39,7 +39,6 @@ static struct format *fmt; static struct comp *datecomp; /* pntr to "date" comp */ -static struct comp *bodycomp; /* pntr to "body" pseudo-comp (if referenced) */ static int ncomps = 0; /* # of interesting components */ static char **compbuffers = NULL; /* buffers for component text */ static struct comp **used_buf = NULL; /* stack for comp that use buffers */ @@ -71,13 +70,12 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, int i, compnum, state; unsigned char *cp, *tmpbuf; char **nxtbuf; - char *saved_c_text = NULL; struct comp *cptr; struct comp **savecomp; char *scnmsg = NULL; FILE *scnout = NULL; char name[NAMESZ]; - static int rlwidth, slwidth; + static int slwidth; char returnpath[BUFSIZ]; char deliverydate[BUFSIZ]; int incing = (outnum > 0); @@ -100,7 +98,6 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, /* Compile format string */ ncomps = fmt_compile(fmtstr, &fmt) + 1; - FINDCOMP(bodycomp, "body"); FINDCOMP(datecomp, "date"); nxtbuf = compbuffers = (char **) calloc((size_t) ncomps, sizeof(char *)); @@ -111,9 +108,8 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, if (used_buf == NULL) adios(NULL, "unable to allocate component buffer stack"); used_buf += ncomps+1; *--used_buf = 0; - rlwidth = bodycomp && (width > SBUFSIZ) ? width : SBUFSIZ; for (i = ncomps; i--; ) - *nxtbuf++ = mh_xmalloc(rlwidth); + *nxtbuf++ = mh_xmalloc(SBUFSIZ); } /* @@ -130,7 +126,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, ** Get the first field. If the message is non-empty ** and we're doing an "inc", open the output file. */ - if ((state = m_getfld(FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) { + if ((state = m_getfld(FLD, name, tmpbuf, SBUFSIZ, inb)) == FILEEOF) { if (ferror(inb)) { advise("read", "unable to"); /* "read error" */ return SCNFAT; @@ -160,7 +156,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, /* scan - main loop */ for (compnum = 1; ; - state = m_getfld(state, name, tmpbuf, rlwidth, inb)) { + state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb)) { switch (state) { case FLD: case FLDPLUS: @@ -196,7 +192,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, } while (state == FLDPLUS) { - state = m_getfld(state, name, tmpbuf, rlwidth, + state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb); if (incing) FPUTS(tmpbuf); @@ -279,12 +275,6 @@ finished: return SCNFAT; } - /* Save and restore buffer so we don't trash our dynamic pool! */ - if (bodycomp) { - saved_c_text = bodycomp->c_text; - bodycomp->c_text = tmpbuf; - } - if (incing) { if ((dat[2] = ftell(scnout)) == EOF) adios(scnmsg, "write error on"); @@ -315,9 +305,6 @@ finished: if (fmtstr) fputs(scanl, stdout); - if (bodycomp) - bodycomp->c_text = saved_c_text; - /* return dynamically allocated buffers to pool */ while ((cptr = *savecomp++)) { *--nxtbuf = cptr->c_text; -- 1.7.10.4