Revert commit 255d4c646c0d7aa6b049052fef47fa083b1b1506 and solve
authorKen Hornstein <kenh@pobox.com>
Sat, 24 Mar 2012 05:16:42 +0000 (01:16 -0400)
committerKen Hornstein <kenh@pobox.com>
Sat, 24 Mar 2012 05:16:42 +0000 (01:16 -0400)
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().

h/fmt_scan.h
sbr/fmt_scan.c
uip/fmtdump.c
uip/replsbr.c

index dbe955f..ed4e2f0 100644 (file)
@@ -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;
 
index 29b87d0..b194235 100644 (file)
@@ -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;
index 6566317..26a6e58 100644 (file)
@@ -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);
 }
index e2f63c5..613b3d9 100644 (file)
@@ -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 {