diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-12-01 22:42:07 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-12-01 22:42:07 +0200 |
commit | f77e1318c515d495ac9c08bdfdf2dadf79a9649f (patch) | |
tree | 10811b68fc7b1af1909213db7b991d79e580c0a9 /pc | |
parent | 4285d605b8c0cbe4e0b15724af1b4bd223f25403 (diff) | |
download | egawk-f77e1318c515d495ac9c08bdfdf2dadf79a9649f.tar.gz egawk-f77e1318c515d495ac9c08bdfdf2dadf79a9649f.tar.bz2 egawk-f77e1318c515d495ac9c08bdfdf2dadf79a9649f.zip |
Convert w32_maybe_set_errno to os_maybe_set_errno.
Diffstat (limited to 'pc')
-rw-r--r-- | pc/ChangeLog | 5 | ||||
-rw-r--r-- | pc/gawkmisc.pc | 38 |
2 files changed, 25 insertions, 18 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog index ba9334fd..d2b2c564 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,8 @@ +2021-12-01 Arnold D. Robbins <arnold@skeeve.com> + + * gawkmisc.pc (os_maybe_set_errno): Renamed from + w32_maybe_set_errno. Add check for errno values. + 2021-11-21 Arnold D. Robbins <arnold@skeeve.com> * Makefile.tst: Regenerated. diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc index 1843a168..149ea62c 100644 --- a/pc/gawkmisc.pc +++ b/pc/gawkmisc.pc @@ -1066,25 +1066,27 @@ w32_status_to_termsig (unsigned status) } void -w32_maybe_set_errno (void) +os_maybe_set_errno (void) { - DWORD w32err = GetLastError (); - - switch (w32err) - { - /* When stdout is redirected to a pipe, and the program that - reads the pipe (e.g., a pager) exits, Windows doesn't set - errno to a useful value. Help it DTRT. */ - case ERROR_BAD_PIPE: - case ERROR_PIPE_BUSY: - case ERROR_NO_DATA: - case ERROR_PIPE_NOT_CONNECTED: - errno = EPIPE; - break; - default: - errno = EINVAL; - break; - } + if (errno == 0 || errno == EINVAL) { + DWORD w32err = GetLastError (); + + switch (w32err) + { + /* When stdout is redirected to a pipe, and the program that + reads the pipe (e.g., a pager) exits, Windows doesn't set + errno to a useful value. Help it DTRT. */ + case ERROR_BAD_PIPE: + case ERROR_PIPE_BUSY: + case ERROR_NO_DATA: + case ERROR_PIPE_NOT_CONNECTED: + errno = EPIPE; + break; + default: + errno = EINVAL; + break; + } + } } #endif /* __MINGW32__ */ |