]> git.marmaro.de Git - mmh/commitdiff
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 dbe955fc562cbacaed271ffc0c566170277c4cc3..ed4e2f0d68fe4d821a057fda3e5dcefe103fda48 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 29b87d02713d18cf26b2f0c0250150429210adee..b1942350de9f729689805e1c35e0ba3c0e411a78 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 656631753c30ed583fb2914ce50092317753f054..26a6e58cd80ba7138cfa3538316e41acf49bc8d9 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 e2f63c578a8676e116b2b6a955556b3c334bfa45..613b3d9d7326685537c19d4b435d25823c16807a 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 {