Merge pull request !1 from syyhao/init
This commit is contained in:
openeuler-ci-bot 2020-01-13 09:21:07 +08:00 committed by Gitee
commit f4da2df07e
20 changed files with 8 additions and 3227 deletions

View File

@ -1,298 +0,0 @@
From e0da6e47c9d1eaafcbe2b26c2ac9c5304b755efd Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Thu, 18 Apr 2019 20:15:15 +0300
Subject: [PATCH] Fix core dump upon syntax error.
---
awk.h | 1 +
awkgram.c | 2 +-
awkgram.y | 2 +-
command.c | 14 +++++++-------
command.y | 14 +++++++-------
main.c | 6 ++++++
test/Makefile.am | 4 +++-
test/Makefile.in | 9 ++++++++-
test/Maketests | 5 +++++
test/synerr3.awk | 1 +
test/synerr3.ok | 5 +++++
11 files changed, 45 insertions(+), 18 deletions(-)
create mode 100644 test/synerr3.awk
create mode 100644 test/synerr3.ok
diff --git a/awk.h b/awk.h
index cdf683d1..679cbde5 100644
--- a/awk.h
+++ b/awk.h
@@ -1114,6 +1114,7 @@ extern NODE *Null_field;
extern NODE **fields_arr;
extern int sourceline;
extern char *source;
+extern int errcount;
extern int (*interpret)(INSTRUCTION *); /* interpreter routine */
extern NODE *(*make_number)(double); /* double instead of AWKNUM on purpose */
extern NODE *(*str2number)(NODE *);
diff --git a/awkgram.c b/awkgram.c
index d3c4e830..878a83a9 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -173,7 +173,7 @@ static int continue_allowed; /* kludge for continue */
static char *tokstart = NULL;
static char *tok = NULL;
static char *tokend;
-static int errcount = 0;
+int errcount = 0;
extern char *source;
extern int sourceline;
diff --git a/awkgram.y b/awkgram.y
index caed09e0..c16616f9 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -133,7 +133,7 @@ static int continue_allowed; /* kludge for continue */
static char *tokstart = NULL;
static char *tok = NULL;
static char *tokend;
-static int errcount = 0;
+int errcount = 0;
extern char *source;
extern int sourceline;
diff --git a/command.c b/command.c
index 0876f02f..90742dd7 100644
--- a/command.c
+++ b/command.c
@@ -90,7 +90,7 @@ static bool want_nodeval = false;
static int cmd_idx = -1; /* index of current command in cmd table */
static int repeat_idx = -1; /* index of last repeatable command in command table */
static CMDARG *arg_list = NULL; /* list of arguments */
-static long errcount = 0;
+static long dbg_errcount = 0;
static char *lexptr_begin = NULL;
static bool in_commands = false;
static int num_dim;
@@ -1548,7 +1548,7 @@ yyreduce:
case 5:
#line 130 "command.y" /* yacc.c:1646 */
{
- if (errcount == 0 && cmd_idx >= 0) {
+ if (dbg_errcount == 0 && cmd_idx >= 0) {
Func_cmd cmdfunc;
bool terminate = false;
CMDARG *args;
@@ -1616,7 +1616,7 @@ yyreduce:
case 23:
#line 219 "command.y" /* yacc.c:1646 */
{
- if (errcount == 0) {
+ if (dbg_errcount == 0) {
/* don't free arg_list; passed on to statement_list
* non-terminal (empty rule action). See below.
*/
@@ -1783,7 +1783,7 @@ yyreduce:
if ((yyvsp[0]) != NULL)
num = (yyvsp[0])->a_int;
- if (errcount != 0)
+ if (dbg_errcount != 0)
;
else if (in_commands)
yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands"));
@@ -2766,7 +2766,7 @@ yyerror(const char *mesg, ...)
vfprintf(out_fp, mesg, args);
fprintf(out_fp, "\n");
va_end(args);
- errcount++;
+ dbg_errcount++;
repeat_idx = -1;
}
@@ -2788,9 +2788,9 @@ yylex(void)
yylval = (CMDARG *) NULL;
- if (errcount > 0 && lexptr_begin == NULL) {
+ if (dbg_errcount > 0 && lexptr_begin == NULL) {
/* fake a new line */
- errcount = 0;
+ dbg_errcount = 0;
return '\n';
}
diff --git a/command.y b/command.y
index 58880dee..96148eff 100644
--- a/command.y
+++ b/command.y
@@ -44,7 +44,7 @@ static bool want_nodeval = false;
static int cmd_idx = -1; /* index of current command in cmd table */
static int repeat_idx = -1; /* index of last repeatable command in command table */
static CMDARG *arg_list = NULL; /* list of arguments */
-static long errcount = 0;
+static long dbg_errcount = 0;
static char *lexptr_begin = NULL;
static bool in_commands = false;
static int num_dim;
@@ -128,7 +128,7 @@ line
: nls
| command nls
{
- if (errcount == 0 && cmd_idx >= 0) {
+ if (dbg_errcount == 0 && cmd_idx >= 0) {
Func_cmd cmdfunc;
bool terminate = false;
CMDARG *args;
@@ -217,7 +217,7 @@ set_want_nodeval
eval_prologue
: D_EVAL set_want_nodeval opt_param_list nls
{
- if (errcount == 0) {
+ if (dbg_errcount == 0) {
/* don't free arg_list; passed on to statement_list
* non-terminal (empty rule action). See below.
*/
@@ -335,7 +335,7 @@ command
if ($2 != NULL)
num = $2->a_int;
- if (errcount != 0)
+ if (dbg_errcount != 0)
;
else if (in_commands)
yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands"));
@@ -1017,7 +1017,7 @@ yyerror(const char *mesg, ...)
vfprintf(out_fp, mesg, args);
fprintf(out_fp, "\n");
va_end(args);
- errcount++;
+ dbg_errcount++;
repeat_idx = -1;
}
@@ -1039,9 +1039,9 @@ yylex(void)
yylval = (CMDARG *) NULL;
- if (errcount > 0 && lexptr_begin == NULL) {
+ if (dbg_errcount > 0 && lexptr_begin == NULL) {
/* fake a new line */
- errcount = 0;
+ dbg_errcount = 0;
return '\n';
}
diff --git a/main.c b/main.c
index 25a628ba..754f2050 100644
--- a/main.c
+++ b/main.c
@@ -1223,6 +1223,9 @@ catchsig(int sig)
|| sig == SIGBUS
#endif
) {
+ if (errcount > 0) // assume a syntax error corrupted our data structures
+ exit(EXIT_FATAL);
+
set_loc(__FILE__, __LINE__);
msg(_("fatal error: internal error"));
/* fatal won't abort() if not compiled for debugging */
@@ -1240,6 +1243,9 @@ catchsig(int sig)
static int
catchsegv(void *fault_address, int serious)
{
+ if (errcount > 0) // assume a syntax error corrupted our data structures
+ exit(EXIT_FATAL);
+
set_loc(__FILE__, __LINE__);
msg(_("fatal error: internal error: segfault"));
fflush(NULL);
diff --git a/test/Makefile.am b/test/Makefile.am
index 13f53f95..98d4d1d0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1141,6 +1141,8 @@ EXTRA_DIST = \
synerr1.ok \
synerr2.awk \
synerr2.ok \
+ synerr3.awk \
+ synerr3.ok \
tailrecurse.awk \
tailrecurse.ok \
testext.ok \
@@ -1261,7 +1263,7 @@ BASIC_TESTS = \
scalar sclforin sclifin setrec0 setrec1 \
sigpipe1 sortempty sortglos splitargv splitarr \
splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \
- subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \
+ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 synerr3 \
tailrecurse tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs uplus \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
diff --git a/test/Makefile.in b/test/Makefile.in
index b23bd8ea..5b348528 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1399,6 +1399,8 @@ EXTRA_DIST = \
synerr1.ok \
synerr2.awk \
synerr2.ok \
+ synerr3.awk \
+ synerr3.ok \
tailrecurse.awk \
tailrecurse.ok \
testext.ok \
@@ -1518,7 +1520,7 @@ BASIC_TESTS = \
scalar sclforin sclifin setrec0 setrec1 \
sigpipe1 sortempty sortglos splitargv splitarr \
splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \
- subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \
+ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 synerr3 \
tailrecurse tradanch tweakfld \
uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs uplus \
wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
@@ -3944,6 +3946,11 @@ synerr2:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+synerr3:
+ @echo $@
+ @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: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index f5840e5f..314f0c0b 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1007,6 +1007,11 @@ synerr2:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+synerr3:
+ @echo $@
+ @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: $$? >>_$@
diff --git a/test/synerr3.awk b/test/synerr3.awk
new file mode 100644
index 00000000..49b9e30a
--- /dev/null
+++ b/test/synerr3.awk
@@ -0,0 +1 @@
+for (i = ) in foo bar baz
diff --git a/test/synerr3.ok b/test/synerr3.ok
new file mode 100644
index 00000000..b8b9dd89
--- /dev/null
+++ b/test/synerr3.ok
@@ -0,0 +1,5 @@
+gawk: synerr3.awk:1: for (i = ) in foo bar baz
+gawk: synerr3.awk:1: ^ syntax error
+gawk: synerr3.awk:1: for (i = ) in foo bar baz
+gawk: synerr3.awk:1: ^ syntax error
+EXIT CODE: 2
--
2.19.1

View File

@ -1,135 +0,0 @@
From 435c438649584eb00de06e07faf6827d4bb6f9fc Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Sun, 21 Apr 2019 15:01:03 +0300
Subject: [PATCH] Fix bug with ^ in FS.
---
field.c | 1 +
test/Makefile.am | 5 ++++-
test/Makefile.in | 10 +++++++++-
test/Maketests | 5 +++++
test/fscaret.awk | 8 ++++++++
test/fscaret.in | 1 +
test/fscaret.ok | 1 +
7 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 test/fscaret.awk
create mode 100644 test/fscaret.in
create mode 100644 test/fscaret.ok
diff --git a/field.c b/field.c
index 52963249..f6a3241c 100644
--- a/field.c
+++ b/field.c
@@ -840,6 +840,7 @@ get_field(long requested, Func_ptr *assign)
if (! field0_valid) {
/* first, parse remainder of input record */
if (NF == -1) {
+ in_middle = (parse_high_water != 0);
NF = (*parse_field)(UNLIMITED - 1, &parse_extent,
fields_arr[0]->stlen -
(parse_extent - fields_arr[0]->stptr),
diff --git a/test/Makefile.am b/test/Makefile.am
index f5546067..13f53f95 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -350,6 +350,9 @@ EXTRA_DIST = \
fsbs.awk \
fsbs.in \
fsbs.ok \
+ fscaret.awk \
+ fscaret.in \
+ fscaret.ok \
fsfwfs.awk \
fsfwfs.in \
fsfwfs.ok \
@@ -1234,7 +1237,7 @@ BASIC_TESTS = \
datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \
eofsplit exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 \
fldchg fldchgnf fldterm fnamedat fnarray fnarray2 fnaryscl fnasgnm fnmisc \
- fordel forref forsimp fsbs fsnul1 fsrs fsspcoln fstabplus funsemnl \
+ fordel forref forsimp fsbs fscaret fsnul1 fsrs fsspcoln fstabplus funsemnl \
funsmnam funstack \
getline getline2 getline3 getline4 getline5 getlnbuf getnr2tb getnr2tm \
gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 gsubtst7 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 4133b58a..b23bd8ea 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -608,6 +608,9 @@ EXTRA_DIST = \
fsbs.awk \
fsbs.in \
fsbs.ok \
+ fscaret.awk \
+ fscaret.in \
+ fscaret.ok \
fsfwfs.awk \
fsfwfs.in \
fsfwfs.ok \
@@ -1491,7 +1494,7 @@ BASIC_TESTS = \
datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \
eofsplit exit2 exitval1 exitval2 exitval3 fcall_exit fcall_exit2 \
fldchg fldchgnf fldterm fnamedat fnarray fnarray2 fnaryscl fnasgnm fnmisc \
- fordel forref forsimp fsbs fsnul1 fsrs fsspcoln fstabplus funsemnl \
+ fordel forref forsimp fsbs fscaret fsnul1 fsrs fsspcoln fstabplus funsemnl \
funsmnam funstack \
getline getline2 getline3 getline4 getline5 getlnbuf getnr2tb getnr2tm \
gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 gsubtst7 \
@@ -3279,6 +3282,11 @@ fsbs:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+fscaret:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fsnul1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 4a90e3e9..f5840e5f 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -345,6 +345,11 @@ fsbs:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+fscaret:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fsnul1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/fscaret.awk b/test/fscaret.awk
new file mode 100644
index 00000000..134820d7
--- /dev/null
+++ b/test/fscaret.awk
@@ -0,0 +1,8 @@
+BEGIN {
+ FS="^."
+ OFS="|"
+}
+{
+ $1 = $1
+}
+1
diff --git a/test/fscaret.in b/test/fscaret.in
new file mode 100644
index 00000000..257cc564
--- /dev/null
+++ b/test/fscaret.in
@@ -0,0 +1 @@
+foo
diff --git a/test/fscaret.ok b/test/fscaret.ok
new file mode 100644
index 00000000..38287d58
--- /dev/null
+++ b/test/fscaret.ok
@@ -0,0 +1 @@
+|oo
--
2.19.1

View File

@ -1,49 +0,0 @@
From 5e4861ab4c41b6e000dc1f66225486330b5e5a2d Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Fri, 21 Sep 2018 13:15:38 +0300
Subject: [PATCH 135/289] Bug fix for trailing backslash in dynamic regexp.
---
ChangeLog | 8 ++++++++
re.c | 8 +++++++-
test/ChangeLog | 5 +++++
test/Makefile.am | 5 ++++-
test/Makefile.in | 10 +++++++++-
test/Maketests | 5 +++++
test/trailbs.awk | 1 +
test/trailbs.in | 1 +
test/trailbs.ok | 2 ++
9 files changed, 42 insertions(+), 3 deletions(-)
create mode 100644 test/trailbs.awk
create mode 100644 test/trailbs.in
create mode 100644 test/trailbs.ok
diff --git a/re.c b/re.c
index eefdfcd7..a693a9ad 100644
--- a/re.c
+++ b/re.c
@@ -112,6 +112,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
(*src == '\\')) {
c = *++src;
switch (c) {
+ case '\0': /* \\ before \0, either dynamic data or real end of string */
+ if (src >= s + len)
+ *dest++ = '\\'; // at end of string, will fatal below
+ else
+ fatal(_("invalid NUL byte in dynamic regexp"));
+ break;
case 'a':
case 'b':
case 'f':
@@ -241,7 +247,7 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
error("%s: /%s/", rerr, buf);
return NULL;
}
- fatal("%s: /%s/", rerr, buf);
+ fatal("invalid regexp: %s: /%s/", rerr, buf);
}
/* gack. this must be done *after* re_compile_pattern */
--
2.19.1

View File

@ -1,30 +0,0 @@
From dc189dc65b6c9b0f521beb4c6105130c6e33a274 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Fri, 25 Jan 2019 11:54:54 +0200
Subject: [PATCH 243/289] Bug fix in support/regexec.c.
---
support/ChangeLog | 7 +++++++
support/regexec.c | 6 ++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/support/regexec.c b/support/regexec.c
index ecb430d3..ff6ab120 100644
--- a/support/regexec.c
+++ b/support/regexec.c
@@ -1293,8 +1293,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
else if (naccepted)
{
char *buf = (char *) re_string_get_buffer (&mctx->input);
- if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
- naccepted) != 0)
+ if (mctx->input.valid_len - *pidx < naccepted
+ || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+ naccepted)
+ != 0))
return -1;
}
}
--
2.19.1

View File

@ -1,238 +0,0 @@
From 29f1563294ac1ab19aa252f3fd5fca94c4f88516 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Sun, 27 May 2018 18:43:20 +0300
Subject: [PATCH 061/289] Bug fix to extract.awk. Rerun and update files.
---
awklib/ChangeLog | 4 +
awklib/eg/network/stoxpred.awk | 29 ++
awklib/eg/prog/extract.awk | 11 +-
awklib/eg/prog/indirectcall.awk | 45 +++
awklib/extract.awk | 10 +-
doc/ChangeLog | 8 +
doc/gawk.info | 492 ++++++++++++++++----------------
doc/gawk.texi | 29 +-
doc/gawktexi.in | 29 +-
9 files changed, 390 insertions(+), 267 deletions(-)
diff --git a/awklib/eg/network/stoxpred.awk b/awklib/eg/network/stoxpred.awk
index 62744c14..aa1fbe9f 100644
--- a/awklib/eg/network/stoxpred.awk
+++ b/awklib/eg/network/stoxpred.awk
@@ -1,3 +1,32 @@
+BEGIN {
+ Init()
+ ReadQuotes()
+ CleanUp()
+ Prediction()
+ Report()
+ SendMail()
+}
+function Init() {
+ if (ARGC != 1) {
+ print "STOXPRED - daily stock share prediction"
+ print "IN:\n no parameters, nothing on stdin"
+ print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80"
+ print "OUT:\n commented predictions as email"
+ print "JK 09.10.2000"
+ exit
+ }
+ # Remember ticker symbols from Dow Jones Industrial Index
+ StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \
+ SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \
+ MRK XOM EK IP", name);
+ # Remember the current date as the end of the time series
+ day = strftime("%d")
+ month = strftime("%m")
+ year = strftime("%Y")
+ if (Proxy == "") Proxy = "chart.yahoo.com"
+ if (ProxyPort == 0) ProxyPort = 80
+ YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort
+}
function ReadQuotes() {
# Retrieve historical data for each ticker symbol
FS = ","
diff --git a/awklib/eg/prog/extract.awk b/awklib/eg/prog/extract.awk
index f5dfcf40..ff598e8e 100644
--- a/awklib/eg/prog/extract.awk
+++ b/awklib/eg/prog/extract.awk
@@ -30,7 +30,7 @@ BEGIN { IGNORECASE = 1 }
}
if ($3 != curfile) {
if (curfile != "")
- close(curfile)
+ filelist[curfile]++ # save to close later
curfile = $3
}
@@ -60,14 +60,13 @@ BEGIN { IGNORECASE = 1 }
print join(a, 1, n, SUBSEP) > curfile
}
}
+END {
+ for (f in filelist)
+ close(filelist[f])
+}
function unexpected_eof()
{
printf("extract: %s:%d: unexpected EOF or error\n",
FILENAME, FNR) > "/dev/stderr"
exit 1
}
-
-END {
- if (curfile)
- close(curfile)
-}
diff --git a/awklib/eg/prog/indirectcall.awk b/awklib/eg/prog/indirectcall.awk
index 165b022a..b2b82686 100644
--- a/awklib/eg/prog/indirectcall.awk
+++ b/awklib/eg/prog/indirectcall.awk
@@ -1,3 +1,48 @@
+# indirectcall.awk --- Demonstrate indirect function calls
+#
+# Arnold Robbins, arnold@skeeve.com, Public Domain
+# January 2009
+# average --- return the average of the values in fields $first - $last
+
+function average(first, last, sum, i)
+{
+ sum = 0;
+ for (i = first; i <= last; i++)
+ sum += $i
+
+ return sum / (last - first + 1)
+}
+
+# sum --- return the sum of the values in fields $first - $last
+
+function sum(first, last, ret, i)
+{
+ ret = 0;
+ for (i = first; i <= last; i++)
+ ret += $i
+
+ return ret
+}
+# For each record, print the class name and the requested statistics
+{
+ class_name = $1
+ gsub(/_/, " ", class_name) # Replace _ with spaces
+
+ # find start
+ for (i = 1; i <= NF; i++) {
+ if ($i == "data:") {
+ start = i + 1
+ break
+ }
+ }
+
+ printf("%s:\n", class_name)
+ for (i = 2; $i != "data:"; i++) {
+ the_function = $i
+ printf("\t%s: <%s>\n", $i, @the_function(start, NF) "")
+ }
+ print ""
+}
# num_lt --- do a numeric less than comparison
function num_lt(left, right)
diff --git a/awklib/extract.awk b/awklib/extract.awk
index 2662574b..96fc9498 100644
--- a/awklib/extract.awk
+++ b/awklib/extract.awk
@@ -30,7 +30,7 @@ BEGIN { IGNORECASE = 1 }
}
if ($3 != curfile) {
if (curfile != "")
- close(curfile)
+ filelist[curfile]++ # save to close later
curfile = $3
}
@@ -60,6 +60,10 @@ BEGIN { IGNORECASE = 1 }
print join(a, 1, n, SUBSEP) > curfile
}
}
+END {
+ for (f in filelist)
+ close(filelist[f])
+}
function unexpected_eof()
{
printf("extract: %s:%d: unexpected EOF or error\n",
@@ -67,10 +71,6 @@ function unexpected_eof()
exit 1
}
-END {
- if (curfile)
- close(curfile)
-}
# join.awk --- join an array into a string
#
# Arnold Robbins, arnold@gnu.org, Public Domain
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index b62d12cd..c645a8ec 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -20124,7 +20124,7 @@ using indirect function calls:
@ignore
@c file eg/prog/indirectcall.awk
#
-# Arnold Robbins, arnold@skeeve.com, Public Domain
+# Arnold Robbins, arnold@@skeeve.com, Public Domain
# January 2009
@c endfile
@end ignore
@@ -25741,7 +25741,7 @@ line. That line is then printed to the output file:
@}
if ($3 != curfile) @{
if (curfile != "")
- close(curfile)
+ filelist[curfile]++ # save to close later
curfile = $3
@}
@@ -25785,6 +25785,26 @@ sample source file (as has been done here!) without any hassle. The file is
only closed when a new @value{DF} name is encountered or at the end of the
input file.
+When a new @value{FN} is encountered, instead of closing the file,
+the program saves the name of the current file in @code{filelist}.
+This makes it possible to interleave the code for more than one file in
+the Texinfo input file. (Previous versions of this program @emph{did}
+close the file. But because of the @samp{>} redirection, a file whose
+parts were not all one after the other ended up getting clobbered.)
+An @code{END} rule then closes all the open files when processing
+is finished:
+
+@example
+@c file eg/prog/extract.awk
+@group
+END @{
+ for (f in filelist)
+ close(filelist[f])
+@}
+@end group
+@c endfile
+@end example
+
Finally, the function @code{@w{unexpected_eof()}} prints an appropriate
error message and then exits.
The @code{END} rule handles the final cleanup, closing the open file:
@@ -25799,11 +25819,6 @@ function unexpected_eof()
exit 1
@}
@end group
-
-END @{
- if (curfile)
- close(curfile)
-@}
@c endfile
@end example
--
2.19.1

View File

@ -1,55 +0,0 @@
From f856979d85ace61bfeb2d31146485ec668202ad8 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Tue, 31 Jul 2018 09:07:29 +0300
Subject: [PATCH 090/289] Fix coredump from IGNORECASE array sorting.
---
ChangeLog | 6 ++++++
array.c | 9 ++++++---
test/ChangeLog | 5 +++++
test/Makefile.am | 4 +++-
test/Makefile.in | 9 ++++++++-
test/Maketests | 5 +++++
test/arraysort2.awk | 34 ++++++++++++++++++++++++++++++++++
test/arraysort2.ok | 26 ++++++++++++++++++++++++++
8 files changed, 93 insertions(+), 5 deletions(-)
create mode 100644 test/arraysort2.awk
create mode 100644 test/arraysort2.ok
diff --git a/array.c b/array.c
index 5d953c04..aa52f3a1 100644
--- a/array.c
+++ b/array.c
@@ -979,7 +979,6 @@ cmp_strings(const NODE *n1, const NODE *n2)
char *s1, *s2;
size_t len1, len2;
int ret;
- size_t lmin;
s1 = n1->stptr;
len1 = n1->stlen;
@@ -992,7 +991,9 @@ cmp_strings(const NODE *n1, const NODE *n2)
return 1;
/* len1 > 0 && len2 > 0 */
- lmin = len1 < len2 ? len1 : len2;
+ // make const to ensure it doesn't change if we
+ // need to call memcmp(), below
+ const size_t lmin = len1 < len2 ? len1 : len2;
if (IGNORECASE) {
const unsigned char *cp1 = (const unsigned char *) s1;
@@ -1002,7 +1003,9 @@ cmp_strings(const NODE *n1, const NODE *n2)
ret = strncasecmpmbs((const unsigned char *) cp1,
(const unsigned char *) cp2, lmin);
} else {
- for (ret = 0; lmin-- > 0 && ret == 0; cp1++, cp2++)
+ size_t count = lmin;
+
+ for (ret = 0; count-- > 0 && ret == 0; cp1++, cp2++)
ret = casetable[*cp1] - casetable[*cp2];
}
if (ret != 0)
--
2.19.1

View File

@ -1,37 +0,0 @@
From da86689ae1669c27f0bf0c975d5e3d1e10058dfd Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Thu, 27 Sep 2018 14:51:00 +0300
Subject: [PATCH 141/289] Fix problem with MPFR conversion to int from hex
numbers.
---
ChangeLog | 6 ++++++
mpfr.c | 2 +-
test/ChangeLog | 5 +++++
test/Makefile.am | 7 +++++--
test/Makefile.in | 12 ++++++++++--
test/Maketests | 5 +++++
test/mpfrbigint2.awk | 3 +++
test/mpfrbigint2.in | 1 +
test/mpfrbigint2.ok | 3 +++
9 files changed, 39 insertions(+), 5 deletions(-)
create mode 100644 test/mpfrbigint2.awk
create mode 100644 test/mpfrbigint2.in
create mode 100644 test/mpfrbigint2.ok
diff --git a/mpfr.c b/mpfr.c
index b6e9c16e..8478570f 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -296,7 +296,7 @@ force_mpnum(NODE *n, int do_nondec, int use_locale)
if (do_nondec)
base = get_numbase(cp1, cpend - cp1, use_locale);
- if (! mpg_maybe_float(cp1, use_locale)) {
+ if (base != 10 || ! mpg_maybe_float(cp1, use_locale)) {
mpg_zero(n);
errno = 0;
mpg_strtoui(n->mpg_i, cp1, cpend - cp1, & ptr, base);
--
2.19.1

View File

@ -1,68 +0,0 @@
From 63a31bee666a9bf9e37eda447f7742b07917dc74 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Mon, 14 Jan 2019 20:33:32 +0200
Subject: [PATCH 228/289] Fix small potential memory leak for intdiv.
---
ChangeLog | 6 ++++++
builtin.c | 4 +++-
mpfr.c | 4 +++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/builtin.c b/builtin.c
index f2d31059..3d57234b 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2018 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-2019 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -4048,11 +4048,13 @@ do_intdiv(int nargs)
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = make_number((AWKNUM) quotient);
+ unref(sub);
sub = make_string("remainder", 9);
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = make_number((AWKNUM) remainder);
+ unref(sub);
DEREF(denominator);
DEREF(numerator);
diff --git a/mpfr.c b/mpfr.c
index 8478570f..c3ba2a6a 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2012, 2013, 2015, 2017, 2018,
+ * Copyright (C) 2012, 2013, 2015, 2017, 2018, 2019,
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -1265,11 +1265,13 @@ do_mpfr_intdiv(int nargs)
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = quotient;
+ unref(sub);
sub = make_string("remainder", 9);
lhs = assoc_lookup(result, sub);
unref(*lhs);
*lhs = remainder;
+ unref(sub);
return make_number((AWKNUM) 0.0);
}
--
2.19.1

View File

@ -1,91 +0,0 @@
From f006165d77037b99e205496d8b79cb80e9f280c0 Mon Sep 17 00:00:00 2001
From: "Arnold D. Robbins" <arnold@skeeve.com>
Date: Thu, 31 May 2018 12:57:02 +0300
Subject: [PATCH 063/289] Further fixes to extract.awk.
---
awklib/eg/prog/extract.awk | 7 +-
awklib/extract.awk | 7 +-
doc/ChangeLog | 6 +
doc/gawk.info | 479 +++++++++++++++++++------------------
doc/gawk.texi | 7 +-
doc/gawktexi.in | 7 +-
6 files changed, 262 insertions(+), 251 deletions(-)
diff --git a/awklib/eg/prog/extract.awk b/awklib/eg/prog/extract.awk
index ff598e8e..0e9bcca3 100644
--- a/awklib/eg/prog/extract.awk
+++ b/awklib/eg/prog/extract.awk
@@ -30,7 +30,7 @@ BEGIN { IGNORECASE = 1 }
}
if ($3 != curfile) {
if (curfile != "")
- filelist[curfile]++ # save to close later
+ filelist[curfile] = 1 # save to close later
curfile = $3
}
@@ -61,8 +61,9 @@ BEGIN { IGNORECASE = 1 }
}
}
END {
- for (f in filelist)
- close(filelist[f])
+ close(curfile) # close the last one
+ for (f in filelist) # close all the rest
+ close(f)
}
function unexpected_eof()
{
diff --git a/awklib/extract.awk b/awklib/extract.awk
index 96fc9498..0c20e299 100644
--- a/awklib/extract.awk
+++ b/awklib/extract.awk
@@ -30,7 +30,7 @@ BEGIN { IGNORECASE = 1 }
}
if ($3 != curfile) {
if (curfile != "")
- filelist[curfile]++ # save to close later
+ filelist[curfile] = 1 # save to close later
curfile = $3
}
@@ -61,8 +61,9 @@ BEGIN { IGNORECASE = 1 }
}
}
END {
- for (f in filelist)
- close(filelist[f])
+ close(curfile) # close the last one
+ for (f in filelist) # close all the rest
+ close(f)
}
function unexpected_eof()
{
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index c645a8ec..e857747e 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -25741,7 +25741,7 @@ line. That line is then printed to the output file:
@}
if ($3 != curfile) @{
if (curfile != "")
- filelist[curfile]++ # save to close later
+ filelist[curfile] = 1 # save to close later
curfile = $3
@}
@@ -25798,8 +25798,9 @@ is finished:
@c file eg/prog/extract.awk
@group
END @{
- for (f in filelist)
- close(filelist[f])
+ close(curfile) # close the last one
+ for (f in filelist) # close all the rest
+ close(f)
@}
@end group
@c endfile
--
2.19.1

