commit 5832e8244e7c2dc92fb6076926759fc1df10ee27 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:39:14 2019 -0400 Package init diff --git a/Bug-fix-for-trailing-backslash-in-dynamic-regexp.patch b/Bug-fix-for-trailing-backslash-in-dynamic-regexp.patch new file mode 100644 index 0000000..15820bf --- /dev/null +++ b/Bug-fix-for-trailing-backslash-in-dynamic-regexp.patch @@ -0,0 +1,49 @@ +From 5e4861ab4c41b6e000dc1f66225486330b5e5a2d Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/Bug-fix-in-support-regexec.c.patch b/Bug-fix-in-support-regexec.c.patch new file mode 100644 index 0000000..a556d31 --- /dev/null +++ b/Bug-fix-in-support-regexec.c.patch @@ -0,0 +1,30 @@ +From dc189dc65b6c9b0f521beb4c6105130c6e33a274 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/Bug-fix-to-extract.awk.-Rerun-and-update-files.patch b/Bug-fix-to-extract.awk.-Rerun-and-update-files.patch new file mode 100644 index 0000000..8c64b27 --- /dev/null +++ b/Bug-fix-to-extract.awk.-Rerun-and-update-files.patch @@ -0,0 +1,238 @@ +From 29f1563294ac1ab19aa252f3fd5fca94c4f88516 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/Fix-coredump-from-IGNORECASE-array-sorting.patch b/Fix-coredump-from-IGNORECASE-array-sorting.patch new file mode 100644 index 0000000..22bddde --- /dev/null +++ b/Fix-coredump-from-IGNORECASE-array-sorting.patch @@ -0,0 +1,55 @@ +From f856979d85ace61bfeb2d31146485ec668202ad8 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/Fix-problem-with-MPFR-conversion-to-int-from-hex-num.patch b/Fix-problem-with-MPFR-conversion-to-int-from-hex-num.patch new file mode 100644 index 0000000..945cc97 --- /dev/null +++ b/Fix-problem-with-MPFR-conversion-to-int-from-hex-num.patch @@ -0,0 +1,37 @@ +From da86689ae1669c27f0bf0c975d5e3d1e10058dfd Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/Fix-small-potential-memory-leak-for-intdiv.patch b/Fix-small-potential-memory-leak-for-intdiv.patch new file mode 100644 index 0000000..c6b2379 --- /dev/null +++ b/Fix-small-potential-memory-leak-for-intdiv.patch @@ -0,0 +1,68 @@ +From 63a31bee666a9bf9e37eda447f7742b07917dc74 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/Further-fixes-to-extract.awk.patch b/Further-fixes-to-extract.awk.patch new file mode 100644 index 0000000..875d950 --- /dev/null +++ b/Further-fixes-to-extract.awk.patch @@ -0,0 +1,91 @@ +From f006165d77037b99e205496d8b79cb80e9f280c0 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 diff --git a/Huge-numeric-values-that-overflow-should-convert-to-.patch b/Huge-numeric-values-that-overflow-should-convert-to-.patch new file mode 100644 index 0000000..ae99e50 --- /dev/null +++ b/Huge-numeric-values-that-overflow-should-convert-to-.patch @@ -0,0 +1,36 @@ +From c7d9eb0bb45e11da69c420488aa7af865f2ed5bd Mon Sep 17 00:00:00 2001 +From: "Andrew J. Schorr" +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 + diff --git a/gawk-4.2.1-000-add-support-for-a-and-A-in-printf.patch b/gawk-4.2.1-000-add-support-for-a-and-A-in-printf.patch new file mode 100644 index 0000000..eff117b --- /dev/null +++ b/gawk-4.2.1-000-add-support-for-a-and-A-in-printf.patch @@ -0,0 +1,1321 @@ +From 51e6897a1dc72dd5e39921e8a1c8fa4efb568ca6 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +Date: Thu, 22 Mar 2018 18:37:52 +0200 +Subject: [PATCH] Add support for %a and %A in printf. + +--- + NEWS | 5 + + builtin.c | 31 +- + configh.in | 3 + + configure | 42 +++ + configure.ac | 28 ++ + doc/awkcard.in | 1 + + doc/gawk.1 | 12 +- + doc/gawk.info | 925 ++++++++++++++++++++++++++++---------------------------- + doc/gawk.texi | 19 ++ + doc/gawktexi.in | 19 ++ + doc/wordlist | 2 + + doc/wordlist2 | 1 + + pc/config.h | 3 + + pc/config.sed | 2 + + 14 files changed, 631 insertions(+), 462 deletions(-) + +diff --git a/NEWS b/NEWS +index c2885c8..71d9608 100644 +--- a/NEWS ++++ b/NEWS +@@ -5,6 +5,11 @@ + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + ++Changes from 4.2.1 to 4.2.2 ++--------------------------- ++ ++1. Support for the POSIX standard %a and %A formats has been added. ++ + Changes from 4.2.0 to 4.2.1 + --------------------------- + +diff --git a/builtin.c b/builtin.c +index 6927205..c54be9b 100644 +--- a/builtin.c ++++ b/builtin.c +@@ -1493,6 +1493,17 @@ mpf1: + case 'e': + case 'f': + case 'E': ++#if defined(PRINTF_HAS_A_FORMAT) && PRINTF_HAS_A_FORMAT == 1 ++ case 'A': ++ case 'a': ++ { ++ static bool warned = false; ++ if (do_lint && tolower(cs1) == 'a' && ! warned) { ++ warned = true; ++ lintwarn(_("%%%c format is POSIX standard but not portable to other awks"), cs1); ++ } ++ } ++#endif + need_format = false; + parse_next_arg(); + (void) force_number(arg); +@@ -1557,11 +1568,21 @@ mpf1: + break; + #endif + default: +- sprintf(cp, "*.*%c", cs1); +- while ((nc = snprintf(obufout, ofre, cpbuf, +- (int) fw, (int) prec, +- (double) tmpval)) >= ofre) +- chksize(nc) ++ if (have_prec || tolower(cs1) != 'a') { ++ sprintf(cp, "*.*%c", cs1); ++ while ((nc = snprintf(obufout, ofre, cpbuf, ++ (int) fw, (int) prec, ++ (double) tmpval)) >= ofre) ++ chksize(nc) ++ } else { ++ // For %a and %A, use the default precision if it ++ // wasn't supplied by the user. ++ sprintf(cp, "*%c", cs1); ++ while ((nc = snprintf(obufout, ofre, cpbuf, ++ (int) fw, ++ (double) tmpval)) >= ofre) ++ chksize(nc) ++ } + } + + #if defined(LC_NUMERIC) +diff --git a/configh.in b/configh.in +index e600005..8c4d94d 100644 +--- a/configh.in ++++ b/configh.in +@@ -368,6 +368,9 @@ + /* Define to the version of this package. */ + #undef PACKAGE_VERSION + ++/* Define to 1 if *printf supports %a format */ ++#undef PRINTF_HAS_A_FORMAT ++ + /* Define to 1 if *printf supports %F format */ + #undef PRINTF_HAS_F_FORMAT + +diff --git a/configure b/configure +index 2283f09..f492a75 100755 +--- a/configure ++++ b/configure +@@ -10210,6 +10210,48 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_f_format" >&5 + $as_echo "$has_f_format" >&6; } + ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf %a format" >&5 ++$as_echo_n "checking for printf %a format... " >&6; } ++if test "$cross_compiling" = yes; then : ++ has_a_format=no ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++ ++#include ++ ++int main() ++{ ++ char buf[100]; ++ ++ sprintf(buf, "%a", 8.0); ++ ++ if (strncmp(buf, "0x", 2) == 0) ++ return 0; ++ else ++ return 1; ++} ++ ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ has_a_format=yes ++else ++ has_a_format=no ++fi ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ ++ conftest.$ac_objext conftest.beam conftest.$ac_ext ++fi ++ ++if test "$has_a_format" = yes ++then ++ ++$as_echo "#define PRINTF_HAS_A_FORMAT 1" >>confdefs.h ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_a_format" >&5 ++$as_echo "$has_a_format" >&6; } ++ + + gawk_have_sockets=no + # Check for system-dependent location of socket libraries +diff --git a/configure.ac b/configure.ac +index f45c710..a4817ee 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -395,6 +395,34 @@ then + fi + AC_MSG_RESULT($has_f_format) + ++dnl check for printf %a format ++AC_MSG_CHECKING([for printf %a format]) ++AC_RUN_IFELSE([ ++AC_LANG_SOURCE([ ++#include ++ ++int main() ++{ ++ char buf[[100]]; ++ ++ sprintf(buf, "%a", 8.0); ++ ++ if (strncmp(buf, "0x", 2) == 0) ++ return 0; ++ else ++ return 1; ++} ++])], ++ has_a_format=yes, ++ has_a_format=no, ++ has_a_format=no dnl Cross-compiling, assuming the worst. ++) ++if test "$has_a_format" = yes ++then ++ AC_DEFINE(PRINTF_HAS_A_FORMAT, 1, [Define to 1 if *printf supports %a format]) ++fi ++AC_MSG_RESULT($has_a_format) ++ + dnl check for sockets + GAWK_AC_LIB_SOCKETS + +diff --git a/doc/awkcard.in b/doc/awkcard.in +index 1148294..d4df342 100644 +--- a/doc/awkcard.in ++++ b/doc/awkcard.in +@@ -1431,6 +1431,7 @@ the error.\*(CX + accept the following conversion specification formats: + .sp .5 + .nf ++\*(CB\*(FC%a\fP, \*(FC%A\fP A C99 floating point hexadecimal number\*(CD + \*(FC%c\fP An \s-1ASCII\s+1 character + \*(FC%d\fP, \*(FC%i\fP A decimal number (the integer part) + \*(FC%e\fP A floating point number of the form +diff --git a/doc/gawk.1 b/doc/gawk.1 +index 16762a8..48c07b7 100644 +--- a/doc/gawk.1 ++++ b/doc/gawk.1 +@@ -13,7 +13,7 @@ + . if \w'\(rq' .ds rq "\(rq + . \} + .\} +-.TH GAWK 1 "Feb 15 2018" "Free Software Foundation" "Utility Commands" ++.TH GAWK 1 "Mar 22 2018" "Free Software Foundation" "Utility Commands" + .SH NAME + gawk \- pattern scanning and processing language + .SH SYNOPSIS +@@ -1264,7 +1264,7 @@ behavior: + \fBPROCINFO["NONFATAL"]\fR + If this exists, then I/O errors for all redirections become nonfatal. + .TP +-\fBPROCINFO["\fname\fB", "NONFATAL"]\fR ++\fBPROCINFO["\fIname\fB", "NONFATAL"]\fR + Make I/O errors for + .I name + be nonfatal. +@@ -2429,6 +2429,14 @@ function + (see below) + accept the following conversion specification formats: + .TP "\w'\fB%g\fR, \fB%G\fR'u+2n" ++.BR "%a" "," " %A" ++A floating point number of the form ++[\fB\-\fP]\fB0x\fIh\fB.\fIhhhh\fBp+\-\fIdd\fR ++(C99 hexadecimal floating point format). ++For ++.BR %A , ++uppercase letters are used instead of lowercase ones. ++.TP + .B %c + A single character. + If the argument used for +diff --git a/doc/gawk.info b/doc/gawk.info +index 738de09..c01e43b 100644 +--- a/doc/gawk.info ++++ b/doc/gawk.info +@@ -6614,6 +6614,21 @@ print. The rest of the format specifier is made up of optional + "modifiers" that control _how_ to print the value, such as the field + width. Here is a list of the format-control letters: + ++'%a', '%A' ++ A floating point number of the form ['-']'0xH.HHHHp+-DD' (C99 ++ hexadecimal floating point format). For '%A', uppercase letters ++ are used instead of lowercase ones. ++ ++ NOTE: While the current POSIX standard requires support for ++ '%a' and '%A' in 'awk', as far as we know, no other version of ++ 'awk' actually implements it. It's use is thus highly ++ nonportable! ++ ++ Furthermore, these formats are not available on any system ++ where the underlying C library 'printf()' function does not ++ support them. As of this writing, among current systems, only ++ OpenVMS is known to not support them. ++ + '%c' + Print a number as a character; thus, 'printf "%c", 65' outputs the + letter 'A'. The output for a string value is the first character +@@ -33759,9 +33774,9 @@ Index + * dark corner, FILENAME variable: Getline Notes. (line 19) + * dark corner, FILENAME variable <1>: Auto-set. (line 108) + * dark corner, FNR/NR variables: Auto-set. (line 389) +-* dark corner, format-control characters: Control Letters. (line 18) ++* dark corner, format-control characters: Control Letters. (line 33) + * dark corner, format-control characters <1>: Control Letters. +- (line 93) ++ (line 108) + * dark corner, FS as null string: Single Character Fields. + (line 20) + * dark corner, input files: awk split records. (line 110) +@@ -34459,8 +34474,8 @@ Index + * gawk, FIELDWIDTHS variable in: Fixed width data. (line 17) + * gawk, FIELDWIDTHS variable in <1>: User-modified. (line 37) + * gawk, file names in: Special Files. (line 6) +-* gawk, format-control characters: Control Letters. (line 18) +-* gawk, format-control characters <1>: Control Letters. (line 93) ++* gawk, format-control characters: Control Letters. (line 33) ++* gawk, format-control characters <1>: Control Letters. (line 108) + * gawk, FPAT variable in: Splitting By Content. + (line 25) + * gawk, FPAT variable in <1>: User-modified. (line 46) +@@ -36129,456 +36144,456 @@ Node: OFMT288591 + Node: Printf289947 + Node: Basic Printf290732 + Node: Control Letters292306 +-Node: Format Modifiers296302 +-Node: Printf Examples302317 +-Node: Redirection304803 +-Node: Special FD311644 +-Ref: Special FD-Footnote-1314812 +-Node: Special Files314886 +-Node: Other Inherited Files315503 +-Node: Special Network316504 +-Node: Special Caveats317364 +-Node: Close Files And Pipes318313 +-Ref: table-close-pipe-return-values325220 +-Ref: Close Files And Pipes-Footnote-1326033 +-Ref: Close Files And Pipes-Footnote-2326181 +-Node: Nonfatal326333 +-Node: Output Summary328671 +-Node: Output Exercises329893 +-Node: Expressions330572 +-Node: Values331760 +-Node: Constants332438 +-Node: Scalar Constants333129 +-Ref: Scalar Constants-Footnote-1333993 +-Node: Nondecimal-numbers334243 +-Node: Regexp Constants337244 +-Node: Using Constant Regexps337770 +-Node: Standard Regexp Constants338392 +-Node: Strong Regexp Constants341580 +-Node: Variables344538 +-Node: Using Variables345195 +-Node: Assignment Options347105 +-Node: Conversion348978 +-Node: Strings And Numbers349502 +-Ref: Strings And Numbers-Footnote-1352565 +-Node: Locale influences conversions352674 +-Ref: table-locale-affects355432 +-Node: All Operators356050 +-Node: Arithmetic Ops356679 +-Node: Concatenation359185 +-Ref: Concatenation-Footnote-1362032 +-Node: Assignment Ops362139 +-Ref: table-assign-ops367130 +-Node: Increment Ops368443 +-Node: Truth Values and Conditions371903 +-Node: Truth Values372977 +-Node: Typing and Comparison374025 +-Node: Variable Typing374845 +-Ref: Variable Typing-Footnote-1381308 +-Ref: Variable Typing-Footnote-2381380 +-Node: Comparison Operators381457 +-Ref: table-relational-ops381876 +-Node: POSIX String Comparison385371 +-Ref: POSIX String Comparison-Footnote-1387066 +-Ref: POSIX String Comparison-Footnote-2387205 +-Node: Boolean Ops387289 +-Ref: Boolean Ops-Footnote-1391771 +-Node: Conditional Exp391863 +-Node: Function Calls393599 +-Node: Precedence397476 +-Node: Locales401135 +-Node: Expressions Summary402767 +-Node: Patterns and Actions405340 +-Node: Pattern Overview406460 +-Node: Regexp Patterns408137 +-Node: Expression Patterns408679 +-Node: Ranges412460 +-Node: BEGIN/END415568 +-Node: Using BEGIN/END416329 +-Ref: Using BEGIN/END-Footnote-1419065 +-Node: I/O And BEGIN/END419171 +-Node: BEGINFILE/ENDFILE421485 +-Node: Empty424398 +-Node: Using Shell Variables424715 +-Node: Action Overview426989 +-Node: Statements429314 +-Node: If Statement431162 +-Node: While Statement432657 +-Node: Do Statement434685 +-Node: For Statement435833 +-Node: Switch Statement439004 +-Node: Break Statement441390 +-Node: Continue Statement443482 +-Node: Next Statement445309 +-Node: Nextfile Statement447692 +-Node: Exit Statement450344 +-Node: Built-in Variables452747 +-Node: User-modified453880 +-Node: Auto-set461647 +-Ref: Auto-set-Footnote-1477946 +-Ref: Auto-set-Footnote-2478152 +-Node: ARGC and ARGV478208 +-Node: Pattern Action Summary482421 +-Node: Arrays484851 +-Node: Array Basics486180 +-Node: Array Intro487024 +-Ref: figure-array-elements488999 +-Ref: Array Intro-Footnote-1491703 +-Node: Reference to Elements491831 +-Node: Assigning Elements494295 +-Node: Array Example494786 +-Node: Scanning an Array496545 +-Node: Controlling Scanning499567 +-Ref: Controlling Scanning-Footnote-1504966 +-Node: Numeric Array Subscripts505282 +-Node: Uninitialized Subscripts507466 +-Node: Delete509085 +-Ref: Delete-Footnote-1511837 +-Node: Multidimensional511894 +-Node: Multiscanning514989 +-Node: Arrays of Arrays516580 +-Node: Arrays Summary521347 +-Node: Functions523440 +-Node: Built-in524478 +-Node: Calling Built-in525559 +-Node: Numeric Functions527555 +-Ref: Numeric Functions-Footnote-1531583 +-Ref: Numeric Functions-Footnote-2531940 +-Ref: Numeric Functions-Footnote-3531988 +-Node: String Functions532260 +-Ref: String Functions-Footnote-1555918 +-Ref: String Functions-Footnote-2556046 +-Ref: String Functions-Footnote-3556294 +-Node: Gory Details556381 +-Ref: table-sub-escapes558172 +-Ref: table-sub-proposed559691 +-Ref: table-posix-sub561054 +-Ref: table-gensub-escapes562595 +-Ref: Gory Details-Footnote-1563418 +-Node: I/O Functions563572 +-Ref: table-system-return-values570040 +-Ref: I/O Functions-Footnote-1572020 +-Ref: I/O Functions-Footnote-2572168 +-Node: Time Functions572288 +-Ref: Time Functions-Footnote-1582959 +-Ref: Time Functions-Footnote-2583027 +-Ref: Time Functions-Footnote-3583185 +-Ref: Time Functions-Footnote-4583296 +-Ref: Time Functions-Footnote-5583408 +-Ref: Time Functions-Footnote-6583635 +-Node: Bitwise Functions583901 +-Ref: table-bitwise-ops584495 +-Ref: Bitwise Functions-Footnote-1590540 +-Ref: Bitwise Functions-Footnote-2590713 +-Node: Type Functions590904 +-Node: I18N Functions593655 +-Node: User-defined595306 +-Node: Definition Syntax596111 +-Ref: Definition Syntax-Footnote-1601798 +-Node: Function Example601869 +-Ref: Function Example-Footnote-1604791 +-Node: Function Caveats604813 +-Node: Calling A Function605331 +-Node: Variable Scope606289 +-Node: Pass By Value/Reference609283 +-Node: Return Statement612782 +-Node: Dynamic Typing615761 +-Node: Indirect Calls616691 +-Ref: Indirect Calls-Footnote-1626943 +-Node: Functions Summary627071 +-Node: Library Functions629776 +-Ref: Library Functions-Footnote-1633383 +-Ref: Library Functions-Footnote-2633526 +-Node: Library Names633697 +-Ref: Library Names-Footnote-1637157 +-Ref: Library Names-Footnote-2637380 +-Node: General Functions637466 +-Node: Strtonum Function638569 +-Node: Assert Function641591 +-Node: Round Function644917 +-Node: Cliff Random Function646457 +-Node: Ordinal Functions647473 +-Ref: Ordinal Functions-Footnote-1650536 +-Ref: Ordinal Functions-Footnote-2650788 +-Node: Join Function650998 +-Ref: Join Function-Footnote-1652768 +-Node: Getlocaltime Function652968 +-Node: Readfile Function656710 +-Node: Shell Quoting658687 +-Node: Data File Management660088 +-Node: Filetrans Function660720 +-Node: Rewind Function664816 +-Node: File Checking666726 +-Ref: File Checking-Footnote-1668060 +-Node: Empty Files668261 +-Node: Ignoring Assigns670240 +-Node: Getopt Function671790 +-Ref: Getopt Function-Footnote-1683259 +-Node: Passwd Functions683459 +-Ref: Passwd Functions-Footnote-1692298 +-Node: Group Functions692386 +-Ref: Group Functions-Footnote-1700284 +-Node: Walking Arrays700491 +-Node: Library Functions Summary703499 +-Node: Library Exercises704905 +-Node: Sample Programs705370 +-Node: Running Examples706140 +-Node: Clones706868 +-Node: Cut Program708092 +-Node: Egrep Program718021 +-Ref: Egrep Program-Footnote-1725533 +-Node: Id Program725643 +-Node: Split Program729323 +-Ref: Split Program-Footnote-1732781 +-Node: Tee Program732910 +-Node: Uniq Program735700 +-Node: Wc Program743126 +-Ref: Wc Program-Footnote-1747381 +-Node: Miscellaneous Programs747475 +-Node: Dupword Program748688 +-Node: Alarm Program750718 +-Node: Translate Program755573 +-Ref: Translate Program-Footnote-1760138 +-Node: Labels Program760408 +-Ref: Labels Program-Footnote-1763759 +-Node: Word Sorting763843 +-Node: History Sorting767915 +-Node: Extract Program769750 +-Node: Simple Sed777280 +-Node: Igawk Program780354 +-Ref: Igawk Program-Footnote-1794685 +-Ref: Igawk Program-Footnote-2794887 +-Ref: Igawk Program-Footnote-3795009 +-Node: Anagram Program795124 +-Node: Signature Program798186 +-Node: Programs Summary799433 +-Node: Programs Exercises800647 +-Ref: Programs Exercises-Footnote-1804776 +-Node: Advanced Features804867 +-Node: Nondecimal Data806857 +-Node: Array Sorting808448 +-Node: Controlling Array Traversal809148 +-Ref: Controlling Array Traversal-Footnote-1817516 +-Node: Array Sorting Functions817634 +-Ref: Array Sorting Functions-Footnote-1822725 +-Node: Two-way I/O822921 +-Ref: Two-way I/O-Footnote-1829473 +-Ref: Two-way I/O-Footnote-2829660 +-Node: TCP/IP Networking829742 +-Node: Profiling832860 +-Ref: Profiling-Footnote-1841532 +-Node: Advanced Features Summary841855 +-Node: Internationalization843699 +-Node: I18N and L10N845179 +-Node: Explaining gettext845866 +-Ref: Explaining gettext-Footnote-1851758 +-Ref: Explaining gettext-Footnote-2851943 +-Node: Programmer i18n852108 +-Ref: Programmer i18n-Footnote-1857057 +-Node: Translator i18n857106 +-Node: String Extraction857900 +-Ref: String Extraction-Footnote-1859032 +-Node: Printf Ordering859118 +-Ref: Printf Ordering-Footnote-1861904 +-Node: I18N Portability861968 +-Ref: I18N Portability-Footnote-1864424 +-Node: I18N Example864487 +-Ref: I18N Example-Footnote-1867293 +-Node: Gawk I18N867366 +-Node: I18N Summary868011 +-Node: Debugger869352 +-Node: Debugging870375 +-Node: Debugging Concepts870816 +-Node: Debugging Terms872625 +-Node: Awk Debugging875200 +-Node: Sample Debugging Session876106 +-Node: Debugger Invocation876640 +-Node: Finding The Bug878026 +-Node: List of Debugger Commands884504 +-Node: Breakpoint Control885837 +-Node: Debugger Execution Control889531 +-Node: Viewing And Changing Data892893 +-Node: Execution Stack896267 +-Node: Debugger Info897904 +-Node: Miscellaneous Debugger Commands901975 +-Node: Readline Support907037 +-Node: Limitations907933 +-Node: Debugging Summary910042 +-Node: Arbitrary Precision Arithmetic911321 +-Node: Computer Arithmetic912806 +-Ref: table-numeric-ranges916572 +-Ref: table-floating-point-ranges917065 +-Ref: Computer Arithmetic-Footnote-1917723 +-Node: Math Definitions917780 +-Ref: table-ieee-formats921096 +-Ref: Math Definitions-Footnote-1921699 +-Node: MPFR features921804 +-Node: FP Math Caution923522 +-Ref: FP Math Caution-Footnote-1924594 +-Node: Inexactness of computations924963 +-Node: Inexact representation925923 +-Node: Comparing FP Values927283 +-Node: Errors accumulate928365 +-Node: Getting Accuracy929798 +-Node: Try To Round932508 +-Node: Setting precision933407 +-Ref: table-predefined-precision-strings934104 +-Node: Setting the rounding mode935934 +-Ref: table-gawk-rounding-modes936308 +-Ref: Setting the rounding mode-Footnote-1940239 +-Node: Arbitrary Precision Integers940418 +-Ref: Arbitrary Precision Integers-Footnote-1943593 +-Node: Checking for MPFR943742 +-Node: POSIX Floating Point Problems945216 +-Ref: POSIX Floating Point Problems-Footnote-1949087 +-Node: Floating point summary949125 +-Node: Dynamic Extensions951315 +-Node: Extension Intro952868 +-Node: Plugin License954134 +-Node: Extension Mechanism Outline954931 +-Ref: figure-load-extension955370 +-Ref: figure-register-new-function956935 +-Ref: figure-call-new-function958027 +-Node: Extension API Description960089 +-Node: Extension API Functions Introduction961731 +-Node: General Data Types967271 +-Ref: General Data Types-Footnote-1975632 +-Node: Memory Allocation Functions975931 +-Ref: Memory Allocation Functions-Footnote-1980141 +-Node: Constructor Functions980240 +-Node: Registration Functions983826 +-Node: Extension Functions984511 +-Node: Exit Callback Functions989726 +-Node: Extension Version String990976 +-Node: Input Parsers991639 +-Node: Output Wrappers1004360 +-Node: Two-way processors1008872 +-Node: Printing Messages1011137 +-Ref: Printing Messages-Footnote-11012308 +-Node: Updating ERRNO1012461 +-Node: Requesting Values1013200 +-Ref: table-value-types-returned1013937 +-Node: Accessing Parameters1014873 +-Node: Symbol Table Access1016108 +-Node: Symbol table by name1016620 +-Node: Symbol table by cookie1018409 +-Ref: Symbol table by cookie-Footnote-11022594 +-Node: Cached values1022658 +-Ref: Cached values-Footnote-11026194 +-Node: Array Manipulation1026347 +-Ref: Array Manipulation-Footnote-11027438 +-Node: Array Data Types1027475 +-Ref: Array Data Types-Footnote-11030133 +-Node: Array Functions1030225 +-Node: Flattening Arrays1034723 +-Node: Creating Arrays1041699 +-Node: Redirection API1046466 +-Node: Extension API Variables1049299 +-Node: Extension Versioning1050010 +-Ref: gawk-api-version1050439 +-Node: Extension GMP/MPFR Versioning1052170 +-Node: Extension API Informational Variables1053798 +-Node: Extension API Boilerplate1054871 +-Node: Changes from API V11058845 +-Node: Finding Extensions1060417 +-Node: Extension Example1060976 +-Node: Internal File Description1061774 +-Node: Internal File Ops1065854 +-Ref: Internal File Ops-Footnote-11077204 +-Node: Using Internal File Ops1077344 +-Ref: Using Internal File Ops-Footnote-11079727 +-Node: Extension Samples1080001 +-Node: Extension Sample File Functions1081530 +-Node: Extension Sample Fnmatch1089179 +-Node: Extension Sample Fork1090666 +-Node: Extension Sample Inplace1091884 +-Node: Extension Sample Ord1095101 +-Node: Extension Sample Readdir1095937 +-Ref: table-readdir-file-types1096826 +-Node: Extension Sample Revout1097631 +-Node: Extension Sample Rev2way1098220 +-Node: Extension Sample Read write array1098960 +-Node: Extension Sample Readfile1100902 +-Node: Extension Sample Time1101997 +-Node: Extension Sample API Tests1103345 +-Node: gawkextlib1103837 +-Node: Extension summary1106755 +-Node: Extension Exercises1110457 +-Node: Language History1111955 +-Node: V7/SVR3.11113611 +-Node: SVR41115763 +-Node: POSIX1117197 +-Node: BTL1118577 +-Node: POSIX/GNU1119306 +-Node: Feature History1125084 +-Node: Common Extensions1140943 +-Node: Ranges and Locales1142226 +-Ref: Ranges and Locales-Footnote-11146842 +-Ref: Ranges and Locales-Footnote-21146869 +-Ref: Ranges and Locales-Footnote-31147104 +-Node: Contributors1147325 +-Node: History summary1153270 +-Node: Installation1154650 +-Node: Gawk Distribution1155594 +-Node: Getting1156078 +-Node: Extracting1157041 +-Node: Distribution contents1158679 +-Node: Unix Installation1165159 +-Node: Quick Installation1165841 +-Node: Shell Startup Files1168255 +-Node: Additional Configuration Options1169344 +-Node: Configuration Philosophy1171637 +-Node: Non-Unix Installation1174006 +-Node: PC Installation1174466 +-Node: PC Binary Installation1175304 +-Node: PC Compiling1175739 +-Node: PC Using1176856 +-Node: Cygwin1180071 +-Node: MSYS1181170 +-Node: VMS Installation1181671 +-Node: VMS Compilation1182462 +-Ref: VMS Compilation-Footnote-11183691 +-Node: VMS Dynamic Extensions1183749 +-Node: VMS Installation Details1185434 +-Node: VMS Running1187687 +-Node: VMS GNV1191966 +-Node: VMS Old Gawk1192701 +-Node: Bugs1193172 +-Node: Bug address1193835 +-Node: Usenet1196627 +-Node: Maintainers1197404 +-Node: Other Versions1198665 +-Node: Installation summary1205427 +-Node: Notes1206629 +-Node: Compatibility Mode1207494 +-Node: Additions1208276 +-Node: Accessing The Source1209201 +-Node: Adding Code1210638 +-Node: New Ports1216857 +-Node: Derived Files1221345 +-Ref: Derived Files-Footnote-11226991 +-Ref: Derived Files-Footnote-21227026 +-Ref: Derived Files-Footnote-31227624 +-Node: Future Extensions1227738 +-Node: Implementation Limitations1228396 +-Node: Extension Design1229579 +-Node: Old Extension Problems1230733 +-Ref: Old Extension Problems-Footnote-11232251 +-Node: Extension New Mechanism Goals1232308 +-Ref: Extension New Mechanism Goals-Footnote-11235672 +-Node: Extension Other Design Decisions1235861 +-Node: Extension Future Growth1237974 +-Node: Old Extension Mechanism1238810 +-Node: Notes summary1240573 +-Node: Basic Concepts1241755 +-Node: Basic High Level1242436 +-Ref: figure-general-flow1242718 +-Ref: figure-process-flow1243403 +-Ref: Basic High Level-Footnote-11246704 +-Node: Basic Data Typing1246889 +-Node: Glossary1250217 +-Node: Copying1282055 +-Node: GNU Free Documentation License1319598 +-Node: Index1344718 ++Node: Format Modifiers296985 ++Node: Printf Examples303000 ++Node: Redirection305486 ++Node: Special FD312327 ++Ref: Special FD-Footnote-1315495 ++Node: Special Files315569 ++Node: Other Inherited Files316186 ++Node: Special Network317187 ++Node: Special Caveats318047 ++Node: Close Files And Pipes318996 ++Ref: table-close-pipe-return-values325903 ++Ref: Close Files And Pipes-Footnote-1326716 ++Ref: Close Files And Pipes-Footnote-2326864 ++Node: Nonfatal327016 ++Node: Output Summary329354 ++Node: Output Exercises330576 ++Node: Expressions331255 ++Node: Values332443 ++Node: Constants333121 ++Node: Scalar Constants333812 ++Ref: Scalar Constants-Footnote-1334676 ++Node: Nondecimal-numbers334926 ++Node: Regexp Constants337927 ++Node: Using Constant Regexps338453 ++Node: Standard Regexp Constants339075 ++Node: Strong Regexp Constants342263 ++Node: Variables345221 ++Node: Using Variables345878 ++Node: Assignment Options347788 ++Node: Conversion349661 ++Node: Strings And Numbers350185 ++Ref: Strings And Numbers-Footnote-1353248 ++Node: Locale influences conversions353357 ++Ref: table-locale-affects356115 ++Node: All Operators356733 ++Node: Arithmetic Ops357362 ++Node: Concatenation359868 ++Ref: Concatenation-Footnote-1362715 ++Node: Assignment Ops362822 ++Ref: table-assign-ops367813 ++Node: Increment Ops369126 ++Node: Truth Values and Conditions372586 ++Node: Truth Values373660 ++Node: Typing and Comparison374708 ++Node: Variable Typing375528 ++Ref: Variable Typing-Footnote-1381991 ++Ref: Variable Typing-Footnote-2382063 ++Node: Comparison Operators382140 ++Ref: table-relational-ops382559 ++Node: POSIX String Comparison386054 ++Ref: POSIX String Comparison-Footnote-1387749 ++Ref: POSIX String Comparison-Footnote-2387888 ++Node: Boolean Ops387972 ++Ref: Boolean Ops-Footnote-1392454 ++Node: Conditional Exp392546 ++Node: Function Calls394282 ++Node: Precedence398159 ++Node: Locales401818 ++Node: Expressions Summary403450 ++Node: Patterns and Actions406023 ++Node: Pattern Overview407143 ++Node: Regexp Patterns408820 ++Node: Expression Patterns409362 ++Node: Ranges413143 ++Node: BEGIN/END416251 ++Node: Using BEGIN/END417012 ++Ref: Using BEGIN/END-Footnote-1419748 ++Node: I/O And BEGIN/END419854 ++Node: BEGINFILE/ENDFILE422168 ++Node: Empty425081 ++Node: Using Shell Variables425398 ++Node: Action Overview427672 ++Node: Statements429997 ++Node: If Statement431845 ++Node: While Statement433340 ++Node: Do Statement435368 ++Node: For Statement436516 ++Node: Switch Statement439687 ++Node: Break Statement442073 ++Node: Continue Statement444165 ++Node: Next Statement445992 ++Node: Nextfile Statement448375 ++Node: Exit Statement451027 ++Node: Built-in Variables453430 ++Node: User-modified454563 ++Node: Auto-set462330 ++Ref: Auto-set-Footnote-1478629 ++Ref: Auto-set-Footnote-2478835 ++Node: ARGC and ARGV478891 ++Node: Pattern Action Summary483104 ++Node: Arrays485534 ++Node: Array Basics486863 ++Node: Array Intro487707 ++Ref: figure-array-elements489682 ++Ref: Array Intro-Footnote-1492386 ++Node: Reference to Elements492514 ++Node: Assigning Elements494978 ++Node: Array Example495469 ++Node: Scanning an Array497228 ++Node: Controlling Scanning500250 ++Ref: Controlling Scanning-Footnote-1505649 ++Node: Numeric Array Subscripts505965 ++Node: Uninitialized Subscripts508149 ++Node: Delete509768 ++Ref: Delete-Footnote-1512520 ++Node: Multidimensional512577 ++Node: Multiscanning515672 ++Node: Arrays of Arrays517263 ++Node: Arrays Summary522030 ++Node: Functions524123 ++Node: Built-in525161 ++Node: Calling Built-in526242 ++Node: Numeric Functions528238 ++Ref: Numeric Functions-Footnote-1532266 ++Ref: Numeric Functions-Footnote-2532623 ++Ref: Numeric Functions-Footnote-3532671 ++Node: String Functions532943 ++Ref: String Functions-Footnote-1556601 ++Ref: String Functions-Footnote-2556729 ++Ref: String Functions-Footnote-3556977 ++Node: Gory Details557064 ++Ref: table-sub-escapes558855 ++Ref: table-sub-proposed560374 ++Ref: table-posix-sub561737 ++Ref: table-gensub-escapes563278 ++Ref: Gory Details-Footnote-1564101 ++Node: I/O Functions564255 ++Ref: table-system-return-values570723 ++Ref: I/O Functions-Footnote-1572703 ++Ref: I/O Functions-Footnote-2572851 ++Node: Time Functions572971 ++Ref: Time Functions-Footnote-1583642 ++Ref: Time Functions-Footnote-2583710 ++Ref: Time Functions-Footnote-3583868 ++Ref: Time Functions-Footnote-4583979 ++Ref: Time Functions-Footnote-5584091 ++Ref: Time Functions-Footnote-6584318 ++Node: Bitwise Functions584584 ++Ref: table-bitwise-ops585178 ++Ref: Bitwise Functions-Footnote-1591223 ++Ref: Bitwise Functions-Footnote-2591396 ++Node: Type Functions591587 ++Node: I18N Functions594338 ++Node: User-defined595989 ++Node: Definition Syntax596794 ++Ref: Definition Syntax-Footnote-1602481 ++Node: Function Example602552 ++Ref: Function Example-Footnote-1605474 ++Node: Function Caveats605496 ++Node: Calling A Function606014 ++Node: Variable Scope606972 ++Node: Pass By Value/Reference609966 ++Node: Return Statement613465 ++Node: Dynamic Typing616444 ++Node: Indirect Calls617374 ++Ref: Indirect Calls-Footnote-1627626 ++Node: Functions Summary627754 ++Node: Library Functions630459 ++Ref: Library Functions-Footnote-1634066 ++Ref: Library Functions-Footnote-2634209 ++Node: Library Names634380 ++Ref: Library Names-Footnote-1637840 ++Ref: Library Names-Footnote-2638063 ++Node: General Functions638149 ++Node: Strtonum Function639252 ++Node: Assert Function642274 ++Node: Round Function645600 ++Node: Cliff Random Function647140 ++Node: Ordinal Functions648156 ++Ref: Ordinal Functions-Footnote-1651219 ++Ref: Ordinal Functions-Footnote-2651471 ++Node: Join Function651681 ++Ref: Join Function-Footnote-1653451 ++Node: Getlocaltime Function653651 ++Node: Readfile Function657393 ++Node: Shell Quoting659370 ++Node: Data File Management660771 ++Node: Filetrans Function661403 ++Node: Rewind Function665499 ++Node: File Checking667409 ++Ref: File Checking-Footnote-1668743 ++Node: Empty Files668944 ++Node: Ignoring Assigns670923 ++Node: Getopt Function672473 ++Ref: Getopt Function-Footnote-1683942 ++Node: Passwd Functions684142 ++Ref: Passwd Functions-Footnote-1692981 ++Node: Group Functions693069 ++Ref: Group Functions-Footnote-1700967 ++Node: Walking Arrays701174 ++Node: Library Functions Summary704182 ++Node: Library Exercises705588 ++Node: Sample Programs706053 ++Node: Running Examples706823 ++Node: Clones707551 ++Node: Cut Program708775 ++Node: Egrep Program718704 ++Ref: Egrep Program-Footnote-1726216 ++Node: Id Program726326 ++Node: Split Program730006 ++Ref: Split Program-Footnote-1733464 ++Node: Tee Program733593 ++Node: Uniq Program736383 ++Node: Wc Program743809 ++Ref: Wc Program-Footnote-1748064 ++Node: Miscellaneous Programs748158 ++Node: Dupword Program749371 ++Node: Alarm Program751401 ++Node: Translate Program756256 ++Ref: Translate Program-Footnote-1760821 ++Node: Labels Program761091 ++Ref: Labels Program-Footnote-1764442 ++Node: Word Sorting764526 ++Node: History Sorting768598 ++Node: Extract Program770433 ++Node: Simple Sed777963 ++Node: Igawk Program781037 ++Ref: Igawk Program-Footnote-1795368 ++Ref: Igawk Program-Footnote-2795570 ++Ref: Igawk Program-Footnote-3795692 ++Node: Anagram Program795807 ++Node: Signature Program798869 ++Node: Programs Summary800116 ++Node: Programs Exercises801330 ++Ref: Programs Exercises-Footnote-1805459 ++Node: Advanced Features805550 ++Node: Nondecimal Data807540 ++Node: Array Sorting809131 ++Node: Controlling Array Traversal809831 ++Ref: Controlling Array Traversal-Footnote-1818199 ++Node: Array Sorting Functions818317 ++Ref: Array Sorting Functions-Footnote-1823408 ++Node: Two-way I/O823604 ++Ref: Two-way I/O-Footnote-1830156 ++Ref: Two-way I/O-Footnote-2830343 ++Node: TCP/IP Networking830425 ++Node: Profiling833543 ++Ref: Profiling-Footnote-1842215 ++Node: Advanced Features Summary842538 ++Node: Internationalization844382 ++Node: I18N and L10N845862 ++Node: Explaining gettext846549 ++Ref: Explaining gettext-Footnote-1852441 ++Ref: Explaining gettext-Footnote-2852626 ++Node: Programmer i18n852791 ++Ref: Programmer i18n-Footnote-1857740 ++Node: Translator i18n857789 ++Node: String Extraction858583 ++Ref: String Extraction-Footnote-1859715 ++Node: Printf Ordering859801 ++Ref: Printf Ordering-Footnote-1862587 ++Node: I18N Portability862651 ++Ref: I18N Portability-Footnote-1865107 ++Node: I18N Example865170 ++Ref: I18N Example-Footnote-1867976 ++Node: Gawk I18N868049 ++Node: I18N Summary868694 ++Node: Debugger870035 ++Node: Debugging871058 ++Node: Debugging Concepts871499 ++Node: Debugging Terms873308 ++Node: Awk Debugging875883 ++Node: Sample Debugging Session876789 ++Node: Debugger Invocation877323 ++Node: Finding The Bug878709 ++Node: List of Debugger Commands885187 ++Node: Breakpoint Control886520 ++Node: Debugger Execution Control890214 ++Node: Viewing And Changing Data893576 ++Node: Execution Stack896950 ++Node: Debugger Info898587 ++Node: Miscellaneous Debugger Commands902658 ++Node: Readline Support907720 ++Node: Limitations908616 ++Node: Debugging Summary910725 ++Node: Arbitrary Precision Arithmetic912004 ++Node: Computer Arithmetic913489 ++Ref: table-numeric-ranges917255 ++Ref: table-floating-point-ranges917748 ++Ref: Computer Arithmetic-Footnote-1918406 ++Node: Math Definitions918463 ++Ref: table-ieee-formats921779 ++Ref: Math Definitions-Footnote-1922382 ++Node: MPFR features922487 ++Node: FP Math Caution924205 ++Ref: FP Math Caution-Footnote-1925277 ++Node: Inexactness of computations925646 ++Node: Inexact representation926606 ++Node: Comparing FP Values927966 ++Node: Errors accumulate929048 ++Node: Getting Accuracy930481 ++Node: Try To Round933191 ++Node: Setting precision934090 ++Ref: table-predefined-precision-strings934787 ++Node: Setting the rounding mode936617 ++Ref: table-gawk-rounding-modes936991 ++Ref: Setting the rounding mode-Footnote-1940922 ++Node: Arbitrary Precision Integers941101 ++Ref: Arbitrary Precision Integers-Footnote-1944276 ++Node: Checking for MPFR944425 ++Node: POSIX Floating Point Problems945899 ++Ref: POSIX Floating Point Problems-Footnote-1949770 ++Node: Floating point summary949808 ++Node: Dynamic Extensions951998 ++Node: Extension Intro953551 ++Node: Plugin License954817 ++Node: Extension Mechanism Outline955614 ++Ref: figure-load-extension956053 ++Ref: figure-register-new-function957618 ++Ref: figure-call-new-function958710 ++Node: Extension API Description960772 ++Node: Extension API Functions Introduction962414 ++Node: General Data Types967954 ++Ref: General Data Types-Footnote-1976315 ++Node: Memory Allocation Functions976614 ++Ref: Memory Allocation Functions-Footnote-1980824 ++Node: Constructor Functions980923 ++Node: Registration Functions984509 ++Node: Extension Functions985194 ++Node: Exit Callback Functions990409 ++Node: Extension Version String991659 ++Node: Input Parsers992322 ++Node: Output Wrappers1005043 ++Node: Two-way processors1009555 ++Node: Printing Messages1011820 ++Ref: Printing Messages-Footnote-11012991 ++Node: Updating ERRNO1013144 ++Node: Requesting Values1013883 ++Ref: table-value-types-returned1014620 ++Node: Accessing Parameters1015556 ++Node: Symbol Table Access1016791 ++Node: Symbol table by name1017303 ++Node: Symbol table by cookie1019092 ++Ref: Symbol table by cookie-Footnote-11023277 ++Node: Cached values1023341 ++Ref: Cached values-Footnote-11026877 ++Node: Array Manipulation1027030 ++Ref: Array Manipulation-Footnote-11028121 ++Node: Array Data Types1028158 ++Ref: Array Data Types-Footnote-11030816 ++Node: Array Functions1030908 ++Node: Flattening Arrays1035406 ++Node: Creating Arrays1042382 ++Node: Redirection API1047149 ++Node: Extension API Variables1049982 ++Node: Extension Versioning1050693 ++Ref: gawk-api-version1051122 ++Node: Extension GMP/MPFR Versioning1052853 ++Node: Extension API Informational Variables1054481 ++Node: Extension API Boilerplate1055554 ++Node: Changes from API V11059528 ++Node: Finding Extensions1061100 ++Node: Extension Example1061659 ++Node: Internal File Description1062457 ++Node: Internal File Ops1066537 ++Ref: Internal File Ops-Footnote-11077887 ++Node: Using Internal File Ops1078027 ++Ref: Using Internal File Ops-Footnote-11080410 ++Node: Extension Samples1080684 ++Node: Extension Sample File Functions1082213 ++Node: Extension Sample Fnmatch1089862 ++Node: Extension Sample Fork1091349 ++Node: Extension Sample Inplace1092567 ++Node: Extension Sample Ord1095784 ++Node: Extension Sample Readdir1096620 ++Ref: table-readdir-file-types1097509 ++Node: Extension Sample Revout1098314 ++Node: Extension Sample Rev2way1098903 ++Node: Extension Sample Read write array1099643 ++Node: Extension Sample Readfile1101585 ++Node: Extension Sample Time1102680 ++Node: Extension Sample API Tests1104028 ++Node: gawkextlib1104520 ++Node: Extension summary1107438 ++Node: Extension Exercises1111140 ++Node: Language History1112638 ++Node: V7/SVR3.11114294 ++Node: SVR41116446 ++Node: POSIX1117880 ++Node: BTL1119260 ++Node: POSIX/GNU1119989 ++Node: Feature History1125767 ++Node: Common Extensions1141626 ++Node: Ranges and Locales1142909 ++Ref: Ranges and Locales-Footnote-11147525 ++Ref: Ranges and Locales-Footnote-21147552 ++Ref: Ranges and Locales-Footnote-31147787 ++Node: Contributors1148008 ++Node: History summary1153953 ++Node: Installation1155333 ++Node: Gawk Distribution1156277 ++Node: Getting1156761 ++Node: Extracting1157724 ++Node: Distribution contents1159362 ++Node: Unix Installation1165842 ++Node: Quick Installation1166524 ++Node: Shell Startup Files1168938 ++Node: Additional Configuration Options1170027 ++Node: Configuration Philosophy1172320 ++Node: Non-Unix Installation1174689 ++Node: PC Installation1175149 ++Node: PC Binary Installation1175987 ++Node: PC Compiling1176422 ++Node: PC Using1177539 ++Node: Cygwin1180754 ++Node: MSYS1181853 ++Node: VMS Installation1182354 ++Node: VMS Compilation1183145 ++Ref: VMS Compilation-Footnote-11184374 ++Node: VMS Dynamic Extensions1184432 ++Node: VMS Installation Details1186117 ++Node: VMS Running1188370 ++Node: VMS GNV1192649 ++Node: VMS Old Gawk1193384 ++Node: Bugs1193855 ++Node: Bug address1194518 ++Node: Usenet1197310 ++Node: Maintainers1198087 ++Node: Other Versions1199348 ++Node: Installation summary1206110 ++Node: Notes1207312 ++Node: Compatibility Mode1208177 ++Node: Additions1208959 ++Node: Accessing The Source1209884 ++Node: Adding Code1211321 ++Node: New Ports1217540 ++Node: Derived Files1222028 ++Ref: Derived Files-Footnote-11227674 ++Ref: Derived Files-Footnote-21227709 ++Ref: Derived Files-Footnote-31228307 ++Node: Future Extensions1228421 ++Node: Implementation Limitations1229079 ++Node: Extension Design1230262 ++Node: Old Extension Problems1231416 ++Ref: Old Extension Problems-Footnote-11232934 ++Node: Extension New Mechanism Goals1232991 ++Ref: Extension New Mechanism Goals-Footnote-11236355 ++Node: Extension Other Design Decisions1236544 ++Node: Extension Future Growth1238657 ++Node: Old Extension Mechanism1239493 ++Node: Notes summary1241256 ++Node: Basic Concepts1242438 ++Node: Basic High Level1243119 ++Ref: figure-general-flow1243401 ++Ref: figure-process-flow1244086 ++Ref: Basic High Level-Footnote-11247387 ++Node: Basic Data Typing1247572 ++Node: Glossary1250900 ++Node: Copying1282738 ++Node: GNU Free Documentation License1320281 ++Node: Index1345401 +  + End Tag Table +diff --git a/doc/gawk.texi b/doc/gawk.texi +index 7b69b52..7dfa3b3 100644 +--- a/doc/gawk.texi ++++ b/doc/gawk.texi +@@ -9557,6 +9557,25 @@ the field width. Here is a list of the format-control letters: + + @c @asis for docbook to come out right + @table @asis ++@item @code{%a}, @code{%A} ++A floating point number of the form ++[@code{-}]@code{0x@var{h}.@var{hhhh}p+-@var{dd}} ++(C99 hexadecimal floating point format). ++For @code{%A}, ++uppercase letters are used instead of lowercase ones. ++ ++@quotation NOTE ++While the current POSIX standard requires support for @code{%a} ++and @code{%A} in @command{awk}, as far as we know, no other version ++of @command{awk} actually implements it. It's use is thus highly ++nonportable! ++ ++Furthermore, these formats are not available on any system where the ++underlying C library @code{printf()} function does not support them. As ++of this writing, among current systems, only OpenVMS is known to not ++support them. ++@end quotation ++ + @item @code{%c} + Print a number as a character; thus, @samp{printf "%c", + 65} outputs the letter @samp{A}. The output for a string value is +diff --git a/doc/gawktexi.in b/doc/gawktexi.in +index 6203e1a..f2cb710 100644 +--- a/doc/gawktexi.in ++++ b/doc/gawktexi.in +@@ -9156,6 +9156,25 @@ the field width. Here is a list of the format-control letters: + + @c @asis for docbook to come out right + @table @asis ++@item @code{%a}, @code{%A} ++A floating point number of the form ++[@code{-}]@code{0x@var{h}.@var{hhhh}p+-@var{dd}} ++(C99 hexadecimal floating point format). ++For @code{%A}, ++uppercase letters are used instead of lowercase ones. ++ ++@quotation NOTE ++While the current POSIX standard requires support for @code{%a} ++and @code{%A} in @command{awk}, as far as we know, no other version ++of @command{awk} actually implements it. It's use is thus highly ++nonportable! ++ ++Furthermore, these formats are not available on any system where the ++underlying C library @code{printf()} function does not support them. As ++of this writing, among current systems, only OpenVMS is known to not ++support them. ++@end quotation ++ + @item @code{%c} + Print a number as a character; thus, @samp{printf "%c", + 65} outputs the letter @samp{A}. The output for a string value is +diff --git a/doc/wordlist b/doc/wordlist +index 3c3c7e9..3763056 100644 +--- a/doc/wordlist ++++ b/doc/wordlist +@@ -865,6 +865,7 @@ dayname + db + dcgettext + dcngettext ++dd + ddd + de + deallocations +@@ -1132,6 +1133,7 @@ helpfull + helplib + hfil + hh ++hhhh + hhob + histsort + hlp +diff --git a/doc/wordlist2 b/doc/wordlist2 +index 9275fdb..7bf7ad3 100644 +--- a/doc/wordlist2 ++++ b/doc/wordlist2 +@@ -60,6 +60,7 @@ distclean + docbook + du + dvi ++elled + emph + en + env +diff --git a/pc/config.h b/pc/config.h +index de2b7ec..2ec5352 100644 +--- a/pc/config.h ++++ b/pc/config.h +@@ -473,6 +473,9 @@ + /* Define to the version of this package. */ + #define PACKAGE_VERSION "4.2.1" + ++/* Define to 1 if *printf supports %a format */ ++#define PRINTF_HAS_A_FORMAT 1 ++ + /* Define to 1 if *printf supports %F format */ + #ifdef __DJGPP__ + #define PRINTF_HAS_F_FORMAT 1 +diff --git a/pc/config.sed b/pc/config.sed +index 5b3cc32..a7ba878 100644 +--- a/pc/config.sed ++++ b/pc/config.sed +@@ -273,6 +273,8 @@ s/^#undef HAVE_VPRINTF *$/#define HAVE_VPRINTF 1/ + #ifdef __DJGPP__\ + #define HAVE__BOOL 1\ + #endif ++/^#undef PRINTF_HAS_A_FORMAT *$/c\ ++#define PRINTF_HAS_A_FORMAT 1 + /^#undef PRINTF_HAS_F_FORMAT *$/c\ + #ifdef __DJGPP__\ + #define PRINTF_HAS_F_FORMAT 1\ +-- +2.14.4 + diff --git a/gawk-4.2.1-001-remove-the-tail-recursion-optimization.patch b/gawk-4.2.1-001-remove-the-tail-recursion-optimization.patch new file mode 100644 index 0000000..0063c28 --- /dev/null +++ b/gawk-4.2.1-001-remove-the-tail-recursion-optimization.patch @@ -0,0 +1,309 @@ +From 47316d294571673a8dbf1e9e435893e2660f46a8 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/gawk-4.2.1-002-copy-MPZ-MPFR-bits-also-in-r_dupnode.patch b/gawk-4.2.1-002-copy-MPZ-MPFR-bits-also-in-r_dupnode.patch new file mode 100644 index 0000000..af71827 --- /dev/null +++ b/gawk-4.2.1-002-copy-MPZ-MPFR-bits-also-in-r_dupnode.patch @@ -0,0 +1,208 @@ +From 0fafaee9bb38a3ea4b8be4009e9ce99334460ddd Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/gawk-4.2.1-003-fix-rebuilding-records-if-using-API-parser.patch b/gawk-4.2.1-003-fix-rebuilding-records-if-using-API-parser.patch new file mode 100644 index 0000000..f5740e0 --- /dev/null +++ b/gawk-4.2.1-003-fix-rebuilding-records-if-using-API-parser.patch @@ -0,0 +1,129 @@ +From 50f617427403434dcca156fb081c1bdc7eb714b7 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/gawk-4.2.1-004-fix-a-corner-case-with-EPIPE-to-stdout-stderr.patch b/gawk-4.2.1-004-fix-a-corner-case-with-EPIPE-to-stdout-stderr.patch new file mode 100644 index 0000000..0671fd4 --- /dev/null +++ b/gawk-4.2.1-004-fix-a-corner-case-with-EPIPE-to-stdout-stderr.patch @@ -0,0 +1,116 @@ +From 06fe8e801efc0e6a098d93cf104157fb4ef705e8 Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" +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 + diff --git a/gawk-4.2.1-200-fix-build-for-f29.patch b/gawk-4.2.1-200-fix-build-for-f29.patch new file mode 100644 index 0000000..5e63ede --- /dev/null +++ b/gawk-4.2.1-200-fix-build-for-f29.patch @@ -0,0 +1,26 @@ +From fad95bcf352bd77e5ed42aaf20eb0e24b761c62f Mon Sep 17 00:00:00 2001 +From: 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 + diff --git a/gawk-4.2.1.tar.xz b/gawk-4.2.1.tar.xz new file mode 100644 index 0000000..156da1e Binary files /dev/null and b/gawk-4.2.1.tar.xz differ diff --git a/gawk.spec b/gawk.spec new file mode 100644 index 0000000..f32ac5f --- /dev/null +++ b/gawk.spec @@ -0,0 +1,125 @@ +%global gawk_api_major %(tar -xf %{name}-%{version}.tar.xz %{name}-%{version}/gawkapi.h --to-stdout |\ + egrep -i "gawk_api_major.*[0-9]+" | egrep -o "[0-9]") +%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]") +Name: gawk +Version: 4.2.1 +Release: 4 +License: GPLv3+ and GPLv2+ and LGPLv2+ and BSD +Summary: The GNU version of the AWK text processing utility +URL: https://www.gnu.org/software/gawk/ +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 + +BuildRequires: git gcc automake grep +BuildRequires: bison texinfo texinfo-tex ghostscript texlive-ec texlive-cm-super glibc-all-langpacks +BuildRequires: libsigsegv-devel mpfr-devel readline-devel +Requires: filesystem >= 3 + + +Provides: /bin/awk +Provides: /bin/gawk +Provides: gawk(abi) = %{gawk_api_major}.%{gawk_api_minor} + + + +%description +The gawk package is the GNU implementation of awk. +The awk utility interprets a special-purpose programming language that +makes it possible to handle simple data-reformatting jobs with just a +few lines of code. + + +%package devel +Summary: Header file for gawk extensions development +Requires: %{name}%{?_isa} = %{version}-%{release} +%description devel +This subpackage provides /usr/include/gawkapi.h header file, which contains +definitions for use by extension functions calling into gawk. + +%package help +Summary: Documentation for gawk utility +Requires: %{name} = %{version}-%{release} +Requires: man,info +BuildArch: noarch +%description help +This subpackage provide addtional documents and manuals for gawk. + +%package lang +Summary: Language files and locale +Requires: %{name} = %{version}-%{release} +%description lang +This subpackage provides with language releated files and locales for gawk. + +%prep +%autosetup -n %{name}-%{version} -S git + +%build +autoreconf -fv +%configure +%make_build +%make_build -C doc pdf +mkdir -p html/gawk html/gawkinet +makeinfo --html -I doc -o html/gawk doc/gawk.texi +makeinfo --html -I doc -o html/gawkinet doc/gawkinet.texi + +%check +make check + +%install +%make_install + +rm -f ${RPM_BUILD_ROOT}%{_bindir}/gawk-%{version}* +rm -f ${RPM_BUILD_ROOT}%{_infodir}/dir + +ln -sf gawk ${RPM_BUILD_ROOT}%{_bindir}/awk +ln -sf gawk.1.gz ${RPM_BUILD_ROOT}%{_mandir}/man1/awk.1.gz +ln -sf /usr/share/awk ${RPM_BUILD_ROOT}%{_datadir}/gawk +ln -sf /usr/libexec/awk ${RPM_BUILD_ROOT}%{_libexecdir}/gawk + +install -m 0755 -d ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/gawk/ +install -m 0755 -d ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/gawkinet/ +install -m 0644 -p html/gawk/* ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/gawk/ +install -m 0644 -p html/gawkinet/* ${RPM_BUILD_ROOT}%{_docdir}/%{name}/html/gawkinet/ +install -m 0644 -p doc/gawk.{pdf,ps} ${RPM_BUILD_ROOT}%{_docdir}/%{name} +install -m 0644 -p doc/gawkinet.{pdf,ps} ${RPM_BUILD_ROOT}%{_docdir}/%{name} + +%files +%doc NEWS README POSIX.STD +%license COPYING +%{_bindir}/*awk +%{_libdir}/*awk +%{_datadir}/*awk +%{_libexecdir}/*awk +%{_sysconfdir}/profile.d/gawk.* + +%files devel +%{_includedir}/gawkapi.h + +%files help +%doc NEWS POSIX.STD README_d/README.multibyte +%doc %{_docdir}/%{name}/gawk.{pdf,ps} +%doc %{_docdir}/%{name}/gawkinet.{pdf,ps} +%doc %{_docdir}/%{name}/html +%{_mandir}/man{1/*,3/*} +%{_infodir}/*awk*.info* + +%files lang +%{_datadir}/locale/* + +%changelog +* Thu Aug 29 2019 openEuler Buildteam - 4.2.1-4 +- Package Init