diff -wur ./mail.local/mail.local.c ./debian/patches/mail.local/mail.local.c --- ./mail.local/mail.local.c Tue Dec 29 18:42:53 1998 +++ ./debian/patches/mail.local/mail.local.c Sun May 7 17:30:14 2000 @@ -593,6 +593,7 @@ FILE *fp = NULL; time_t tval; int fd, eline; + int prevfl, fl = 1; char line[2048]; char tmpbuf[sizeof _PATH_LOCTMP + 1]; @@ -620,12 +621,13 @@ for (eline = 1; fgets(line, sizeof(line), stdin);) { size_t line_len = strlen(line); + prevfl=fl; if (line_len >= 2 && line[line_len - 2] == '\r' && line[line_len - 1] == '\n') { strcpy(line + line_len - 2, "\n"); } - if (lmtprcpts && line[0] == '.') { + if (prevfl && lmtprcpts && line[0] == '.') { char *src = line + 1, *dest = line; if (line[1] == '\n') @@ -634,7 +636,39 @@ *dest++ = *src++; *dest = '\0'; } - if (line[0] == '\n') + + fl=0; + if (line_len > 0) + { + if (line[line_len - 1] == '\n') + { + if (line_len >= 2 && + line[line_len - 2] == '\r') + { + line[line_len - 2] = '\n'; + line[line_len - 1] = '\0'; + line_len--; + } + fl = 1; + } + else if (line[line_len - 1] == '\r') + { + int peek; + /* Did we just miss the CRLF? */ + peek = fgetc(stdin); + if (peek == '\n') + { + line[line_len - 1] = '\n'; + fl = 1; + } + else + (void) ungetc(peek, stdin); + } + } + else + fl = 1; + + if (prevfl && line[0] == '\n') eline = 1; else { if (eline && line[0] == 'F' &&