harden the crlf vs lf tests even more; use binary mode explicitly on OS/2

This commit is contained in:
tg
2015-07-09 20:52:43 +00:00
parent dcd8b6389b
commit edf76ec8e6
10 changed files with 80 additions and 43 deletions

10
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.298 2015/07/09 19:46:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.299 2015/07/09 20:52:40 tg Exp $");
extern char **environ;
@ -193,6 +193,12 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
ssize_t k;
#endif
#ifdef __OS2__
for (i = 0; i < 3; ++i)
if (!isatty(i))
setmode(i, O_BINARY);
#endif
/* do things like getpgrp() et al. */
chvt_reinit();
@ -1637,7 +1643,7 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist)
} while (len < 6);
/* check if this one works */
if ((i = open(tp->tffn, O_CREAT | O_EXCL | O_RDWR | O_BINARY,
if ((i = binopen3(tp->tffn, O_CREAT | O_EXCL | O_RDWR,
0600)) < 0 && errno != EEXIST)
goto maketemp_out;
} while (i < 0);