From 10216cc37ad6dd9086aeacca813d3551b7c209ef Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 3 Jun 2013 19:50:22 +0300 Subject: Minor cleanups for init_socket function. --- io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index c8b1f9a1..4921c82f 100644 --- a/io.c +++ b/io.c @@ -294,10 +294,9 @@ init_io() { long tmout; -#ifdef HAVE_SOCKETS /* Only MinGW has a non-trivial implementation of this. */ init_sockets(); -#endif + /* * N.B.: all these hacks are to minimize the effect * on programs that do not care about timeout. -- cgit v1.2.3 From fe4f4f372625682b10d5df11fef3c6f643e13410 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 9 Jun 2013 06:15:42 +0300 Subject: Minor change in io.c:iop_finish. --- io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 4921c82f..a918c390 100644 --- a/io.c +++ b/io.c @@ -2996,8 +2996,6 @@ iop_finish(IOBUF *iop) if (isdir) iop->errcode = EISDIR; else { - struct stat sbuf; - iop->errcode = EIO; /* * Extensions can supply values that are not @@ -3005,8 +3003,10 @@ iop_finish(IOBUF *iop) * file descriptors. So check the fd before * trying to close it, which avoids errors * on some operating systems. + * + * The fcntl call works for Windows, too. */ - if (fstat(iop->public.fd, & sbuf) == 0) + if (fcntl(iop->public.fd, F_GETFL) >= 0) (void) close(iop->public.fd); iop->public.fd = INVALID_HANDLE; } -- cgit v1.2.3 From 612ea8d837f14a15a44c2d4941ff62c0ebf30461 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 11 Jun 2013 18:44:10 +0300 Subject: Improve fix for debugger on Windows. --- io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index a918c390..44530967 100644 --- a/io.c +++ b/io.c @@ -2731,11 +2731,18 @@ find_source(const char *src, struct stat *stb, int *errcode, int is_extlib) int srcopen(SRCFILE *s) { + int fd = INVALID_HANDLE; + if (s->stype == SRC_STDIN) - return fileno(stdin); - if (s->stype == SRC_FILE || s->stype == SRC_INC) - return devopen(s->fullpath, "r"); - return INVALID_HANDLE; + fd = fileno(stdin); + else if (s->stype == SRC_FILE || s->stype == SRC_INC) + fd = devopen(s->fullpath, "r"); + + /* set binary mode so that debugger byte offset calculations will be right */ + if (fd != INVALID_HANDLE) + os_setbinmode(fd, O_BINARY); + + return fd; } /* input parsers, mainly for use by extension functions */ -- cgit v1.2.3 From aff720deb9f0b4f5790aaf414ecb0ceff67d905a Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sat, 15 Jun 2013 21:56:52 +0300 Subject: Minor fix for io.c for VMS. --- io.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index 44530967..dad7c7b9 100644 --- a/io.c +++ b/io.c @@ -116,6 +116,10 @@ #define ENFILE EMFILE #endif +#if defined(VMS) +#define closemaybesocket(fd) close(fd) +#endif + #ifdef HAVE_SOCKETS #ifndef SHUT_RD @@ -3013,7 +3017,9 @@ iop_finish(IOBUF *iop) * * The fcntl call works for Windows, too. */ +#if defined(F_GETFL) if (fcntl(iop->public.fd, F_GETFL) >= 0) +#endif (void) close(iop->public.fd); iop->public.fd = INVALID_HANDLE; } -- cgit v1.2.3 From ab2409635268791a2696d864251590672f4954b4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 24 Jun 2013 19:34:04 +0300 Subject: Fix inconsistency in system vs pipes in non-socket Windows builds. io.c: Move #include "popen.h" out of the HAVE_SOCKETS condition, as this is needed for non-sockets builds as well. See http://lists.gnu.org/archive/html/bug-gawk/2013-06/msg00014.html for the details of the problem this caused. --- io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index dad7c7b9..dc41aea3 100644 --- a/io.c +++ b/io.c @@ -76,10 +76,6 @@ #include #endif /* HAVE_NETDB_H */ -#if defined(HAVE_POPEN_H) -#include "popen.h" -#endif - #ifndef HAVE_GETADDRINFO #include "missing_d/getaddrinfo.h" #endif @@ -108,6 +104,10 @@ #include #endif +#if defined(HAVE_POPEN_H) +#include "popen.h" +#endif + #ifdef __EMX__ #include #endif -- cgit v1.2.3 From 9ff2ae36ec0633b8017612b13224447c716bbcc2 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 8 Jul 2013 15:06:25 +0300 Subject: Make min be MIN. --- io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index dc41aea3..a1c902ba 100644 --- a/io.c +++ b/io.c @@ -3500,12 +3500,12 @@ get_a_record(char **out, /* pointer to pointer to data */ recm.rt_start = iop->off + recm.len; /* read more data, break if EOF */ -#ifndef min -#define min(x, y) (x < y ? x : y) +#ifndef MIN +#define MIN(x, y) (x < y ? x : y) #endif /* subtract one in read count to leave room for sentinel */ room_left = iop->end - iop->dataend - 1; - amt_to_read = min(iop->readsize, room_left); + amt_to_read = MIN(iop->readsize, room_left); if (amt_to_read < iop->readsize) { grow_iop_buffer(iop); @@ -3516,7 +3516,7 @@ get_a_record(char **out, /* pointer to pointer to data */ /* recalculate amt_to_read */ room_left = iop->end - iop->dataend - 1; - amt_to_read = min(iop->readsize, room_left); + amt_to_read = MIN(iop->readsize, room_left); } while (amt_to_read + iop->readsize < room_left) amt_to_read += iop->readsize; @@ -3526,7 +3526,7 @@ get_a_record(char **out, /* pointer to pointer to data */ * POSIX limits read to SSIZE_MAX. There are (bizarre) * systems where this amount is small. */ - amt_to_read = min(amt_to_read, SSIZE_MAX); + amt_to_read = MIN(amt_to_read, SSIZE_MAX); #endif iop->count = iop->public.read_func(iop->public.fd, iop->dataend, amt_to_read); -- cgit v1.2.3 From 0981cc089ea88f146a6c949146e73f88c1b295e9 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 24 Jul 2013 21:53:30 +0300 Subject: Fix compiling on MinGW. --- io.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index a1c902ba..59ddd115 100644 --- a/io.c +++ b/io.c @@ -185,10 +185,6 @@ #define INCREMENT_REC(X) X++ #endif -/* This is for fake directory file descriptors on systems that don't - allow to open() a directory. */ -#define FAKE_FD_VALUE 42 - typedef enum { CLOSE_ALL, CLOSE_TO, CLOSE_FROM } two_way_close_type; /* Several macros to make the code a bit clearer. */ -- cgit v1.2.3 From c3e4d0cf3f1fd24164e0a58db23b86b56c6dc7c8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 8 Sep 2013 12:46:20 +0200 Subject: Fixes based on problems from a static checker. --- io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'io.c') diff --git a/io.c b/io.c index 59ddd115..e0632d8b 100644 --- a/io.c +++ b/io.c @@ -1463,7 +1463,7 @@ socketopen(int family, int type, const char *localpname, #ifdef MSG_PEEK char buf[10]; struct sockaddr_storage remote_addr; - socklen_t read_len; + socklen_t read_len = 0; if (recvfrom(socket_fd, buf, 1, MSG_PEEK, (struct sockaddr *) & remote_addr, @@ -1915,6 +1915,7 @@ two_way_open(const char *str, struct redirect *rp) case -1: save_errno = errno; close(master); + close(slave); errno = save_errno; return false; -- cgit v1.2.3 From 25520aab6144927a20d501c0396e9597f36fc871 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 24 Oct 2013 22:03:09 +0300 Subject: Improve handling of writes to dead pipes. --- io.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index e0632d8b..3daadb32 100644 --- a/io.c +++ b/io.c @@ -1261,12 +1261,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 +1319,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; } -- cgit v1.2.3 From 7bc4e38b948e20f3d72e06662691a527a50eecbf Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 3 Dec 2013 22:13:49 +0200 Subject: VMS fixes in io.c. --- io.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 3daadb32..ce63ec7a 100644 --- a/io.c +++ b/io.c @@ -947,7 +947,10 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) /* Alpha/VMS V7.1's C RTL is returning this instead of EMFILE (haven't tried other post-V6.2 systems) */ #define SS$_EXQUOTA 0x001C - else if (errno == EIO && vaxc$errno == SS$_EXQUOTA) +#define SS$_EXBYTLM 0x2a14 /* VMS 8.4 seen */ + else if (errno == EIO && + (vaxc$errno == SS$_EXQUOTA || + vaxc$errno == SS$_EXBYTLM)) close_one(); #endif else { @@ -2632,7 +2635,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); -- cgit v1.2.3 From 4b44495a814afb5ed896ac21fe5aaeb4b3a1cd4a Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 10 Dec 2013 21:11:33 +0200 Subject: DJGPP fixes, including update pc/Makefile.tst. --- io.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index ce63ec7a..4f244532 100644 --- a/io.c +++ b/io.c @@ -116,6 +116,10 @@ #define ENFILE EMFILE #endif +#if defined(__DJGPP__) +#define closemaybesocket(fd) close(fd) +#endif + #if defined(VMS) #define closemaybesocket(fd) close(fd) #endif -- cgit v1.2.3