aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-01-12 20:42:08 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-01-12 20:42:08 +0200
commit624d70844fe63068132adb7c66ea3f8a231e56a7 (patch)
tree79781e2b0e24b5e478804001c83fcde64602f502 /io.c
parentda83b6857bf0a67b15fc75d31a0b6802ac9baffe (diff)
parentf934f2192779db0091d1706d97d1fd43cb26dc9a (diff)
downloadegawk-624d70844fe63068132adb7c66ea3f8a231e56a7.tar.gz
egawk-624d70844fe63068132adb7c66ea3f8a231e56a7.tar.bz2
egawk-624d70844fe63068132adb7c66ea3f8a231e56a7.zip
Merge branch 'master' into comment
Diffstat (limited to 'io.c')
-rw-r--r--io.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/io.c b/io.c
index e0632d8b..3e527da0 100644
--- a/io.c
+++ b/io.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2013 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-2014 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -116,7 +116,16 @@
#define ENFILE EMFILE
#endif
+#if defined(__DJGPP__)
+#define closemaybesocket(fd) close(fd)
+#endif
+
#if defined(VMS)
+#include <ssdef.h>
+#ifndef SS$_EXBYTLM
+#define SS$_EXBYTLM 0x2a14 /* VMS 8.4 seen */
+#endif
+#include <rmsdef.h>
#define closemaybesocket(fd) close(fd)
#endif
@@ -458,6 +467,11 @@ nextfile(IOBUF **curfile, bool skipping)
/* IOBUF management: */
errno = 0;
fd = devopen(fname, binmode("r"));
+ if (fd == INVALID_HANDLE && errno == EMFILE) {
+ close_one();
+ close_one();
+ fd = devopen(fname, binmode("r"));
+ }
errcode = errno;
if (! do_traditional)
update_ERRNO_int(errno);
@@ -944,10 +958,13 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
if (errno == EMFILE || errno == ENFILE)
close_one();
#ifdef VMS
- /* Alpha/VMS V7.1's C RTL is returning this instead
+ /* Alpha/VMS V7.1+ C RTL is returning these instead
of EMFILE (haven't tried other post-V6.2 systems) */
-#define SS$_EXQUOTA 0x001C
- else if (errno == EIO && vaxc$errno == SS$_EXQUOTA)
+ else if ((errno == EIO || errno == EVMSERR) &&
+ (vaxc$errno == SS$_EXQUOTA ||
+ vaxc$errno == SS$_EXBYTLM ||
+ vaxc$errno == RMS$_ACC ||
+ vaxc$errno == RMS$_SYN))
close_one();
#endif
else {
@@ -1261,12 +1278,15 @@ flush_io()
int status = 0;
errno = 0;
+ /* we don't warn about stdout/stderr if EPIPE, but we do error exit */
if (fflush(stdout)) {
- warning(_("error writing standard output (%s)"), strerror(errno));
+ if (errno != EPIPE)
+ warning(_("error writing standard output (%s)"), strerror(errno));
status++;
}
if (fflush(stderr)) {
- warning(_("error writing standard error (%s)"), strerror(errno));
+ if (errno != EPIPE)
+ warning(_("error writing standard error (%s)"), strerror(errno));
status++;
}
for (rp = red_head; rp != NULL; rp = rp->next)
@@ -1316,13 +1336,16 @@ close_io(bool *stdio_problem)
* them, we just flush them, and do that across the board.
*/
*stdio_problem = false;
- if (fflush(stdout)) {
- warning(_("error writing standard output (%s)"), strerror(errno));
+ /* we don't warn about stdout/stderr if EPIPE, but we do error exit */
+ if (fflush(stdout) != 0) {
+ if (errno != EPIPE)
+ warning(_("error writing standard output (%s)"), strerror(errno));
status++;
*stdio_problem = true;
}
- if (fflush(stderr)) {
- warning(_("error writing standard error (%s)"), strerror(errno));
+ if (fflush(stderr) != 0) {
+ if (errno != EPIPE)
+ warning(_("error writing standard error (%s)"), strerror(errno));
status++;
*stdio_problem = true;
}
@@ -2626,7 +2649,10 @@ do_find_source(const char *src, struct stat *stb, int *errcode, path_info *pi)
return NULL;
}
erealloc(path, char *, strlen(path) + strlen(src) + 2, "do_find_source");
-#ifndef VMS
+#ifdef VMS
+ if (strcspn(path,">]:") == strlen(path))
+ strcat(path, "/");
+#else
strcat(path, "/");
#endif
strcat(path, src);