X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d0bd14488c8392bcbbaa444759bae9c735178475..76ddfab4d76264b1cb30d7df642965c141e61545:/uip/mhoutsbr.c diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index aac061dd..db64c4b8 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -161,7 +161,14 @@ output_content (CT ct, FILE *out) default: switch (ct->c_encoding) { case CE_7BIT: - putc ('\n', out); + /* Special case: if this is a non-MIME message with no + body, don't emit the newline that would appear between + the headers and body. In that case, the call to + write8Bit() shouldn't be needed, but is harmless. */ + if (ct->c_ctinfo.ci_attrs[0] != NULL || + ct->c_begin != ct->c_end) { + putc ('\n', out); + } result = write8Bit (ct, out); break; @@ -291,6 +298,7 @@ static int write8Bit (CT ct, FILE *out) { int fd; + size_t inbytes; char c, *file, buffer[BUFSIZ]; CE ce = ct->c_cefile; @@ -299,9 +307,9 @@ write8Bit (CT ct, FILE *out) return NOTOK; c = '\n'; - while (fgets (buffer, sizeof(buffer) - 1, ce->ce_fp)) { - c = buffer[strlen (buffer) - 1]; - fputs (buffer, out); + while ((inbytes = fread (buffer, 1, sizeof buffer, ce->ce_fp)) > 0) { + c = buffer[inbytes - 1]; + fwrite (buffer, 1, inbytes, out); } if (c != '\n') putc ('\n', out);