aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-09-23 20:04:21 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-09-23 20:04:21 +0300
commitffab492af7444f26e3eb4945700cf72841a36e6e (patch)
tree2eb63dfcf2d1ec7cf7bc6debb26d2ef8d5e6d17a /io.c
parentfc9b58482ce186b2fa0461351d4e060735e21b78 (diff)
downloadegawk-ffab492af7444f26e3eb4945700cf72841a36e6e.tar.gz
egawk-ffab492af7444f26e3eb4945700cf72841a36e6e.tar.bz2
egawk-ffab492af7444f26e3eb4945700cf72841a36e6e.zip
Rework handling of special files, and doc thereof.
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;