aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-10-13 11:27:13 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-10-13 11:27:13 +0300
commit0485d6bfe2417a7640ef95c9de6f48e1f35003fd (patch)
treef26c8a24a4a12bf9be5038f40e6a20a4f6e9aa79 /io.c
parent7504a8fbc86b327ad07c79c943b8fe2d253f256d (diff)
parent2a8c128ca91b42261720368e5d25431ee4362c70 (diff)
downloadegawk-0485d6bfe2417a7640ef95c9de6f48e1f35003fd.tar.gz
egawk-0485d6bfe2417a7640ef95c9de6f48e1f35003fd.tar.bz2
egawk-0485d6bfe2417a7640ef95c9de6f48e1f35003fd.zip
Merge branch 'master' into cmake
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;