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.info773
-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, 1134 insertions, 511 deletions
diff --git a/ChangeLog b/ChangeLog
index c4a1a1a3..6383cb73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -81,11 +81,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.
@@ -94,6 +110,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.
@@ -572,6 +591,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 ab84c58b..eb90be67 100644
--- a/awk.h
+++ b/awk.h
@@ -1065,6 +1065,8 @@ struct block_header {
enum block_id {
BLOCK_NODE = 0,
BLOCK_BUCKET,
+ BLOCK_MPFR,
+ BLOCK_MPZ,
BLOCK_MAX /* count */
};
@@ -1968,6 +1970,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 4325e77d..a2471b39 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},
@@ -6864,6 +6866,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)
@@ -6873,6 +6876,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 e4f5bab0..b7214166 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},
@@ -4444,6 +4446,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)
@@ -4453,6 +4456,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 96f308b5..a09b0881 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -31,6 +31,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 2988fe4a..996e3669 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -12400,24 +12400,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,
@@ -23215,59 +23197,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 ----------
@@ -27579,9 +27509,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
@@ -28046,8 +27973,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::.
@@ -34459,8 +34384,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.
@@ -34610,9 +34533,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)
@@ -35076,12 +34999,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)
@@ -35259,7 +35182,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)
@@ -35363,8 +35286,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)
@@ -35414,10 +35337,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)
@@ -35982,341 +35905,341 @@ Node: Functions521910
Node: Built-in522948
Node: Calling Built-in524029
Node: Numeric Functions526025
-Ref: Numeric Functions-Footnote-1530970
-Ref: Numeric Functions-Footnote-2531327
-Ref: Numeric Functions-Footnote-3531375
-Node: String Functions531647
-Ref: String Functions-Footnote-1555305
-Ref: String Functions-Footnote-2555433
-Ref: String Functions-Footnote-3555681
-Node: Gory Details555768
-Ref: table-sub-escapes557559
-Ref: table-sub-proposed559078
-Ref: table-posix-sub560441
-Ref: table-gensub-escapes561982
-Ref: Gory Details-Footnote-1562805
-Node: I/O Functions562959
-Ref: table-system-return-values569541
-Ref: I/O Functions-Footnote-1571521
-Ref: I/O Functions-Footnote-2571669
-Node: Time Functions571789
-Ref: Time Functions-Footnote-1582456
-Ref: Time Functions-Footnote-2582524
-Ref: Time Functions-Footnote-3582682
-Ref: Time Functions-Footnote-4582793
-Ref: Time Functions-Footnote-5582905
-Ref: Time Functions-Footnote-6583132
-Node: Bitwise Functions583398
-Ref: table-bitwise-ops583992
-Ref: Bitwise Functions-Footnote-1590025
-Ref: Bitwise Functions-Footnote-2590198
-Node: Type Functions590389
-Node: I18N Functions593064
-Node: User-defined594715
-Node: Definition Syntax595520
-Ref: Definition Syntax-Footnote-1601207
-Node: Function Example601278
-Ref: Function Example-Footnote-1604200
-Node: Function Caveats604222
-Node: Calling A Function604740
-Node: Variable Scope605698
-Node: Pass By Value/Reference608692
-Node: Return Statement612191
-Node: Dynamic Typing615170
-Node: Indirect Calls616100
-Ref: Indirect Calls-Footnote-1626351
-Node: Functions Summary626479
-Node: Library Functions629184
-Ref: Library Functions-Footnote-1632791
-Ref: Library Functions-Footnote-2632934
-Node: Library Names633105
-Ref: Library Names-Footnote-1636565
-Ref: Library Names-Footnote-2636788
-Node: General Functions636874
-Node: Strtonum Function637977
-Node: Assert Function640999
-Node: Round Function644325
-Node: Cliff Random Function645866
-Node: Ordinal Functions646882
-Ref: Ordinal Functions-Footnote-1649945
-Ref: Ordinal Functions-Footnote-2650197
-Node: Join Function650407
-Ref: Join Function-Footnote-1652177
-Node: Getlocaltime Function652377
-Node: Readfile Function656119
-Node: Shell Quoting658091
-Node: Data File Management659492
-Node: Filetrans Function660124
-Node: Rewind Function664220
-Node: File Checking666130
-Ref: File Checking-Footnote-1667464
-Node: Empty Files667665
-Node: Ignoring Assigns669644
-Node: Getopt Function671194
-Ref: Getopt Function-Footnote-1682663
-Node: Passwd Functions682863
-Ref: Passwd Functions-Footnote-1691702
-Node: Group Functions691790
-Ref: Group Functions-Footnote-1699688
-Node: Walking Arrays699895
-Node: Library Functions Summary702903
-Node: Library Exercises704309
-Node: Sample Programs704774
-Node: Running Examples705544
-Node: Clones706272
-Node: Cut Program707496
-Node: Egrep Program717425
-Ref: Egrep Program-Footnote-1724937
-Node: Id Program725047
-Node: Split Program728727
-Ref: Split Program-Footnote-1732186
-Node: Tee Program732315
-Node: Uniq Program735105
-Node: Wc Program742531
-Ref: Wc Program-Footnote-1746786
-Node: Miscellaneous Programs746880
-Node: Dupword Program748093
-Node: Alarm Program750123
-Node: Translate Program754978
-Ref: Translate Program-Footnote-1759543
-Node: Labels Program759813
-Ref: Labels Program-Footnote-1763164
-Node: Word Sorting763248
-Node: History Sorting767320
-Node: Extract Program769155
-Node: Simple Sed776684
-Node: Igawk Program779758
-Ref: Igawk Program-Footnote-1794089
-Ref: Igawk Program-Footnote-2794291
-Ref: Igawk Program-Footnote-3794413
-Node: Anagram Program794528
-Node: Signature Program797590
-Node: Programs Summary798837
-Node: Programs Exercises800051
-Ref: Programs Exercises-Footnote-1804180
-Node: Advanced Features804271
-Node: Nondecimal Data806261
-Node: Array Sorting807852
-Node: Controlling Array Traversal808552
-Ref: Controlling Array Traversal-Footnote-1816919
-Node: Array Sorting Functions817037
-Ref: Array Sorting Functions-Footnote-1822128
-Node: Two-way I/O822324
-Ref: Two-way I/O-Footnote-1828875
-Ref: Two-way I/O-Footnote-2829062
-Node: TCP/IP Networking829144
-Node: Profiling832262
-Ref: Profiling-Footnote-1840934
-Node: Advanced Features Summary841257
-Node: Internationalization843101
-Node: I18N and L10N844581
-Node: Explaining gettext845268
-Ref: Explaining gettext-Footnote-1851160
-Ref: Explaining gettext-Footnote-2851345
-Node: Programmer i18n851510
-Ref: Programmer i18n-Footnote-1856459
-Node: Translator i18n856508
-Node: String Extraction857302
-Ref: String Extraction-Footnote-1858434
-Node: Printf Ordering858520
-Ref: Printf Ordering-Footnote-1861306
-Node: I18N Portability861370
-Ref: I18N Portability-Footnote-1863826
-Node: I18N Example863889
-Ref: I18N Example-Footnote-1866695
-Node: Gawk I18N866768
-Node: I18N Summary867413
-Node: Debugger868754
-Node: Debugging869776
-Node: Debugging Concepts870217
-Node: Debugging Terms872026
-Node: Awk Debugging874601
-Node: Sample Debugging Session875507
-Node: Debugger Invocation876041
-Node: Finding The Bug877427
-Node: List of Debugger Commands883905
-Node: Breakpoint Control885238
-Node: Debugger Execution Control888932
-Node: Viewing And Changing Data892294
-Node: Execution Stack895668
-Node: Debugger Info897305
-Node: Miscellaneous Debugger Commands901376
-Node: Readline Support906464
-Node: Limitations907360
-Node: Debugging Summary909469
-Node: Arbitrary Precision Arithmetic910748
-Node: Computer Arithmetic912233
-Ref: table-numeric-ranges915824
-Ref: Computer Arithmetic-Footnote-1916546
-Node: Math Definitions916603
-Ref: table-ieee-formats919917
-Ref: Math Definitions-Footnote-1920520
-Node: MPFR features920625
-Node: FP Math Caution922342
-Ref: FP Math Caution-Footnote-1923414
-Node: Inexactness of computations923783
-Node: Inexact representation924743
-Node: Comparing FP Values926103
-Node: Errors accumulate927185
-Node: Getting Accuracy928618
-Node: Try To Round931328
-Node: Setting precision932227
-Ref: table-predefined-precision-strings932924
-Node: Setting the rounding mode934754
-Ref: table-gawk-rounding-modes935128
-Ref: Setting the rounding mode-Footnote-1938536
-Node: Arbitrary Precision Integers938715
-Ref: Arbitrary Precision Integers-Footnote-1943620
-Node: Checking for MPFR943769
-Node: POSIX Floating Point Problems945066
-Ref: POSIX Floating Point Problems-Footnote-1948937
-Node: Floating point summary948975
-Node: Dynamic Extensions951165
-Node: Extension Intro952718
-Node: Plugin License953984
-Node: Extension Mechanism Outline954781
-Ref: figure-load-extension955220
-Ref: figure-register-new-function956785
-Ref: figure-call-new-function957877
-Node: Extension API Description959939
-Node: Extension API Functions Introduction961581
-Node: General Data Types966915
-Ref: General Data Types-Footnote-1974120
-Node: Memory Allocation Functions974419
-Ref: Memory Allocation Functions-Footnote-1977264
-Node: Constructor Functions977363
-Node: Registration Functions980362
-Node: Extension Functions981047
-Node: Exit Callback Functions986260
-Node: Extension Version String987510
-Node: Input Parsers988173
-Node: Output Wrappers1000880
-Node: Two-way processors1005392
-Node: Printing Messages1007657
-Ref: Printing Messages-Footnote-11008828
-Node: Updating ERRNO1008981
-Node: Requesting Values1009720
-Ref: table-value-types-returned1010457
-Node: Accessing Parameters1011393
-Node: Symbol Table Access1012628
-Node: Symbol table by name1013140
-Node: Symbol table by cookie1014929
-Ref: Symbol table by cookie-Footnote-11019114
-Node: Cached values1019178
-Ref: Cached values-Footnote-11022714
-Node: Array Manipulation1022805
-Ref: Array Manipulation-Footnote-11023896
-Node: Array Data Types1023933
-Ref: Array Data Types-Footnote-11026591
-Node: Array Functions1026683
-Node: Flattening Arrays1031082
-Node: Creating Arrays1038023
-Node: Redirection API1042792
-Node: Extension API Variables1045634
-Node: Extension Versioning1046267
-Ref: gawk-api-version1046704
-Node: Extension API Informational Variables1048432
-Node: Extension API Boilerplate1049496
-Node: Changes from API V11053358
-Node: Finding Extensions1054018
-Node: Extension Example1054577
-Node: Internal File Description1055375
-Node: Internal File Ops1059455
-Ref: Internal File Ops-Footnote-11070855
-Node: Using Internal File Ops1070995
-Ref: Using Internal File Ops-Footnote-11073378
-Node: Extension Samples1073652
-Node: Extension Sample File Functions1075181
-Node: Extension Sample Fnmatch1082830
-Node: Extension Sample Fork1084317
-Node: Extension Sample Inplace1085535
-Node: Extension Sample Ord1088752
-Node: Extension Sample Readdir1089588
-Ref: table-readdir-file-types1090477
-Node: Extension Sample Revout1091282
-Node: Extension Sample Rev2way1091871
-Node: Extension Sample Read write array1092611
-Node: Extension Sample Readfile1094553
-Node: Extension Sample Time1095648
-Node: Extension Sample API Tests1096996
-Node: gawkextlib1097488
-Node: Extension summary1099935
-Node: Extension Exercises1103637
-Node: Language History1105135
-Node: V7/SVR3.11106791
-Node: SVR41108943
-Node: POSIX1110377
-Node: BTL1111756
-Node: POSIX/GNU1112485
-Node: Feature History1118377
-Node: Common Extensions1132801
-Node: Ranges and Locales1134084
-Ref: Ranges and Locales-Footnote-11138700
-Ref: Ranges and Locales-Footnote-21138727
-Ref: Ranges and Locales-Footnote-31138962
-Node: Contributors1139183
-Node: History summary1144743
-Node: Installation1146123
-Node: Gawk Distribution1147067
-Node: Getting1147551
-Node: Extracting1148512
-Node: Distribution contents1150150
-Node: Unix Installation1156492
-Node: Quick Installation1157174
-Node: Shell Startup Files1159588
-Node: Additional Configuration Options1160677
-Node: Configuration Philosophy1162666
-Node: Non-Unix Installation1165035
-Node: PC Installation1165495
-Node: PC Binary Installation1166333
-Node: PC Compiling1166768
-Node: PC Using1167885
-Node: Cygwin1170930
-Node: MSYS1171700
-Node: VMS Installation1172201
-Node: VMS Compilation1172992
-Ref: VMS Compilation-Footnote-11174221
-Node: VMS Dynamic Extensions1174279
-Node: VMS Installation Details1175964
-Node: VMS Running1178217
-Node: VMS GNV1182496
-Node: VMS Old Gawk1183231
-Node: Bugs1183702
-Node: Bug address1184365
-Node: Usenet1186762
-Node: Maintainers1187539
-Node: Other Versions1188915
-Node: Installation summary1195499
-Node: Notes1196534
-Node: Compatibility Mode1197399
-Node: Additions1198181
-Node: Accessing The Source1199106
-Node: Adding Code1200541
-Node: New Ports1206759
-Node: Derived Files1211247
-Ref: Derived Files-Footnote-11216732
-Ref: Derived Files-Footnote-21216767
-Ref: Derived Files-Footnote-31217365
-Node: Future Extensions1217479
-Node: Implementation Limitations1218137
-Node: Extension Design1219320
-Node: Old Extension Problems1220474
-Ref: Old Extension Problems-Footnote-11221992
-Node: Extension New Mechanism Goals1222049
-Ref: Extension New Mechanism Goals-Footnote-11225413
-Node: Extension Other Design Decisions1225602
-Node: Extension Future Growth1227715
-Node: Old Extension Mechanism1228551
-Node: Notes summary1230314
-Node: Basic Concepts1231496
-Node: Basic High Level1232177
-Ref: figure-general-flow1232459
-Ref: figure-process-flow1233144
-Ref: Basic High Level-Footnote-11236445
-Node: Basic Data Typing1236630
-Node: Glossary1239958
-Node: Copying1271905
-Node: GNU Free Documentation License1309444
-Node: Index1334562
+Ref: Numeric Functions-Footnote-1530053
+Ref: Numeric Functions-Footnote-2530410
+Ref: Numeric Functions-Footnote-3530458
+Node: String Functions530730
+Ref: String Functions-Footnote-1554388
+Ref: String Functions-Footnote-2554516
+Ref: String Functions-Footnote-3554764
+Node: Gory Details554851
+Ref: table-sub-escapes556642
+Ref: table-sub-proposed558161
+Ref: table-posix-sub559524
+Ref: table-gensub-escapes561065
+Ref: Gory Details-Footnote-1561888
+Node: I/O Functions562042
+Ref: table-system-return-values568624
+Ref: I/O Functions-Footnote-1570604
+Ref: I/O Functions-Footnote-2570752
+Node: Time Functions570872
+Ref: Time Functions-Footnote-1581539
+Ref: Time Functions-Footnote-2581607
+Ref: Time Functions-Footnote-3581765
+Ref: Time Functions-Footnote-4581876
+Ref: Time Functions-Footnote-5581988
+Ref: Time Functions-Footnote-6582215
+Node: Bitwise Functions582481
+Ref: table-bitwise-ops583075
+Ref: Bitwise Functions-Footnote-1589108
+Ref: Bitwise Functions-Footnote-2589281
+Node: Type Functions589472
+Node: I18N Functions592147
+Node: User-defined593798
+Node: Definition Syntax594603
+Ref: Definition Syntax-Footnote-1600290
+Node: Function Example600361
+Ref: Function Example-Footnote-1603283
+Node: Function Caveats603305
+Node: Calling A Function603823
+Node: Variable Scope604781
+Node: Pass By Value/Reference607775
+Node: Return Statement611274
+Node: Dynamic Typing614253
+Node: Indirect Calls615183
+Ref: Indirect Calls-Footnote-1625434
+Node: Functions Summary625562
+Node: Library Functions628267
+Ref: Library Functions-Footnote-1631874
+Ref: Library Functions-Footnote-2632017
+Node: Library Names632188
+Ref: Library Names-Footnote-1635648
+Ref: Library Names-Footnote-2635871
+Node: General Functions635957
+Node: Strtonum Function637060
+Node: Assert Function640082
+Node: Round Function643408
+Node: Cliff Random Function644949
+Node: Ordinal Functions645965
+Ref: Ordinal Functions-Footnote-1649028
+Ref: Ordinal Functions-Footnote-2649280
+Node: Join Function649490
+Ref: Join Function-Footnote-1651260
+Node: Getlocaltime Function651460
+Node: Readfile Function655202
+Node: Shell Quoting657174
+Node: Data File Management658575
+Node: Filetrans Function659207
+Node: Rewind Function663303
+Node: File Checking665213
+Ref: File Checking-Footnote-1666547
+Node: Empty Files666748
+Node: Ignoring Assigns668727
+Node: Getopt Function670277
+Ref: Getopt Function-Footnote-1681746
+Node: Passwd Functions681946
+Ref: Passwd Functions-Footnote-1690785
+Node: Group Functions690873
+Ref: Group Functions-Footnote-1698771
+Node: Walking Arrays698978
+Node: Library Functions Summary701986
+Node: Library Exercises703392
+Node: Sample Programs703857
+Node: Running Examples704627
+Node: Clones705355
+Node: Cut Program706579
+Node: Egrep Program716508
+Ref: Egrep Program-Footnote-1724020
+Node: Id Program724130
+Node: Split Program727810
+Ref: Split Program-Footnote-1731269
+Node: Tee Program731398
+Node: Uniq Program734188
+Node: Wc Program741614
+Ref: Wc Program-Footnote-1745869
+Node: Miscellaneous Programs745963
+Node: Dupword Program747176
+Node: Alarm Program749206
+Node: Translate Program754061
+Ref: Translate Program-Footnote-1758626
+Node: Labels Program758896
+Ref: Labels Program-Footnote-1762247
+Node: Word Sorting762331
+Node: History Sorting766403
+Node: Extract Program768238
+Node: Simple Sed775767
+Node: Igawk Program778841
+Ref: Igawk Program-Footnote-1793172
+Ref: Igawk Program-Footnote-2793374
+Ref: Igawk Program-Footnote-3793496
+Node: Anagram Program793611
+Node: Signature Program796673
+Node: Programs Summary797920
+Node: Programs Exercises799134
+Ref: Programs Exercises-Footnote-1803263
+Node: Advanced Features803354
+Node: Nondecimal Data805344
+Node: Array Sorting806935
+Node: Controlling Array Traversal807635
+Ref: Controlling Array Traversal-Footnote-1816002
+Node: Array Sorting Functions816120
+Ref: Array Sorting Functions-Footnote-1821211
+Node: Two-way I/O821407
+Ref: Two-way I/O-Footnote-1827958
+Ref: Two-way I/O-Footnote-2828145
+Node: TCP/IP Networking828227
+Node: Profiling831345
+Ref: Profiling-Footnote-1840017
+Node: Advanced Features Summary840340
+Node: Internationalization842184
+Node: I18N and L10N843664
+Node: Explaining gettext844351
+Ref: Explaining gettext-Footnote-1850243
+Ref: Explaining gettext-Footnote-2850428
+Node: Programmer i18n850593
+Ref: Programmer i18n-Footnote-1855542
+Node: Translator i18n855591
+Node: String Extraction856385
+Ref: String Extraction-Footnote-1857517
+Node: Printf Ordering857603
+Ref: Printf Ordering-Footnote-1860389
+Node: I18N Portability860453
+Ref: I18N Portability-Footnote-1862909
+Node: I18N Example862972
+Ref: I18N Example-Footnote-1865778
+Node: Gawk I18N865851
+Node: I18N Summary866496
+Node: Debugger867837
+Node: Debugging868859
+Node: Debugging Concepts869300
+Node: Debugging Terms871109
+Node: Awk Debugging873684
+Node: Sample Debugging Session874590
+Node: Debugger Invocation875124
+Node: Finding The Bug876510
+Node: List of Debugger Commands882988
+Node: Breakpoint Control884321
+Node: Debugger Execution Control888015
+Node: Viewing And Changing Data891377
+Node: Execution Stack894751
+Node: Debugger Info896388
+Node: Miscellaneous Debugger Commands900459
+Node: Readline Support905547
+Node: Limitations906443
+Node: Debugging Summary908552
+Node: Arbitrary Precision Arithmetic909831
+Node: Computer Arithmetic911316
+Ref: table-numeric-ranges914907
+Ref: Computer Arithmetic-Footnote-1915629
+Node: Math Definitions915686
+Ref: table-ieee-formats919000
+Ref: Math Definitions-Footnote-1919603
+Node: MPFR features919708
+Node: FP Math Caution921425
+Ref: FP Math Caution-Footnote-1922497
+Node: Inexactness of computations922866
+Node: Inexact representation923826
+Node: Comparing FP Values925186
+Node: Errors accumulate926268
+Node: Getting Accuracy927701
+Node: Try To Round930411
+Node: Setting precision931310
+Ref: table-predefined-precision-strings932007
+Node: Setting the rounding mode933837
+Ref: table-gawk-rounding-modes934211
+Ref: Setting the rounding mode-Footnote-1937619
+Node: Arbitrary Precision Integers937798
+Ref: Arbitrary Precision Integers-Footnote-1940973
+Node: Checking for MPFR941122
+Node: POSIX Floating Point Problems942419
+Ref: POSIX Floating Point Problems-Footnote-1946290
+Node: Floating point summary946328
+Node: Dynamic Extensions948518
+Node: Extension Intro950071
+Node: Plugin License951337
+Node: Extension Mechanism Outline952134
+Ref: figure-load-extension952573
+Ref: figure-register-new-function954138
+Ref: figure-call-new-function955230
+Node: Extension API Description957292
+Node: Extension API Functions Introduction958934
+Node: General Data Types964268
+Ref: General Data Types-Footnote-1971473
+Node: Memory Allocation Functions971772
+Ref: Memory Allocation Functions-Footnote-1974617
+Node: Constructor Functions974716
+Node: Registration Functions977715
+Node: Extension Functions978400
+Node: Exit Callback Functions983613
+Node: Extension Version String984863
+Node: Input Parsers985526
+Node: Output Wrappers998233
+Node: Two-way processors1002745
+Node: Printing Messages1005010
+Ref: Printing Messages-Footnote-11006181
+Node: Updating ERRNO1006334
+Node: Requesting Values1007073
+Ref: table-value-types-returned1007810
+Node: Accessing Parameters1008746
+Node: Symbol Table Access1009981
+Node: Symbol table by name1010493
+Node: Symbol table by cookie1012282
+Ref: Symbol table by cookie-Footnote-11016467
+Node: Cached values1016531
+Ref: Cached values-Footnote-11020067
+Node: Array Manipulation1020158
+Ref: Array Manipulation-Footnote-11021249
+Node: Array Data Types1021286
+Ref: Array Data Types-Footnote-11023944
+Node: Array Functions1024036
+Node: Flattening Arrays1028435
+Node: Creating Arrays1035376
+Node: Redirection API1040145
+Node: Extension API Variables1042987
+Node: Extension Versioning1043620
+Ref: gawk-api-version1044057
+Node: Extension API Informational Variables1045785
+Node: Extension API Boilerplate1046849
+Node: Changes from API V11050711
+Node: Finding Extensions1051371
+Node: Extension Example1051930
+Node: Internal File Description1052728
+Node: Internal File Ops1056808
+Ref: Internal File Ops-Footnote-11068208
+Node: Using Internal File Ops1068348
+Ref: Using Internal File Ops-Footnote-11070731
+Node: Extension Samples1071005
+Node: Extension Sample File Functions1072534
+Node: Extension Sample Fnmatch1080183
+Node: Extension Sample Fork1081670
+Node: Extension Sample Inplace1082888
+Node: Extension Sample Ord1086105
+Node: Extension Sample Readdir1086941
+Ref: table-readdir-file-types1087830
+Node: Extension Sample Revout1088635
+Node: Extension Sample Rev2way1089224
+Node: Extension Sample Read write array1089964
+Node: Extension Sample Readfile1091906
+Node: Extension Sample Time1093001
+Node: Extension Sample API Tests1094349
+Node: gawkextlib1094841
+Node: Extension summary1097288
+Node: Extension Exercises1100990
+Node: Language History1102488
+Node: V7/SVR3.11104144
+Node: SVR41106296
+Node: POSIX1107730
+Node: BTL1109109
+Node: POSIX/GNU1109838
+Node: Feature History1115616
+Node: Common Extensions1129981
+Node: Ranges and Locales1131264
+Ref: Ranges and Locales-Footnote-11135880
+Ref: Ranges and Locales-Footnote-21135907
+Ref: Ranges and Locales-Footnote-31136142
+Node: Contributors1136363
+Node: History summary1141923
+Node: Installation1143303
+Node: Gawk Distribution1144247
+Node: Getting1144731
+Node: Extracting1145692
+Node: Distribution contents1147330
+Node: Unix Installation1153672
+Node: Quick Installation1154354
+Node: Shell Startup Files1156768
+Node: Additional Configuration Options1157857
+Node: Configuration Philosophy1159846
+Node: Non-Unix Installation1162215
+Node: PC Installation1162675
+Node: PC Binary Installation1163513
+Node: PC Compiling1163948
+Node: PC Using1165065
+Node: Cygwin1168110
+Node: MSYS1168880
+Node: VMS Installation1169381
+Node: VMS Compilation1170172
+Ref: VMS Compilation-Footnote-11171401
+Node: VMS Dynamic Extensions1171459
+Node: VMS Installation Details1173144
+Node: VMS Running1175397
+Node: VMS GNV1179676
+Node: VMS Old Gawk1180411
+Node: Bugs1180882
+Node: Bug address1181545
+Node: Usenet1183942
+Node: Maintainers1184719
+Node: Other Versions1186095
+Node: Installation summary1192679
+Node: Notes1193714
+Node: Compatibility Mode1194579
+Node: Additions1195361
+Node: Accessing The Source1196286
+Node: Adding Code1197721
+Node: New Ports1203939
+Node: Derived Files1208427
+Ref: Derived Files-Footnote-11213912
+Ref: Derived Files-Footnote-21213947
+Ref: Derived Files-Footnote-31214545
+Node: Future Extensions1214659
+Node: Implementation Limitations1215317
+Node: Extension Design1216500
+Node: Old Extension Problems1217654
+Ref: Old Extension Problems-Footnote-11219172
+Node: Extension New Mechanism Goals1219229
+Ref: Extension New Mechanism Goals-Footnote-11222593
+Node: Extension Other Design Decisions1222782
+Node: Extension Future Growth1224895
+Node: Old Extension Mechanism1225731
+Node: Notes summary1227494
+Node: Basic Concepts1228676
+Node: Basic High Level1229357
+Ref: figure-general-flow1229639
+Ref: figure-process-flow1230324
+Ref: Basic High Level-Footnote-11233625
+Node: Basic Data Typing1233810
+Node: Glossary1237138
+Node: Copying1269085
+Node: GNU Free Documentation License1306624
+Node: Index1331742

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 79292a00..7e9b5987 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -17566,9 +17566,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}
@@ -17586,6 +17587,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}
@@ -32016,16 +32018,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
@@ -32036,12 +32040,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)
@@ -32128,6 +32135,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 Checking for MPFR
@section How To Check If MPFR Is Available
@@ -37228,10 +37236,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
@@ -38027,9 +38037,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 e4c91645..8ca76fd6 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -16839,9 +16839,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}
@@ -16859,6 +16860,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}
@@ -31030,16 +31032,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
@@ -31050,12 +31054,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)
@@ -31142,6 +31149,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 Checking for MPFR
@section How To Check If MPFR Is Available
@@ -36242,10 +36250,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
@@ -37041,9 +37051,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 0d8978fe..a8f4b307 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -25,6 +25,11 @@
* Makefile.am (charset-msg-start): Document that having
el_GR.iso88597 is helpful.
+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