aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-09-23 20:07:54 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-09-23 20:07:54 +0300
commit2a4725673f46d42cddff89b7002b193c67222c85 (patch)
tree1cff0b8c26f43269f9f62e3f1010f1b2b42b1fa5 /io.c
parent6641754c13e38dd6198832f23aa2be4b4546b324 (diff)
parent32649f52d26b1c3a6d09ffbca04928b476698713 (diff)
downloadegawk-2a4725673f46d42cddff89b7002b193c67222c85.tar.gz
egawk-2a4725673f46d42cddff89b7002b193c67222c85.tar.bz2
egawk-2a4725673f46d42cddff89b7002b193c67222c85.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/io.c b/io.c
index 7930904d..7154a710 100644
--- a/io.c
+++ b/io.c
@@ -1550,6 +1550,17 @@ nextrres:
* change the string.
*/
+/*
+ * 9/2014: Flow here is a little messy.
+ *
+ * For do_posix, we don't allow any of the special filenames.
+ *
+ * For do_traditional, we allow /dev/{stdin,stdout,stderr} since BWK awk
+ * (and mawk) support them. But we don't allow /dev/fd/N or /inet.
+ *
+ * Note that for POSIX systems os_devopen() is a no-op.
+ */
+
int
devopen(const char *name, const char *mode)
{
@@ -1565,7 +1576,7 @@ devopen(const char *name, const char *mode)
flag = str2mode(mode);
openfd = INVALID_HANDLE;
- if (do_traditional)
+ if (do_posix)
goto strictopen;
if ((openfd = os_devopen(name, flag)) != INVALID_HANDLE) {
@@ -1582,6 +1593,8 @@ devopen(const char *name, const char *mode)
openfd = fileno(stdout);
else if (strcmp(cp, "stderr") == 0 && (flag & O_ACCMODE) == O_WRONLY)
openfd = fileno(stderr);
+ else if (do_traditional)
+ goto strictopen;
else if (strncmp(cp, "fd/", 3) == 0) {
struct stat sbuf;
@@ -1594,6 +1607,8 @@ devopen(const char *name, const char *mode)
/* do not set close-on-exec for inherited fd's */
if (openfd != INVALID_HANDLE)
return openfd;
+ } else if (do_traditional) {
+ goto strictopen;
} else if (inetfile(name, & isi)) {
#ifdef HAVE_SOCKETS
cp = (char *) name;