aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-02-08 19:45:44 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-02-08 19:45:44 +0200
commit2f9c84e82632cbce017a6d342acb3dede5e59e12 (patch)
tree8e4fdcfb76af851550d73ff8be5d27c53fe1cada /builtin.c
parent15a1d8d213380bd99b5dfe7f4cafcd6dedb8f0dc (diff)
downloadegawk-2f9c84e82632cbce017a6d342acb3dede5e59e12.tar.gz
egawk-2f9c84e82632cbce017a6d342acb3dede5e59e12.tar.bz2
egawk-2f9c84e82632cbce017a6d342acb3dede5e59e12.zip
Reset non-fatal-io to 31 December, add fixes from Andrew Schorr.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/builtin.c b/builtin.c
index e80d46d4..aa8caf09 100644
--- a/builtin.c
+++ b/builtin.c
@@ -131,10 +131,9 @@ wrerror:
/* otherwise die verbosely */
- if ( (rp != NULL && (rp->flag & RED_NON_FATAL) != 0)
- || is_non_fatal_std(fp)) {
+ if ((rp != NULL) ? is_non_fatal_redirect(rp->value) : is_non_fatal_std(fp))
update_ERRNO_int(errno);
- } else
+ else
fatal(_("%s to \"%s\" failed (%s)"), from,
rp ? rp->value : _("standard output"),
errno ? strerror(errno) : _("reason unknown"));
@@ -1649,7 +1648,7 @@ do_printf(int nargs, int redirtype)
redir_exp = TOP();
if (redir_exp->type != Node_val)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp));
- rp = redirect(redir_exp, redirtype, & errflg);
+ rp = redirect(redir_exp, redirtype, & errflg, true);
DEREF(redir_exp);
decr_sp();
}
@@ -1662,7 +1661,7 @@ do_printf(int nargs, int redirtype)
redir_exp = PEEK(nargs);
if (redir_exp->type != Node_val)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp));
- rp = redirect(redir_exp, redirtype, & errflg);
+ rp = redirect(redir_exp, redirtype, & errflg, true);
if (rp != NULL)
fp = rp->output.fp;
else if (errflg) {
@@ -2093,7 +2092,7 @@ do_print(int nargs, int redirtype)
redir_exp = PEEK(nargs);
if (redir_exp->type != Node_val)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp));
- rp = redirect(redir_exp, redirtype, & errflg);
+ rp = redirect(redir_exp, redirtype, & errflg, true);
if (rp != NULL)
fp = rp->output.fp;
else if (errflg) {
@@ -2161,7 +2160,7 @@ do_print_rec(int nargs, int redirtype)
assert(nargs == 0);
if (redirtype != 0) {
redir_exp = TOP();
- rp = redirect(redir_exp, redirtype, & errflg);
+ rp = redirect(redir_exp, redirtype, & errflg, true);
if (rp != NULL)
fp = rp->output.fp;
DEREF(redir_exp);
@@ -2169,17 +2168,17 @@ do_print_rec(int nargs, int redirtype)
} else
fp = output_fp;
+ if (errflg) {
+ update_ERRNO_int(errflg);
+ return;
+ }
+
if (fp == NULL)
return;
if (! field0_valid)
(void) get_field(0L, NULL); /* rebuild record */
- if (errflg) {
- update_ERRNO_int(errflg);
- return;
- }
-
f0 = fields_arr[0];
if (do_lint && (f0->flags & NULL_FIELD) != 0)