From 2bdaa6b89e00984d79305ba1066cf98c5674b556 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 06:24:55 +0300 Subject: Minor doc edits. --- doc/gawk.texi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'doc/gawk.texi') diff --git a/doc/gawk.texi b/doc/gawk.texi index e9d987f0..e0b44fa1 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -8807,6 +8807,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1 @end example When this element exists, @command{gawk} checks the value of the system +(C language) @code{errno} variable when an I/O error occurs. If @code{errno} indicates a subsequent I/O attempt may succeed, @code{getline} instead returns @minus{}2 and @@ -35284,6 +35285,11 @@ As of this writing, there are seven extensions: @item GD graphics library extension +@item +MPFR library extension +(this provides access to a number of MPFR functions that @command{gawk}'s +native MPFR support does not) + @item PDF extension @@ -35291,12 +35297,10 @@ PDF extension PostgreSQL extension @item -MPFR library extension -(this provides access to a number of MPFR functions that @command{gawk}'s -native MPFR support does not) +Redis extension @item -Redis extension +Select extension @item XML parser extension, using the @uref{http://expat.sourceforge.net, Expat} -- cgit v1.2.3 From 0ed7e09458bdb6185586a8a0bec747b2f800ca16 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 22:21:30 +0300 Subject: Update doc on calling built-ins indirectly. --- doc/gawk.texi | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'doc/gawk.texi') diff --git a/doc/gawk.texi b/doc/gawk.texi index 80f8528d..d23b2128 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -20344,10 +20344,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: -- cgit v1.2.3 From 9730efeabb2116fdf7e93b4553825ba147f5f523 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 22:27:48 +0300 Subject: Small doc fix. --- doc/gawk.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/gawk.texi') diff --git a/doc/gawk.texi b/doc/gawk.texi index d23b2128..eb2e968b 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -16991,8 +16991,8 @@ function randint(n) @end example @noindent -The multiplication produces a random number greater than zero and less -than @code{n}. Using @code{int()}, this result is made into +The multiplication produces a random number greater than or equal to +zero and less than @code{n}. Using @code{int()}, this result is made into an integer between zero and @code{n} @minus{} 1, inclusive. The following example uses a similar function to produce random integers -- cgit v1.2.3 From ddc290584b39bab2c1edcec935a31ea12d343246 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 3 Apr 2015 09:08:54 +0300 Subject: Rename "div()" to "intdiv()". --- doc/gawk.texi | 59 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'doc/gawk.texi') diff --git a/doc/gawk.texi b/doc/gawk.texi index f710d725..ca378cca 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -17089,23 +17089,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of @cindex cosine Return the cosine of @var{x}, with @var{x} in radians. -@item @code{div(@var{numerator}, @var{denominator}, @var{result})} -@cindexawkfunc{div} -@cindex div -Perform integer division, similar to the standard C function of the -same name. First, truncate @code{numerator} and @code{denominator} -towards zero, creating integer values. Clear the @code{result} -array, and then set @code{result["quotient"]} to the result of -@samp{numerator / denominator}, truncated towards zero to an integer, -and set @code{result["remainder"]} to the result of @samp{numerator % -denominator}, truncated towards zero to an integer. This function is -primarily intended for use with arbitrary length integers; it avoids -creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary -Precision Integers}). - -This function is a @code{gawk} extension. It is not available in -compatibility mode (@pxref{Options}). - @item @code{exp(@var{x})} @cindexawkfunc{exp} @cindex exponent @@ -17121,6 +17104,23 @@ 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 +Perform integer division, similar to the standard C function of the +same name. First, truncate @code{numerator} and @code{denominator} +towards zero, creating integer values. Clear the @code{result} +array, and then set @code{result["quotient"]} to the result of +@samp{numerator / denominator}, truncated towards zero to an integer, +and set @code{result["remainder"]} to the result of @samp{numerator % +denominator}, truncated towards zero to an integer. This function is +primarily intended for use with arbitrary length integers; it avoids +creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary +Precision Integers}). + +This function is a @code{gawk} extension. It is not available in +compatibility mode (@pxref{Options}). + @item @code{log(@var{x})} @cindexawkfunc{log} @cindex logarithm @@ -31114,27 +31114,30 @@ When dividing two arbitrary precision integers with either 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 -@code{div()} function (@pxref{Numeric Functions}). +@code{intdiv()} function (@pxref{Numeric Functions}). -You can simulate the @code{div()} function in standard @command{awk} +You can simulate the @code{intdiv()} function in standard @command{awk} using this user-defined function: @example -@c file eg/lib/div.awk -# div --- do integer division +@c file eg/lib/intdiv.awk +# intdiv --- do integer division @c endfile @ignore -@c file eg/lib/div.awk +@c file eg/lib/intdiv.awk # # Arnold Robbins, arnold@@skeeve.com, Public Domain # July, 2014 +# +# Name changed from div() to intdiv() +# April, 2015 @c endfile @end ignore -@c file eg/lib/div.awk -function div(numerator, denominator, result) +@c file eg/lib/intdiv.awk +function intdiv(numerator, denominator, result) @{ split("", result) @@ -31149,7 +31152,7 @@ function div(numerator, denominator, result) @end example The following example program, contributed by Katie Wasserman, -uses @code{div()} to +uses @code{intdiv()} to compute the digits of @value{PI} to as many places as you choose to set: @@ -31174,7 +31177,7 @@ BEGIN @{ for (m = digits * 4; m > 0; --m) @{ d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two @} @@ -36043,7 +36046,7 @@ functions for internationalization (@pxref{Programmer i18n}) @item -The @code{div()} function for doing integer +The @code{intdiv()} function for doing integer division and remainder (@pxref{Numeric Functions}) @end itemize @@ -36824,7 +36827,7 @@ installed when @command{gawk} is built. @xref{Igawk Program}. @item -The @code{div()} function. +The @code{intdiv()} function. @xref{Numeric Functions}. @item -- cgit v1.2.3