From: Ken Hornstein Date: Sat, 24 Mar 2012 05:16:42 +0000 (-0400) Subject: Revert commit 255d4c646c0d7aa6b049052fef47fa083b1b1506 and solve X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=59b086daa57105e8fbd8b1e6ba60be6a845faf95;p=mmh Revert commit 255d4c646c0d7aa6b049052fef47fa083b1b1506 and solve the problem another way. The component parser needs to save the newlines so it can combine multiple headers properly. So for us, strip out any trailing newlines when we call fmt_scan(). --- diff --git a/h/fmt_scan.h b/h/fmt_scan.h index dbe955f..ed4e2f0 100644 --- a/h/fmt_scan.h +++ b/h/fmt_scan.h @@ -39,6 +39,7 @@ struct comp { #define CF_TRUE (1<<0) /* usually means component is present */ #define CF_PARSED (1<<1) /* address/date has been parsed */ #define CF_DATEFAB (1<<2) /* datefield fabricated */ +#define CF_TRIMMED (1<<3) /* Component has been trimmed */ extern int fmt_norm; diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 29b87d0..b194235 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -313,6 +313,21 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) case FT_PARSEDATE: fmt->f_comp->c_flags &= ~CF_PARSED; break; + case FT_COMP: + case FT_COMPF: + case FT_LS_COMP: + case FT_LS_DECODECOMP: + /* + * Trim these components of any newlines + */ + if (! (fmt->f_comp->c_flags & CF_TRIMMED) && + fmt->f_comp->c_text) { + int i = strlen(fmt->f_comp->c_text); + if (fmt->f_comp->c_text[i - 1] == '\n') + fmt->f_comp->c_text[i - 1] = '\0'; + fmt->f_comp->c_flags |= CF_TRIMMED; + } + break; } fmt = format; diff --git a/uip/fmtdump.c b/uip/fmtdump.c index 6566317..26a6e58 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -470,13 +470,14 @@ c_flagsstr(int t) static char buf[64]; buf[0] = '\0'; - if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB)) + if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB|CF_TRIMMED)) printf(buf, "0x%x ", t); strcat(buf, "<"); i = 0; FNORD(CF_TRUE, "TRUE"); FNORD(CF_PARSED, "PARSED"); FNORD(CF_DATEFAB, "DATEFAB"); + FNORD(CF_TRIMMED, "TRIMMED"); strcat(buf, ">"); return(buf); } diff --git a/uip/replsbr.c b/uip/replsbr.c index e2f63c5..613b3d9 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -164,9 +164,7 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, if (!mh_strcasecmp(name, cptr->c_name)) { char_read += msg_count; if (! cptr->c_text) { - i = strlen(cptr->c_text = tmpbuf) - 1; - if (tmpbuf[i] == '\n') - tmpbuf[i] = '\0'; + cptr->c_text = tmpbuf; *--savecomp = cptr; tmpbuf = *nxtbuf++; } else {