From 549694bc88a7345c10551d13017fa8a0eccb8619 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 9 Dec 2012 20:02:07 +0200 Subject: Change BINMODE to use symbolic values. --- io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index c57aef2a..efdec065 100644 --- a/io.c +++ b/io.c @@ -233,12 +233,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; } @@ -1017,7 +1017,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->fp); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); rp->fp = NULL; @@ -2134,7 +2134,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; -- cgit v1.2.3 From 134fa0445295460d897661ee18027c645b2baa73 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 9 Dec 2012 21:35:46 +0200 Subject: Use posix_openpt() if available. --- io.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index efdec065..4b658950 100644 --- a/io.c +++ b/io.c @@ -1598,7 +1598,7 @@ two_way_open(const char *str, struct redirect *rp) if (! no_ptys && pty_vs_pipe(str)) { static int 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]; @@ -1615,7 +1615,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; @@ -1630,8 +1630,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; -- cgit v1.2.3