aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog60
-rw-r--r--awk.h15
-rw-r--r--awkgram.c6
-rw-r--r--awkgram.y6
-rw-r--r--awklib/eg/lib/intdiv.awk7
-rw-r--r--builtin.c2
-rw-r--r--configh.in3
-rwxr-xr-xconfigure18
-rw-r--r--configure.ac11
-rw-r--r--doc/ChangeLog7
-rw-r--r--doc/awkcard.in6
-rw-r--r--doc/gawk.12
-rw-r--r--doc/gawk.info771
-rw-r--r--doc/gawk.texi32
-rw-r--r--doc/gawktexi.in32
-rw-r--r--extension/ChangeLog30
-rw-r--r--extension/Makefile.am5
-rw-r--r--extension/Makefile.in43
-rw-r--r--extension/aclocal.m41
-rw-r--r--extension/configh.in6
-rwxr-xr-xextension/configure88
-rw-r--r--extension/configure.ac13
-rw-r--r--extension/intdiv.c215
-rw-r--r--gawkapi.c117
-rw-r--r--gawkapi.h97
-rw-r--r--mpfr.c22
-rw-r--r--node.c14
-rw-r--r--test/ChangeLog5
-rw-r--r--test/dumpvars.ok2
-rw-r--r--test/id.ok1
-rw-r--r--test/mpfrsqrt.awk2
-rw-r--r--test/symtab6.ok2
-rw-r--r--test/symtab8.ok2
33 files changed, 1133 insertions, 510 deletions
diff --git a/ChangeLog b/ChangeLog
index 39df2d48..9238218e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,11 +12,27 @@
2017-04-16 Arnold D. Robbins <arnold@skeeve.com>
+ Rename intdiv it intdiv0 and require enabling at configure time.
+
+ * awkgram.y (tokentab): Bracket intdiv0 in #ifdef SUPPLY_INTDIV.
+ (snode): Similar.
+ * builtin.c (do_intdiv): Bracket in #ifdef SUPPLY_INTDIV.
+ * mpfr.c (do_mpfr_intdiv): Bracket in #ifdef SUPPLY_INTDIV.
+ * configure.ac: Add --enable-builtin-intdiv0 option. If enabled,
+ also revise doc/gawktexi.in.
+
+2017-04-16 Arnold D. Robbins <arnold@skeeve.com>
+
* builtin.c (do_intdiv): Use DEREF on the arguments.
Thanks to Andrew Schorr for finding the problem.
* mpfr.c (do_mpfr_intdiv): Return -1 if numerator or denominator
are not valid numbers. Unref various bits first.
+2017-04-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (make_number_node): Simplify.
+ * mpfr.c (mpg_node): Change parameter name to `flags'.
+
2017-04-12 Arnold D. Robbins <arnold@skeeve.com>
* mpfr.c (mpg_format_val): Set STRCUR flag when we're done.
@@ -25,6 +41,9 @@
* builtin.c (do_dcgettext): Move declaration of reslen to
outside the ifdefs. Thanks to Hermann Peifer for the report.
+ * gawkapi.c (awk_value_to_node): Initialize ext_ret_val to NULL
+ to avoid compiler warnings.
+
2017-04-12 Manuel Collado <m-collado@users.sourceforge.net>
Fix the FPAT bug reported by Ed Morton in the gawk-bug mailing list.
@@ -503,6 +522,47 @@
not updating the node correctly by setting STRING and STRCUR flags
and setting stfmt.
+2017-01-06 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ Enhance API to support extended-precision arithmetic.
+ * awk.h (enum block_id): Add new values BLOCK_MPFR and BLOCK_MPZ.
+ (make_number_node): New inline function to reduce code duplication
+ for creating numeric nodes.
+ * gawkapi.h (gawk_api_major_version): Bump to 3.
+ (awk_number_t): New typedef to represent numbers with varying internal
+ representations.
+ (awk_value_t): For numbers, replace double with awk_number_t.
+ (num_value): Redefine.
+ (num_type, num_ptr): New defines for awk_number_t union members.
+ (gawk_api_t): Add constants for version checking: gmp_major_version,
+ gmp_minor_version, mpfr_major_version, and mpfr_minor_version.
+ Add functions api_get_mpfr and api_get_mpz to allocate memory for
+ extended-precision numbers to hand to gawk.
+ (get_mpfr_ptr, get_mpz_ptr): Helper macros to wrap api_get_mpfr and
+ api_get_mpz.
+ (make_number): Modify to populate awk_number_t correctly.
+ (make_number_mpz, make_number_mpfr): New helper functions to create
+ extended-precision numeric nodes.
+ (check_mpfr_version): New macro to check GMP/MPFR version compatibility
+ in extensions that want to support extended-precision math.
+ * gawkapi.c (getmpfr, freempfr, getmpz, freempz): New macros to
+ allocate and free memory blocks for extended-precision math.
+ (awk_value_to_node): For AWK_NUMBER values, support three different
+ kinds of internal numbers: double, mpz_t, and mpfr_t.
+ (assign_number): New helper function to convert a numeric node to
+ an awk_value_t.
+ (node_to_awk_value): Use assign_number to pass numbers properly.
+ (api_get_mpfr): Implement new api_get_mpfr hook.
+ (api_get_mpfz): Implement new api_get_mpz hook.
+ (api_impl): Add GMP & MPFR versions, api_get_mpfr, and api_get_mpz.
+ * node.c (r_make_number): Use new make_number_node inline function
+ to reduce code duplication.
+ (nextfree): Add block allocators for mpfr_t and mpz_t.
+ (more_blocks): Add an assert to protect against cases where the block
+ size is too small to hold our structure.
+ * mpfr.c (mpg_node): Use new make_number_node inline function
+ to reduce code duplication.
+
2017-01-04 Arnold Robbins <arnold@skeeve.com>
* config.guess, config.sub, compile, depcomp: Sync from latest
diff --git a/awk.h b/awk.h
index 33ea980d..e2a400a6 100644
--- a/awk.h
+++ b/awk.h
@@ -1081,6 +1081,8 @@ struct block_header {
enum block_id {
BLOCK_NODE = 0,
BLOCK_BUCKET,
+ BLOCK_MPFR,
+ BLOCK_MPZ,
BLOCK_MAX /* count */
};
@@ -1984,6 +1986,19 @@ erealloc_real(void *ptr, size_t count, const char *where, const char *var, const
return ret;
}
+/* make_number_node --- make node with the given flags */
+
+static inline NODE *
+make_number_node(unsigned int flags)
+{
+ NODE *r;
+ getnode(r);
+ memset(r, 0, sizeof(*r));
+ r->type = Node_val;
+ r->valref = 1;
+ r->flags = (flags|MALLOC|NUMBER|NUMCUR);
+ return r;
+}
/*
* str_terminate_f, str_terminate, str_restore: function and macros to
diff --git a/awkgram.c b/awkgram.c
index 3ad04500..fc935dc4 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4547,7 +4547,9 @@ static const struct token tokentab[] = {
{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0},
{"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0},
{"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)},
-{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
+#ifdef SUPPLY_INTDIV
+{"intdiv0", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
+#endif
{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0},
{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0},
{"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0},
@@ -6846,6 +6848,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
arg = subn->nexti;
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg_untyped; /* argument may be untyped */
+#ifdef SUPPLY_INTDIV
} else if (r->builtin == do_intdiv
#ifdef HAVE_MPFR
|| r->builtin == MPF(intdiv)
@@ -6855,6 +6858,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
ip = arg->lasti;
if (ip->opcode == Op_push)
ip->opcode = Op_push_array;
+#endif /* SUPPLY_INTDIV */
} else if (r->builtin == do_match) {
static bool warned = false;
diff --git a/awkgram.y b/awkgram.y
index 46970eee..3cdb77d3 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2127,7 +2127,9 @@ static const struct token tokentab[] = {
{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0},
{"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0},
{"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)},
-{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
+#ifdef SUPPLY_INTDIV
+{"intdiv0", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
+#endif
{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0},
{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0},
{"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0},
@@ -4426,6 +4428,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
arg = subn->nexti;
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg_untyped; /* argument may be untyped */
+#ifdef SUPPLY_INTDIV
} else if (r->builtin == do_intdiv
#ifdef HAVE_MPFR
|| r->builtin == MPF(intdiv)
@@ -4435,6 +4438,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
ip = arg->lasti;
if (ip->opcode == Op_push)
ip->opcode = Op_push_array;
+#endif /* SUPPLY_INTDIV */
} else if (r->builtin == do_match) {
static bool warned = false;
diff --git a/awklib/eg/lib/intdiv.awk b/awklib/eg/lib/intdiv.awk
index dbc553b0..9de5978e 100644
--- a/awklib/eg/lib/intdiv.awk
+++ b/awklib/eg/lib/intdiv.awk
@@ -1,4 +1,4 @@
-# intdiv --- do integer division
+# intdiv0 --- do integer division
#
# Arnold Robbins, arnold@skeeve.com, Public Domain
@@ -6,8 +6,11 @@
#
# Name changed from div() to intdiv()
# April, 2015
+#
+# Changed to intdiv0()
+# April, 2016
-function intdiv(numerator, denominator, result)
+function intdiv0(numerator, denominator, result)
{
split("", result)
diff --git a/builtin.c b/builtin.c
index 87d9dcb8..b60d8b42 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3971,6 +3971,7 @@ do_bindtextdomain(int nargs)
return make_string(the_result, strlen(the_result));
}
+#ifdef SUPPLY_INTDIV
/* do_intdiv --- do integer division, return quotient and remainder in dest array */
/*
@@ -4039,6 +4040,7 @@ do_intdiv(int nargs)
return make_number((AWKNUM) 0.0);
}
+#endif /* SUPPLY_INTDIV */
/* do_typeof --- return a string with the type of the arg */
diff --git a/configh.in b/configh.in
index 41f63d4f..4d5ce95e 100644
--- a/configh.in
+++ b/configh.in
@@ -377,6 +377,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* enable built-in intdiv0 function */
+#undef SUPPLY_INTDIV
+
/* some systems define this type here */
#undef TIME_T_IN_SYS_TYPES_H
diff --git a/configure b/configure
index c1b5eca4..4b1b3209 100755
--- a/configure
+++ b/configure
@@ -766,6 +766,7 @@ enable_silent_rules
with_whiny_user_strftime
enable_lint
enable_severe_portability_problems
+enable_builtin_intdiv0
enable_mpfr
enable_dependency_tracking
enable_largefile
@@ -1413,6 +1414,8 @@ Optional Features:
--disable-lint do not compile in gawk lint checking
--enable-severe-portability-problems
allow really nasty portability problems
+ --enable-builtin-intdiv0
+ enable built-in intdiv0 function
--disable-mpfr do not check for MPFR
--enable-dependency-tracking
do not reject slow dependency extractors
@@ -3245,6 +3248,21 @@ $as_echo "#define I_DONT_KNOW_WHAT_IM_DOING 1" >>confdefs.h
fi
+# Check whether --enable-builtin-intdiv0 was given.
+if test "${enable_builtin_intdiv0+set}" = set; then :
+ enableval=$enable_builtin_intdiv0; if test "$enableval" = yes
+ then
+
+$as_echo "#define SUPPLY_INTDIV 1" >>confdefs.h
+
+ sed '/^@set PATCHLEVEL/a\
+@set INTDIV' < "$srcdir"/doc/gawktexi.in > foo
+ cp foo "$srcdir"/doc/gawktexi.in
+ rm foo
+ fi
+
+fi
+
SKIP_MPFR=no
# Check whether --enable-mpfr was given.
diff --git a/configure.ac b/configure.ac
index 011532f4..79a70e3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,17 @@ AC_ARG_ENABLE([severe-portability-problems],
AC_DEFINE(I_DONT_KNOW_WHAT_IM_DOING, 1, [enable severe portability problems])
fi
)
+AC_ARG_ENABLE([builtin-intdiv0],
+ [AS_HELP_STRING([--enable-builtin-intdiv0],[enable built-in intdiv0 function])],
+ if test "$enableval" = yes
+ then
+ AC_DEFINE(SUPPLY_INTDIV, 1, [enable built-in intdiv0 function])
+ sed '/^@set PATCHLEVEL/a\
+@set INTDIV' < "$srcdir"/doc/gawktexi.in > foo
+ cp foo "$srcdir"/doc/gawktexi.in
+ rm foo
+ fi
+)
SKIP_MPFR=no
AC_ARG_ENABLE([mpfr],
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 24ff43aa..dd8b910f 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -4,6 +4,13 @@
2017-04-16 Arnold D. Robbins <arnold@skeeve.com>
+ * awkcard.in: Comment out description of intdiv().
+ * gawk.1: Ditto.
+ * gawktexi.in: References to intdiv changed to intdiv0 and
+ bracketed inside @ifset INTDIV. Not set by default.
+
+2017-04-16 Arnold D. Robbins <arnold@skeeve.com>
+
* gawktexi.in: Improve documentation of the intdiv() function.
2017-04-12 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/doc/awkcard.in b/doc/awkcard.in
index 86aeee2e..165fca43 100644
--- a/doc/awkcard.in
+++ b/doc/awkcard.in
@@ -1617,9 +1617,9 @@ l lw(1.9i).
\*(FCcos(\*(FIexpr\*(FC)\*(FR The cosine of \*(FIexpr\fP, which is in radians.
\*(FCexp(\*(FIexpr\*(FC)\*(FR The exponential function (\*(FIe \*(FC^ \*(FIx\*(FR).
\*(FCint(\*(FIexpr\*(FC)\*(FR Truncate to integer.
-\*(CB\*(FCintdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI r\*(FR\*(FC)\*(FR T{
-Return result of integer division in \*(FIr\*(FR.\*(CD
-T}
+.\" \*(CB\*(FCintdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI r\*(FR\*(FC)\*(FR T{
+.\" Return result of integer division in \*(FIr\*(FR.\*(CD
+.\" T}
\*(FClog(\*(FIexpr\*(FC)\*(FR The natural logarithm function (base \*(FIe\^\*(FR).
\*(FCrand()\fP A random number \*(FIN\fP such that 0 \(<= \*(FIN\fP < 1.
\*(FCsin(\*(FIexpr\*(FC)\*(FR The sine of \*(FIexpr\fP, which is in radians.
diff --git a/doc/gawk.1 b/doc/gawk.1
index b04cb013..1b42cc90 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -2711,6 +2711,7 @@ The exponential function.
.TP
.BI int( expr )
Truncate to integer.
+.ig
.TP
.BI intdiv( num ", " denom ", " result )
Truncate
@@ -2728,6 +2729,7 @@ This is a
.I gawk
extension, primarily of value when working with
arbitrarily large integers.
+..
.TP
.BI log( expr )
The natural logarithm function.
diff --git a/doc/gawk.info b/doc/gawk.info
index f2fd50fe..20702093 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -12267,24 +12267,6 @@ brackets ([ ]):
truncated toward zero. For example, 'int(3)' is 3, 'int(3.9)' is
3, 'int(-3.9)' is -3, and 'int(-3)' is -3 as well.
-'intdiv(NUMERATOR, DENOMINATOR, RESULT)'
- Perform integer division, similar to the standard C 'div()'
- function. First, truncate 'numerator' and 'denominator' towards
- zero, creating integer values. Clear the 'result' array, and then
- set 'result["quotient"]' to the result of 'numerator /
- denominator', truncated towards zero to an integer, and set
- 'result["remainder"]' to the result of 'numerator % denominator',
- truncated towards zero to an integer. Attempting division by zero
- causes a fatal error. The function returns zero upon success, and
- -1 upon error.
-
- This function is primarily intended for use with arbitrary length
- integers; it avoids creating MPFR arbitrary precision
- floating-point values (*note Arbitrary Precision Integers::).
-
- This function is a 'gawk' extension. It is not available in
- compatibility mode (*note Options::).
-
'log(X)'
Return the natural logarithm of X, if X is positive; otherwise,
return 'NaN' ("not a number") on IEEE 754 systems. Additionally,
@@ -23081,59 +23063,7 @@ the following:
When dividing two arbitrary precision integers with either '/' or
'%', the result is typically an arbitrary precision floating point value
-(unless the denominator evenly divides into the numerator). In order to
-do integer division or remainder with arbitrary precision integers, use
-the built-in 'intdiv()' function (*note Numeric Functions::).
-
- You can simulate the 'intdiv()' function in standard 'awk' using this
-user-defined function:
-
- # intdiv --- do integer division
-
- function intdiv(numerator, denominator, result)
- {
- split("", result)
-
- numerator = int(numerator)
- denominator = int(denominator)
- result["quotient"] = int(numerator / denominator)
- result["remainder"] = int(numerator % denominator)
-
- return 0.0
- }
-
- The following example program, contributed by Katie Wasserman, uses
-'intdiv()' to compute the digits of pi to as many places as you choose
-to set:
-
- # pi.awk --- compute the digits of pi
-
- BEGIN {
- digits = 100000
- two = 2 * 10 ^ digits
- pi = two
- for (m = digits * 4; m > 0; --m) {
- d = m * 2 + 1
- x = pi * m
- intdiv(x, d, result)
- pi = result["quotient"]
- pi = pi + two
- }
- print pi
- }
-
- When asked about the algorithm used, Katie replied:
-
- It's not that well known but it's not that obscure either. It's
- Euler's modification to Newton's method for calculating pi. Take a
- look at lines (23) - (25) here:
- <http://mathworld.wolfram.com/PiFormulas.html>.
-
- The algorithm I wrote simply expands the multiply by 2 and works
- from the innermost expression outwards. I used this to program HP
- calculators because it's quite easy to modify for tiny memory
- devices with smallish word sizes. See
- <http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899>.
+(unless the denominator evenly divides into the numerator).
---------- Footnotes ----------
@@ -27408,9 +27338,6 @@ current version of 'gawk'.
- The 'bindtextdomain()', 'dcgettext()', and 'dcngettext()'
functions for internationalization (*note Programmer i18n::)
- - The 'intdiv()' function for doing integer division and
- remainder (*note Numeric Functions::)
-
* Changes and/or additions in the command-line options:
- The 'AWKPATH' environment variable for specifying a path
@@ -27873,8 +27800,6 @@ POSIX 'awk', in the order they were added to 'gawk'.
* The 'igawk' program and its manual page are no longer installed
when 'gawk' is built. *Note Igawk Program::.
- * The 'intdiv()' function. *Note Numeric Functions::.
-
* The maximum number of hexadecimal digits in '\x' escapes is now
two. *Note Escape Sequences::.
@@ -34283,8 +34208,6 @@ Index
* instruction tracing, in debugger: Debugger Info. (line 90)
* int: Numeric Functions. (line 24)
* INT signal (MS-Windows): Profiling. (line 212)
-* intdiv: Numeric Functions. (line 29)
-* intdiv <1>: Numeric Functions. (line 29)
* integer array indices: Numeric Array Subscripts.
(line 31)
* integers, arbitrary precision: Arbitrary Precision Integers.
@@ -34434,9 +34357,9 @@ Index
* localization: I18N and L10N. (line 6)
* localization, See internationalization, localization: I18N and L10N.
(line 6)
-* log: Numeric Functions. (line 47)
+* log: Numeric Functions. (line 29)
* log files, timestamps in: Time Functions. (line 6)
-* logarithm: Numeric Functions. (line 47)
+* logarithm: Numeric Functions. (line 29)
* logical false/true: Truth Values. (line 6)
* logical operators, See Boolean expressions: Boolean Ops. (line 6)
* login information: Passwd Functions. (line 16)
@@ -34899,12 +34822,12 @@ Index
* Rakitzis, Byron: History Sorting. (line 25)
* Ramey, Chet: Acknowledgments. (line 60)
* Ramey, Chet <1>: General Data Types. (line 6)
-* rand: Numeric Functions. (line 52)
+* rand: Numeric Functions. (line 34)
* random numbers, Cliff: Cliff Random Function.
(line 6)
* random numbers, rand()/srand() functions: Numeric Functions.
- (line 52)
-* random numbers, seed of: Numeric Functions. (line 82)
+ (line 34)
+* random numbers, seed of: Numeric Functions. (line 64)
* range expressions (regexps): Bracket Expressions. (line 6)
* range patterns: Ranges. (line 6)
* range patterns, line continuation and: Ranges. (line 64)
@@ -35082,7 +35005,7 @@ Index
* sed utility: Full Line Fields. (line 22)
* sed utility <1>: Simple Sed. (line 6)
* sed utility <2>: Glossary. (line 16)
-* seeding random number generator: Numeric Functions. (line 82)
+* seeding random number generator: Numeric Functions. (line 64)
* semicolon (;), AWKPATH variable and: PC Using. (line 9)
* semicolon (;), separating statements in actions: Statements/Lines.
(line 90)
@@ -35186,8 +35109,8 @@ Index
* SIGUSR1 signal, for dynamic profiling: Profiling. (line 186)
* silent debugger command: Debugger Execution Control.
(line 10)
-* sin: Numeric Functions. (line 93)
-* sine: Numeric Functions. (line 93)
+* sin: Numeric Functions. (line 75)
+* sine: Numeric Functions. (line 75)
* single quote ('): One-shot. (line 15)
* single quote (') in gawk command lines: Long. (line 35)
* single quote ('), in shell commands: Quoting. (line 48)
@@ -35237,10 +35160,10 @@ Index
* sprintf() function, OFMT variable and: User-modified. (line 116)
* sprintf() function, print/printf statements and: Round Function.
(line 6)
-* sqrt: Numeric Functions. (line 96)
+* sqrt: Numeric Functions. (line 78)
* square brackets ([]), regexp operator: Regexp Operators. (line 56)
-* square root: Numeric Functions. (line 96)
-* srand: Numeric Functions. (line 100)
+* square root: Numeric Functions. (line 78)
+* srand: Numeric Functions. (line 82)
* stack frame: Debugging Terms. (line 10)
* Stallman, Richard: Manual History. (line 6)
* Stallman, Richard <1>: Acknowledgments. (line 18)
@@ -35800,340 +35723,340 @@ Node: Functions516532
Node: Built-in517570
Node: Calling Built-in518651
Node: Numeric Functions520647
-Ref: Numeric Functions-Footnote-1525592
-Ref: Numeric Functions-Footnote-2525949
-Ref: Numeric Functions-Footnote-3525997
-Node: String Functions526269
-Ref: String Functions-Footnote-1549927
-Ref: String Functions-Footnote-2550055
-Ref: String Functions-Footnote-3550303
-Node: Gory Details550390
-Ref: table-sub-escapes552181
-Ref: table-sub-proposed553700
-Ref: table-posix-sub555063
-Ref: table-gensub-escapes556604
-Ref: Gory Details-Footnote-1557427
-Node: I/O Functions557581
-Ref: table-system-return-values564163
-Ref: I/O Functions-Footnote-1566143
-Ref: I/O Functions-Footnote-2566291
-Node: Time Functions566411
-Ref: Time Functions-Footnote-1577078
-Ref: Time Functions-Footnote-2577146
-Ref: Time Functions-Footnote-3577304
-Ref: Time Functions-Footnote-4577415
-Ref: Time Functions-Footnote-5577527
-Ref: Time Functions-Footnote-6577754
-Node: Bitwise Functions578020
-Ref: table-bitwise-ops578614
-Ref: Bitwise Functions-Footnote-1584647
-Ref: Bitwise Functions-Footnote-2584820
-Node: Type Functions585011
-Node: I18N Functions587686
-Node: User-defined589337
-Node: Definition Syntax590142
-Ref: Definition Syntax-Footnote-1595829
-Node: Function Example595900
-Ref: Function Example-Footnote-1598822
-Node: Function Caveats598844
-Node: Calling A Function599362
-Node: Variable Scope600320
-Node: Pass By Value/Reference603314
-Node: Return Statement606813
-Node: Dynamic Typing609792
-Node: Indirect Calls610722
-Ref: Indirect Calls-Footnote-1620973
-Node: Functions Summary621101
-Node: Library Functions623806
-Ref: Library Functions-Footnote-1627413
-Ref: Library Functions-Footnote-2627556
-Node: Library Names627727
-Ref: Library Names-Footnote-1631187
-Ref: Library Names-Footnote-2631410
-Node: General Functions631496
-Node: Strtonum Function632599
-Node: Assert Function635621
-Node: Round Function638947
-Node: Cliff Random Function640488
-Node: Ordinal Functions641504
-Ref: Ordinal Functions-Footnote-1644567
-Ref: Ordinal Functions-Footnote-2644819
-Node: Join Function645029
-Ref: Join Function-Footnote-1646799
-Node: Getlocaltime Function646999
-Node: Readfile Function650741
-Node: Shell Quoting652713
-Node: Data File Management654114
-Node: Filetrans Function654746
-Node: Rewind Function658842
-Node: File Checking660748
-Ref: File Checking-Footnote-1662082
-Node: Empty Files662283
-Node: Ignoring Assigns664262
-Node: Getopt Function665812
-Ref: Getopt Function-Footnote-1677281
-Node: Passwd Functions677481
-Ref: Passwd Functions-Footnote-1686320
-Node: Group Functions686408
-Ref: Group Functions-Footnote-1694306
-Node: Walking Arrays694513
-Node: Library Functions Summary697521
-Node: Library Exercises698927
-Node: Sample Programs699392
-Node: Running Examples700162
-Node: Clones700890
-Node: Cut Program702114
-Node: Egrep Program712043
-Ref: Egrep Program-Footnote-1719555
-Node: Id Program719665
-Node: Split Program723345
-Ref: Split Program-Footnote-1726804
-Node: Tee Program726933
-Node: Uniq Program729723
-Node: Wc Program737149
-Ref: Wc Program-Footnote-1741404
-Node: Miscellaneous Programs741498
-Node: Dupword Program742711
-Node: Alarm Program744741
-Node: Translate Program749596
-Ref: Translate Program-Footnote-1754161
-Node: Labels Program754431
-Ref: Labels Program-Footnote-1757782
-Node: Word Sorting757866
-Node: History Sorting761938
-Node: Extract Program763773
-Node: Simple Sed771302
-Node: Igawk Program774376
-Ref: Igawk Program-Footnote-1788707
-Ref: Igawk Program-Footnote-2788909
-Ref: Igawk Program-Footnote-3789031
-Node: Anagram Program789146
-Node: Signature Program792208
-Node: Programs Summary793455
-Node: Programs Exercises794669
-Ref: Programs Exercises-Footnote-1798798
-Node: Advanced Features798889
-Node: Nondecimal Data800879
-Node: Array Sorting802470
-Node: Controlling Array Traversal803170
-Ref: Controlling Array Traversal-Footnote-1811537
-Node: Array Sorting Functions811655
-Ref: Array Sorting Functions-Footnote-1816746
-Node: Two-way I/O816942
-Ref: Two-way I/O-Footnote-1823493
-Ref: Two-way I/O-Footnote-2823680
-Node: TCP/IP Networking823762
-Node: Profiling826880
-Ref: Profiling-Footnote-1835552
-Node: Advanced Features Summary835875
-Node: Internationalization837719
-Node: I18N and L10N839199
-Node: Explaining gettext839886
-Ref: Explaining gettext-Footnote-1845778
-Ref: Explaining gettext-Footnote-2845963
-Node: Programmer i18n846128
-Ref: Programmer i18n-Footnote-1851077
-Node: Translator i18n851126
-Node: String Extraction851920
-Ref: String Extraction-Footnote-1853052
-Node: Printf Ordering853138
-Ref: Printf Ordering-Footnote-1855924
-Node: I18N Portability855988
-Ref: I18N Portability-Footnote-1858444
-Node: I18N Example858507
-Ref: I18N Example-Footnote-1861313
-Node: Gawk I18N861386
-Node: I18N Summary862031
-Node: Debugger863372
-Node: Debugging864394
-Node: Debugging Concepts864835
-Node: Debugging Terms866644
-Node: Awk Debugging869219
-Node: Sample Debugging Session870125
-Node: Debugger Invocation870659
-Node: Finding The Bug872045
-Node: List of Debugger Commands878523
-Node: Breakpoint Control879856
-Node: Debugger Execution Control883550
-Node: Viewing And Changing Data886912
-Node: Execution Stack890286
-Node: Debugger Info891923
-Node: Miscellaneous Debugger Commands895994
-Node: Readline Support901082
-Node: Limitations901978
-Node: Debugging Summary904087
-Node: Arbitrary Precision Arithmetic905366
-Node: Computer Arithmetic906782
-Ref: table-numeric-ranges910373
-Ref: Computer Arithmetic-Footnote-1911095
-Node: Math Definitions911152
-Ref: table-ieee-formats914466
-Ref: Math Definitions-Footnote-1915069
-Node: MPFR features915174
-Node: FP Math Caution916891
-Ref: FP Math Caution-Footnote-1917963
-Node: Inexactness of computations918332
-Node: Inexact representation919292
-Node: Comparing FP Values920652
-Node: Errors accumulate921734
-Node: Getting Accuracy923167
-Node: Try To Round925877
-Node: Setting precision926776
-Ref: table-predefined-precision-strings927473
-Node: Setting the rounding mode929303
-Ref: table-gawk-rounding-modes929677
-Ref: Setting the rounding mode-Footnote-1933085
-Node: Arbitrary Precision Integers933264
-Ref: Arbitrary Precision Integers-Footnote-1938181
-Node: POSIX Floating Point Problems938330
-Ref: POSIX Floating Point Problems-Footnote-1942212
-Node: Floating point summary942250
-Node: Dynamic Extensions944440
-Node: Extension Intro945993
-Node: Plugin License947259
-Node: Extension Mechanism Outline948056
-Ref: figure-load-extension948495
-Ref: figure-register-new-function950060
-Ref: figure-call-new-function951152
-Node: Extension API Description953214
-Node: Extension API Functions Introduction954856
-Node: General Data Types960190
-Ref: General Data Types-Footnote-1967395
-Node: Memory Allocation Functions967694
-Ref: Memory Allocation Functions-Footnote-1970539
-Node: Constructor Functions970638
-Node: Registration Functions973637
-Node: Extension Functions974322
-Node: Exit Callback Functions979535
-Node: Extension Version String980785
-Node: Input Parsers981448
-Node: Output Wrappers994155
-Node: Two-way processors998667
-Node: Printing Messages1000932
-Ref: Printing Messages-Footnote-11002103
-Node: Updating ERRNO1002256
-Node: Requesting Values1002995
-Ref: table-value-types-returned1003732
-Node: Accessing Parameters1004668
-Node: Symbol Table Access1005903
-Node: Symbol table by name1006415
-Node: Symbol table by cookie1008204
-Ref: Symbol table by cookie-Footnote-11012389
-Node: Cached values1012453
-Ref: Cached values-Footnote-11015989
-Node: Array Manipulation1016080
-Ref: Array Manipulation-Footnote-11017171
-Node: Array Data Types1017208
-Ref: Array Data Types-Footnote-11019866
-Node: Array Functions1019958
-Node: Flattening Arrays1024357
-Node: Creating Arrays1031298
-Node: Redirection API1036067
-Node: Extension API Variables1038909
-Node: Extension Versioning1039542
-Ref: gawk-api-version1039979
-Node: Extension API Informational Variables1041707
-Node: Extension API Boilerplate1042771
-Node: Changes from API V11046633
-Node: Finding Extensions1047293
-Node: Extension Example1047852
-Node: Internal File Description1048650
-Node: Internal File Ops1052730
-Ref: Internal File Ops-Footnote-11064130
-Node: Using Internal File Ops1064270
-Ref: Using Internal File Ops-Footnote-11066653
-Node: Extension Samples1066927
-Node: Extension Sample File Functions1068456
-Node: Extension Sample Fnmatch1076105
-Node: Extension Sample Fork1077592
-Node: Extension Sample Inplace1078810
-Node: Extension Sample Ord1082020
-Node: Extension Sample Readdir1082856
-Ref: table-readdir-file-types1083745
-Node: Extension Sample Revout1084550
-Node: Extension Sample Rev2way1085139
-Node: Extension Sample Read write array1085879
-Node: Extension Sample Readfile1087821
-Node: Extension Sample Time1088916
-Node: Extension Sample API Tests1090264
-Node: gawkextlib1090756
-Node: Extension summary1093203
-Node: Extension Exercises1096905
-Node: Language History1098403
-Node: V7/SVR3.11100059
-Node: SVR41102211
-Node: POSIX1103645
-Node: BTL1105024
-Node: POSIX/GNU1105753
-Node: Feature History1111645
-Node: Common Extensions1126015
-Node: Ranges and Locales1127298
-Ref: Ranges and Locales-Footnote-11131914
-Ref: Ranges and Locales-Footnote-21131941
-Ref: Ranges and Locales-Footnote-31132176
-Node: Contributors1132397
-Node: History summary1137957
-Node: Installation1139337
-Node: Gawk Distribution1140281
-Node: Getting1140765
-Node: Extracting1141726
-Node: Distribution contents1143364
-Node: Unix Installation1149706
-Node: Quick Installation1150388
-Node: Shell Startup Files1152802
-Node: Additional Configuration Options1153891
-Node: Configuration Philosophy1155880
-Node: Non-Unix Installation1158249
-Node: PC Installation1158709
-Node: PC Binary Installation1159547
-Node: PC Compiling1159982
-Node: PC Using1161099
-Node: Cygwin1164144
-Node: MSYS1164914
-Node: VMS Installation1165415
-Node: VMS Compilation1166206
-Ref: VMS Compilation-Footnote-11167435
-Node: VMS Dynamic Extensions1167493
-Node: VMS Installation Details1169178
-Node: VMS Running1171431
-Node: VMS GNV1175710
-Node: VMS Old Gawk1176445
-Node: Bugs1176916
-Node: Bug address1177579
-Node: Usenet1179976
-Node: Maintainers1180753
-Node: Other Versions1182129
-Node: Installation summary1188713
-Node: Notes1189748
-Node: Compatibility Mode1190613
-Node: Additions1191395
-Node: Accessing The Source1192320
-Node: Adding Code1193755
-Node: New Ports1199973
-Node: Derived Files1204461
-Ref: Derived Files-Footnote-11209946
-Ref: Derived Files-Footnote-21209981
-Ref: Derived Files-Footnote-31210579
-Node: Future Extensions1210693
-Node: Implementation Limitations1211351
-Node: Extension Design1212534
-Node: Old Extension Problems1213688
-Ref: Old Extension Problems-Footnote-11215206
-Node: Extension New Mechanism Goals1215263
-Ref: Extension New Mechanism Goals-Footnote-11218627
-Node: Extension Other Design Decisions1218816
-Node: Extension Future Growth1220929
-Node: Old Extension Mechanism1221765
-Node: Notes summary1223528
-Node: Basic Concepts1224710
-Node: Basic High Level1225391
-Ref: figure-general-flow1225673
-Ref: figure-process-flow1226358
-Ref: Basic High Level-Footnote-11229659
-Node: Basic Data Typing1229844
-Node: Glossary1233172
-Node: Copying1265119
-Node: GNU Free Documentation License1302658
-Node: Index1327776
+Ref: Numeric Functions-Footnote-1524675
+Ref: Numeric Functions-Footnote-2525032
+Ref: Numeric Functions-Footnote-3525080
+Node: String Functions525352
+Ref: String Functions-Footnote-1549010
+Ref: String Functions-Footnote-2549138
+Ref: String Functions-Footnote-3549386
+Node: Gory Details549473
+Ref: table-sub-escapes551264
+Ref: table-sub-proposed552783
+Ref: table-posix-sub554146
+Ref: table-gensub-escapes555687
+Ref: Gory Details-Footnote-1556510
+Node: I/O Functions556664
+Ref: table-system-return-values563246
+Ref: I/O Functions-Footnote-1565226
+Ref: I/O Functions-Footnote-2565374
+Node: Time Functions565494
+Ref: Time Functions-Footnote-1576161
+Ref: Time Functions-Footnote-2576229
+Ref: Time Functions-Footnote-3576387
+Ref: Time Functions-Footnote-4576498
+Ref: Time Functions-Footnote-5576610
+Ref: Time Functions-Footnote-6576837
+Node: Bitwise Functions577103
+Ref: table-bitwise-ops577697
+Ref: Bitwise Functions-Footnote-1583730
+Ref: Bitwise Functions-Footnote-2583903
+Node: Type Functions584094
+Node: I18N Functions586769
+Node: User-defined588420
+Node: Definition Syntax589225
+Ref: Definition Syntax-Footnote-1594912
+Node: Function Example594983
+Ref: Function Example-Footnote-1597905
+Node: Function Caveats597927
+Node: Calling A Function598445
+Node: Variable Scope599403
+Node: Pass By Value/Reference602397
+Node: Return Statement605896
+Node: Dynamic Typing608875
+Node: Indirect Calls609805
+Ref: Indirect Calls-Footnote-1620056
+Node: Functions Summary620184
+Node: Library Functions622889
+Ref: Library Functions-Footnote-1626496
+Ref: Library Functions-Footnote-2626639
+Node: Library Names626810
+Ref: Library Names-Footnote-1630270
+Ref: Library Names-Footnote-2630493
+Node: General Functions630579
+Node: Strtonum Function631682
+Node: Assert Function634704
+Node: Round Function638030
+Node: Cliff Random Function639571
+Node: Ordinal Functions640587
+Ref: Ordinal Functions-Footnote-1643650
+Ref: Ordinal Functions-Footnote-2643902
+Node: Join Function644112
+Ref: Join Function-Footnote-1645882
+Node: Getlocaltime Function646082
+Node: Readfile Function649824
+Node: Shell Quoting651796
+Node: Data File Management653197
+Node: Filetrans Function653829
+Node: Rewind Function657925
+Node: File Checking659831
+Ref: File Checking-Footnote-1661165
+Node: Empty Files661366
+Node: Ignoring Assigns663345
+Node: Getopt Function664895
+Ref: Getopt Function-Footnote-1676364
+Node: Passwd Functions676564
+Ref: Passwd Functions-Footnote-1685403
+Node: Group Functions685491
+Ref: Group Functions-Footnote-1693389
+Node: Walking Arrays693596
+Node: Library Functions Summary696604
+Node: Library Exercises698010
+Node: Sample Programs698475
+Node: Running Examples699245
+Node: Clones699973
+Node: Cut Program701197
+Node: Egrep Program711126
+Ref: Egrep Program-Footnote-1718638
+Node: Id Program718748
+Node: Split Program722428
+Ref: Split Program-Footnote-1725887
+Node: Tee Program726016
+Node: Uniq Program728806
+Node: Wc Program736232
+Ref: Wc Program-Footnote-1740487
+Node: Miscellaneous Programs740581
+Node: Dupword Program741794
+Node: Alarm Program743824
+Node: Translate Program748679
+Ref: Translate Program-Footnote-1753244
+Node: Labels Program753514
+Ref: Labels Program-Footnote-1756865
+Node: Word Sorting756949
+Node: History Sorting761021
+Node: Extract Program762856
+Node: Simple Sed770385
+Node: Igawk Program773459
+Ref: Igawk Program-Footnote-1787790
+Ref: Igawk Program-Footnote-2787992
+Ref: Igawk Program-Footnote-3788114
+Node: Anagram Program788229
+Node: Signature Program791291
+Node: Programs Summary792538
+Node: Programs Exercises793752
+Ref: Programs Exercises-Footnote-1797881
+Node: Advanced Features797972
+Node: Nondecimal Data799962
+Node: Array Sorting801553
+Node: Controlling Array Traversal802253
+Ref: Controlling Array Traversal-Footnote-1810620
+Node: Array Sorting Functions810738
+Ref: Array Sorting Functions-Footnote-1815829
+Node: Two-way I/O816025
+Ref: Two-way I/O-Footnote-1822576
+Ref: Two-way I/O-Footnote-2822763
+Node: TCP/IP Networking822845
+Node: Profiling825963
+Ref: Profiling-Footnote-1834635
+Node: Advanced Features Summary834958
+Node: Internationalization836802
+Node: I18N and L10N838282
+Node: Explaining gettext838969
+Ref: Explaining gettext-Footnote-1844861
+Ref: Explaining gettext-Footnote-2845046
+Node: Programmer i18n845211
+Ref: Programmer i18n-Footnote-1850160
+Node: Translator i18n850209
+Node: String Extraction851003
+Ref: String Extraction-Footnote-1852135
+Node: Printf Ordering852221
+Ref: Printf Ordering-Footnote-1855007
+Node: I18N Portability855071
+Ref: I18N Portability-Footnote-1857527
+Node: I18N Example857590
+Ref: I18N Example-Footnote-1860396
+Node: Gawk I18N860469
+Node: I18N Summary861114
+Node: Debugger862455
+Node: Debugging863477
+Node: Debugging Concepts863918
+Node: Debugging Terms865727
+Node: Awk Debugging868302
+Node: Sample Debugging Session869208
+Node: Debugger Invocation869742
+Node: Finding The Bug871128
+Node: List of Debugger Commands877606
+Node: Breakpoint Control878939
+Node: Debugger Execution Control882633
+Node: Viewing And Changing Data885995
+Node: Execution Stack889369
+Node: Debugger Info891006
+Node: Miscellaneous Debugger Commands895077
+Node: Readline Support900165
+Node: Limitations901061
+Node: Debugging Summary903170
+Node: Arbitrary Precision Arithmetic904449
+Node: Computer Arithmetic905865
+Ref: table-numeric-ranges909456
+Ref: Computer Arithmetic-Footnote-1910178
+Node: Math Definitions910235
+Ref: table-ieee-formats913549
+Ref: Math Definitions-Footnote-1914152
+Node: MPFR features914257
+Node: FP Math Caution915974
+Ref: FP Math Caution-Footnote-1917046
+Node: Inexactness of computations917415
+Node: Inexact representation918375
+Node: Comparing FP Values919735
+Node: Errors accumulate920817
+Node: Getting Accuracy922250
+Node: Try To Round924960
+Node: Setting precision925859
+Ref: table-predefined-precision-strings926556
+Node: Setting the rounding mode928386
+Ref: table-gawk-rounding-modes928760
+Ref: Setting the rounding mode-Footnote-1932168
+Node: Arbitrary Precision Integers932347
+Ref: Arbitrary Precision Integers-Footnote-1935534
+Node: POSIX Floating Point Problems935683
+Ref: POSIX Floating Point Problems-Footnote-1939565
+Node: Floating point summary939603
+Node: Dynamic Extensions941793
+Node: Extension Intro943346
+Node: Plugin License944612
+Node: Extension Mechanism Outline945409
+Ref: figure-load-extension945848
+Ref: figure-register-new-function947413
+Ref: figure-call-new-function948505
+Node: Extension API Description950567
+Node: Extension API Functions Introduction952209
+Node: General Data Types957543
+Ref: General Data Types-Footnote-1964748
+Node: Memory Allocation Functions965047
+Ref: Memory Allocation Functions-Footnote-1967892
+Node: Constructor Functions967991
+Node: Registration Functions970990
+Node: Extension Functions971675
+Node: Exit Callback Functions976888
+Node: Extension Version String978138
+Node: Input Parsers978801
+Node: Output Wrappers991508
+Node: Two-way processors996020
+Node: Printing Messages998285
+Ref: Printing Messages-Footnote-1999456
+Node: Updating ERRNO999609
+Node: Requesting Values1000348
+Ref: table-value-types-returned1001085
+Node: Accessing Parameters1002021
+Node: Symbol Table Access1003256
+Node: Symbol table by name1003768
+Node: Symbol table by cookie1005557
+Ref: Symbol table by cookie-Footnote-11009742
+Node: Cached values1009806
+Ref: Cached values-Footnote-11013342
+Node: Array Manipulation1013433
+Ref: Array Manipulation-Footnote-11014524
+Node: Array Data Types1014561
+Ref: Array Data Types-Footnote-11017219
+Node: Array Functions1017311
+Node: Flattening Arrays1021710
+Node: Creating Arrays1028651
+Node: Redirection API1033420
+Node: Extension API Variables1036262
+Node: Extension Versioning1036895
+Ref: gawk-api-version1037332
+Node: Extension API Informational Variables1039060
+Node: Extension API Boilerplate1040124
+Node: Changes from API V11043986
+Node: Finding Extensions1044646
+Node: Extension Example1045205
+Node: Internal File Description1046003
+Node: Internal File Ops1050083
+Ref: Internal File Ops-Footnote-11061483
+Node: Using Internal File Ops1061623
+Ref: Using Internal File Ops-Footnote-11064006
+Node: Extension Samples1064280
+Node: Extension Sample File Functions1065809
+Node: Extension Sample Fnmatch1073458
+Node: Extension Sample Fork1074945
+Node: Extension Sample Inplace1076163
+Node: Extension Sample Ord1079373
+Node: Extension Sample Readdir1080209
+Ref: table-readdir-file-types1081098
+Node: Extension Sample Revout1081903
+Node: Extension Sample Rev2way1082492
+Node: Extension Sample Read write array1083232
+Node: Extension Sample Readfile1085174
+Node: Extension Sample Time1086269
+Node: Extension Sample API Tests1087617
+Node: gawkextlib1088109
+Node: Extension summary1090556
+Node: Extension Exercises1094258
+Node: Language History1095756
+Node: V7/SVR3.11097412
+Node: SVR41099564
+Node: POSIX1100998
+Node: BTL1102377
+Node: POSIX/GNU1103106
+Node: Feature History1108884
+Node: Common Extensions1123195
+Node: Ranges and Locales1124478
+Ref: Ranges and Locales-Footnote-11129094
+Ref: Ranges and Locales-Footnote-21129121
+Ref: Ranges and Locales-Footnote-31129356
+Node: Contributors1129577
+Node: History summary1135137
+Node: Installation1136517
+Node: Gawk Distribution1137461
+Node: Getting1137945
+Node: Extracting1138906
+Node: Distribution contents1140544
+Node: Unix Installation1146886
+Node: Quick Installation1147568
+Node: Shell Startup Files1149982
+Node: Additional Configuration Options1151071
+Node: Configuration Philosophy1153060
+Node: Non-Unix Installation1155429
+Node: PC Installation1155889
+Node: PC Binary Installation1156727
+Node: PC Compiling1157162
+Node: PC Using1158279
+Node: Cygwin1161324
+Node: MSYS1162094
+Node: VMS Installation1162595
+Node: VMS Compilation1163386
+Ref: VMS Compilation-Footnote-11164615
+Node: VMS Dynamic Extensions1164673
+Node: VMS Installation Details1166358
+Node: VMS Running1168611
+Node: VMS GNV1172890
+Node: VMS Old Gawk1173625
+Node: Bugs1174096
+Node: Bug address1174759
+Node: Usenet1177156
+Node: Maintainers1177933
+Node: Other Versions1179309
+Node: Installation summary1185893
+Node: Notes1186928
+Node: Compatibility Mode1187793
+Node: Additions1188575
+Node: Accessing The Source1189500
+Node: Adding Code1190935
+Node: New Ports1197153
+Node: Derived Files1201641
+Ref: Derived Files-Footnote-11207126
+Ref: Derived Files-Footnote-21207161
+Ref: Derived Files-Footnote-31207759
+Node: Future Extensions1207873
+Node: Implementation Limitations1208531
+Node: Extension Design1209714
+Node: Old Extension Problems1210868
+Ref: Old Extension Problems-Footnote-11212386
+Node: Extension New Mechanism Goals1212443
+Ref: Extension New Mechanism Goals-Footnote-11215807
+Node: Extension Other Design Decisions1215996
+Node: Extension Future Growth1218109
+Node: Old Extension Mechanism1218945
+Node: Notes summary1220708
+Node: Basic Concepts1221890
+Node: Basic High Level1222571
+Ref: figure-general-flow1222853
+Ref: figure-process-flow1223538
+Ref: Basic High Level-Footnote-11226839
+Node: Basic Data Typing1227024
+Node: Glossary1230352
+Node: Copying1262299
+Node: GNU Free Documentation License1299838
+Node: Index1324956

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 6db3fb01..6641705c 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -17458,9 +17458,10 @@ truncated toward zero.
For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
is @minus{}3, and @code{int(-3)} is @minus{}3 as well.
-@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})}
-@cindexawkfunc{intdiv}
-@cindex intdiv
+@ifset INTDIV
+@item @code{intdiv0(@var{numerator}, @var{denominator}, @var{result})}
+@cindexawkfunc{intdiv0}
+@cindex intdiv0
Perform integer division, similar to the standard C @code{div()} function.
First, truncate @code{numerator} and @code{denominator}
towards zero, creating integer values. Clear the @code{result}
@@ -17478,6 +17479,7 @@ Precision Integers}).
This function is a @code{gawk} extension. It is not available in
compatibility mode (@pxref{Options}).
+@end ifset
@item @code{log(@var{x})}
@cindexawkfunc{log}
@@ -31907,16 +31909,18 @@ gawk -M 'BEGIN @{ n = 13; print n % 2 @}'
When dividing two arbitrary precision integers with either
@samp{/} or @samp{%}, the result is typically an arbitrary
precision floating point value (unless the denominator evenly
-divides into the numerator). In order to do integer division
+divides into the numerator).
+@ifset INTDIV
+In order to do integer division
or remainder with arbitrary precision integers, use the built-in
-@code{intdiv()} function (@pxref{Numeric Functions}).
+@code{intdiv0()} function (@pxref{Numeric Functions}).
-You can simulate the @code{intdiv()} function in standard @command{awk}
+You can simulate the @code{intdiv0()} function in standard @command{awk}
using this user-defined function:
@example
@c file eg/lib/intdiv.awk
-# intdiv --- do integer division
+# intdiv0 --- do integer division
@c endfile
@ignore
@@ -31927,12 +31931,15 @@ using this user-defined function:
#
# Name changed from div() to intdiv()
# April, 2015
+#
+# Changed to intdiv0()
+# April, 2016
@c endfile
@end ignore
@c file eg/lib/intdiv.awk
-function intdiv(numerator, denominator, result)
+function intdiv0(numerator, denominator, result)
@{
split("", result)
@@ -32019,6 +32026,7 @@ because it's quite easy to modify for tiny memory devices with smallish
word sizes. See
@uref{http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899}.
@end quotation
+@end ifset
@node POSIX Floating Point Problems
@section Standards Versus Existing Practice
@@ -37067,10 +37075,12 @@ The @code{bindtextdomain()}, @code{dcgettext()}, and @code{dcngettext()}
functions for internationalization
(@pxref{Programmer i18n})
+@ifset INTDIV
@item
-The @code{intdiv()} function for doing integer
+The @code{intdiv0()} function for doing integer
division and remainder
(@pxref{Numeric Functions})
+@end ifset
@end itemize
@item
@@ -37862,9 +37872,11 @@ The @command{igawk} program and its manual page are no longer
installed when @command{gawk} is built.
@xref{Igawk Program}.
+@ifset INTDIV
@item
-The @code{intdiv()} function.
+The @code{intdiv0()} function.
@xref{Numeric Functions}.
+@end ifset
@item
The maximum number of hexadecimal digits in @samp{\x} escapes
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index bbf7f5d6..0a8c30fe 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -16731,9 +16731,10 @@ truncated toward zero.
For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
is @minus{}3, and @code{int(-3)} is @minus{}3 as well.
-@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})}
-@cindexawkfunc{intdiv}
-@cindex intdiv
+@ifset INTDIV
+@item @code{intdiv0(@var{numerator}, @var{denominator}, @var{result})}
+@cindexawkfunc{intdiv0}
+@cindex intdiv0
Perform integer division, similar to the standard C @code{div()} function.
First, truncate @code{numerator} and @code{denominator}
towards zero, creating integer values. Clear the @code{result}
@@ -16751,6 +16752,7 @@ Precision Integers}).
This function is a @code{gawk} extension. It is not available in
compatibility mode (@pxref{Options}).
+@end ifset
@item @code{log(@var{x})}
@cindexawkfunc{log}
@@ -30921,16 +30923,18 @@ gawk -M 'BEGIN @{ n = 13; print n % 2 @}'
When dividing two arbitrary precision integers with either
@samp{/} or @samp{%}, the result is typically an arbitrary
precision floating point value (unless the denominator evenly
-divides into the numerator). In order to do integer division
+divides into the numerator).
+@ifset INTDIV
+In order to do integer division
or remainder with arbitrary precision integers, use the built-in
-@code{intdiv()} function (@pxref{Numeric Functions}).
+@code{intdiv0()} function (@pxref{Numeric Functions}).
-You can simulate the @code{intdiv()} function in standard @command{awk}
+You can simulate the @code{intdiv0()} function in standard @command{awk}
using this user-defined function:
@example
@c file eg/lib/intdiv.awk
-# intdiv --- do integer division
+# intdiv0 --- do integer division
@c endfile
@ignore
@@ -30941,12 +30945,15 @@ using this user-defined function:
#
# Name changed from div() to intdiv()
# April, 2015
+#
+# Changed to intdiv0()
+# April, 2016
@c endfile
@end ignore
@c file eg/lib/intdiv.awk
-function intdiv(numerator, denominator, result)
+function intdiv0(numerator, denominator, result)
@{
split("", result)
@@ -31033,6 +31040,7 @@ because it's quite easy to modify for tiny memory devices with smallish
word sizes. See
@uref{http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899}.
@end quotation
+@end ifset
@node POSIX Floating Point Problems
@section Standards Versus Existing Practice
@@ -36081,10 +36089,12 @@ The @code{bindtextdomain()}, @code{dcgettext()}, and @code{dcngettext()}
functions for internationalization
(@pxref{Programmer i18n})
+@ifset INTDIV
@item
-The @code{intdiv()} function for doing integer
+The @code{intdiv0()} function for doing integer
division and remainder
(@pxref{Numeric Functions})
+@end ifset
@end itemize
@item
@@ -36876,9 +36886,11 @@ The @command{igawk} program and its manual page are no longer
installed when @command{gawk} is built.
@xref{Igawk Program}.
+@ifset INTDIV
@item
-The @code{intdiv()} function.
+The @code{intdiv0()} function.
@xref{Numeric Functions}.
+@end ifset
@item
The maximum number of hexadecimal digits in @samp{\x} escapes
diff --git a/extension/ChangeLog b/extension/ChangeLog
index d10dc766..7307a11a 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,23 @@
+2017-04-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * intdiv.c (func_table): Function is now named intdiv.
+
+2017-04-14 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * intdiv.c (do_intdiv): On division by zero, return -1 and issue a
+ warning instead of throwing a fatal error.
+
+2017-04-13 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * intdiv.c (do_intdiv): On a division by zero fatal error, there's
+ no need to clear the numerator and denominator and add a fake return.
+
+2017-04-13 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Alphabetize function list in AC_CHECK_FUNCS.
+ * intdiv.c: Add descriptive comments to some functions.
+ (do_intdiv): Make division by zero fatal in MPFR case.
+
2017-04-03 Arnold D. Robbins <arnold@skeeve.com>
* inplace.c (inplace_end): Correct the function name in the
@@ -64,6 +84,16 @@
system headers assume that if this is defined, it must have a
numeric value.
+2017-01-06 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * intdiv.c: New extension to demonstrate how to implement intdiv
+ using the new extended-precision math API.
+ * Makefile.am (pkgextension_LTLIBRARIES): Add intdiv.la.
+ (intdiv_la_SOURCES, intdiv_la_LDFLAGS, intdiv_la_LIBADD): Add support
+ for new intdiv library.
+ * configure.ac (AC_CHECK_FUNCS): Check for fmod needed by intdiv.
+ (GNUPG_CHECK_MPFR): Add check for MPFR support.
+
2016-12-22 Arnold D. Robbins <arnold@skeeve.com>
* testext.c (valrep2str): Update for new API types.
diff --git a/extension/Makefile.am b/extension/Makefile.am
index 6ea16f5d..54975b8e 100644
--- a/extension/Makefile.am
+++ b/extension/Makefile.am
@@ -39,6 +39,7 @@ pkgextension_LTLIBRARIES = \
fnmatch.la \
fork.la \
inplace.la \
+ intdiv.la \
ordchr.la \
readdir.la \
readfile.la \
@@ -72,6 +73,10 @@ inplace_la_SOURCES = inplace.c
inplace_la_LDFLAGS = $(MY_MODULE_FLAGS)
inplace_la_LIBADD = $(MY_LIBS)
+intdiv_la_SOURCES = intdiv.c
+intdiv_la_LDFLAGS = $(MY_MODULE_FLAGS)
+intdiv_la_LIBADD = $(MY_LIBS)
+
ordchr_la_SOURCES = ordchr.c
ordchr_la_LDFLAGS = $(MY_MODULE_FLAGS)
ordchr_la_LIBADD = $(MY_LIBS)
diff --git a/extension/Makefile.in b/extension/Makefile.in
index c0e2676b..000c3b78 100644
--- a/extension/Makefile.in
+++ b/extension/Makefile.in
@@ -114,10 +114,10 @@ host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../m4/arch.m4 \
- $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/../m4/mpfr.m4 $(top_srcdir)/m4/dirfd.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -187,6 +187,12 @@ inplace_la_OBJECTS = $(am_inplace_la_OBJECTS)
inplace_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(inplace_la_LDFLAGS) $(LDFLAGS) -o $@
+intdiv_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_intdiv_la_OBJECTS = intdiv.lo
+intdiv_la_OBJECTS = $(am_intdiv_la_OBJECTS)
+intdiv_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(intdiv_la_LDFLAGS) $(LDFLAGS) -o $@
ordchr_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_ordchr_la_OBJECTS = ordchr.lo
ordchr_la_OBJECTS = $(am_ordchr_la_OBJECTS)
@@ -277,17 +283,17 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(filefuncs_la_SOURCES) $(fnmatch_la_SOURCES) \
- $(fork_la_SOURCES) $(inplace_la_SOURCES) $(ordchr_la_SOURCES) \
- $(readdir_la_SOURCES) $(readdir_test_la_SOURCES) \
- $(readfile_la_SOURCES) $(revoutput_la_SOURCES) \
- $(revtwoway_la_SOURCES) $(rwarray_la_SOURCES) \
- $(testext_la_SOURCES) $(time_la_SOURCES)
+ $(fork_la_SOURCES) $(inplace_la_SOURCES) $(intdiv_la_SOURCES) \
+ $(ordchr_la_SOURCES) $(readdir_la_SOURCES) \
+ $(readdir_test_la_SOURCES) $(readfile_la_SOURCES) \
+ $(revoutput_la_SOURCES) $(revtwoway_la_SOURCES) \
+ $(rwarray_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
DIST_SOURCES = $(filefuncs_la_SOURCES) $(fnmatch_la_SOURCES) \
- $(fork_la_SOURCES) $(inplace_la_SOURCES) $(ordchr_la_SOURCES) \
- $(readdir_la_SOURCES) $(readdir_test_la_SOURCES) \
- $(readfile_la_SOURCES) $(revoutput_la_SOURCES) \
- $(revtwoway_la_SOURCES) $(rwarray_la_SOURCES) \
- $(testext_la_SOURCES) $(time_la_SOURCES)
+ $(fork_la_SOURCES) $(inplace_la_SOURCES) $(intdiv_la_SOURCES) \
+ $(ordchr_la_SOURCES) $(readdir_la_SOURCES) \
+ $(readdir_test_la_SOURCES) $(readfile_la_SOURCES) \
+ $(revoutput_la_SOURCES) $(revtwoway_la_SOURCES) \
+ $(rwarray_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
@@ -422,6 +428,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
+LIBMPFR = @LIBMPFR@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
@@ -520,6 +527,7 @@ pkgextension_LTLIBRARIES = \
fnmatch.la \
fork.la \
inplace.la \
+ intdiv.la \
ordchr.la \
readdir.la \
readfile.la \
@@ -549,6 +557,9 @@ fork_la_LIBADD = $(MY_LIBS)
inplace_la_SOURCES = inplace.c
inplace_la_LDFLAGS = $(MY_MODULE_FLAGS)
inplace_la_LIBADD = $(MY_LIBS)
+intdiv_la_SOURCES = intdiv.c
+intdiv_la_LDFLAGS = $(MY_MODULE_FLAGS)
+intdiv_la_LIBADD = $(MY_LIBS)
ordchr_la_SOURCES = ordchr.c
ordchr_la_LDFLAGS = $(MY_MODULE_FLAGS)
ordchr_la_LIBADD = $(MY_LIBS)
@@ -713,6 +724,9 @@ fork.la: $(fork_la_OBJECTS) $(fork_la_DEPENDENCIES) $(EXTRA_fork_la_DEPENDENCIES
inplace.la: $(inplace_la_OBJECTS) $(inplace_la_DEPENDENCIES) $(EXTRA_inplace_la_DEPENDENCIES)
$(AM_V_CCLD)$(inplace_la_LINK) -rpath $(pkgextensiondir) $(inplace_la_OBJECTS) $(inplace_la_LIBADD) $(LIBS)
+intdiv.la: $(intdiv_la_OBJECTS) $(intdiv_la_DEPENDENCIES) $(EXTRA_intdiv_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(intdiv_la_LINK) -rpath $(pkgextensiondir) $(intdiv_la_OBJECTS) $(intdiv_la_LIBADD) $(LIBS)
+
ordchr.la: $(ordchr_la_OBJECTS) $(ordchr_la_DEPENDENCIES) $(EXTRA_ordchr_la_DEPENDENCIES)
$(AM_V_CCLD)$(ordchr_la_LINK) -rpath $(pkgextensiondir) $(ordchr_la_OBJECTS) $(ordchr_la_LIBADD) $(LIBS)
@@ -751,6 +765,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fork.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gawkfts.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inplace.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intdiv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordchr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdir.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdir_test.Plo@am__quote@
diff --git a/extension/aclocal.m4 b/extension/aclocal.m4
index 5665d48e..1e7a343c 100644
--- a/extension/aclocal.m4
+++ b/extension/aclocal.m4
@@ -1211,6 +1211,7 @@ AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([../m4/arch.m4])
+m4_include([../m4/mpfr.m4])
m4_include([m4/dirfd.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
diff --git a/extension/configh.in b/extension/configh.in
index d3a226a5..9d3d9919 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -27,6 +27,9 @@
/* Define to 1 if you have the `fdopendir' function. */
#undef HAVE_FDOPENDIR
+/* Define to 1 if you have the `fmod' function. */
+#undef HAVE_FMOD
+
/* Define to 1 if you have the `fnmatch' function. */
#undef HAVE_FNMATCH
@@ -51,6 +54,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have fully functional mpfr and gmp libraries. */
+#undef HAVE_MPFR
+
/* Define to 1 if you have the `nanosleep' function. */
#undef HAVE_NANOSLEEP
diff --git a/extension/configure b/extension/configure
index 40601550..7ae66543 100755
--- a/extension/configure
+++ b/extension/configure
@@ -635,6 +635,7 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
+LIBMPFR
pkgextensiondir
LT_SYS_LIBRARY_PATH
OTOOL64
@@ -763,6 +764,7 @@ with_aix_soname
with_gnu_ld
with_sysroot
enable_libtool_lock
+with_mpfr
'
ac_precious_vars='build_alias
host_alias
@@ -1416,6 +1418,7 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
+ --with-mpfr=DIR look for the mpfr and gmp libraries in DIR
Some influential environment variables:
CC C compiler command
@@ -12859,8 +12862,89 @@ $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
fi
-for ac_func in fdopendir fnmatch gettimeofday \
- getdtablesize nanosleep select statvfs GetSystemTimeAsFileTime
+case `uname -m` in
+*'Power Macintosh'*)
+ : ;;
+*)
+
+
+# Check whether --with-mpfr was given.
+if test "${with_mpfr+set}" = set; then :
+ withval=$with_mpfr; _do_mpfr=$withval
+else
+ _do_mpfr=yes
+fi
+
+
+ if test "$_do_mpfr" != "no" ; then
+ if test -d "$withval" ; then
+ CPPFLAGS="${CPPFLAGS} -I$withval/include"
+ LDFLAGS="${LDFLAGS} -L$withval/lib"
+ fi
+
+ _mpfr_save_libs=$LIBS
+ _combo="-lmpfr -lgmp"
+ LIBS="$LIBS $_combo"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mpfr via \"$_combo\" is present and usable" >&5
+$as_echo_n "checking whether mpfr via \"$_combo\" is present and usable... " >&6; }
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdio.h>
+#include <mpfr.h>
+#include <gmp.h>
+
+int
+main ()
+{
+
+mpfr_t p;
+mpz_t z;
+mpfr_init(p);
+mpz_init(z);
+mpfr_printf("%Rf%Zd", p, z);
+mpfr_clear(p);
+mpz_clear(z);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ _found_mpfr=yes
+else
+ _found_mpfr=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_found_mpfr" >&5
+$as_echo "$_found_mpfr" >&6; }
+
+ LIBS=$_mpfr_save_libs
+
+ if test $_found_mpfr = yes ; then
+
+$as_echo "#define HAVE_MPFR 1" >>confdefs.h
+
+ LIBMPFR=$_combo
+
+ break
+ fi
+
+ unset _mpfr_save_libs
+ unset _combo
+ unset _found_mpfr
+ fi
+
+ ;;
+esac
+
+for ac_func in fdopendir fmod fnmatch getdtablesize \
+ gettimeofday nanosleep select statvfs GetSystemTimeAsFileTime
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/extension/configure.ac b/extension/configure.ac
index b5b27d03..bde6e3d3 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -69,8 +69,17 @@ AC_HEADER_DIRENT
AC_HEADER_MAJOR
AC_HEADER_TIME
-AC_CHECK_FUNCS(fdopendir fnmatch gettimeofday \
- getdtablesize nanosleep select statvfs GetSystemTimeAsFileTime)
+dnl check for mpfr support
+case `uname -m` in
+*'Power Macintosh'*)
+ : ;;
+*)
+ GNUPG_CHECK_MPFR
+ ;;
+esac
+
+AC_CHECK_FUNCS(fdopendir fmod fnmatch getdtablesize \
+ gettimeofday nanosleep select statvfs GetSystemTimeAsFileTime)
GAWK_FUNC_DIRFD
GAWK_PREREQ_DIRFD
diff --git a/extension/intdiv.c b/extension/intdiv.c
new file mode 100644
index 00000000..77b4290b
--- /dev/null
+++ b/extension/intdiv.c
@@ -0,0 +1,215 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "gawkapi.h"
+
+#ifdef HAVE_MPFR
+#include <gmp.h>
+#include <mpfr.h>
+#endif
+
+#include "gettext.h"
+#define _(msgid) gettext(msgid)
+#define N_(msgid) msgid
+
+static const gawk_api_t *api; /* for convenience macros to work */
+static awk_ext_id_t *ext_id;
+static const char *ext_version = "intdiv extension: version 1.0";
+
+int plugin_is_GPL_compatible;
+
+/* double_to_int --- get the integer part of a double */
+
+static double
+double_to_int(double d)
+{
+ if (d >= 0)
+ d = floor(d);
+ else
+ d = ceil(d);
+ return d;
+}
+
+/* array_set_number --- set an array element to a numeric value */
+
+static void
+array_set_number(awk_array_t array, const char *sub, size_t sublen, double num)
+{
+ awk_value_t index, tmp;
+
+ set_array_element(array, make_const_string(sub, sublen, & index), make_number(num, & tmp));
+}
+
+#ifdef HAVE_MPFR
+
+/* mpz_conv --- convert an awk_value_t to an MPZ value */
+
+static mpz_ptr
+mpz_conv(const awk_value_t *arg, mpz_ptr tmp)
+{
+ switch (arg->num_type) {
+ case AWK_NUMBER_TYPE_MPZ:
+ return arg->num_ptr;
+ case AWK_NUMBER_TYPE_MPFR:
+ if (! mpfr_number_p(arg->num_ptr))
+ return NULL;
+ mpz_init(tmp);
+ mpfr_get_z(tmp, arg->num_ptr, MPFR_RNDZ);
+ return tmp;
+ case AWK_NUMBER_TYPE_DOUBLE: /* can this happen? */
+ mpz_init(tmp);
+ mpz_set_d(tmp, double_to_int(arg->num_value));
+ return tmp;
+ default: /* should never happen */
+ fatal(ext_id, _("intdiv: invalid numeric type `%d'"), arg->num_type);
+ return NULL;
+ }
+}
+
+/* array_set_mpz --- set an array element to an MPZ value */
+
+static void
+array_set_mpz(awk_array_t array, const char *sub, size_t sublen, mpz_ptr num)
+{
+ awk_value_t index, tmp;
+
+ set_array_element(array, make_const_string(sub, sublen, & index), make_number_mpz(num, & tmp));
+}
+
+#endif
+
+/* do_intdiv --- do integer division, return quotient and remainder in dest array */
+
+/*
+ * We define the semantics as:
+ * numerator = int(numerator)
+ * denominator = int(denonmator)
+ * quotient = int(numerator / denomator)
+ * remainder = int(numerator % denomator)
+ */
+
+static awk_value_t *
+do_intdiv(int nargs, awk_value_t *result, struct awk_ext_func *unused)
+{
+ awk_value_t nv, dv, array_param;
+ awk_array_t array;
+
+ if (! get_argument(0, AWK_NUMBER, & nv)) {
+ warning(ext_id, _("intdiv: first argument must be numeric"));
+ return make_number(-1, result);
+ }
+ if (! get_argument(1, AWK_NUMBER, & dv)) {
+ warning(ext_id, _("intdiv: second argument must be numeric"));
+ return make_number(-1, result);
+ }
+ if (! get_argument(2, AWK_ARRAY, & array_param)) {
+ warning(ext_id, _("intdiv: third argument must be an array"));
+ return make_number(-1, result);
+ }
+ array = array_param.array_cookie;
+ clear_array(array);
+
+#ifdef HAVE_MPFR
+ if (nv.num_type == AWK_NUMBER_TYPE_DOUBLE && dv.num_type == AWK_NUMBER_TYPE_DOUBLE) {
+#endif
+ /* regular precision */
+ double num, denom, quotient, remainder;
+
+ num = double_to_int(nv.num_value);
+ denom = double_to_int(dv.num_value);
+
+ if (denom == 0.0) {
+ warning(ext_id, _("intdiv: division by zero attempted"));
+ return make_number(-1, result);
+ }
+
+ quotient = double_to_int(num / denom);
+#ifdef HAVE_FMOD
+ remainder = fmod(num, denom);
+#else /* ! HAVE_FMOD */
+ (void) modf(num / denom, & remainder);
+ remainder = num - remainder * denom;
+#endif /* ! HAVE_FMOD */
+ remainder = double_to_int(remainder);
+
+ array_set_number(array, "quotient", 8, quotient);
+ array_set_number(array, "remainder", 9, remainder);
+#ifdef HAVE_MPFR
+ } else {
+ /* extended precision */
+ mpz_ptr numer, denom;
+ mpz_t numer_tmp, denom_tmp;
+ mpz_ptr quotient, remainder;
+
+ /* convert numerator and denominator to integer */
+ if (!(numer = mpz_conv(&nv, numer_tmp))) {
+ warning(ext_id, _("intdiv: numerator is not finite"));
+ return make_number(-1, result);
+ }
+ if (!(denom = mpz_conv(&dv, denom_tmp))) {
+ warning(ext_id, _("intdiv: denominator is not finite"));
+ if (numer == numer_tmp)
+ mpz_clear(numer);
+ return make_number(-1, result);
+ }
+ if (mpz_sgn(denom) == 0) {
+ warning(ext_id, _("intdiv: division by zero attempted"));
+ if (numer == numer_tmp)
+ mpz_clear(numer);
+ if (denom == denom_tmp)
+ mpz_clear(denom);
+ return make_number(-1, result);
+ }
+
+ /* ask gawk to allocate return values for us */
+ quotient = get_mpz_ptr();
+ remainder = get_mpz_ptr();
+
+ /* do the division */
+ mpz_tdiv_qr(quotient, remainder, numer, denom);
+
+ array_set_mpz(array, "quotient", 8, quotient);
+ array_set_mpz(array, "remainder", 9, remainder);
+
+ /* release temporary variables */
+ if (numer == numer_tmp)
+ mpz_clear(numer);
+ if (denom == denom_tmp)
+ mpz_clear(denom);
+ }
+#endif
+
+ return make_number(0, result);
+}
+
+static awk_ext_func_t func_table[] = {
+ { "intdiv", do_intdiv, 3, 3, awk_false, NULL },
+};
+
+/* init_intdiv --- initialization routine */
+
+static awk_bool_t
+init_intdiv(void)
+{
+#ifdef HAVE_MPFR
+ check_mpfr_version(intdiv)
+#endif
+ return awk_true;
+}
+
+static awk_bool_t (*init_func)(void) = init_intdiv;
+
+/* define the dl_load function using the boilerplate macro */
+
+dl_load_func(func_table, intdiv, "")
diff --git a/gawkapi.c b/gawkapi.c
index 4c6a2f8f..6928c1ce 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -25,6 +25,14 @@
#include "awk.h"
+#ifdef HAVE_MPFR
+#define getmpfr(n) getblock(n, BLOCK_MPFR, mpfr_ptr)
+#define freempfr(n) freeblock(n, BLOCK_MPFR)
+
+#define getmpz(n) getblock(n, BLOCK_MPZ, mpz_ptr)
+#define freempz(n) freeblock(n, BLOCK_MPZ)
+#endif
+
/* Declare some globals used by api_get_file: */
extern IOBUF *curfile;
extern INSTRUCTION *main_beginfile;
@@ -145,7 +153,7 @@ api_set_argument(awk_ext_id_t id,
NODE *
awk_value_to_node(const awk_value_t *retval)
{
- NODE *ext_ret_val;
+ NODE *ext_ret_val = NULL;
NODE *v;
if (retval == NULL)
@@ -159,7 +167,36 @@ awk_value_to_node(const awk_value_t *retval)
ext_ret_val = dupnode(Nnull_string);
break;
case AWK_NUMBER:
- ext_ret_val = make_number(retval->num_value);
+ switch (retval->num_type) {
+ case AWK_NUMBER_TYPE_DOUBLE:
+ ext_ret_val = make_number(retval->num_value);
+ break;
+ case AWK_NUMBER_TYPE_MPFR:
+#ifdef HAVE_MPFR
+ if (! do_mpfr)
+ fatal(_("awk_value_to_node: not in MPFR mode"));
+ ext_ret_val = make_number_node(MPFN);
+ memcpy(&ext_ret_val->mpg_numbr, retval->num_ptr, sizeof(ext_ret_val->mpg_numbr));
+ freempfr(retval->num_ptr);
+#else
+ fatal(_("awk_value_to_node: MPFR not supported"));
+#endif
+ break;
+ case AWK_NUMBER_TYPE_MPZ:
+#ifdef HAVE_MPFR
+ if (! do_mpfr)
+ fatal(_("awk_value_to_node: not in MPFR mode"));
+ ext_ret_val = make_number_node(MPZN);
+ memcpy(&ext_ret_val->mpg_i, retval->num_ptr, sizeof(ext_ret_val->mpg_i));
+ freempz(retval->num_ptr);
+#else
+ fatal(_("awk_value_to_node: MPFR not supported"));
+#endif
+ break;
+ default:
+ fatal(_("awk_value_to_node: invalid number type `%d'"), retval->num_type);
+ break;
+ }
break;
case AWK_STRING:
ext_ret_val = make_str_node(retval->str_value.str,
@@ -450,6 +487,34 @@ assign_string(NODE *node, awk_value_t *val, awk_valtype_t val_type)
val->str_value.len = node->stlen;
}
+/* assign_number -- return a number node */
+
+static inline void
+assign_number(NODE *node, awk_value_t *val)
+{
+ val->val_type = AWK_NUMBER;
+ switch (node->flags & (MPFN|MPZN)) {
+ case 0:
+ val->num_value = node->numbr;
+ val->num_type = AWK_NUMBER_TYPE_DOUBLE;
+ val->num_ptr = NULL;
+ break;
+ case MPFN:
+ val->num_value = mpfr_get_d(node->mpg_numbr, ROUND_MODE);
+ val->num_type = AWK_NUMBER_TYPE_MPFR;
+ val->num_ptr = &node->mpg_numbr;
+ break;
+ case MPZN:
+ val->num_value = mpz_get_d(node->mpg_i);
+ val->num_type = AWK_NUMBER_TYPE_MPZ;
+ val->num_ptr = &node->mpg_i;
+ break;
+ default:
+ fatal(_("node_to_awk_value: detected invalid numeric flags combination `%s'; please file a bug report."), flags2str(node->flags));
+ break;
+ }
+}
+
/* assign_regex --- return a regex node */
static inline void
@@ -502,9 +567,8 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted)
if (node->flags & REGEX)
val->val_type = AWK_REGEX;
else {
- val->val_type = AWK_NUMBER;
(void) force_number(node);
- val->num_value = get_number_d(node);
+ assign_number(node, val);
ret = awk_true;
}
break;
@@ -606,8 +670,7 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted)
ret = awk_true;
break;
case NUMBER:
- val->val_type = AWK_NUMBER;
- val->num_value = get_number_d(node);
+ assign_number(node, val);
ret = awk_true;
break;
case NUMBER|USER_INPUT:
@@ -1220,6 +1283,36 @@ api_release_value(awk_ext_id_t id, awk_value_cookie_t value)
return awk_true;
}
+/* api_get_mpfr --- allocate an mpfr_ptr */
+
+static void *
+api_get_mpfr(awk_ext_id_t id)
+{
+#ifdef HAVE_MPFR
+ mpfr_ptr p;
+ getmpfr(p);
+ mpfr_init(p);
+ return p;
+#else
+ fatal(_("api_get_mpfr: MPFR not supported"));
+#endif
+}
+
+/* api_get_mpz --- allocate an mpz_ptr */
+
+static void *
+api_get_mpz(awk_ext_id_t id)
+{
+#ifdef HAVE_MPFR
+ mpz_ptr p;
+ getmpz(p);
+ mpz_init(p);
+ return p;
+#else
+ fatal(_("api_get_mpfr: MPFR not supported"));
+#endif
+}
+
/* api_get_file --- return a handle to an existing or newly opened file */
static awk_bool_t
@@ -1347,6 +1440,16 @@ gawk_api_t api_impl = {
/* data */
GAWK_API_MAJOR_VERSION, /* major and minor versions */
GAWK_API_MINOR_VERSION,
+
+#ifdef HAVE_MPFR
+ __GNU_MP_VERSION,
+ __GNU_MP_VERSION_MINOR,
+ MPFR_VERSION_MAJOR,
+ MPFR_VERSION_MINOR,
+#else
+ 0, 0, 0, 0,
+#endif
+
{ 0 }, /* do_flags */
/* registration functions */
@@ -1399,6 +1502,8 @@ gawk_api_t api_impl = {
calloc,
realloc,
free,
+ api_get_mpfr,
+ api_get_mpz,
/* Find/open a file */
api_get_file,
diff --git a/gawkapi.h b/gawkapi.h
index 484ab27e..03ac3b9e 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -296,7 +296,7 @@ typedef struct awk_two_way_processor {
awk_const struct awk_two_way_processor *awk_const next; /* for use by gawk */
} awk_two_way_processor_t;
-#define gawk_api_major_version 2
+#define gawk_api_major_version 3
#define gawk_api_minor_version 0
/* Current version of the API. */
@@ -322,6 +322,16 @@ typedef struct awk_string {
size_t len; /* length thereof, in chars */
} awk_string_t;
+typedef struct awk_number {
+ double d; /* always populated in data received from gawk */
+ enum AWK_NUMBER_TYPE {
+ AWK_NUMBER_TYPE_DOUBLE,
+ AWK_NUMBER_TYPE_MPFR,
+ AWK_NUMBER_TYPE_MPZ
+ } type;
+ void *ptr; /* either NULL or mpfr_ptr or mpz_ptr */
+} awk_number_t;
+
/* Arrays are represented as an opaque type. */
typedef void *awk_array_t;
@@ -357,7 +367,7 @@ typedef struct awk_value {
awk_valtype_t val_type;
union {
awk_string_t s;
- double d;
+ awk_number_t n;
awk_array_t a;
awk_scalar_t scl;
awk_value_cookie_t vc;
@@ -365,7 +375,9 @@ typedef struct awk_value {
#define str_value u.s
#define strnum_value str_value
#define regex_value str_value
-#define num_value u.d
+#define num_value u.n.d
+#define num_type u.n.type
+#define num_ptr u.n.ptr
#define array_cookie u.a
#define scalar_cookie u.scl
#define value_cookie u.vc
@@ -451,6 +463,12 @@ typedef struct gawk_api {
awk_const int major_version;
awk_const int minor_version;
+ /* GMP/MPFR versions, if extended-precision is available */
+ awk_const int gmp_major_version;
+ awk_const int gmp_minor_version;
+ awk_const int mpfr_major_version;
+ awk_const int mpfr_minor_version;
+
/*
* These can change on the fly as things happen within gawk.
* Currently only do_lint is prone to change, but we reserve
@@ -747,6 +765,20 @@ typedef struct gawk_api {
void *(*api_realloc)(void *ptr, size_t size);
void (*api_free)(void *ptr);
+ /*
+ * A function that returns mpfr data should call this function
+ * to allocate and initialize an mpfr_ptr for use in an
+ * awk_value_t structure that will be handed to gawk.
+ */
+ void *(*api_get_mpfr)(awk_ext_id_t id);
+
+ /*
+ * A function that returns mpz data should call this function
+ * to allocate and initialize an mpz_ptr for use in an
+ * awk_value_t structure that will be handed to gawk.
+ */
+ void *(*api_get_mpz)(awk_ext_id_t id);
+
/*
* Look up a file. If the name is NULL or name_len is 0, it returns
* data for the currently open input file corresponding to FILENAME
@@ -779,7 +811,6 @@ typedef struct gawk_api {
*/
const awk_input_buf_t **ibufp,
const awk_output_buf_t **obufp);
-
} gawk_api_t;
#ifndef GAWK /* these are not for the gawk code itself! */
@@ -869,6 +900,9 @@ typedef struct gawk_api {
#define get_file(name, namelen, filetype, fd, ibuf, obuf) \
(api->api_get_file(ext_id, name, namelen, filetype, fd, ibuf, obuf))
+#define get_mpfr_ptr() (api->api_get_mpfr(ext_id))
+#define get_mpz_ptr() (api->api_get_mpz(ext_id))
+
#define register_ext_version(version) \
(api->api_register_ext_version(ext_id, version))
@@ -959,11 +993,39 @@ make_null_string(awk_value_t *result)
static inline awk_value_t *
make_number(double num, awk_value_t *result)
{
- memset(result, 0, sizeof(*result));
-
result->val_type = AWK_NUMBER;
result->num_value = num;
+ result->num_type = AWK_NUMBER_TYPE_DOUBLE;
+ return result;
+}
+
+/*
+ * make_number_mpz --- make an mpz number value in result.
+ * The mpz_ptr must be from a call to get_mpz_ptr. Gawk will now
+ * take ownership of this memory.
+ */
+static inline awk_value_t *
+make_number_mpz(void *mpz_ptr, awk_value_t *result)
+{
+ result->val_type = AWK_NUMBER;
+ result->num_type = AWK_NUMBER_TYPE_MPZ;
+ result->num_ptr = mpz_ptr;
+ return result;
+}
+
+/*
+ * make_number_mpfr --- make an mpfr number value in result.
+ * The mpfr_ptr must be from a call to get_mpfr_ptr. Gawk will now
+ * take ownership of this memory.
+ */
+
+static inline awk_value_t *
+make_number_mpfr(void *mpfr_ptr, awk_value_t *result)
+{
+ result->val_type = AWK_NUMBER;
+ result->num_type = AWK_NUMBER_TYPE_MPFR;
+ result->num_ptr = mpfr_ptr;
return result;
}
@@ -1056,6 +1118,29 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \
return (errors == 0); \
}
+/*
+ * If you are using extended-precision calculations in your library, please
+ * call this macro from your init_func.
+ */
+#define check_mpfr_version(extension) { \
+ if (api->gmp_major_version != __GNU_MP_VERSION \
+ || api->gmp_minor_version < __GNU_MP_VERSION_MINOR) { \
+ fprintf(stderr, #extension ": GMP version mismatch with gawk!\n"); \
+ fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n", \
+ __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, \
+ api->gmp_major_version, api->gmp_minor_version); \
+ exit(1); \
+ } \
+ if (api->mpfr_major_version != MPFR_VERSION_MAJOR \
+ || api->mpfr_minor_version < MPFR_VERSION_MINOR) { \
+ fprintf(stderr, #extension ": MPFR version mismatch with gawk!\n"); \
+ fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n", \
+ MPFR_VERSION_MAJOR, MPFR_VERSION_MINOR, \
+ api->mpfr_major_version, api->mpfr_minor_version); \
+ exit(1); \
+ } \
+}
+
#endif /* GAWK */
#ifdef __cplusplus
diff --git a/mpfr.c b/mpfr.c
index c83a57b3..a8a517c3 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -103,28 +103,16 @@ cleanup_mpfr(void)
/* mpg_node --- allocate a node to store MPFR float or GMP integer */
NODE *
-mpg_node(unsigned int tp)
+mpg_node(unsigned int flags)
{
- NODE *r;
- getnode(r);
- r->type = Node_val;
+ NODE *r = make_number_node(flags);
- if (tp == MPFN) {
+ if (flags == MPFN)
/* Initialize, set precision to the default precision, and value to NaN */
mpfr_init(r->mpg_numbr);
- r->flags = MPFN;
- } else {
+ else
/* Initialize and set value to 0 */
mpz_init(r->mpg_i);
- r->flags = MPZN;
- }
-
- r->valref = 1;
- r->flags |= MALLOC|NUMBER|NUMCUR;
- r->stptr = NULL;
- r->stlen = 0;
- r->wstptr = NULL;
- r->wstlen = 0;
return r;
}
@@ -1181,6 +1169,7 @@ do_mpfr_srand(int nargs)
return res;
}
+#ifdef SUPPLY_INTDIV
/* do_mpfr_intdiv --- do integer division, return quotient and remainder in dest array */
/*
@@ -1274,6 +1263,7 @@ do_mpfr_intdiv(int nargs)
return make_number((AWKNUM) 0.0);
}
+#endif /* SUPPLY_INTDIV */
/*
* mpg_tofloat --- convert an arbitrary-precision integer operand to
diff --git a/node.c b/node.c
index 962a650d..3e5c934b 100644
--- a/node.c
+++ b/node.c
@@ -333,16 +333,8 @@ r_dupnode(NODE *n)
static NODE *
r_make_number(double x)
{
- NODE *r;
- getnode(r);
- r->type = Node_val;
+ NODE *r = make_number_node(0);
r->numbr = x;
- r->flags = MALLOC|NUMBER|NUMCUR;
- r->valref = 1;
- r->stptr = NULL;
- r->stlen = 0;
- r->wstptr = NULL;
- r->wstlen = 0;
return r;
}
@@ -1006,6 +998,10 @@ void init_btowc_cache()
struct block_header nextfree[BLOCK_MAX] = {
{ NULL, sizeof(NODE) },
{ NULL, sizeof(BUCKET) },
+#ifdef HAVE_MPFR
+ { NULL, sizeof(mpfr_t) },
+ { NULL, sizeof(mpz_t) },
+#endif
};
diff --git a/test/ChangeLog b/test/ChangeLog
index ecac0519..04077f1e 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * mpfrsqrt.awk: Add `@load intdiv'.
+ * dumpvars.ok, id.ok, symtab6.ok, symtab8.ok: Updated.
+
2017-04-12 Manuel Collado <m-collado@users.sourceforge.net>
* Makefile.am (fpat6): New test.
diff --git a/test/dumpvars.ok b/test/dumpvars.ok
index 7caecd35..85d1c859 100644
--- a/test/dumpvars.ok
+++ b/test/dumpvars.ok
@@ -9,7 +9,7 @@ FILENAME: "-"
FNR: 3
FPAT: "[^[:space:]]+"
FS: " "
-FUNCTAB: array, 42 elements
+FUNCTAB: array, 41 elements
IGNORECASE: 0
LINT: 0
NF: 1
diff --git a/test/id.ok b/test/id.ok
index 7454a4fc..79130657 100644
--- a/test/id.ok
+++ b/test/id.ok
@@ -47,7 +47,6 @@ gsub -> builtin
i -> untyped
index -> builtin
int -> builtin
-intdiv -> builtin
isarray -> builtin
length -> builtin
log -> builtin
diff --git a/test/mpfrsqrt.awk b/test/mpfrsqrt.awk
index 3fb1f5f8..8cc416bb 100644
--- a/test/mpfrsqrt.awk
+++ b/test/mpfrsqrt.awk
@@ -9,6 +9,8 @@
#
# Running this program (sqrt-bug.awk):
# --------------------------------------------------------------------
+
+@load "intdiv"
BEGIN {
a=11111111111111111111111111111111111111111111111111111111111
print sqrt(a^2)
diff --git a/test/symtab6.ok b/test/symtab6.ok
index 34c10636..7de717a0 100644
--- a/test/symtab6.ok
+++ b/test/symtab6.ok
@@ -9,7 +9,7 @@ FILENAME: ""
FNR: 0
FPAT: "[^[:space:]]+"
FS: " "
-FUNCTAB: array, 42 elements
+FUNCTAB: array, 41 elements
IGNORECASE: 0
LINT: 0
NF: 0
diff --git a/test/symtab8.ok b/test/symtab8.ok
index 0cf40fe9..da29b585 100644
--- a/test/symtab8.ok
+++ b/test/symtab8.ok
@@ -9,7 +9,7 @@ FIELDWIDTHS: ""
FNR: 1
FPAT: "[^[:space:]]+"
FS: " "
-FUNCTAB: array, 42 elements
+FUNCTAB: array, 41 elements
IGNORECASE: 0
LINT: 0
NF: 1