diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-12-09 21:46:24 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-12-09 21:46:24 +0200 |
commit | 28f187d2b3871c0e76d301b51c4b4855bd3c56e4 (patch) | |
tree | b6b56858a715d6402d14da96f78cd9b013e61f18 /io.c | |
parent | f634938f90ef8c85cfd9ca7421f10f4b70c0137e (diff) | |
parent | 134fa0445295460d897661ee18027c645b2baa73 (diff) | |
download | egawk-28f187d2b3871c0e76d301b51c4b4855bd3c56e4.tar.gz egawk-28f187d2b3871c0e76d301b51c4b4855bd3c56e4.tar.bz2 egawk-28f187d2b3871c0e76d301b51c4b4855bd3c56e4.zip |
Merge branch 'gawk-4.0-stable'
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -290,12 +290,12 @@ binmode(const char *mode) { switch (mode[0]) { case 'r': - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) mode = "rb"; break; case 'w': case 'a': - if ((BINMODE & 2) != 0) + if ((BINMODE & BINMODE_OUTPUT) != 0) mode = (mode[0] == 'w' ? "wb" : "ab"); break; } @@ -1114,7 +1114,7 @@ close_rp(struct redirect *rp, two_way_close_type how) } else if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) { /* write to pipe */ status = pclose(rp->output.fp); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); rp->output.fp = NULL; @@ -1697,7 +1697,7 @@ two_way_open(const char *str, struct redirect *rp) if (! no_ptys && pty_vs_pipe(str)) { static bool initialized = false; static char first_pty_letter; -#ifdef HAVE_GRANTPT +#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT) static int have_dev_ptmx; #endif char slavenam[32]; @@ -1714,7 +1714,7 @@ two_way_open(const char *str, struct redirect *rp) if (! initialized) { initialized = true; -#ifdef HAVE_GRANTPT +#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT) have_dev_ptmx = (stat("/dev/ptmx", & statb) >= 0); #endif i = 0; @@ -1729,8 +1729,13 @@ two_way_open(const char *str, struct redirect *rp) } #ifdef HAVE_GRANTPT +#ifdef HAVE_POSIX_OPENPT + { + master = posix_openpt(O_RDWR|O_NOCTTY); +#else if (have_dev_ptmx) { master = open("/dev/ptmx", O_RDWR); +#endif if (master >= 0) { char *tem; @@ -2255,7 +2260,7 @@ gawk_popen(const char *cmd, struct redirect *rp) os_restore_mode(fileno(stdin)); current = popen(cmd, binmode("r")); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); if (current == NULL) return NULL; |