New upstream release

This commit is contained in:
Jakub Martisko 2019-06-24 09:33:25 +02:00
parent 3240dbaea1
commit 7b513a74c8
7 changed files with 2 additions and 2084 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/gawk-4.1.4.tar.xz
/gawk-4.2.0.tar.xz
/gawk-4.2.1.tar.xz
/gawk-5.0.1.tar.xz

File diff suppressed because it is too large Load Diff

View File

@ -1,309 +0,0 @@
From 47316d294571673a8dbf1e9e435893e2660f46a8 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Mon, 26 Mar 2018 10:45:01 +0300
Subject: [PATCH] Remove the tail recursion optimization.
---
awk.h | 4 ----
awkgram.y | 27 ++-------------------------
eval.c | 49 +++++++------------------------------------------
test/Makefile.am | 4 +++-
test/Makefile.in | 9 ++++++++-
test/Maketests | 5 +++++
test/tailrecurse.awk | 15 +++++++++++++++
test/tailrecurse.ok | 5 +++++
8 files changed, 45 insertions(+), 73 deletions(-)
create mode 100644 test/tailrecurse.awk
create mode 100644 test/tailrecurse.ok
diff --git a/awk.h b/awk.h
index 3b351c2..36e71f2 100644
--- a/awk.h
+++ b/awk.h
@@ -527,7 +527,6 @@ typedef struct exp_node {
#define func_node sub.nodep.x.extra
#define prev_frame_size sub.nodep.reflags
#define reti sub.nodep.l.li
-#define num_tail_calls sub.nodep.cnt
/* Node_var: */
#define var_value lnode
@@ -862,9 +861,6 @@ typedef struct exp_instruction {
/* Op_func_call, Op_func */
#define func_body x.xn
-/* Op_func_call */
-#define tail_call d.dl
-
/* Op_subscript */
#define sub_count d.dl
diff --git a/awkgram.y b/awkgram.y
index ad830a5..caed09e 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -993,20 +993,9 @@ non_compound_stmt
$$ = list_create($1);
(void) list_prepend($$, instruction(Op_push_i));
$$->nexti->memory = dupnode(Nnull_string);
- } else {
- if (do_optimize
- && $3->lasti->opcode == Op_func_call
- && strcmp($3->lasti->func_name, in_function) == 0
- ) {
- /* Do tail recursion optimization. Tail
- * call without a return value is recognized
- * in mk_function().
- */
- ($3->lasti + 1)->tail_call = true;
- }
-
+ } else
$$ = list_append($3, $1);
- }
+
$$ = add_pending_comment($$);
}
| simple_stmt statement_term
@@ -4736,18 +4725,6 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
thisfunc = fi->func_body;
assert(thisfunc != NULL);
- if (do_optimize && def->lasti->opcode == Op_pop) {
- /* tail call which does not return any value. */
-
- INSTRUCTION *t;
-
- for (t = def->nexti; t->nexti != def->lasti; t = t->nexti)
- ;
- if (t->opcode == Op_func_call
- && strcmp(t->func_name, thisfunc->vname) == 0)
- (t + 1)->tail_call = true;
- }
-
/* add any pre-function comment to start of action for profile.c */
if (function_comment != NULL) {
diff --git a/eval.c b/eval.c
index 6ece236..34ba174 100644
--- a/eval.c
+++ b/eval.c
@@ -674,7 +674,7 @@ void
dump_fcall_stack(FILE *fp)
{
NODE *f, *func;
- long i = 0, j, k = 0;
+ long i = 0, k = 0;
if (fcall_count == 0)
return;
@@ -682,15 +682,13 @@ dump_fcall_stack(FILE *fp)
/* current frame */
func = frame_ptr->func_node;
- for (j = 0; j <= frame_ptr->num_tail_calls; j++)
- fprintf(fp, "\t# %3ld. %s\n", k++, func->vname);
+ fprintf(fp, "\t# %3ld. %s\n", k++, func->vname);
/* outer frames except main */
for (i = 1; i < fcall_count; i++) {
f = fcall_list[i];
func = f->func_node;
- for (j = 0; j <= f->num_tail_calls; j++)
- fprintf(fp, "\t# %3ld. %s\n", k++, func->vname);
+ fprintf(fp, "\t# %3ld. %s\n", k++, func->vname);
}
fprintf(fp, "\t# %3ld. -- main --\n", k);
@@ -1242,38 +1240,16 @@ setup_frame(INSTRUCTION *pc)
NODE *m, *f, *fp;
NODE **sp = NULL;
int pcount, arg_count, i, j;
- bool tail_optimize = false;
f = pc->func_body;
pcount = f->param_cnt;
fp = f->fparms;
arg_count = (pc + 1)->expr_count;
- /* tail recursion optimization */
- tail_optimize = ((pc + 1)->tail_call && do_optimize
- && ! do_debug && ! do_profile);
-
- if (tail_optimize) {
- /* free local vars of calling frame */
-
- NODE *func;
- int n;
-
- func = frame_ptr->func_node;
- for (n = func->param_cnt, sp = frame_ptr->stack; n > 0; n--) {
- r = *sp++;
- if (r->type == Node_var) /* local variable */
- DEREF(r->var_value);
- else if (r->type == Node_var_array) /* local array */
- assoc_clear(r);
- }
- sp = frame_ptr->stack;
-
- } else if (pcount > 0) {
+ if (pcount > 0) {
ezalloc(sp, NODE **, pcount * sizeof(NODE *), "setup_frame");
}
-
/* check for extra args */
if (arg_count > pcount) {
warning(
@@ -1287,13 +1263,9 @@ setup_frame(INSTRUCTION *pc)
}
for (i = 0, j = arg_count - 1; i < pcount; i++, j--) {
- if (tail_optimize)
- r = sp[i];
- else {
- getnode(r);
- memset(r, 0, sizeof(NODE));
- sp[i] = r;
- }
+ getnode(r);
+ memset(r, 0, sizeof(NODE));
+ sp[i] = r;
if (i >= arg_count) {
/* local variable */
@@ -1348,11 +1320,6 @@ setup_frame(INSTRUCTION *pc)
stack_adj(-arg_count); /* adjust stack pointer */
- if (tail_optimize) {
- frame_ptr->num_tail_calls++;
- return f->code_ptr;
- }
-
if (pc->opcode == Op_indirect_func_call) {
r = POP(); /* indirect var */
DEREF(r);
@@ -1372,7 +1339,6 @@ setup_frame(INSTRUCTION *pc)
frame_ptr->stack = sp;
frame_ptr->prev_frame_size = (stack_ptr - stack_bottom); /* size of the previous stack frame */
frame_ptr->func_node = f;
- frame_ptr->num_tail_calls = 0;
frame_ptr->vname = NULL;
frame_ptr->reti = pc; /* on return execute pc->nexti */
@@ -1774,7 +1740,6 @@ init_interpret()
frame_ptr->type = Node_frame;
frame_ptr->stack = NULL;
frame_ptr->func_node = NULL; /* in main */
- frame_ptr->num_tail_calls = 0;
frame_ptr->vname = NULL;
/* initialize true and false nodes */
diff --git a/test/Makefile.am b/test/Makefile.am
index bf1dbd3..40e25b2 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1134,6 +1134,8 @@ EXTRA_DIST = \
synerr1.ok \
synerr2.awk \
synerr2.ok \
+ tailrecurse.awk \
+ tailrecurse.ok \
testext.ok \
time.awk \
time.ok \
@@ -1253,7 +1255,7 @@ BASIC_TESTS = \
sigpipe1 sortempty sortglos splitargv splitarr \
splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \
subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \
- tradanch tweakfld \
+ tailrecurse tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs uplus \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
zero2 zeroe0 zeroflag
diff --git a/test/Makefile.in b/test/Makefile.in
index f96151b..74405f8 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1392,6 +1392,8 @@ EXTRA_DIST = \
synerr1.ok \
synerr2.awk \
synerr2.ok \
+ tailrecurse.awk \
+ tailrecurse.ok \
testext.ok \
time.awk \
time.ok \
@@ -1510,7 +1512,7 @@ BASIC_TESTS = \
sigpipe1 sortempty sortglos splitargv splitarr \
splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \
subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \
- tradanch tweakfld \
+ tailrecurse tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs uplus \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
zero2 zeroe0 zeroflag
@@ -3919,6 +3921,11 @@ synerr2:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+tailrecurse:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
uninit2:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index e449dd3..4a90e3e 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1002,6 +1002,11 @@ synerr2:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+tailrecurse:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
uninit2:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/tailrecurse.awk b/test/tailrecurse.awk
new file mode 100644
index 0000000..b287d16
--- /dev/null
+++ b/test/tailrecurse.awk
@@ -0,0 +1,15 @@
+BEGIN {
+ abc(2)
+}
+
+
+function abc(c, A, B)
+{
+ print "abc(" c ", " length(A) ")"
+ if (! c--) {
+ return
+ }
+ B[""]
+ print length(B)
+ return abc(c, B)
+}
diff --git a/test/tailrecurse.ok b/test/tailrecurse.ok
new file mode 100644
index 0000000..73ce1ed
--- /dev/null
+++ b/test/tailrecurse.ok
@@ -0,0 +1,5 @@
+abc(2, 0)
+1
+abc(1, 1)
+1
+abc(0, 1)
--
2.14.4

View File

@ -1,208 +0,0 @@
From 0fafaee9bb38a3ea4b8be4009e9ce99334460ddd Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Mon, 2 Apr 2018 16:37:17 +0300
Subject: [PATCH] Copy MPZ/MPFR bits also, in r_dupnode.
---
interpret.h | 27 ++++++++++++++++++---------
node.c | 20 ++++++++++++++++++--
test/Makefile.am | 12 ++++++++++--
test/Makefile.in | 12 ++++++++++--
test/mpfrfield.awk | 14 ++++++++++++++
test/mpfrfield.in | 10 ++++++++++
test/mpfrfield.ok | 1 +
7 files changed, 81 insertions(+), 15 deletions(-)
create mode 100644 test/mpfrfield.awk
create mode 100644 test/mpfrfield.in
create mode 100644 test/mpfrfield.ok
diff --git a/interpret.h b/interpret.h
index 96e2c89..20fcb7a 100644
--- a/interpret.h
+++ b/interpret.h
@@ -32,16 +32,25 @@
* valref 1, that effectively means that this is an assignment like "$n = $n",
* so a no-op, other than triggering $0 reconstitution.
*/
-#define UNFIELD(l, r) \
-{ \
- /* if was a field, turn it into a var */ \
- if ((r->flags & MALLOC) != 0 || r->valref == 1) { \
- l = r; \
- } else { \
- l = dupnode(r); \
- DEREF(r); \
- } \
+
+// not a macro so we can step into it with a debugger
+#ifndef UNFIELD_DEFINED
+#define UNFIELD_DEFINED 1
+static inline void
+unfield(NODE **l, NODE **r)
+{
+ /* if was a field, turn it into a var */
+ if (((*r)->flags & MALLOC) != 0 || (*r)->valref == 1) {
+ (*l) = (*r);
+ } else {
+ (*l) = dupnode(*r);
+ DEREF(*r);
+ }
}
+
+#define UNFIELD(l, r) unfield(& (l), & (r))
+#endif
+
int
r_interpret(INSTRUCTION *code)
{
diff --git a/node.c b/node.c
index add959f..fcd2bf3 100644
--- a/node.c
+++ b/node.c
@@ -306,8 +306,24 @@ r_dupnode(NODE *n)
}
#endif
- getnode(r);
- *r = *n;
+#ifdef HAVE_MPFR
+ if ((n->flags & MPZN) != 0) {
+ r = mpg_integer();
+ mpz_set(r->mpg_i, n->mpg_i);
+ r->flags = n->flags;
+ } else if ((n->flags & MPFN) != 0) {
+ r = mpg_float();
+ int tval = mpfr_set(r->mpg_numbr, n->mpg_numbr, ROUND_MODE);
+ IEEE_FMT(r->mpg_numbr, tval);
+ r->flags = n->flags;
+ } else {
+#endif
+ getnode(r);
+ *r = *n;
+#ifdef HAVE_MPFR
+ }
+#endif
+
r->flags |= MALLOC;
r->valref = 1;
/*
diff --git a/test/Makefile.am b/test/Makefile.am
index 40e25b2..93a6ee5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -655,6 +655,9 @@ EXTRA_DIST = \
mpfrbigint.ok \
mpfrexprange.awk \
mpfrexprange.ok \
+ mpfrfield.awk \
+ mpfrfield.in \
+ mpfrfield.ok \
mpfrieee.awk \
mpfrieee.ok \
mpfrmemok1.awk \
@@ -1302,8 +1305,8 @@ INET_TESTS = inetdayu inetdayt inetechu inetecht
MACHINE_TESTS = double1 double2 fmtspcl intformat
-MPFR_TESTS = mpfrbigint mpfrexprange mpfrieee mpfrmemok1 mpfrnegzero \
- mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
+MPFR_TESTS = mpfrbigint mpfrexprange mpfrfield mpfrieee mpfrmemok1 \
+ mpfrnegzero mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
mpfrstrtonum mpgforcenum mpfruplus
LOCALE_CHARSET_TESTS = \
@@ -2148,6 +2151,11 @@ mpfrmemok1:
@$(AWK) -p- -M -f "$(srcdir)"/$@.awk 2>&1 | sed 1d > _$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+mpfrfield:
+ @echo $@
+ @$(AWK) -M -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in > _$@ 2>&1
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
jarebug::
@echo $@
@"$(srcdir)"/$@.sh "$(AWKPROG)" "$(srcdir)"/$@.awk "$(srcdir)"/$@.in "_$@"
diff --git a/test/Makefile.in b/test/Makefile.in
index 74405f8..2358988 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -913,6 +913,9 @@ EXTRA_DIST = \
mpfrbigint.ok \
mpfrexprange.awk \
mpfrexprange.ok \
+ mpfrfield.awk \
+ mpfrfield.in \
+ mpfrfield.ok \
mpfrieee.awk \
mpfrieee.ok \
mpfrmemok1.awk \
@@ -1555,8 +1558,8 @@ ARRAYDEBUG_TESTS = arrdbg
EXTRA_TESTS = inftest regtest ignrcas3
INET_TESTS = inetdayu inetdayt inetechu inetecht
MACHINE_TESTS = double1 double2 fmtspcl intformat
-MPFR_TESTS = mpfrbigint mpfrexprange mpfrieee mpfrmemok1 mpfrnegzero \
- mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
+MPFR_TESTS = mpfrbigint mpfrexprange mpfrfield mpfrieee mpfrmemok1 \
+ mpfrnegzero mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
mpfrstrtonum mpgforcenum mpfruplus
LOCALE_CHARSET_TESTS = \
@@ -2588,6 +2591,11 @@ mpfrmemok1:
@$(AWK) -p- -M -f "$(srcdir)"/$@.awk 2>&1 | sed 1d > _$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+mpfrfield:
+ @echo $@
+ @$(AWK) -M -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in > _$@ 2>&1
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
jarebug::
@echo $@
@"$(srcdir)"/$@.sh "$(AWKPROG)" "$(srcdir)"/$@.awk "$(srcdir)"/$@.in "_$@"
diff --git a/test/mpfrfield.awk b/test/mpfrfield.awk
new file mode 100644
index 0000000..35a97b7
--- /dev/null
+++ b/test/mpfrfield.awk
@@ -0,0 +1,14 @@
+#! /bin/gawk -Mf
+
+NR == 1 {
+ min = $1
+}
+
+{
+ if ($1 < min)
+ min = $1
+}
+
+END {
+ print "min", min
+}
diff --git a/test/mpfrfield.in b/test/mpfrfield.in
new file mode 100644
index 0000000..05d3344
--- /dev/null
+++ b/test/mpfrfield.in
@@ -0,0 +1,10 @@
+7
+9
+1
+3
+9
+1
+9
+5
+0
+8
diff --git a/test/mpfrfield.ok b/test/mpfrfield.ok
new file mode 100644
index 0000000..3736de4
--- /dev/null
+++ b/test/mpfrfield.ok
@@ -0,0 +1 @@
+min 0
--
2.14.4

View File

@ -1,129 +0,0 @@
From 50f617427403434dcca156fb081c1bdc7eb714b7 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Tue, 17 Apr 2018 15:44:57 +0300
Subject: [PATCH] Fix problem with rebuilding records if using API parser.
---
field.c | 5 +++++
test/Makefile.am | 10 +++++++++-
test/Makefile.in | 10 +++++++++-
test/readdir_retest.awk | 7 +++++++
4 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 test/readdir_retest.awk
diff --git a/field.c b/field.c
index 0d7e633..5296324 100644
--- a/field.c
+++ b/field.c
@@ -338,6 +338,11 @@ reset_record()
{
fields_arr[0] = force_string(fields_arr[0]);
purge_record();
+ if (api_parser_override) {
+ api_parser_override = false;
+ parse_field = normal_parse_field;
+ update_PROCINFO_str("FS", current_field_sep_str());
+ }
}
static void
diff --git a/test/Makefile.am b/test/Makefile.am
index 93a6ee5..f554606 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -906,6 +906,7 @@ EXTRA_DIST = \
readbuf.ok \
readdir.awk \
readdir0.awk \
+ readdir_retest.awk \
readfile2.awk \
readfile2.ok \
rebrackloc.awk \
@@ -1321,7 +1322,7 @@ SHLIB_TESTS = \
getfile \
inplace1 inplace2 inplace3 \
ordchr ordchr2 \
- readdir readdir_test readfile readfile2 revout \
+ readdir readdir_test readdir_retest readfile readfile2 revout \
revtwoway rwarray \
testext time
@@ -2279,6 +2280,12 @@ readdir_test:
@$(AWK) -lreaddir_test '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, $$4}' "$(top_srcdir)" > _$@
@-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+readdir_retest:
+ @echo $@
+ @$(AWK) -lreaddir -F/ -f $@.awk "$(top_srcdir)" > $@.ok
+ @$(AWK) -lreaddir_test -F/ -f $@.awk "$(top_srcdir)" > _$@
+ @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+
fts:
@case `uname` in \
IRIX) \
@@ -2500,6 +2507,7 @@ Maketests: $(srcdir)/Makefile.am $(srcdir)/Gentests
clean-local:
rm -fr _* core core.* fmtspcl.ok junk strftime.ok test1 test2 \
seq *~ readfile.ok fork.tmp.* testext.awk fts.ok readdir.ok \
+ readdir_test.ok readdir_retest.ok \
mmap8k.ok profile1.ok
# An attempt to print something that can be grepped for in build logs
diff --git a/test/Makefile.in b/test/Makefile.in
index 2358988..4133b58 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1164,6 +1164,7 @@ EXTRA_DIST = \
readbuf.ok \
readdir.awk \
readdir0.awk \
+ readdir_retest.awk \
readfile2.awk \
readfile2.ok \
rebrackloc.awk \
@@ -1574,7 +1575,7 @@ SHLIB_TESTS = \
getfile \
inplace1 inplace2 inplace3 \
ordchr ordchr2 \
- readdir readdir_test readfile readfile2 revout \
+ readdir readdir_test readdir_retest readfile readfile2 revout \
revtwoway rwarray \
testext time
@@ -2719,6 +2720,12 @@ readdir_test:
@$(AWK) -lreaddir_test '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, $$4}' "$(top_srcdir)" > _$@
@-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+readdir_retest:
+ @echo $@
+ @$(AWK) -lreaddir -F/ -f $@.awk "$(top_srcdir)" > $@.ok
+ @$(AWK) -lreaddir_test -F/ -f $@.awk "$(top_srcdir)" > _$@
+ @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+
fts:
@case `uname` in \
IRIX) \
@@ -4654,6 +4661,7 @@ Maketests: $(srcdir)/Makefile.am $(srcdir)/Gentests
clean-local:
rm -fr _* core core.* fmtspcl.ok junk strftime.ok test1 test2 \
seq *~ readfile.ok fork.tmp.* testext.awk fts.ok readdir.ok \
+ readdir_test.ok readdir_retest.ok \
mmap8k.ok profile1.ok
# An attempt to print something that can be grepped for in build logs
diff --git a/test/readdir_retest.awk b/test/readdir_retest.awk
new file mode 100644
index 0000000..079a993
--- /dev/null
+++ b/test/readdir_retest.awk
@@ -0,0 +1,7 @@
+# Test field values after reparsing
+FNR == 1 { record1 = $0 }
+{
+ printf "[%s] [%s] [%s] [%s]\n", $1, $2, $3, $4
+ $0 = record1
+ printf "[%s] [%s] [%s] [%s]\n", $1, $2, $3, $4
+}
--
2.14.4

View File

@ -1,116 +0,0 @@
From 06fe8e801efc0e6a098d93cf104157fb4ef705e8 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Sun, 17 Jun 2018 21:52:28 +0300
Subject: [PATCH] Fix a corner case with EPIPE to stdout/stderr.
---
awk.h | 2 +-
debug.c | 4 ++--
interpret.h | 6 +++++-
io.c | 9 ++++++++-
4 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/awk.h b/awk.h
index 36e71f2..cdf683d 100644
--- a/awk.h
+++ b/awk.h
@@ -1581,7 +1581,7 @@ extern struct redirect *redirect_string(const char *redir_exp_str,
int *errflg, int extfd, bool failure_fatal);
extern NODE *do_close(int nargs);
extern int flush_io(void);
-extern int close_io(bool *stdio_problem);
+extern int close_io(bool *stdio_problem, bool *got_EPIPE);
typedef enum { CLOSE_ALL, CLOSE_TO, CLOSE_FROM } two_way_close_type;
extern int close_rp(struct redirect *rp, two_way_close_type how);
extern int devopen_simple(const char *name, const char *mode, bool try_real_open);
diff --git a/debug.c b/debug.c
index 3e76ae6..a587d8f 100644
--- a/debug.c
+++ b/debug.c
@@ -5398,11 +5398,11 @@ save_options(const char *file)
static void
close_all()
{
- bool stdio_problem;
+ bool stdio_problem, got_EPIPE;
struct command_source *cs;
(void) nextfile(& curfile, true); /* close input data file */
- (void) close_io(& stdio_problem);
+ (void) close_io(& stdio_problem, & got_EPIPE);
if (cur_srcfile->fd != INVALID_HANDLE) {
close(cur_srcfile->fd);
cur_srcfile->fd = INVALID_HANDLE;
diff --git a/interpret.h b/interpret.h
index 20fcb7a..8408a53 100644
--- a/interpret.h
+++ b/interpret.h
@@ -110,6 +110,7 @@ top:
case Op_atexit:
{
bool stdio_problem = false;
+ bool got_EPIPE = false;
/* avoid false source indications */
source = NULL;
@@ -125,7 +126,7 @@ top:
* and pipes, in that it doesn't affect their exit status.
* So we no longer do either.
*/
- (void) close_io(& stdio_problem);
+ (void) close_io(& stdio_problem, & got_EPIPE);
/*
* However, we do want to exit non-zero if there was a problem
* with stdout/stderr, so we reinstate a slightly different
@@ -135,6 +136,9 @@ top:
exit_val = 1;
close_extensions();
+
+ if (got_EPIPE)
+ die_via_sigpipe();
}
break;
diff --git a/io.c b/io.c
index 1a1d8cc..faccb4b 100644
--- a/io.c
+++ b/io.c
@@ -1474,12 +1474,13 @@ flush_io()
/* close_io --- close all open files, called when exiting */
int
-close_io(bool *stdio_problem)
+close_io(bool *stdio_problem, bool *got_EPIPE)
{
struct redirect *rp;
struct redirect *next;
int status = 0;
+ *stdio_problem = *got_EPIPE = false;
errno = 0;
for (rp = red_head; rp != NULL; rp = next) {
next = rp->next;
@@ -1505,6 +1506,9 @@ close_io(bool *stdio_problem)
#endif
if (errno != EPIPE)
warning(_("error writing standard output (%s)"), strerror(errno));
+ else
+ *got_EPIPE = true;
+
status++;
*stdio_problem = true;
}
@@ -1515,6 +1519,9 @@ close_io(bool *stdio_problem)
#endif
if (errno != EPIPE)
warning(_("error writing standard error (%s)"), strerror(errno));
+ else
+ *got_EPIPE = true;
+
status++;
*stdio_problem = true;
}
--
2.14.4

View File

@ -1 +1 @@
SHA512 (gawk-4.2.1.tar.xz) = 0e3006a795dc3ac91359a7d2590c0cccbfd39b18a1d491617d68505c55a2800355b1439050681b4fcacf65fb0d533151a046babe0fd774503037bab363ef2ae4
SHA512 (gawk-5.0.1.tar.xz) = ff9842a91035f843482d93eac8a35cddf2ce16acaa43a0112c1efff08802aebf705ee70d47eff74a190dca7be330c31f7204ad27cb63bdee65333f9b9c984212