X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/55f65ae2d3baf60396d3359db952460939de03ca..db4a24d1ab8005f7512b66a160568cdc94e76c54:/uip/mhoutsbr.c diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index df23047e..88f610dd 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -326,15 +326,15 @@ writeQuoted (CT ct, FILE *out) { int fd; char *cp, *file; - char c, buffer[BUFSIZ]; + char c = '\0', buffer[BUFSIZ]; CE ce = &ct->c_cefile; + int n = 0; file = NULL; if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK) return NOTOK; while (fgets (buffer, sizeof(buffer) - 1, ce->ce_fp)) { - int n; cp = buffer + strlen (buffer) - 1; if ((c = *cp) == '\n') @@ -342,10 +342,9 @@ writeQuoted (CT ct, FILE *out) if (strncmp (cp = buffer, "From ", sizeof("From ") - 1) == 0) { fprintf (out, "=%02X", *cp++ & 0xff); - n = 3; - } else { - n = 0; + n += 3; } + for (; *cp; cp++) { if (n > CPERLIN - 3) { fputs ("=\n", out); @@ -379,11 +378,13 @@ three_print: fputs ("=\n", out); putc ('\n', out); - } else { - fputs ("=\n", out); + n = 0; } } + if (c != '\n') + putc ('\n', out); + (*ct->c_ceclosefnx) (ct); return OK; } @@ -404,7 +405,7 @@ writeBase64ct (CT ct, FILE *out) if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK) return NOTOK; - result = writeBase64aux (ce->ce_fp, out); + result = writeBase64aux (ce->ce_fp, out, (ct->c_type == CT_TEXT)); (*ct->c_ceclosefnx) (ct); return result; }