diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-05-11 03:07:11 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-05-11 03:07:11 +0000 |
commit | 0746a554bf1fa07af8e00cb7b5f06ba96862137f (patch) | |
tree | 3a4e448000d9adfea17428977451cfb6e6396f3f /usr.bin/mail | |
parent | afb22517a4b42f28d916681663def4e7188d56b8 (diff) | |
download | FreeBSD-src-0746a554bf1fa07af8e00cb7b5f06ba96862137f.zip FreeBSD-src-0746a554bf1fa07af8e00cb7b5f06ba96862137f.tar.gz |
Allow mail(1) to be able to read Eudora mailboxes by transforming
lines that end in <CR><LF> to just <LF>.
Reviewed by: imp
Obtained from: OpenBSD
Diffstat (limited to 'usr.bin/mail')
-rw-r--r-- | usr.bin/mail/fio.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c index 2bf9963..fe6480a 100644 --- a/usr.bin/mail/fio.c +++ b/usr.bin/mail/fio.c @@ -94,6 +94,16 @@ setptr(ibuf) return; } count = strlen(linebuf); + /* + * Transforms lines ending in <CR><LF> to just <LF>. + * This allows mail to be able to read Eudora mailboxes. + */ + if (count >= 2 && linebuf[count - 1] == '\n' && + linebuf[count - 2] == '\r') { + count--; + linebuf[count - 1] = '\n'; + } + (void) fwrite(linebuf, sizeof *linebuf, count, otf); if (ferror(otf)) errx(1, "/tmp"); @@ -160,7 +170,7 @@ putline(obuf, linebuf) /* * Read up a line from the specified input into the line * buffer. Return the number of characters read. Do not - * include the newline at the end. + * include the newline (or carriage return) at the end. */ int readline(ibuf, linebuf, linesize) @@ -176,6 +186,8 @@ readline(ibuf, linebuf, linesize) n = strlen(linebuf); if (n > 0 && linebuf[n - 1] == '\n') linebuf[--n] = '\0'; + if (n > 0 && linebuf[n - 1] == '\r') + linebuf[--n] = '\0'; return n; } |