diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index d288fde2c2cef606a60507a7a56b81352ab5d06e..ee6ca0ebcd0a9ad63da79575f6bc26116b5606c2 100644 (file)
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
}
static struct strbuf buf = STRBUF_INIT;
+static int keep_cr;
/* Called with the first line (potentially partial)
* already in buf[] -- normally that should begin with
* "From " and having something that looks like a date format.
*/
for (;;) {
+ if (!keep_cr && buf.len > 1 && buf.buf[buf.len-1] == '\n' &&
+ buf.buf[buf.len-2] == '\r') {
+ strbuf_setlen(&buf, buf.len-2);
+ strbuf_addch(&buf, '\n');
+ }
+
if (fwrite(buf.buf, 1, buf.len, output) != buf.len)
die_errno("cannot write output");
nr = strtol(arg+2, NULL, 10);
} else if ( arg[1] == 'b' && !arg[2] ) {
allow_bare = 1;
+ } else if (!strcmp(arg, "--keep-cr")) {
+ keep_cr = 1;
} else if ( arg[1] == 'o' && arg[2] ) {
dir = arg+2;
} else if ( arg[1] == '-' && !arg[2] ) {