View File

@ -1,36 +0,0 @@
From c7d9eb0bb45e11da69c420488aa7af865f2ed5bd Mon Sep 17 00:00:00 2001
From: "Andrew J. Schorr" <aschorr@telemetry-investments.com>
Date: Fri, 22 Jun 2018 11:48:23 -0400
Subject: [PATCH 072/289] Huge numeric values that overflow should convert to
infinity instead of zero.
---
ChangeLog | 8 ++++++++
node.c | 3 ++-
test/ChangeLog | 5 +++++
test/Makefile.am | 4 +++-
test/Makefile.in | 9 ++++++++-
test/Maketests | 5 +++++
test/numrange.awk | 5 +++++
test/numrange.ok | 2 ++
8 files changed, 38 insertions(+), 3 deletions(-)
create mode 100644 test/numrange.awk
create mode 100644 test/numrange.ok
diff --git a/node.c b/node.c
index fcd2bf33..984cec81 100644
--- a/node.c
+++ b/node.c
@@ -140,7 +140,8 @@ r_force_number(NODE *n)
*cpend = save;
}
- if (errno == 0) {
+ if (errno == 0 || errno == ERANGE) {
+ errno = 0; /* reset in case of ERANGE */
if (ptr == cpend)
goto goodnum;
/* else keep the leading numeric value without updating flags */
--
2.19.1

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,26 +0,0 @@
From fad95bcf352bd77e5ed42aaf20eb0e24b761c62f Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 21 Jun 2018 15:51:13 +0200
Subject: [PATCH] configure.ac: fix build for F29+, where we use the
'aclocal-1.16' now
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index a4817ee..736b38b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ then
fi
AC_PREREQ([2.69])
-AM_INIT_AUTOMAKE([1.15 dist-xz dist-lzip])
+AM_INIT_AUTOMAKE([1.16 dist-xz dist-lzip])
AC_CONFIG_MACRO_DIR([m4])
--
2.14.4

Binary file not shown.

BIN
gawk-5.0.1.tar.xz Normal file

Binary file not shown.

View File

@ -3,49 +3,28 @@
%global gawk_api_minor %(tar -xf %{name}-%{version}.tar.xz %{name}-%{version}/gawkapi.h --to-stdout |\ %global gawk_api_minor %(tar -xf %{name}-%{version}.tar.xz %{name}-%{version}/gawkapi.h --to-stdout |\
egrep -i "gawk_api_minor.*[0-9]+" | egrep -o "[0-9]") egrep -i "gawk_api_minor.*[0-9]+" | egrep -o "[0-9]")
Name: gawk Name: gawk
Version: 4.2.1 Version: 5.0.1
Release: 5 Release: 1
License: GPLv3+ and GPLv2+ and LGPLv2+ and BSD License: GPLv3+ and GPLv2+ and LGPLv2+ and BSD
Summary: The GNU version of the AWK text processing utility Summary: The GNU version of the AWK text processing utility
URL: https://www.gnu.org/software/gawk/ URL: https://www.gnu.org/software/gawk/
Source0: https://ftp.gnu.org/gnu/gawk/gawk-%{version}.tar.xz Source0: https://ftp.gnu.org/gnu/gawk/gawk-%{version}.tar.xz
Patch0: gawk-4.2.1-000-add-support-for-a-and-A-in-printf.patch
Patch1: gawk-4.2.1-001-remove-the-tail-recursion-optimization.patch
Patch2: gawk-4.2.1-002-copy-MPZ-MPFR-bits-also-in-r_dupnode.patch
Patch3: gawk-4.2.1-003-fix-rebuilding-records-if-using-API-parser.patch
Patch4: gawk-4.2.1-004-fix-a-corner-case-with-EPIPE-to-stdout-stderr.patch
Patch5: gawk-4.2.1-200-fix-build-for-f29.patch
Patch6000: Bug-fix-to-extract.awk.-Rerun-and-update-files.patch
Patch6001: Further-fixes-to-extract.awk.patch
Patch6002: Huge-numeric-values-that-overflow-should-convert-to-.patch
Patch6003: Fix-coredump-from-IGNORECASE-array-sorting.patch
Patch6004: Bug-fix-for-trailing-backslash-in-dynamic-regexp.patch
Patch6005: Fix-problem-with-MPFR-conversion-to-int-from-hex-num.patch
Patch6006: Fix-small-potential-memory-leak-for-intdiv.patch
Patch6007: Bug-fix-in-support-regexec.c.patch
Patch6008: 0040-Fix-core-dump-upon-syntax-error.patch
Patch6009: 0045-Fix-bug-with-in-FS.patch
Patch6010: refix-remove-the-tail-recursion-optimization.patch
BuildRequires: git gcc automake grep BuildRequires: git gcc automake grep
BuildRequires: bison texinfo texinfo-tex ghostscript texlive-ec texlive-cm-super glibc-all-langpacks BuildRequires: bison texinfo texinfo-tex ghostscript texlive-ec texlive-cm-super glibc-all-langpacks
BuildRequires: libsigsegv-devel mpfr-devel readline-devel BuildRequires: libsigsegv-devel mpfr-devel readline-devel
Requires: filesystem >= 3 Requires: filesystem >= 3
Provides: /bin/awk Provides: /bin/awk
Provides: /bin/gawk Provides: /bin/gawk
Provides: gawk(abi) = %{gawk_api_major}.%{gawk_api_minor} Provides: gawk(abi) = %{gawk_api_major}.%{gawk_api_minor}
%description %description
The gawk package is the GNU implementation of awk. The gawk package is the GNU implementation of awk.
The awk utility interprets a special-purpose programming language that The awk utility interprets a special-purpose programming language that
makes it possible to handle simple data-reformatting jobs with just a makes it possible to handle simple data-reformatting jobs with just a
few lines of code. few lines of code.
%package devel %package devel
Summary: Header file for gawk extensions development Summary: Header file for gawk extensions development
Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}%{?_isa} = %{version}-%{release}
@ -124,6 +103,12 @@ install -m 0644 -p doc/gawkinet.{pdf,ps} ${RPM_BUILD_ROOT}%{_docdir}/%{name}
%{_datadir}/locale/* %{_datadir}/locale/*
%changelog %changelog
* Sun Jan 12 2020 openEuler Buildteam <buildteam@openeuler.org> - 5.0.1-1
- Type:enhancement
- ID:NA
- SUG:restart
- DESC:update to 5.0.1
* Mon Dec 16 2019 openEuler Buildteam <buildteam@openeuler.org> - 4.2.1-5 * Mon Dec 16 2019 openEuler Buildteam <buildteam@openeuler.org> - 4.2.1-5
- Type:enhancement - Type:enhancement
- ID:NA - ID:NA

View File

@ -1,58 +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(refix).
---
awkgram.c | 27 ++-------------------------
1 file changed, 2 insertions(+), 25 deletions(-)
diff --git a/awkgram.c b/awkgram.c
index 52821eab..d3c4e830 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -2820,20 +2820,9 @@ regular_loop:
(yyval) = list_create((yyvsp[-3]));
(void) list_prepend((yyval), instruction(Op_push_i));
(yyval)->nexti->memory = dupnode(Nnull_string);
- } else {
- if (do_optimize
- && (yyvsp[-1])->lasti->opcode == Op_func_call
- && strcmp((yyvsp[-1])->lasti->func_name, in_function) == 0
- ) {
- /* Do tail recursion optimization. Tail
- * call without a return value is recognized
- * in mk_function().
- */
- ((yyvsp[-1])->lasti + 1)->tail_call = true;
- }
-
+ } else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-3]));
- }
+
(yyval) = add_pending_comment((yyval));
}
#line 2840 "awkgram.c" /* yacc.c:1646 */
@@ -7156,18 +7145,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) {
--
2.19.1