- if (stream->textMode)
- {
- if (t > stream->endbuf)
- {
- if ((t - stream->upto) > 1)
- {
- if (*(t - 2) == '\r') /* t is protected, u isn't */
- {
- processed -= 1; /* preparation for add */
- }
- }
- leave = 0;
- }
- else
- {
- if ((*(t - 2) == '\r') && (*(t - 1) == '\n'))
- {
- *(u - 2) = '\n';
- *(u - 1) = '\0';
- }
- else
- {
- t--;
- *(u - 1) = '\0';
- }
- }
- }
- else if (t > stream->endbuf)
- {
- leave = 0;
- }
- else
- {
- *u = '\0';
- }
- if (leave)
- {
- stream->upto = t;
- if (stream->textMode)
- {
- stream->quickText = 1;
- }
- return (s);
- }
- }
- processed += (int)(t - stream->upto) - 1;
- u--;
- stream->bufStartR += (stream->endbuf - stream->fbuf);
-#ifdef __OS2__
- rc = DosRead(stream->hfile, stream->fbuf, stream->szfbuf, &actualRead);
- if (rc != 0)
- {
- actualRead = 0;
- stream->errorInd = 1;
- errno = rc;
- }
-#endif
-#ifdef __MSDOS__
- actualRead = __read(stream->hfile,
- stream->fbuf,
- stream->szfbuf,
- &errind);
- if (errind)
- {
- errno = actualRead;
- actualRead = 0;
- stream->errorInd = 1;
- }
-#endif
- stream->endbuf = stream->fbuf + actualRead;
- *stream->endbuf = '\n';
- if (actualRead == 0)
- {
- *u = '\0';
- if ((u - s) <= 1)
- {
- stream->eofInd = 1;
- return (NULL);
- }
- else
- {
- return (s);
- }
- }
- stream->upto = stream->fbuf;
- }