Read in text mode in a needed place only

Converting CR+LF to LF in blocking_read() which is a underlying read
function, may affect to the functions which do not perform line-based
operation.

    modified:   funcs.c
    modified:   main.c
    modified:   misc.c
    modified:   os2.c
    modified:   shf.c
This commit is contained in:
KO Myung-Hun
2016-12-17 17:04:37 +09:00
parent 18ff277047
commit 20dbf6b45b
5 changed files with 31 additions and 11 deletions

16
shf.c
View File

@@ -518,7 +518,23 @@ shf_getse(char *buf, ssize_t bsize, struct shf *shf)
shf->rnleft -= ncopy;
buf += ncopy;
bsize -= ncopy;
#ifdef __OS2__
if (end && buf > orig_buf + 1 && buf[-2] == '\r') {
buf--;
bsize++;
buf[-1] = '\n';
}
#endif
} while (!end && bsize);
#ifdef __OS2__
if (!bsize && buf[-1] == '\r') {
int c = shf_getc(shf);
if (c == '\n')
buf[-1] = '\n';
else if (c != -1)
shf_ungetc(c, shf);
}
#endif
*buf = '\0';
return (buf);
}