--- read.orig.c Sat Jun 24 21:32:10 2000 +++ read.c Mon Sep 11 11:15:29 2000 @@ -2175,6 +2175,20 @@ readline (linebuffer, stream, flocp) ++nlines; #if defined(WIN32_OR_CYGWIN) || defined(__MSDOS__) + if ((len == 1 || len == 2) && p > buffer) +#else + if (len == 1 && p > buffer) +#endif + /* P is pointing at a newline and it's the beginning of + the buffer returned by the last fgets call. However, + it is not necessarily the beginning of a line if P is + pointing past the beginning of the holding buffer. + If the buffer was just enlarged (right before the newline), + we must account for that, so we pretend that the two lines + were one line. */ + len += lastlen; + +#if defined(WIN32_OR_CYGWIN) || defined(__MSDOS__) /* Check to see if the line was really ended with CRLF; if so ignore the CR. */ if (len > 1 && p[-2] == '\r') @@ -2185,15 +2199,6 @@ readline (linebuffer, stream, flocp) } #endif - if (len == 1 && p > buffer) - /* P is pointing at a newline and it's the beginning of - the buffer returned by the last fgets call. However, - it is not necessarily the beginning of a line if P is - pointing past the beginning of the holding buffer. - If the buffer was just enlarged (right before the newline), - we must account for that, so we pretend that the two lines - were one line. */ - len += lastlen; lastlen = len; backslash = 0; for (p2 = p - 2; --len > 0; --p2)