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
This commit is contained in:
Mike Heffner 2001-05-11 03:07:11 +00:00
parent 66b166c994
commit afa3a100e9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76455

View File

@ -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;
}