aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-05-17 23:01:43 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-05-17 23:01:43 +0300
commita29f25b08f9dce05bea6892e3d5396cf201417c8 (patch)
treeb341ed111749d3cf1694917726e70a36132c37df
parent353b9af72c79e25ba2d45c62d543536aa82c02cf (diff)
downloadegawk-a29f25b08f9dce05bea6892e3d5396cf201417c8.tar.gz
egawk-a29f25b08f9dce05bea6892e3d5396cf201417c8.tar.bz2
egawk-a29f25b08f9dce05bea6892e3d5396cf201417c8.zip
Edits through Chapter 16.
-rw-r--r--doc/ChangeLog4
-rw-r--r--doc/gawk.info627
-rw-r--r--doc/gawk.texi271
-rw-r--r--doc/gawktexi.in271
4 files changed, 551 insertions, 622 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 012511be..c71ec99e 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2014-05-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Edits through Chapter 16.
+
2014-05-16 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Edits through Chapter 14.
diff --git a/doc/gawk.info b/doc/gawk.info
index 5cf6129d..e860045e 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -9710,7 +9710,7 @@ description of each variable.)
`ROUNDMODE #'
The rounding mode to use for arbitrary precision arithmetic on
- numbers, by default `"N"' (`roundTiesToEven' in the IEEE-754
+ numbers, by default `"N"' (`roundTiesToEven' in the IEEE 754
standard; *note Setting Rounding Mode::).
``RS''
@@ -20893,8 +20893,8 @@ as follows:
$ echo 0xDeadBeef | gawk '{ print $1 + 0 }'
-| 0
- `gawk' does ignore case in the four special values. Thus `+nan'
- and `+NaN' are the same.
+ `gawk' ignores case in the four special values. Thus `+nan' and
+ `+NaN' are the same.
---------- Footnotes ----------
@@ -20908,13 +20908,14 @@ File: gawk.info, Node: Integer Programming, Prev: Floating Point Issues, Up:
As has been mentioned already, `awk' uses hardware double precision
with 64-bit IEEE binary floating-point representation for numbers on
-most systems. A large integer like 9,007,199,254,740,997 has a binary
+most systems. A large integer like 9,007,199,254,740,997 has a binary
representation that, although finite, is more than 53 bits long; it
-must also be rounded to 53 bits. The biggest integer that can be
+must also be rounded to 53 bits. (The details are discussed in *note
+Floating-point Representation::.) The biggest integer that can be
stored in a C `double' is usually the same as the largest possible
value of a `double'. If your system `double' is an IEEE 64-bit
`double', this largest possible value is an integer and can be
-represented precisely. What more should one know about integers?
+represented precisely. What more should you know about integers?
If you want to know what is the largest integer, such that it and
all smaller integers can be stored in 64-bit doubles without losing
@@ -20972,9 +20973,9 @@ matters worse, with arbitrary precision floating-point, you can set the
precision before starting a computation, but then you cannot be sure of
the number of significant decimal places in the final result.
- Sometimes, before you start to write any code, you should think more
-about what you really want and what's really happening. Consider the
-two numbers in the following example:
+ So, before you start to write any code, you should think more about
+what you really want and what's really happening. Consider the two
+numbers in the following example:
x = 0.875 # 1/2 + 1/4 + 1/8
y = 0.425
@@ -20999,8 +21000,8 @@ previous example, produces an output identical to the input.
Because the underlying representation can be a little bit off from
the exact value, comparing floating-point values to see if they are
-equal is generally not a good idea. Here is an example where it does
-not work like you expect:
+exactly equal is generally a bad idea. Here is an example where it
+does not work like you expect:
$ gawk 'BEGIN { print (0.1 + 12.2 == 12.3) }'
-| 0
@@ -21056,7 +21057,7 @@ operations in your calculation. The stability and the accuracy of the
computation of the constant pi in the earlier example can be enhanced
by using the following simple algebraic transformation:
- (sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + 1)
+ (sqrt(x * x + 1) - 1) / x == x / (sqrt(x * x + 1) + 1)
After making this, change the program does converge to pi in under 30
iterations:
@@ -21110,7 +21111,7 @@ File: gawk.info, Node: Floating-point Representation, Next: Floating-point Con
Although floating-point representations vary from machine to machine,
the most commonly encountered representation is that defined by the
-IEEE 754 Standard. An IEEE-754 format value has three components:
+IEEE 754 Standard. An IEEE 754 format value has three components:
* A sign bit telling whether the number is positive or negative.
@@ -21120,11 +21121,11 @@ IEEE 754 Standard. An IEEE-754 format value has three components:
The value of the number is then S * 2^E. The first bit of a
non-zero binary significand is always one, so the significand in an
-IEEE-754 format only includes the fractional part, leaving the leading
+IEEE 754 format only includes the fractional part, leaving the leading
one implicit. The significand is stored in "normalized" format, which
means that the first bit is always a one.
- Three of the standard IEEE-754 types are 32-bit single precision,
+ Three of the standard IEEE 754 types are 32-bit single precision,
64-bit double precision and 128-bit quadruple precision. The standard
also specifies extended precision formats to allow greater precisions
and larger exponent ranges.
@@ -21156,7 +21157,7 @@ components:
The rounding mode of the context.
*note table-ieee-formats:: lists the precision and exponent field
-values for the basic IEEE-754 binary formats:
+values for the basic IEEE 754 binary formats:
Name Total bits Precision emin emax
---------------------------------------------------------------------------
@@ -21171,10 +21172,10 @@ Table 15.1: Basic IEEE Format Context Values
A floating-point context can also determine which signals are treated
as exceptions, and can set rules for arithmetic with special values.
-Please consult the IEEE-754 standard or other resources for details.
+Please consult the IEEE 754 standard or other resources for details.
`gawk' ordinarily uses the hardware double precision representation
-for numbers. On most systems, this is IEEE-754 floating-point format,
+for numbers. On most systems, this is IEEE 754 floating-point format,
corresponding to 64-bit binary with 53 bits of precision.
NOTE: In case an underflow occurs, the standard allows, but does
@@ -21182,8 +21183,8 @@ corresponding to 64-bit binary with 53 bits of precision.
number smaller than the smallest nonzero normalized number. Such
numbers do not have as many significant digits as normal numbers,
and are called "denormals" or "subnormals". The alternative,
- simply returning a zero, is called "flush to zero". The basic
- IEEE-754 binary formats support subnormal numbers.
+ simply returning a zero, is called "flush to zero". The basic IEEE
+ 754 binary formats support subnormal numbers.

File: gawk.info, Node: Rounding Mode, Prev: Floating-point Context, Up: Floating-point Programming
@@ -21194,7 +21195,7 @@ File: gawk.info, Node: Rounding Mode, Prev: Floating-point Context, Up: Float
The "rounding mode" specifies the behavior for the results of numerical
operations when discarding extra precision. Each rounding mode indicates
how the least significant returned digit of a rounded result is to be
-calculated. *note table-rounding-modes:: lists the IEEE-754 defined
+calculated. *note table-rounding-modes:: lists the IEEE 754 defined
rounding modes:
Rounding Mode IEEE Name
@@ -21244,7 +21245,7 @@ produces the following output when run on the author's system:(1)
The theory behind the rounding mode `roundTiesToEven' is that it
more or less evenly distributes upward and downward rounds of exact
halves, which might cause any round-off error to cancel itself out.
-This is the default rounding mode used in IEEE-754 computing functions
+This is the default rounding mode used in IEEE 754 computing functions
and operators.
The other rounding modes are rarely used. Round toward positive
@@ -21269,7 +21270,7 @@ significant difference in output when you change the rounding mode.
---------- Footnotes ----------
(1) It is possible for the output to be completely different if the
-C library in your system does not use the IEEE-754 even-rounding rule
+C library in your system does not use the IEEE 754 even-rounding rule
to round halfway cases for `printf'.

@@ -21325,14 +21326,14 @@ rounding mode are set globally for every operation to follow.
The default working precision for arbitrary precision floating-point
values is 53 bits, and the default value for `ROUNDMODE' is `"N"',
-which selects the IEEE-754 `roundTiesToEven' rounding mode (*note
+which selects the IEEE 754 `roundTiesToEven' rounding mode (*note
Rounding Mode::).(1) `gawk' uses the default exponent range in MPFR
(EMAX = 2^30 - 1, EMIN = -EMAX) for all floating-point contexts. There
is no explicit mechanism to adjust the exponent range. MPFR does not
implement subnormal numbers by default, and this behavior cannot be
changed in `gawk'.
- NOTE: When emulating an IEEE-754 format (*note Setting
+ NOTE: When emulating an IEEE 754 format (*note Setting
Precision::), `gawk' internally adjusts the exponent range to the
value defined for the format and also performs computations needed
for gradual underflow (subnormal numbers).
@@ -21355,7 +21356,7 @@ changed in `gawk'.
(1) The default precision is 53 bits, since according to the MPFR
documentation, the library should be able to exactly reproduce all
-computations with double-precision machine floating-point numbers
+computations done with double-precision machine floating-point numbers
(`double' type in C), except the default exponent range is much wider
and subnormal numbers are not implemented.
@@ -21369,12 +21370,12 @@ File: gawk.info, Node: Setting Precision, Next: Setting Rounding Mode, Up: Ar
precision or accuracy of individual numbers. Performing an arithmetic
operation or calling a built-in function rounds the result to the
current working precision. The default working precision is 53 bits,
-which can be modified using the built-in variable `PREC'. You can also
-set the value to one of the pre-defined case-insensitive strings shown
-in *note table-predefined-precision-strings::, to emulate an IEEE-754
+which you can modify using the built-in variable `PREC'. You can also
+set the value to one of the predefined case-insensitive strings shown
+in *note table-predefined-precision-strings::, to emulate an IEEE 754
binary format.
-`PREC' IEEE-754 Binary Format
+`PREC' IEEE 754 Binary Format
---------------------------------------------------
`"half"' 16-bit half-precision.
`"single"' Basic 32-bit single precision.
@@ -21447,9 +21448,9 @@ from zero
Table 15.4: `gawk' Rounding Modes
- `ROUNDMODE' has the default value `"N"', which selects the IEEE-754
+ `ROUNDMODE' has the default value `"N"', which selects the IEEE 754
rounding mode `roundTiesToEven'. In *note Table 15.4:
-table-gawk-rounding-modes, `"A"' is listed to select the IEEE-754 mode
+table-gawk-rounding-modes, `"A"' is listed to select the IEEE 754 mode
`roundTiesToAway'. This is only available if your version of the MPFR
library supports it; otherwise setting `ROUNDMODE' to this value has no
effect. *Note Rounding Mode::, for the meanings of the various rounding
@@ -21468,16 +21469,16 @@ File: gawk.info, Node: Floating-point Constants, Next: Changing Precision, Pr
--------------------------------------------
Be wary of floating-point constants! When reading a floating-point
-constant from program source code, `gawk' uses the default precision,
-unless overridden by an assignment to the special variable `PREC' on
-the command line, to store it internally as a MPFR number. Changing
-the precision using `PREC' in the program text does _not_ change the
-precision of a constant. If you need to represent a floating-point
-constant at a higher precision than the default and cannot use a
-command line assignment to `PREC', you should either specify the
-constant as a string, or as a rational number, whenever possible. The
-following example illustrates the differences among various ways to
-print a floating-point constant:
+constant from program source code, `gawk' uses the default precision
+(that of a C `double'), unless overridden by an assignment to the
+special variable `PREC' on the command line, to store it internally as
+a MPFR number. Changing the precision using `PREC' in the program text
+does _not_ change the precision of a constant. If you need to represent
+a floating-point constant at a higher precision than the default and
+cannot use a command line assignment to `PREC', you should either
+specify the constant as a string, or as a rational number, whenever
+possible. The following example illustrates the differences among
+various ways to print a floating-point constant:
$ gawk -M 'BEGIN { PREC = 113; printf("%0.25f\n", 0.1) }'
-| 0.1000000000000000055511151
@@ -21509,8 +21510,8 @@ File: gawk.info, Node: Changing Precision, Next: Exact Arithmetic, Prev: Floa
`gawk' does not implicitly modify the precision of any previously
computed results when the working precision is changed with an
assignment to `PREC'. The precision of a number is always the one that
-was used at the time of its creation, and there is no way for the user
-to explicitly change it afterwards. However, since the result of a
+was used at the time of its creation, and there is no way for you to
+explicitly change it afterwards. However, since the result of a
floating-point arithmetic operation is always an arbitrary precision
floating-point value--with a precision set by the value of `PREC'--one
of the following workarounds effectively accomplishes the desired
@@ -21570,10 +21571,10 @@ straight test for equality may not work.
So, don't assume that floating-point values can be compared for
equality. You should also exercise caution when using other forms of
-comparisons. The standard way to compare between floating-point
-numbers is to determine how much error (or "tolerance") you will allow
-in a comparison and check to see if one value is within this error
-range of the other.
+comparisons. The standard way to compare two floating-point numbers is
+to determine how much error (or "tolerance") you will allow in a
+comparison and check to see if one value is within this error range of
+the other.
In applications where 15 or fewer decimal places suffice, hardware
double precision arithmetic can be adequate, and is usually much faster.
@@ -21833,9 +21834,9 @@ Figure 16.3: Calling The New Function
the API `struct' to do its work, such as updating variables or arrays,
printing messages, setting `ERRNO', and so on.
- Convenience macros in the `gawkapi.h' header file make calling
-through the function pointers look like regular function calls so that
-extension code is quite readable and understandable.
+ Convenience macros make calling through the function pointers look
+like regular function calls so that extension code is quite readable
+and understandable.
Although all of this sounds somewhat complicated, the result is that
extension code is quite straightforward to write and to read. You can
@@ -21862,7 +21863,10 @@ File: gawk.info, Node: Extension API Description, Next: Finding Extensions, P
16.4 API Description
====================
-This (rather large) minor node describes the API in detail.
+C or C++ code for an extension must include the header file
+`gawkapi.h', which declares the functions and defines the data types
+used to communicate with `gawk'. This (rather large) minor node
+describes the API in detail.
* Menu:
@@ -21946,6 +21950,7 @@ operations:
C Entity Header File
-------------------------------------------
`EOF' `<stdio.h>'
+ Values for `errno' `<errno.h>'
`FILE' `<stdio.h>'
`NULL' `<stddef.h>'
`memcpy()' `<string.h>'
@@ -21960,9 +21965,6 @@ operations:
a portability hodge-podge as can be seen in some parts of the
`gawk' source code.
- To pass reasonable integer values for `ERRNO', you will also need
- to include `<errno.h>'.
-
* The `gawkapi.h' file may be included more than once without ill
effect. Doing so, however, is poor coding practice.
@@ -21982,7 +21984,7 @@ operations:
* The API defines several simple `struct's that map values as seen
from `awk'. A value can be a `double', a string, or an array (as
in multidimensional arrays, or when creating a new array). String
- values maintain both pointer and length since embedded `NUL'
+ values maintain both pointer and length since embedded NUL
characters are allowed.
NOTE: By intent, strings are maintained using the current
@@ -22106,7 +22108,7 @@ that use them.
indicates what is in the `union'.
Representing numbers is easy--the API uses a C `double'. Strings
-require more work. Since `gawk' allows embedded `NUL' bytes in string
+require more work. Since `gawk' allows embedded NUL bytes in string
values, a string must be represented as a pair containing a
data-pointer and length. This is the `awk_string_t' type.
@@ -22476,7 +22478,8 @@ used for `RT', if any.
A pointer to your `XXX_take_control_of()' function.
`awk_const struct input_parser *awk_const next;'
- This pointer is used by `gawk'. The extension cannot modify it.
+ This is for use by `gawk'; therefore it is marked `awk_const' so
+ that the extension cannot modify it.
The steps are as follows:
@@ -22515,8 +22518,8 @@ as follows:
Otherwise, it will.
`struct stat sbuf;'
- If file descriptor is valid, then `gawk' will have filled in this
- structure via a call to the `fstat()' system call.
+ If the file descriptor is valid, then `gawk' will have filled in
+ this structure via a call to the `fstat()' system call.
The `XXX_can_take_file()' function should examine these fields and
decide if the input parser should be used for the file. The decision
@@ -22679,8 +22682,8 @@ an extension to take over the output to a file opened with the `>' or
false otherwise.
`awk_const struct output_wrapper *awk_const next;'
- This is for use by `gawk'; therefore they are marked `awk_const'
- so that the extension cannot modify them.
+ This is for use by `gawk'; therefore it is marked `awk_const' so
+ that the extension cannot modify it.
The `awk_output_buf_t' structure looks like this:
@@ -22737,9 +22740,9 @@ in the `awk_output_buf_t'. The data members are as follows:
the `name' and `mode' fields, and any additional state (such as `awk'
variable values) that is appropriate.
- When `gawk' calls `XXX_take_control_of()', it should fill in the
-other fields, as appropriate, except for `fp', which it should just use
-normally.
+ When `gawk' calls `XXX_take_control_of()', that function should fill
+in the other fields, as appropriate, except for `fp', which it should
+just use normally.
You register your output wrapper with the following function:
@@ -22787,8 +22790,8 @@ structures as described earlier.
respectively. These structures were described earlier.
`awk_const struct two_way_processor *awk_const next;'
- This is for use by `gawk'; therefore they are marked `awk_const'
- so that the extension cannot modify them.
+ This is for use by `gawk'; therefore it is marked `awk_const' so
+ that the extension cannot modify it.
As with the input parser and output processor, you provide "yes I
can take this" and "take over for this" functions,
@@ -22957,7 +22960,7 @@ was discussed earlier, in *note General Data Types::.
`awk_bool_t sym_update_scalar(awk_scalar_t cookie, awk_value_t *value);'
Update the value associated with a scalar cookie. Return false if
- the new value is not one of `AWK_STRING' or `AWK_NUMBER'. Here
+ the new value is not of type `AWK_STRING' or `AWK_NUMBER'. Here
too, the built-in variables may not be updated.
It is not obvious at first glance how to work with scalar cookies or
@@ -23072,9 +23075,10 @@ follows:
`awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);'
Create a cached string or numeric value from `value' for efficient
- later assignment. Only `AWK_NUMBER' and `AWK_STRING' values are
- allowed. Any other type is rejected. While `AWK_UNDEFINED' could
- be allowed, doing so would result in inferior performance.
+ later assignment. Only values of type `AWK_NUMBER' and
+ `AWK_STRING' are allowed. Any other type is rejected. While
+ `AWK_UNDEFINED' could be allowed, doing so would result in
+ inferior performance.
`awk_bool_t release_value(awk_value_cookie_t vc);'
Release the memory associated with a value cookie obtained from
@@ -23128,11 +23132,11 @@ if `awk' code assigns a new value to `VAR1', are all the others be
changed too?"
That's a great question. The answer is that no, it's not a problem.
-Internally, `gawk' uses reference-counted strings. This means that many
-variables can share the same string value, and `gawk' keeps track of
-the usage. When a variable's value changes, `gawk' simply decrements
-the reference count on the old value and updates the variable to use
-the new value.
+Internally, `gawk' uses "reference-counted strings". This means that
+many variables can share the same string value, and `gawk' keeps track
+of the usage. When a variable's value changes, `gawk' simply
+decrements the reference count on the old value and updates the
+variable to use the new value.
Finally, as part of your clean up action (*note Exit Callback
Functions::) you should release any cached values that you created,
@@ -23275,7 +23279,7 @@ The following functions relate to individual array elements.
` const awk_value_t *const value);'
In the array represented by `a_cookie', create or modify the
element whose index is given by `index'. The `ARGV' and `ENVIRON'
- arrays may not be changed.
+ arrays may not be changed, although the `PROCINFO' array can be.
`awk_bool_t set_array_element_by_elem(awk_array_t a_cookie,'
` awk_element_t element);'
@@ -23513,8 +23517,8 @@ code:
Thus, the correct way to build an array is to work "top down."
Create the array, and immediately install it in `gawk''s symbol
table using `sym_update()', or install it as an element in a
- previously existing array using `set_element()'. We show example
- code shortly.
+ previously existing array using `set_array_element()'. We show
+ example code shortly.
2. Due to gawk internals, after using `sym_update()' to install an
array into `gawk', you have to retrieve the array cookie from the
@@ -23704,13 +23708,15 @@ The API provides access to several variables that describe whether the
corresponding command-line options were enabled when `gawk' was
invoked. The variables are:
+`do_debug'
+ This variable is true if `gawk' was invoked with `--debug' option.
+
`do_lint'
This variable is true if `gawk' was invoked with `--lint' option
(*note Options::).
-`do_traditional'
- This variable is true if `gawk' was invoked with `--traditional'
- option.
+`do_mpfr'
+ This variable is true if `gawk' was invoked with `--bignum' option.
`do_profile'
This variable is true if `gawk' was invoked with `--profile'
@@ -23720,11 +23726,9 @@ invoked. The variables are:
This variable is true if `gawk' was invoked with `--sandbox'
option.
-`do_debug'
- This variable is true if `gawk' was invoked with `--debug' option.
-
-`do_mpfr'
- This variable is true if `gawk' was invoked with `--bignum' option.
+`do_traditional'
+ This variable is true if `gawk' was invoked with `--traditional'
+ option.
The value of `do_lint' can change if `awk' code modifies the `LINT'
built-in variable (*note Built-in Variables::). The others should not
@@ -24324,7 +24328,9 @@ for loading each function into `gawk':
static awk_ext_func_t func_table[] = {
{ "chdir", do_chdir, 1 },
{ "stat", do_stat, 2 },
+ #ifndef __MINGW32__
{ "fts", do_fts, 3 },
+ #endif
};
Each extension must have a routine named `dl_load()' to load
@@ -24484,52 +24490,36 @@ follows: The usage is:
successful, `stat()' fills the `statdata' array with information
retrieved from the filesystem, as follows:
- `statdata["name"]' The name of the file.
- `statdata["dev"]' Corresponds to the `st_dev' field in
- the `struct stat'.
- `statdata["ino"]' Corresponds to the `st_ino' field in
- the `struct stat'.
- `statdata["mode"]' Corresponds to the `st_mode' field in
- the `struct stat'.
- `statdata["nlink"]' Corresponds to the `st_nlink' field in
- the `struct stat'.
- `statdata["uid"]' Corresponds to the `st_uid' field in
- the `struct stat'.
- `statdata["gid"]' Corresponds to the `st_gid' field in
- the `struct stat'.
- `statdata["size"]' Corresponds to the `st_size' field in
- the `struct stat'.
- `statdata["atime"]' Corresponds to the `st_atime' field in
- the `struct stat'.
- `statdata["mtime"]' Corresponds to the `st_mtime' field in
- the `struct stat'.
- `statdata["ctime"]' Corresponds to the `st_ctime' field in
- the `struct stat'.
- `statdata["rdev"]' Corresponds to the `st_rdev' field in
- the `struct stat'. This element is
- only present for device files.
- `statdata["major"]' Corresponds to the `st_major' field in
- the `struct stat'. This element is
- only present for device files.
- `statdata["minor"]' Corresponds to the `st_minor' field in
- the `struct stat'. This element is
- only present for device files.
- `statdata["blksize"]' Corresponds to the `st_blksize' field
- in the `struct stat', if this field is
- present on your system. (It is present
- on all modern systems that we know of.)
- `statdata["pmode"]' A human-readable version of the mode
- value, such as printed by `ls'. For
- example, `"-rwxr-xr-x"'.
- `statdata["linkval"]' If the named file is a symbolic link,
- this element will exist and its value
- is the value of the symbolic link
- (where the symbolic link points to).
- `statdata["type"]' The type of the file as a string. One
- of `"file"', `"blockdev"', `"chardev"',
- `"directory"', `"socket"', `"fifo"',
- `"symlink"', `"door"', or `"unknown"'.
- Not all systems support all file types.
+ Subscript Field in `struct stat' File type
+ ------------------------------------------------------------
+ `"name"' The file name All
+ `"dev"' `st_dev' All
+ `"ino"' `st_ino' All
+ `"mode"' `st_mode' All
+ `"nlink"' `st_nlink' All
+ `"uid"' `st_uid' All
+ `"gid"' `st_gid' All
+ `"size"' `st_size' All
+ `"atime"' `st_atime' All
+ `"mtime"' `st_mtime' All
+ `"ctime"' `st_ctime' All
+ `"rdev"' `st_rdev' Device files
+ `"major"' `st_major' Device files
+ `"minor"' `st_minor' Device files
+ `"blksize"'`st_blksize' All
+ `"pmode"' A human-readable version of the All
+ mode value, such as printed by
+ `ls'. For example,
+ `"-rwxr-xr-x"'
+ `"linkval"'The value of the symbolic link Symbolic
+ links
+ `"type"' The type of the file as a string. All
+ One of `"file"', `"blockdev"',
+ `"chardev"', `"directory"',
+ `"socket"', `"fifo"', `"symlink"',
+ `"door"', or `"unknown"'. Not
+ all systems support all file
+ types.
`flags = or(FTS_PHYSICAL, ...)'
`result = fts(pathlist, flags, filedata)'
@@ -24674,18 +24664,14 @@ constant (`FNM_NOMATCH'), and an array of flag values named `FNM'.
The flags are follows:
-`FNM["CASEFOLD"]' Corresponds to the `FNM_CASEFOLD' flag as defined in
- `fnmatch()'.
-`FNM["FILE_NAME"]' Corresponds to the `FNM_FILE_NAME' flag as defined
- in `fnmatch()'.
-`FNM["LEADING_DIR"]' Corresponds to the `FNM_LEADING_DIR' flag as defined
- in `fnmatch()'.
-`FNM["NOESCAPE"]' Corresponds to the `FNM_NOESCAPE' flag as defined in
- `fnmatch()'.
-`FNM["PATHNAME"]' Corresponds to the `FNM_PATHNAME' flag as defined in
- `fnmatch()'.
-`FNM["PERIOD"]' Corresponds to the `FNM_PERIOD' flag as defined in
- `fnmatch()'.
+Array element Corresponding lag defined by `fnmatch()'
+--------------------------------------------------------------------------
+`FNM["CASEFOLD"]' `FNM_CASEFOLD'
+`FNM["FILE_NAME"]' `FNM_FILE_NAME'
+`FNM["LEADING_DIR"]'`FNM_LEADING_DIR'
+`FNM["NOESCAPE"]' `FNM_NOESCAPE'
+`FNM["PATHNAME"]' `FNM_PATHNAME'
+`FNM["PERIOD"]' `FNM_PERIOD'
Here is an example:
@@ -24826,7 +24812,8 @@ returned as a record.
number and the filename, separated by a forward slash character. On
systems where the directory entry contains the file type, the record
has a third field (also separated by a slash) which is a single letter
-indicating the type of the file:
+indicating the type of the file. The letters are file types are shown
+in *note table-readdir-file-types::.
Letter File Type
--------------------------------------------------------------------------
@@ -24839,6 +24826,8 @@ Letter File Type
`s' Socket
`u' Anything else (unknown)
+Table 16.2: File types returned by `readdir()'
+
On systems without the file type information, the third field is
always `u'.
@@ -24870,10 +24859,10 @@ unwary. Here is an example:
BEGIN {
REVOUT = 1
- print "hello, world" > "/dev/stdout"
+ print "don't panic" > "/dev/stdout"
}
- The output from this program is: `dlrow ,olleh'.
+ The output from this program is: `cinap t'nod'.

File: gawk.info, Node: Extension Sample Rev2way, Next: Extension Sample Read write array, Prev: Extension Sample Revout, Up: Extension Samples
@@ -24891,12 +24880,14 @@ example shows how to use it:
BEGIN {
cmd = "/magic/mirror"
- print "hello, world" |& cmd
+ print "don't panic" |& cmd
cmd |& getline result
print result
close(cmd)
}
+ The output from this program is: `cinap t'nod'.
+

File: gawk.info, Node: Extension Sample Read write array, Next: Extension Sample Readfile, Prev: Extension Sample Rev2way, Up: Extension Samples
@@ -24908,8 +24899,8 @@ The `rwarray' extension adds two functions, named `writea()' and
`ret = writea(file, array)'
This function takes a string argument, which is the name of the
- file to which dump the array, and the array itself as the second
- argument. `writea()' understands multidimensional arrays. It
+ file to which to dump the array, and the array itself as the
+ second argument. `writea()' understands arrays of arrays. It
returns one on success, or zero upon failure.
`ret = reada(file, array)'
@@ -24992,9 +24983,8 @@ File: gawk.info, Node: Extension Sample Time, Prev: Extension Sample API Tests
16.7.12 Extension Time Functions
--------------------------------
-These functions can be used either by invoking `gawk' with a
-command-line argument of `-l time' or by inserting `@load "time"' in
-your script.
+The `time' extension adds two functions, named `gettimeofday()' and
+`sleep()', as follows:
`@load "time"'
This is how you load the extension.
@@ -25006,7 +24996,7 @@ your script.
have sub-second precision, but the actual precision may vary based
on the platform. If the standard C `gettimeofday()' system call
is available on this platform, then it simply returns the value.
- Otherwise, if on Windows, it tries to use
+ Otherwise, if on MS-Windows, it tries to use
`GetSystemTimeAsFileTime()'.
`result = sleep(SECONDS)'
@@ -31594,7 +31584,7 @@ Index
* FSF (Free Software Foundation) <2>: Getting. (line 10)
* FSF (Free Software Foundation): Manual History. (line 6)
* fts() extension function: Extension Sample File Functions.
- (line 77)
+ (line 61)
* FUNCTAB array: Auto-set. (line 115)
* function calls: Function Calls. (line 6)
* function calls, indirect: Indirect Calls. (line 6)
@@ -31786,7 +31776,7 @@ Index
* gettext library, locale categories: Explaining gettext. (line 81)
* gettext() function (C library): Explaining gettext. (line 63)
* gettimeofday() extension function: Extension Sample Time.
- (line 13)
+ (line 12)
* git utility <1>: Adding Code. (line 111)
* git utility <2>: Accessing The Source.
(line 10)
@@ -31849,7 +31839,7 @@ Index
* i debugger command (alias for info): Debugger Info. (line 13)
* id utility: Id Program. (line 6)
* id.awk program: Id Program. (line 30)
-* IEEE-754 format: Floating-point Representation.
+* IEEE 754 format: Floating-point Representation.
(line 6)
* if statement: If Statement. (line 6)
* if statement, actions, changing: Ranges. (line 25)
@@ -32835,7 +32825,7 @@ Index
* Skywalker, Luke: Undocumented. (line 6)
* sleep utility: Alarm Program. (line 111)
* sleep() extension function: Extension Sample Time.
- (line 23)
+ (line 22)
* Solaris, POSIX-compliant awk: Other Versions. (line 96)
* sort array: String Functions. (line 42)
* sort array indices: String Functions. (line 42)
@@ -33589,164 +33579,165 @@ Node: String Conversion Precision833417
Ref: String Conversion Precision-Footnote-1835122
Node: Unexpected Results835231
Node: POSIX Floating Point Problems837384
-Ref: POSIX Floating Point Problems-Footnote-1841209
-Node: Integer Programming841247
-Node: Floating-point Programming842986
-Ref: Floating-point Programming-Footnote-1849317
-Ref: Floating-point Programming-Footnote-2849587
-Node: Floating-point Representation849851
-Node: Floating-point Context851016
-Ref: table-ieee-formats851855
-Node: Rounding Mode853239
-Ref: table-rounding-modes853718
-Ref: Rounding Mode-Footnote-1856733
-Node: Gawk and MPFR856912
-Node: Arbitrary Precision Floats858321
-Ref: Arbitrary Precision Floats-Footnote-1860764
-Node: Setting Precision861080
-Ref: table-predefined-precision-strings861766
-Node: Setting Rounding Mode863911
-Ref: table-gawk-rounding-modes864315
-Node: Floating-point Constants865502
-Node: Changing Precision866931
-Ref: Changing Precision-Footnote-1868328
-Node: Exact Arithmetic868502
-Node: Arbitrary Precision Integers871640
-Ref: Arbitrary Precision Integers-Footnote-1874655
-Node: Dynamic Extensions874802
-Node: Extension Intro876260
-Node: Plugin License877525
-Node: Extension Mechanism Outline878210
-Ref: load-extension878627
-Ref: load-new-function880105
-Ref: call-new-function881100
-Node: Extension API Description883115
-Node: Extension API Functions Introduction884402
-Node: General Data Types889329
-Ref: General Data Types-Footnote-1895024
-Node: Requesting Values895323
-Ref: table-value-types-returned896060
-Node: Memory Allocation Functions897014
-Ref: Memory Allocation Functions-Footnote-1899760
-Node: Constructor Functions899856
-Node: Registration Functions901614
-Node: Extension Functions902299
-Node: Exit Callback Functions904601
-Node: Extension Version String905850
-Node: Input Parsers906500
-Node: Output Wrappers916257
-Node: Two-way processors920767
-Node: Printing Messages922975
-Ref: Printing Messages-Footnote-1924052
-Node: Updating `ERRNO'924204
-Node: Accessing Parameters924943
-Node: Symbol Table Access926173
-Node: Symbol table by name926687
-Node: Symbol table by cookie928663
-Ref: Symbol table by cookie-Footnote-1932795
-Node: Cached values932858
-Ref: Cached values-Footnote-1936348
-Node: Array Manipulation936439
-Ref: Array Manipulation-Footnote-1937537
-Node: Array Data Types937576
-Ref: Array Data Types-Footnote-1940279
-Node: Array Functions940371
-Node: Flattening Arrays944207
-Node: Creating Arrays951059
-Node: Extension API Variables955784
-Node: Extension Versioning956420
-Node: Extension API Informational Variables958321
-Node: Extension API Boilerplate959407
-Node: Finding Extensions963211
-Node: Extension Example963771
-Node: Internal File Description964501
-Node: Internal File Ops968592
-Ref: Internal File Ops-Footnote-1980101
-Node: Using Internal File Ops980241
-Ref: Using Internal File Ops-Footnote-1982588
-Node: Extension Samples982854
-Node: Extension Sample File Functions984378
-Node: Extension Sample Fnmatch992865
-Node: Extension Sample Fork994634
-Node: Extension Sample Inplace995847
-Node: Extension Sample Ord997625
-Node: Extension Sample Readdir998461
-Node: Extension Sample Revout999993
-Node: Extension Sample Rev2way1000586
-Node: Extension Sample Read write array1001276
-Node: Extension Sample Readfile1003159
-Node: Extension Sample API Tests1004259
-Node: Extension Sample Time1004784
-Node: gawkextlib1006148
-Node: Language History1008929
-Node: V7/SVR3.11010522
-Node: SVR41012842
-Node: POSIX1014284
-Node: BTL1015670
-Node: POSIX/GNU1016404
-Node: Feature History1022003
-Node: Common Extensions1034979
-Node: Ranges and Locales1036291
-Ref: Ranges and Locales-Footnote-11040908
-Ref: Ranges and Locales-Footnote-21040935
-Ref: Ranges and Locales-Footnote-31041169
-Node: Contributors1041390
-Node: Installation1046771
-Node: Gawk Distribution1047665
-Node: Getting1048149
-Node: Extracting1048975
-Node: Distribution contents1050667
-Node: Unix Installation1056388
-Node: Quick Installation1057005
-Node: Additional Configuration Options1059451
-Node: Configuration Philosophy1061187
-Node: Non-Unix Installation1063541
-Node: PC Installation1063999
-Node: PC Binary Installation1065310
-Node: PC Compiling1067158
-Node: PC Testing1070118
-Node: PC Using1071294
-Node: Cygwin1075462
-Node: MSYS1076271
-Node: VMS Installation1076785
-Node: VMS Compilation1077581
-Ref: VMS Compilation-Footnote-11078833
-Node: VMS Dynamic Extensions1078891
-Node: VMS Installation Details1080264
-Node: VMS Running1082515
-Node: VMS GNV1085349
-Node: VMS Old Gawk1086072
-Node: Bugs1086542
-Node: Other Versions1090460
-Node: Notes1096544
-Node: Compatibility Mode1097344
-Node: Additions1098127
-Node: Accessing The Source1099054
-Node: Adding Code1100494
-Node: New Ports1106539
-Node: Derived Files1110674
-Ref: Derived Files-Footnote-11115995
-Ref: Derived Files-Footnote-21116029
-Ref: Derived Files-Footnote-31116629
-Node: Future Extensions1116727
-Node: Implementation Limitations1117310
-Node: Extension Design1118558
-Node: Old Extension Problems1119712
-Ref: Old Extension Problems-Footnote-11121220
-Node: Extension New Mechanism Goals1121277
-Ref: Extension New Mechanism Goals-Footnote-11124642
-Node: Extension Other Design Decisions1124828
-Node: Extension Future Growth1126934
-Node: Old Extension Mechanism1127770
-Node: Basic Concepts1129510
-Node: Basic High Level1130191
-Ref: figure-general-flow1130463
-Ref: figure-process-flow1131062
-Ref: Basic High Level-Footnote-11134291
-Node: Basic Data Typing1134476
-Node: Glossary1137831
-Node: Copying1163062
-Node: GNU Free Documentation License1200618
-Node: Index1225754
+Ref: POSIX Floating Point Problems-Footnote-1841205
+Node: Integer Programming841243
+Node: Floating-point Programming843054
+Ref: Floating-point Programming-Footnote-1849382
+Ref: Floating-point Programming-Footnote-2849652
+Node: Floating-point Representation849916
+Node: Floating-point Context851081
+Ref: table-ieee-formats851920
+Node: Rounding Mode853304
+Ref: table-rounding-modes853783
+Ref: Rounding Mode-Footnote-1856798
+Node: Gawk and MPFR856977
+Node: Arbitrary Precision Floats858386
+Ref: Arbitrary Precision Floats-Footnote-1860829
+Node: Setting Precision861150
+Ref: table-predefined-precision-strings861834
+Node: Setting Rounding Mode863979
+Ref: table-gawk-rounding-modes864383
+Node: Floating-point Constants865570
+Node: Changing Precision867022
+Ref: Changing Precision-Footnote-1868414
+Node: Exact Arithmetic868588
+Node: Arbitrary Precision Integers871722
+Ref: Arbitrary Precision Integers-Footnote-1874737
+Node: Dynamic Extensions874884
+Node: Extension Intro876342
+Node: Plugin License877607
+Node: Extension Mechanism Outline878292
+Ref: load-extension878709
+Ref: load-new-function880187
+Ref: call-new-function881182
+Node: Extension API Description883166
+Node: Extension API Functions Introduction884616
+Node: General Data Types889482
+Ref: General Data Types-Footnote-1895175
+Node: Requesting Values895474
+Ref: table-value-types-returned896211
+Node: Memory Allocation Functions897165
+Ref: Memory Allocation Functions-Footnote-1899911
+Node: Constructor Functions900007
+Node: Registration Functions901765
+Node: Extension Functions902450
+Node: Exit Callback Functions904752
+Node: Extension Version String906001
+Node: Input Parsers906651
+Node: Output Wrappers916454
+Node: Two-way processors920970
+Node: Printing Messages923173
+Ref: Printing Messages-Footnote-1924250
+Node: Updating `ERRNO'924402
+Node: Accessing Parameters925141
+Node: Symbol Table Access926371
+Node: Symbol table by name926885
+Node: Symbol table by cookie928861
+Ref: Symbol table by cookie-Footnote-1932994
+Node: Cached values933057
+Ref: Cached values-Footnote-1936562
+Node: Array Manipulation936653
+Ref: Array Manipulation-Footnote-1937751
+Node: Array Data Types937790
+Ref: Array Data Types-Footnote-1940493
+Node: Array Functions940585
+Node: Flattening Arrays944459
+Node: Creating Arrays951311
+Node: Extension API Variables956042
+Node: Extension Versioning956678
+Node: Extension API Informational Variables958579
+Node: Extension API Boilerplate959665
+Node: Finding Extensions963469
+Node: Extension Example964029
+Node: Internal File Description964759
+Node: Internal File Ops968850
+Ref: Internal File Ops-Footnote-1980396
+Node: Using Internal File Ops980536
+Ref: Using Internal File Ops-Footnote-1982883
+Node: Extension Samples983149
+Node: Extension Sample File Functions984673
+Node: Extension Sample Fnmatch992240
+Node: Extension Sample Fork993719
+Node: Extension Sample Inplace994932
+Node: Extension Sample Ord996710
+Node: Extension Sample Readdir997546
+Ref: table-readdir-file-types998401
+Node: Extension Sample Revout999200
+Node: Extension Sample Rev2way999791
+Node: Extension Sample Read write array1000532
+Node: Extension Sample Readfile1002411
+Node: Extension Sample API Tests1003511
+Node: Extension Sample Time1004036
+Node: gawkextlib1005351
+Node: Language History1008132
+Node: V7/SVR3.11009725
+Node: SVR41012045
+Node: POSIX1013487
+Node: BTL1014873
+Node: POSIX/GNU1015607
+Node: Feature History1021206
+Node: Common Extensions1034182
+Node: Ranges and Locales1035494
+Ref: Ranges and Locales-Footnote-11040111
+Ref: Ranges and Locales-Footnote-21040138
+Ref: Ranges and Locales-Footnote-31040372
+Node: Contributors1040593
+Node: Installation1045974
+Node: Gawk Distribution1046868
+Node: Getting1047352
+Node: Extracting1048178
+Node: Distribution contents1049870
+Node: Unix Installation1055591
+Node: Quick Installation1056208
+Node: Additional Configuration Options1058654
+Node: Configuration Philosophy1060390
+Node: Non-Unix Installation1062744
+Node: PC Installation1063202
+Node: PC Binary Installation1064513
+Node: PC Compiling1066361
+Node: PC Testing1069321
+Node: PC Using1070497
+Node: Cygwin1074665
+Node: MSYS1075474
+Node: VMS Installation1075988
+Node: VMS Compilation1076784
+Ref: VMS Compilation-Footnote-11078036
+Node: VMS Dynamic Extensions1078094
+Node: VMS Installation Details1079467
+Node: VMS Running1081718
+Node: VMS GNV1084552
+Node: VMS Old Gawk1085275
+Node: Bugs1085745
+Node: Other Versions1089663
+Node: Notes1095747
+Node: Compatibility Mode1096547
+Node: Additions1097330
+Node: Accessing The Source1098257
+Node: Adding Code1099697
+Node: New Ports1105742
+Node: Derived Files1109877
+Ref: Derived Files-Footnote-11115198
+Ref: Derived Files-Footnote-21115232
+Ref: Derived Files-Footnote-31115832
+Node: Future Extensions1115930
+Node: Implementation Limitations1116513
+Node: Extension Design1117761
+Node: Old Extension Problems1118915
+Ref: Old Extension Problems-Footnote-11120423
+Node: Extension New Mechanism Goals1120480
+Ref: Extension New Mechanism Goals-Footnote-11123845
+Node: Extension Other Design Decisions1124031
+Node: Extension Future Growth1126137
+Node: Old Extension Mechanism1126973
+Node: Basic Concepts1128713
+Node: Basic High Level1129394
+Ref: figure-general-flow1129666
+Ref: figure-process-flow1130265
+Ref: Basic High Level-Footnote-11133494
+Node: Basic Data Typing1133679
+Node: Glossary1137034
+Node: Copying1162265
+Node: GNU Free Documentation License1199821
+Node: Index1224957

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 1b8d003f..eeacd2c6 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -13954,7 +13954,7 @@ The working precision of arbitrary precision floating-point numbers,
@item ROUNDMODE #
The rounding mode to use for arbitrary precision arithmetic on
numbers, by default @code{"N"} (@samp{roundTiesToEven} in
-the IEEE-754 standard; @pxref{Setting Rounding Mode}).
+the IEEE 754 standard; @pxref{Setting Rounding Mode}).
@cindex @code{RS} variable
@cindex separators, for records
@@ -29198,7 +29198,7 @@ $ @kbd{echo 0xDeadBeef | gawk '@{ print $1 + 0 @}'}
@print{} 0
@end example
-@command{gawk} does ignore case in the four special values.
+@command{gawk} ignores case in the four special values.
Thus @samp{+nan} and @samp{+NaN} are the same.
@end itemize
@@ -29207,13 +29207,15 @@ Thus @samp{+nan} and @samp{+NaN} are the same.
As has been mentioned already, @command{awk} uses hardware double
precision with 64-bit IEEE binary floating-point representation
-for numbers on most systems. A large integer like 9,007,199,254,740,997
+for numbers on most systems.
+A large integer like 9,007,199,254,740,997
has a binary representation that, although finite, is more than 53 bits long;
it must also be rounded to 53 bits.
+(The details are discussed in @ref{Floating-point Representation}.)
The biggest integer that can be stored in a C @code{double} is usually the same
as the largest possible value of a @code{double}. If your system @code{double}
is an IEEE 64-bit @code{double}, this largest possible value is an integer and
-can be represented precisely. What more should one know about integers?
+can be represented precisely. What more should you know about integers?
If you want to know what is the largest integer, such that it and
all smaller integers can be stored in 64-bit doubles without losing precision,
@@ -29329,7 +29331,7 @@ floating-point, you can set the precision before starting a computation,
but then you cannot be sure of the number of significant decimal places
in the final result.
-Sometimes, before you start to write any code, you should think more
+So, before you start to write any code, you should think more
about what you really want and what's really happening. Consider the
two numbers in the following example:
@@ -29360,7 +29362,7 @@ Usually this is a format string like @code{"%.15g"}, which when
used in the previous example, produces an output identical to the input.
Because the underlying representation can be a little bit off from the exact value,
-comparing floating-point values to see if they are equal is generally not a good idea.
+comparing floating-point values to see if they are exactly equal is generally a bad idea.
Here is an example where it does not work like you expect:
@example
@@ -29427,7 +29429,7 @@ in the earlier example can be enhanced by using the following
simple algebraic transformation:
@example
-(sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + 1)
+(sqrt(x * x + 1) - 1) / x @equiv{} x / (sqrt(x * x + 1) + 1)
@end example
@noindent
@@ -29467,11 +29469,11 @@ implies better precision than is actually the case.
@node Floating-point Representation
@subsection Binary Floating-point Representation
-@cindex IEEE-754 format
+@cindex IEEE 754 format
Although floating-point representations vary from machine to machine,
the most commonly encountered representation is that defined by the
-IEEE 754 Standard. An IEEE-754 format value has three components:
+IEEE 754 Standard. An IEEE 754 format value has three components:
@itemize @bullet
@item
@@ -29499,12 +29501,12 @@ number is then
<emphasis>s &sdot; 2<superscript>e</superscript></emphasis>. @c
@end docbook
The first bit of a non-zero binary significand
-is always one, so the significand in an IEEE-754 format only includes the
+is always one, so the significand in an IEEE 754 format only includes the
fractional part, leaving the leading one implicit.
The significand is stored in @dfn{normalized} format,
which means that the first bit is always a one.
-Three of the standard IEEE-754 types are 32-bit single precision,
+Three of the standard IEEE 754 types are 32-bit single precision,
64-bit double precision and 128-bit quadruple precision.
The standard also specifies extended precision formats
to allow greater precisions and larger exponent ranges.
@@ -29535,7 +29537,7 @@ The rounding mode of the context.
@end table
@ref{table-ieee-formats} lists the precision and exponent
-field values for the basic IEEE-754 binary formats:
+field values for the basic IEEE 754 binary formats:
@float Table,table-ieee-formats
@caption{Basic IEEE Format Context Values}
@@ -29554,10 +29556,10 @@ one extra bit of significand.
A floating-point context can also determine which signals are treated
as exceptions, and can set rules for arithmetic with special values.
-Please consult the IEEE-754 standard or other resources for details.
+Please consult the IEEE 754 standard or other resources for details.
@command{gawk} ordinarily uses the hardware double precision
-representation for numbers. On most systems, this is IEEE-754
+representation for numbers. On most systems, this is IEEE 754
floating-point format, corresponding to 64-bit binary with 53 bits
of precision.
@@ -29567,7 +29569,7 @@ the result from an arithmetic operation to be a number smaller than
the smallest nonzero normalized number. Such numbers do
not have as many significant digits as normal numbers, and are called
@dfn{denormals} or @dfn{subnormals}. The alternative, simply returning a zero,
-is called @dfn{flush to zero}. The basic IEEE-754 binary formats
+is called @dfn{flush to zero}. The basic IEEE 754 binary formats
support subnormal numbers.
@end quotation
@@ -29579,7 +29581,7 @@ The @dfn{rounding mode} specifies the behavior for the results of numerical
operations when discarding extra precision. Each rounding mode indicates
how the least significant returned digit of a rounded result is to
be calculated.
-@ref{table-rounding-modes} lists the IEEE-754 defined
+@ref{table-rounding-modes} lists the IEEE 754 defined
rounding modes:
@float Table,table-rounding-modes
@@ -29622,7 +29624,7 @@ BEGIN @{
@noindent
produces the following output when run on the author's system:@footnote{It
is possible for the output to be completely different if the
-C library in your system does not use the IEEE-754 even-rounding
+C library in your system does not use the IEEE 754 even-rounding
rule to round halfway cases for @code{printf}.}
@example
@@ -29641,7 +29643,7 @@ The theory behind the rounding mode @code{roundTiesToEven} is that
it more or less evenly distributes upward and downward rounds
of exact halves, which might cause any round-off error
to cancel itself out. This is the default rounding mode used
-in IEEE-754 computing functions and operators.
+in IEEE 754 computing functions and operators.
The other rounding modes are rarely used.
Round toward positive infinity (@code{roundTowardPositive})
@@ -29733,10 +29735,10 @@ to follow.
The default working precision for arbitrary precision floating-point values is
53 bits, and the default value for @code{ROUNDMODE} is @code{"N"},
-which selects the IEEE-754 @code{roundTiesToEven} rounding mode
+which selects the IEEE 754 @code{roundTiesToEven} rounding mode
(@pxref{Rounding Mode}).@footnote{The
default precision is 53 bits, since according to the MPFR documentation,
-the library should be able to exactly reproduce all computations with
+the library should be able to exactly reproduce all computations done with
double-precision machine floating-point numbers (@code{double} type
in C), except the default exponent range is much wider and subnormal
numbers are not implemented.}
@@ -29758,7 +29760,7 @@ MPFR does not implement subnormal numbers by default,
and this behavior cannot be changed in @command{gawk}.
@quotation NOTE
-When emulating an IEEE-754 format (@pxref{Setting Precision}),
+When emulating an IEEE 754 format (@pxref{Setting Precision}),
@command{gawk} internally adjusts the exponent range
to the value defined for the format and also performs computations needed for
gradual underflow (subnormal numbers).
@@ -29788,16 +29790,16 @@ your program.
@command{gawk} uses a global working precision; it does not keep track of
the precision or accuracy of individual numbers. Performing an arithmetic
operation or calling a built-in function rounds the result to the current
-working precision. The default working precision is 53 bits, which can be
-modified using the built-in variable @code{PREC}. You can also set the
-value to one of the pre-defined case-insensitive strings
+working precision. The default working precision is 53 bits, which you can
+modify using the built-in variable @code{PREC}. You can also set the
+value to one of the predefined case-insensitive strings
shown in @ref{table-predefined-precision-strings},
-to emulate an IEEE-754 binary format.
+to emulate an IEEE 754 binary format.
@float Table,table-predefined-precision-strings
@caption{Predefined precision strings for @code{PREC}}
@multitable {@code{"double"}} {12345678901234567890123456789012345}
-@headitem @code{PREC} @tab IEEE-754 Binary Format
+@headitem @code{PREC} @tab IEEE 754 Binary Format
@item @code{"half"} @tab 16-bit half-precision.
@item @code{"single"} @tab Basic 32-bit single precision.
@item @code{"double"} @tab Basic 64-bit double precision.
@@ -29886,8 +29888,8 @@ rounding modes is shown in @ref{table-gawk-rounding-modes}.
@end float
@code{ROUNDMODE} has the default value @code{"N"},
-which selects the IEEE-754 rounding mode @code{roundTiesToEven}.
-In @ref{table-gawk-rounding-modes}, @code{"A"} is listed to select the IEEE-754 mode
+which selects the IEEE 754 rounding mode @code{roundTiesToEven}.
+In @ref{table-gawk-rounding-modes}, @code{"A"} is listed to select the IEEE 754 mode
@code{roundTiesToAway}. This is only available
if your version of the MPFR library supports it; otherwise setting
@code{ROUNDMODE} to this value has no effect. @xref{Rounding Mode},
@@ -29906,8 +29908,8 @@ $ @kbd{gawk -M -v ROUNDMODE="Z" 'BEGIN @{ printf("%.2f\n", 1.378) @}'}
@cindex constants, floating-point
Be wary of floating-point constants! When reading a floating-point constant
-from program source code, @command{gawk} uses the default precision,
-unless overridden
+from program source code, @command{gawk} uses the default precision (that
+of a C @code{double}), unless overridden
by an assignment to the special variable @code{PREC} on the command
line, to store it internally as a MPFR number.
Changing the precision using @code{PREC} in the program text does
@@ -29954,7 +29956,7 @@ Electronic Transactions on Numerical Analysis. Volume 28, pp. 168-173, 2008.}
@command{gawk} does not implicitly modify the precision of any previously
computed results when the working precision is changed with an assignment
to @code{PREC}. The precision of a number is always the one that was
-used at the time of its creation, and there is no way for the user
+used at the time of its creation, and there is no way for you
to explicitly change it afterwards. However, since the result of a
floating-point arithmetic operation is always an arbitrary precision
floating-point value---with a precision set by the value of @code{PREC}---one of the
@@ -30019,7 +30021,7 @@ a straight test for equality may not work.
So, don't assume that floating-point values can be compared for equality.
You should also exercise caution when using other forms of comparisons.
-The standard way to compare between floating-point numbers is to determine
+The standard way to compare two floating-point numbers is to determine
how much error (or @dfn{tolerance}) you will allow in a comparison and
check to see if one value is within this error range of the other.
@@ -30344,9 +30346,9 @@ The @code{do_@var{xxx}()} function, in turn, then uses the function
pointers in the API @code{struct} to do its work, such as updating
variables or arrays, printing messages, setting @code{ERRNO}, and so on.
-Convenience macros in the @file{gawkapi.h} header file make calling
-through the function pointers look like regular function calls so that
-extension code is quite readable and understandable.
+Convenience macros make calling through the function pointers look
+like regular function calls so that extension code is quite readable
+and understandable.
Although all of this sounds somewhat complicated, the result is that
extension code is quite straightforward to write and to read. You can
@@ -30377,6 +30379,9 @@ happen, but we all know how @emph{that} goes.)
@section API Description
@cindex extension API
+C or C++ code for an extension must include the header file
+@file{gawkapi.h}, which declares the functions and defines the data
+types used to communicate with @command{gawk}.
This (rather large) @value{SECTION} describes the API in detail.
@menu
@@ -30478,6 +30483,7 @@ corresponding standard header file @emph{before} including @file{gawkapi.h}:
@multitable {@code{memset()}, @code{memcpy()}} {@code{<sys/types.h>}}
@headitem C Entity @tab Header File
@item @code{EOF} @tab @code{<stdio.h>}
+@item Values for @code{errno} @tab @code{<errno.h>}
@item @code{FILE} @tab @code{<stdio.h>}
@item @code{NULL} @tab @code{<stddef.h>}
@item @code{memcpy()} @tab @code{<string.h>}
@@ -30493,9 +30499,6 @@ is necessary in order to keep @file{gawkapi.h} clean, instead of becoming
a portability hodge-podge as can be seen in some parts of
the @command{gawk} source code.
-To pass reasonable integer values for @code{ERRNO}, you will also need to
-include @code{<errno.h>}.
-
@item
The @file{gawkapi.h} file may be included more than once without ill effect.
Doing so, however, is poor coding practice.
@@ -30519,7 +30522,7 @@ and is managed by @command{gawk} from then on.
The API defines several simple @code{struct}s that map values as seen
from @command{awk}. A value can be a @code{double}, a string, or an
array (as in multidimensional arrays, or when creating a new array).
-String values maintain both pointer and length since embedded @code{NUL}
+String values maintain both pointer and length since embedded @sc{nul}
characters are allowed.
@quotation NOTE
@@ -30651,7 +30654,7 @@ Scalar values in @command{awk} are either numbers or strings. The
indicates what is in the @code{union}.
Representing numbers is easy---the API uses a C @code{double}. Strings
-require more work. Since @command{gawk} allows embedded @code{NUL} bytes
+require more work. Since @command{gawk} allows embedded @sc{nul} bytes
in string values, a string must be represented as a pair containing a
data-pointer and length. This is the @code{awk_string_t} type.
@@ -31148,8 +31151,9 @@ A pointer to your @code{@var{XXX}_can_take_file()} function.
A pointer to your @code{@var{XXX}_take_control_of()} function.
@item awk_const struct input_parser *awk_const next;
-This pointer is used by @command{gawk}.
-The extension cannot modify it.
+This is for use by @command{gawk};
+therefore it is marked @code{awk_const} so that the extension cannot
+modify it.
@end table
The steps are as follows:
@@ -31196,7 +31200,7 @@ open the file, then @code{fd} will @emph{not} be equal to
@code{INVALID_HANDLE}. Otherwise, it will.
@item struct stat sbuf;
-If file descriptor is valid, then @command{gawk} will have filled
+If the file descriptor is valid, then @command{gawk} will have filled
in this structure via a call to the @code{fstat()} system call.
@end table
@@ -31377,8 +31381,8 @@ as described below, and return true if successful, false otherwise.
@item awk_const struct output_wrapper *awk_const next;
This is for use by @command{gawk};
-therefore they are marked @code{awk_const} so that the extension cannot
-modify them.
+therefore it is marked @code{awk_const} so that the extension cannot
+modify it.
@end table
The @code{awk_output_buf_t} structure looks like this:
@@ -31440,7 +31444,7 @@ The @code{@var{XXX}_can_take_file()} function should make a decision based
upon the @code{name} and @code{mode} fields, and any additional state
(such as @command{awk} variable values) that is appropriate.
-When @command{gawk} calls @code{@var{XXX}_take_control_of()}, it should fill
+When @command{gawk} calls @code{@var{XXX}_take_control_of()}, that function should fill
in the other fields, as appropriate, except for @code{fp}, which it should just
use normally.
@@ -31494,8 +31498,8 @@ This function should fill in the @code{awk_input_buf_t} and
@item awk_const struct two_way_processor *awk_const next;
This is for use by @command{gawk};
-therefore they are marked @code{awk_const} so that the extension cannot
-modify them.
+therefore it is marked @code{awk_const} so that the extension cannot
+modify it.
@end table
As with the input parser and output processor, you provide
@@ -31661,7 +31665,7 @@ Return false if the value cannot be retrieved.
@item awk_bool_t sym_update_scalar(awk_scalar_t cookie, awk_value_t *value);
Update the value associated with a scalar cookie. Return false if
-the new value is not one of @code{AWK_STRING} or @code{AWK_NUMBER}.
+the new value is not of type @code{AWK_STRING} or @code{AWK_NUMBER}.
Here too, the built-in variables may not be updated.
@end table
@@ -31779,7 +31783,7 @@ is what the routines in this section let you do. The functions are as follows:
@item awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);
Create a cached string or numeric value from @code{value} for efficient later
assignment.
-Only @code{AWK_NUMBER} and @code{AWK_STRING} values are allowed. Any other type
+Only values of type @code{AWK_NUMBER} and @code{AWK_STRING} are allowed. Any other type
is rejected. While @code{AWK_UNDEFINED} could be allowed, doing so would
result in inferior performance.
@@ -31840,7 +31844,7 @@ What happens if @command{awk} code assigns a new value to @code{VAR1},
are all the others be changed too?''
That's a great question. The answer is that no, it's not a problem.
-Internally, @command{gawk} uses reference-counted strings. This means
+Internally, @command{gawk} uses @dfn{reference-counted strings}. This means
that many variables can share the same string value, and @command{gawk}
keeps track of the usage. When a variable's value changes, @command{gawk}
simply decrements the reference count on the old value and updates
@@ -31972,7 +31976,8 @@ the string value of @code{index} must come from the API-provided functions @code
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const@ awk_value_t *const value);
In the array represented by @code{a_cookie}, create or modify
the element whose index is given by @code{index}.
-The @code{ARGV} and @code{ENVIRON} arrays may not be changed.
+The @code{ARGV} and @code{ENVIRON} arrays may not be changed,
+although the @code{PROCINFO} array can be.
@item awk_bool_t set_array_element_by_elem(awk_array_t a_cookie,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_element_t element);
@@ -32243,7 +32248,7 @@ you must add the new array to its parent before adding any elements to it.
Thus, the correct way to build an array is to work ``top down.'' Create
the array, and immediately install it in @command{gawk}'s symbol table
using @code{sym_update()}, or install it as an element in a previously
-existing array using @code{set_element()}. We show example code shortly.
+existing array using @code{set_array_element()}. We show example code shortly.
@item
Due to gawk internals, after using @code{sym_update()} to install an array
@@ -32269,7 +32274,7 @@ of the array cookie after the call to @code{set_element()}.
@end enumerate
The following C code is a simple test extension to create an array
-with two regular elements and with a subarray. The leading @samp{#include}
+with two regular elements and with a subarray. The leading @code{#include}
directives and boilerplate variable declarations are omitted for brevity.
The first step is to create a new array and then install it
in the symbol table:
@@ -32495,12 +32500,15 @@ whether the corresponding command-line options were enabled when
@command{gawk} was invoked. The variables are:
@table @code
+@item do_debug
+This variable is true if @command{gawk} was invoked with @option{--debug} option.
+
@item do_lint
This variable is true if @command{gawk} was invoked with @option{--lint} option
(@pxref{Options}).
-@item do_traditional
-This variable is true if @command{gawk} was invoked with @option{--traditional} option.
+@item do_mpfr
+This variable is true if @command{gawk} was invoked with @option{--bignum} option.
@item do_profile
This variable is true if @command{gawk} was invoked with @option{--profile} option.
@@ -32508,11 +32516,8 @@ This variable is true if @command{gawk} was invoked with @option{--profile} opti
@item do_sandbox
This variable is true if @command{gawk} was invoked with @option{--sandbox} option.
-@item do_debug
-This variable is true if @command{gawk} was invoked with @option{--debug} option.
-
-@item do_mpfr
-This variable is true if @command{gawk} was invoked with @option{--bignum} option.
+@item do_traditional
+This variable is true if @command{gawk} was invoked with @option{--traditional} option.
@end table
The value of @code{do_lint} can change if @command{awk} code
@@ -33196,7 +33201,9 @@ structures for loading each function into @command{gawk}:
static awk_ext_func_t func_table[] = @{
@{ "chdir", do_chdir, 1 @},
@{ "stat", do_stat, 2 @},
+#ifndef __MINGW32__
@{ "fts", do_fts, 3 @},
+#endif
@};
@end example
@@ -33354,69 +33361,27 @@ In all cases, it clears the @code{statdata} array.
When the call is successful, @code{stat()} fills the @code{statdata}
array with information retrieved from the filesystem, as follows:
-@c nested table
-@multitable @columnfractions .25 .60
-@item @code{statdata["name"]} @tab
-The name of the file.
-
-@item @code{statdata["dev"]} @tab
-Corresponds to the @code{st_dev} field in the @code{struct stat}.
-
-@item @code{statdata["ino"]} @tab
-Corresponds to the @code{st_ino} field in the @code{struct stat}.
-
-@item @code{statdata["mode"]} @tab
-Corresponds to the @code{st_mode} field in the @code{struct stat}.
-
-@item @code{statdata["nlink"]} @tab
-Corresponds to the @code{st_nlink} field in the @code{struct stat}.
-
-@item @code{statdata["uid"]} @tab
-Corresponds to the @code{st_uid} field in the @code{struct stat}.
-
-@item @code{statdata["gid"]} @tab
-Corresponds to the @code{st_gid} field in the @code{struct stat}.
-
-@item @code{statdata["size"]} @tab
-Corresponds to the @code{st_size} field in the @code{struct stat}.
-
-@item @code{statdata["atime"]} @tab
-Corresponds to the @code{st_atime} field in the @code{struct stat}.
-
-@item @code{statdata["mtime"]} @tab
-Corresponds to the @code{st_mtime} field in the @code{struct stat}.
-
-@item @code{statdata["ctime"]} @tab
-Corresponds to the @code{st_ctime} field in the @code{struct stat}.
-
-@item @code{statdata["rdev"]} @tab
-Corresponds to the @code{st_rdev} field in the @code{struct stat}.
-This element is only present for device files.
-
-@item @code{statdata["major"]} @tab
-Corresponds to the @code{st_major} field in the @code{struct stat}.
-This element is only present for device files.
-
-@item @code{statdata["minor"]} @tab
-Corresponds to the @code{st_minor} field in the @code{struct stat}.
-This element is only present for device files.
-
-@item @code{statdata["blksize"]} @tab
-Corresponds to the @code{st_blksize} field in the @code{struct stat},
-if this field is present on your system.
-(It is present on all modern systems that we know of.)
-
-@item @code{statdata["pmode"]} @tab
-A human-readable version of the mode value, such as printed by
-@command{ls}. For example, @code{"-rwxr-xr-x"}.
-
-@item @code{statdata["linkval"]} @tab
-If the named file is a symbolic link, this element will exist
-and its value is the value of the symbolic link (where the
-symbolic link points to).
-
-@item @code{statdata["type"]} @tab
-The type of the file as a string. One of
+@multitable @columnfractions .15 .50 .20
+@headitem Subscript @tab Field in @code{struct stat} @tab File type
+@item @code{"name"} @tab The file name @tab All
+@item @code{"dev"} @tab @code{st_dev} @tab All
+@item @code{"ino"} @tab @code{st_ino} @tab All
+@item @code{"mode"} @tab @code{st_mode} @tab All
+@item @code{"nlink"} @tab @code{st_nlink} @tab All
+@item @code{"uid"} @tab @code{st_uid} @tab All
+@item @code{"gid"} @tab @code{st_gid} @tab All
+@item @code{"size"} @tab @code{st_size} @tab All
+@item @code{"atime"} @tab @code{st_atime} @tab All
+@item @code{"mtime"} @tab @code{st_mtime} @tab All
+@item @code{"ctime"} @tab @code{st_ctime} @tab All
+@item @code{"rdev"} @tab @code{st_rdev} @tab Device files
+@item @code{"major"} @tab @code{st_major} @tab Device files
+@item @code{"minor"} @tab @code{st_minor} @tab Device files
+@item @code{"blksize"} @tab @code{st_blksize} @tab All
+@item @code{"pmode"} @tab A human-readable version of the mode value, such as printed by
+@command{ls}. For example, @code{"-rwxr-xr-x"} @tab All
+@item @code{"linkval"} @tab The value of the symbolic link @tab Symbolic links
+@item @code{"type"} @tab The type of the file as a string. One of
@code{"file"},
@code{"blockdev"},
@code{"chardev"},
@@ -33427,7 +33392,7 @@ The type of the file as a string. One of
@code{"door"},
or
@code{"unknown"}.
-Not all systems support all file types.
+Not all systems support all file types. @tab All
@end multitable
@cindex @code{fts()} extension function
@@ -33586,23 +33551,13 @@ flags in the @code{FNM} array.
The flags are follows:
@multitable @columnfractions .25 .75
-@item @code{FNM["CASEFOLD"]} @tab
-Corresponds to the @code{FNM_CASEFOLD} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["FILE_NAME"]} @tab
-Corresponds to the @code{FNM_FILE_NAME} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["LEADING_DIR"]} @tab
-Corresponds to the @code{FNM_LEADING_DIR} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["NOESCAPE"]} @tab
-Corresponds to the @code{FNM_NOESCAPE} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["PATHNAME"]} @tab
-Corresponds to the @code{FNM_PATHNAME} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["PERIOD"]} @tab
-Corresponds to the @code{FNM_PERIOD} flag as defined in @code{fnmatch()}.
+@headitem Array element @tab Corresponding lag defined by @code{fnmatch()}
+@item @code{FNM["CASEFOLD"]} @tab @code{FNM_CASEFOLD}
+@item @code{FNM["FILE_NAME"]} @tab @code{FNM_FILE_NAME}
+@item @code{FNM["LEADING_DIR"]} @tab @code{FNM_LEADING_DIR}
+@item @code{FNM["NOESCAPE"]} @tab @code{FNM_NOESCAPE}
+@item @code{FNM["PATHNAME"]} @tab @code{FNM_PATHNAME}
+@item @code{FNM["PERIOD"]} @tab @code{FNM_PERIOD}
@end multitable
Here is an example:
@@ -33763,8 +33718,11 @@ The record consists of three fields. The first two are the inode number and the
filename, separated by a forward slash character.
On systems where the directory entry contains the file type, the record
has a third field (also separated by a slash) which is a single letter
-indicating the type of the file:
+indicating the type of the file. The letters are file types are shown
+in @ref{table-readdir-file-types}.
+@float Table,table-readdir-file-types
+@caption{File types returned by @code{readdir()}}
@multitable @columnfractions .1 .9
@headitem Letter @tab File Type
@item @code{b} @tab Block device
@@ -33776,6 +33734,7 @@ indicating the type of the file:
@item @code{s} @tab Socket
@item @code{u} @tab Anything else (unknown)
@end multitable
+@end float
On systems without the file type information, the third field is always
@samp{u}.
@@ -33810,12 +33769,12 @@ Here is an example:
BEGIN @{
REVOUT = 1
- print "hello, world" > "/dev/stdout"
+ print "don't panic" > "/dev/stdout"
@}
@end example
The output from this program is:
-@samp{dlrow ,olleh}.
+@samp{cinap t'nod}.
@node Extension Sample Rev2way
@subsection Two-Way I/O Example
@@ -33832,13 +33791,22 @@ The following example shows how to use it:
BEGIN @{
cmd = "/magic/mirror"
- print "hello, world" |& cmd
+ print "don't panic" |& cmd
cmd |& getline result
print result
close(cmd)
@}
@end example
+The output from this program
+@ifnotinfo
+also is:
+@end ifnotinfo
+@ifinfo
+is:
+@end ifinfo
+@samp{cinap t'nod}.
+
@node Extension Sample Read write array
@subsection Dumping and Restoring An Array
@@ -33849,8 +33817,8 @@ named @code{writea()} and @code{reada()}, as follows:
@cindex @code{writea()} extension function
@item ret = writea(file, array)
This function takes a string argument, which is the name of the file
-to which dump the array, and the array itself as the second argument.
-@code{writea()} understands multidimensional arrays. It returns one on
+to which to dump the array, and the array itself as the second argument.
+@code{writea()} understands arrays of arrays. It returns one on
success, or zero upon failure.
@cindex @code{reada()} extension function
@@ -33935,9 +33903,8 @@ for more information.
@node Extension Sample Time
@subsection Extension Time Functions
-These functions can be used either by invoking @command{gawk}
-with a command-line argument of @samp{-l time} or by
-inserting @samp{@@load "time"} in your script.
+The @code{time} extension adds two functions, named @code{gettimeofday()}
+and @code{sleep()}, as follows:
@table @code
@item @@load "time"
@@ -33950,7 +33917,7 @@ floating point value. If the time is unavailable on this platform, return
@minus{}1 and set @code{ERRNO}. The returned time should have sub-second
precision, but the actual precision may vary based on the platform.
If the standard C @code{gettimeofday()} system call is available on this
-platform, then it simply returns the value. Otherwise, if on Windows,
+platform, then it simply returns the value. Otherwise, if on MS-Windows,
it tries to use @code{GetSystemTimeAsFileTime()}.
@cindex @code{sleep()} extension function
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index c905e1d5..17d52797 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -13334,7 +13334,7 @@ The working precision of arbitrary precision floating-point numbers,
@item ROUNDMODE #
The rounding mode to use for arbitrary precision arithmetic on
numbers, by default @code{"N"} (@samp{roundTiesToEven} in
-the IEEE-754 standard; @pxref{Setting Rounding Mode}).
+the IEEE 754 standard; @pxref{Setting Rounding Mode}).
@cindex @code{RS} variable
@cindex separators, for records
@@ -28342,7 +28342,7 @@ $ @kbd{echo 0xDeadBeef | gawk '@{ print $1 + 0 @}'}
@print{} 0
@end example
-@command{gawk} does ignore case in the four special values.
+@command{gawk} ignores case in the four special values.
Thus @samp{+nan} and @samp{+NaN} are the same.
@end itemize
@@ -28351,13 +28351,15 @@ Thus @samp{+nan} and @samp{+NaN} are the same.
As has been mentioned already, @command{awk} uses hardware double
precision with 64-bit IEEE binary floating-point representation
-for numbers on most systems. A large integer like 9,007,199,254,740,997
+for numbers on most systems.
+A large integer like 9,007,199,254,740,997
has a binary representation that, although finite, is more than 53 bits long;
it must also be rounded to 53 bits.
+(The details are discussed in @ref{Floating-point Representation}.)
The biggest integer that can be stored in a C @code{double} is usually the same
as the largest possible value of a @code{double}. If your system @code{double}
is an IEEE 64-bit @code{double}, this largest possible value is an integer and
-can be represented precisely. What more should one know about integers?
+can be represented precisely. What more should you know about integers?
If you want to know what is the largest integer, such that it and
all smaller integers can be stored in 64-bit doubles without losing precision,
@@ -28473,7 +28475,7 @@ floating-point, you can set the precision before starting a computation,
but then you cannot be sure of the number of significant decimal places
in the final result.
-Sometimes, before you start to write any code, you should think more
+So, before you start to write any code, you should think more
about what you really want and what's really happening. Consider the
two numbers in the following example:
@@ -28504,7 +28506,7 @@ Usually this is a format string like @code{"%.15g"}, which when
used in the previous example, produces an output identical to the input.
Because the underlying representation can be a little bit off from the exact value,
-comparing floating-point values to see if they are equal is generally not a good idea.
+comparing floating-point values to see if they are exactly equal is generally a bad idea.
Here is an example where it does not work like you expect:
@example
@@ -28571,7 +28573,7 @@ in the earlier example can be enhanced by using the following
simple algebraic transformation:
@example
-(sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + 1)
+(sqrt(x * x + 1) - 1) / x @equiv{} x / (sqrt(x * x + 1) + 1)
@end example
@noindent
@@ -28611,11 +28613,11 @@ implies better precision than is actually the case.
@node Floating-point Representation
@subsection Binary Floating-point Representation
-@cindex IEEE-754 format
+@cindex IEEE 754 format
Although floating-point representations vary from machine to machine,
the most commonly encountered representation is that defined by the
-IEEE 754 Standard. An IEEE-754 format value has three components:
+IEEE 754 Standard. An IEEE 754 format value has three components:
@itemize @bullet
@item
@@ -28643,12 +28645,12 @@ number is then
<emphasis>s &sdot; 2<superscript>e</superscript></emphasis>. @c
@end docbook
The first bit of a non-zero binary significand
-is always one, so the significand in an IEEE-754 format only includes the
+is always one, so the significand in an IEEE 754 format only includes the
fractional part, leaving the leading one implicit.
The significand is stored in @dfn{normalized} format,
which means that the first bit is always a one.
-Three of the standard IEEE-754 types are 32-bit single precision,
+Three of the standard IEEE 754 types are 32-bit single precision,
64-bit double precision and 128-bit quadruple precision.
The standard also specifies extended precision formats
to allow greater precisions and larger exponent ranges.
@@ -28679,7 +28681,7 @@ The rounding mode of the context.
@end table
@ref{table-ieee-formats} lists the precision and exponent
-field values for the basic IEEE-754 binary formats:
+field values for the basic IEEE 754 binary formats:
@float Table,table-ieee-formats
@caption{Basic IEEE Format Context Values}
@@ -28698,10 +28700,10 @@ one extra bit of significand.
A floating-point context can also determine which signals are treated
as exceptions, and can set rules for arithmetic with special values.
-Please consult the IEEE-754 standard or other resources for details.
+Please consult the IEEE 754 standard or other resources for details.
@command{gawk} ordinarily uses the hardware double precision
-representation for numbers. On most systems, this is IEEE-754
+representation for numbers. On most systems, this is IEEE 754
floating-point format, corresponding to 64-bit binary with 53 bits
of precision.
@@ -28711,7 +28713,7 @@ the result from an arithmetic operation to be a number smaller than
the smallest nonzero normalized number. Such numbers do
not have as many significant digits as normal numbers, and are called
@dfn{denormals} or @dfn{subnormals}. The alternative, simply returning a zero,
-is called @dfn{flush to zero}. The basic IEEE-754 binary formats
+is called @dfn{flush to zero}. The basic IEEE 754 binary formats
support subnormal numbers.
@end quotation
@@ -28723,7 +28725,7 @@ The @dfn{rounding mode} specifies the behavior for the results of numerical
operations when discarding extra precision. Each rounding mode indicates
how the least significant returned digit of a rounded result is to
be calculated.
-@ref{table-rounding-modes} lists the IEEE-754 defined
+@ref{table-rounding-modes} lists the IEEE 754 defined
rounding modes:
@float Table,table-rounding-modes
@@ -28766,7 +28768,7 @@ BEGIN @{
@noindent
produces the following output when run on the author's system:@footnote{It
is possible for the output to be completely different if the
-C library in your system does not use the IEEE-754 even-rounding
+C library in your system does not use the IEEE 754 even-rounding
rule to round halfway cases for @code{printf}.}
@example
@@ -28785,7 +28787,7 @@ The theory behind the rounding mode @code{roundTiesToEven} is that
it more or less evenly distributes upward and downward rounds
of exact halves, which might cause any round-off error
to cancel itself out. This is the default rounding mode used
-in IEEE-754 computing functions and operators.
+in IEEE 754 computing functions and operators.
The other rounding modes are rarely used.
Round toward positive infinity (@code{roundTowardPositive})
@@ -28877,10 +28879,10 @@ to follow.
The default working precision for arbitrary precision floating-point values is
53 bits, and the default value for @code{ROUNDMODE} is @code{"N"},
-which selects the IEEE-754 @code{roundTiesToEven} rounding mode
+which selects the IEEE 754 @code{roundTiesToEven} rounding mode
(@pxref{Rounding Mode}).@footnote{The
default precision is 53 bits, since according to the MPFR documentation,
-the library should be able to exactly reproduce all computations with
+the library should be able to exactly reproduce all computations done with
double-precision machine floating-point numbers (@code{double} type
in C), except the default exponent range is much wider and subnormal
numbers are not implemented.}
@@ -28902,7 +28904,7 @@ MPFR does not implement subnormal numbers by default,
and this behavior cannot be changed in @command{gawk}.
@quotation NOTE
-When emulating an IEEE-754 format (@pxref{Setting Precision}),
+When emulating an IEEE 754 format (@pxref{Setting Precision}),
@command{gawk} internally adjusts the exponent range
to the value defined for the format and also performs computations needed for
gradual underflow (subnormal numbers).
@@ -28932,16 +28934,16 @@ your program.
@command{gawk} uses a global working precision; it does not keep track of
the precision or accuracy of individual numbers. Performing an arithmetic
operation or calling a built-in function rounds the result to the current
-working precision. The default working precision is 53 bits, which can be
-modified using the built-in variable @code{PREC}. You can also set the
-value to one of the pre-defined case-insensitive strings
+working precision. The default working precision is 53 bits, which you can
+modify using the built-in variable @code{PREC}. You can also set the
+value to one of the predefined case-insensitive strings
shown in @ref{table-predefined-precision-strings},
-to emulate an IEEE-754 binary format.
+to emulate an IEEE 754 binary format.
@float Table,table-predefined-precision-strings
@caption{Predefined precision strings for @code{PREC}}
@multitable {@code{"double"}} {12345678901234567890123456789012345}
-@headitem @code{PREC} @tab IEEE-754 Binary Format
+@headitem @code{PREC} @tab IEEE 754 Binary Format
@item @code{"half"} @tab 16-bit half-precision.
@item @code{"single"} @tab Basic 32-bit single precision.
@item @code{"double"} @tab Basic 64-bit double precision.
@@ -29030,8 +29032,8 @@ rounding modes is shown in @ref{table-gawk-rounding-modes}.
@end float
@code{ROUNDMODE} has the default value @code{"N"},
-which selects the IEEE-754 rounding mode @code{roundTiesToEven}.
-In @ref{table-gawk-rounding-modes}, @code{"A"} is listed to select the IEEE-754 mode
+which selects the IEEE 754 rounding mode @code{roundTiesToEven}.
+In @ref{table-gawk-rounding-modes}, @code{"A"} is listed to select the IEEE 754 mode
@code{roundTiesToAway}. This is only available
if your version of the MPFR library supports it; otherwise setting
@code{ROUNDMODE} to this value has no effect. @xref{Rounding Mode},
@@ -29050,8 +29052,8 @@ $ @kbd{gawk -M -v ROUNDMODE="Z" 'BEGIN @{ printf("%.2f\n", 1.378) @}'}
@cindex constants, floating-point
Be wary of floating-point constants! When reading a floating-point constant
-from program source code, @command{gawk} uses the default precision,
-unless overridden
+from program source code, @command{gawk} uses the default precision (that
+of a C @code{double}), unless overridden
by an assignment to the special variable @code{PREC} on the command
line, to store it internally as a MPFR number.
Changing the precision using @code{PREC} in the program text does
@@ -29098,7 +29100,7 @@ Electronic Transactions on Numerical Analysis. Volume 28, pp. 168-173, 2008.}
@command{gawk} does not implicitly modify the precision of any previously
computed results when the working precision is changed with an assignment
to @code{PREC}. The precision of a number is always the one that was
-used at the time of its creation, and there is no way for the user
+used at the time of its creation, and there is no way for you
to explicitly change it afterwards. However, since the result of a
floating-point arithmetic operation is always an arbitrary precision
floating-point value---with a precision set by the value of @code{PREC}---one of the
@@ -29163,7 +29165,7 @@ a straight test for equality may not work.
So, don't assume that floating-point values can be compared for equality.
You should also exercise caution when using other forms of comparisons.
-The standard way to compare between floating-point numbers is to determine
+The standard way to compare two floating-point numbers is to determine
how much error (or @dfn{tolerance}) you will allow in a comparison and
check to see if one value is within this error range of the other.
@@ -29488,9 +29490,9 @@ The @code{do_@var{xxx}()} function, in turn, then uses the function
pointers in the API @code{struct} to do its work, such as updating
variables or arrays, printing messages, setting @code{ERRNO}, and so on.
-Convenience macros in the @file{gawkapi.h} header file make calling
-through the function pointers look like regular function calls so that
-extension code is quite readable and understandable.
+Convenience macros make calling through the function pointers look
+like regular function calls so that extension code is quite readable
+and understandable.
Although all of this sounds somewhat complicated, the result is that
extension code is quite straightforward to write and to read. You can
@@ -29521,6 +29523,9 @@ happen, but we all know how @emph{that} goes.)
@section API Description
@cindex extension API
+C or C++ code for an extension must include the header file
+@file{gawkapi.h}, which declares the functions and defines the data
+types used to communicate with @command{gawk}.
This (rather large) @value{SECTION} describes the API in detail.
@menu
@@ -29622,6 +29627,7 @@ corresponding standard header file @emph{before} including @file{gawkapi.h}:
@multitable {@code{memset()}, @code{memcpy()}} {@code{<sys/types.h>}}
@headitem C Entity @tab Header File
@item @code{EOF} @tab @code{<stdio.h>}
+@item Values for @code{errno} @tab @code{<errno.h>}
@item @code{FILE} @tab @code{<stdio.h>}
@item @code{NULL} @tab @code{<stddef.h>}
@item @code{memcpy()} @tab @code{<string.h>}
@@ -29637,9 +29643,6 @@ is necessary in order to keep @file{gawkapi.h} clean, instead of becoming
a portability hodge-podge as can be seen in some parts of
the @command{gawk} source code.
-To pass reasonable integer values for @code{ERRNO}, you will also need to
-include @code{<errno.h>}.
-
@item
The @file{gawkapi.h} file may be included more than once without ill effect.
Doing so, however, is poor coding practice.
@@ -29663,7 +29666,7 @@ and is managed by @command{gawk} from then on.
The API defines several simple @code{struct}s that map values as seen
from @command{awk}. A value can be a @code{double}, a string, or an
array (as in multidimensional arrays, or when creating a new array).
-String values maintain both pointer and length since embedded @code{NUL}
+String values maintain both pointer and length since embedded @sc{nul}
characters are allowed.
@quotation NOTE
@@ -29795,7 +29798,7 @@ Scalar values in @command{awk} are either numbers or strings. The
indicates what is in the @code{union}.
Representing numbers is easy---the API uses a C @code{double}. Strings
-require more work. Since @command{gawk} allows embedded @code{NUL} bytes
+require more work. Since @command{gawk} allows embedded @sc{nul} bytes
in string values, a string must be represented as a pair containing a
data-pointer and length. This is the @code{awk_string_t} type.
@@ -30292,8 +30295,9 @@ A pointer to your @code{@var{XXX}_can_take_file()} function.
A pointer to your @code{@var{XXX}_take_control_of()} function.
@item awk_const struct input_parser *awk_const next;
-This pointer is used by @command{gawk}.
-The extension cannot modify it.
+This is for use by @command{gawk};
+therefore it is marked @code{awk_const} so that the extension cannot
+modify it.
@end table
The steps are as follows:
@@ -30340,7 +30344,7 @@ open the file, then @code{fd} will @emph{not} be equal to
@code{INVALID_HANDLE}. Otherwise, it will.
@item struct stat sbuf;
-If file descriptor is valid, then @command{gawk} will have filled
+If the file descriptor is valid, then @command{gawk} will have filled
in this structure via a call to the @code{fstat()} system call.
@end table
@@ -30521,8 +30525,8 @@ as described below, and return true if successful, false otherwise.
@item awk_const struct output_wrapper *awk_const next;
This is for use by @command{gawk};
-therefore they are marked @code{awk_const} so that the extension cannot
-modify them.
+therefore it is marked @code{awk_const} so that the extension cannot
+modify it.
@end table
The @code{awk_output_buf_t} structure looks like this:
@@ -30584,7 +30588,7 @@ The @code{@var{XXX}_can_take_file()} function should make a decision based
upon the @code{name} and @code{mode} fields, and any additional state
(such as @command{awk} variable values) that is appropriate.
-When @command{gawk} calls @code{@var{XXX}_take_control_of()}, it should fill
+When @command{gawk} calls @code{@var{XXX}_take_control_of()}, that function should fill
in the other fields, as appropriate, except for @code{fp}, which it should just
use normally.
@@ -30638,8 +30642,8 @@ This function should fill in the @code{awk_input_buf_t} and
@item awk_const struct two_way_processor *awk_const next;
This is for use by @command{gawk};
-therefore they are marked @code{awk_const} so that the extension cannot
-modify them.
+therefore it is marked @code{awk_const} so that the extension cannot
+modify it.
@end table
As with the input parser and output processor, you provide
@@ -30805,7 +30809,7 @@ Return false if the value cannot be retrieved.
@item awk_bool_t sym_update_scalar(awk_scalar_t cookie, awk_value_t *value);
Update the value associated with a scalar cookie. Return false if
-the new value is not one of @code{AWK_STRING} or @code{AWK_NUMBER}.
+the new value is not of type @code{AWK_STRING} or @code{AWK_NUMBER}.
Here too, the built-in variables may not be updated.
@end table
@@ -30923,7 +30927,7 @@ is what the routines in this section let you do. The functions are as follows:
@item awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);
Create a cached string or numeric value from @code{value} for efficient later
assignment.
-Only @code{AWK_NUMBER} and @code{AWK_STRING} values are allowed. Any other type
+Only values of type @code{AWK_NUMBER} and @code{AWK_STRING} are allowed. Any other type
is rejected. While @code{AWK_UNDEFINED} could be allowed, doing so would
result in inferior performance.
@@ -30984,7 +30988,7 @@ What happens if @command{awk} code assigns a new value to @code{VAR1},
are all the others be changed too?''
That's a great question. The answer is that no, it's not a problem.
-Internally, @command{gawk} uses reference-counted strings. This means
+Internally, @command{gawk} uses @dfn{reference-counted strings}. This means
that many variables can share the same string value, and @command{gawk}
keeps track of the usage. When a variable's value changes, @command{gawk}
simply decrements the reference count on the old value and updates
@@ -31116,7 +31120,8 @@ the string value of @code{index} must come from the API-provided functions @code
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const@ awk_value_t *const value);
In the array represented by @code{a_cookie}, create or modify
the element whose index is given by @code{index}.
-The @code{ARGV} and @code{ENVIRON} arrays may not be changed.
+The @code{ARGV} and @code{ENVIRON} arrays may not be changed,
+although the @code{PROCINFO} array can be.
@item awk_bool_t set_array_element_by_elem(awk_array_t a_cookie,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_element_t element);
@@ -31387,7 +31392,7 @@ you must add the new array to its parent before adding any elements to it.
Thus, the correct way to build an array is to work ``top down.'' Create
the array, and immediately install it in @command{gawk}'s symbol table
using @code{sym_update()}, or install it as an element in a previously
-existing array using @code{set_element()}. We show example code shortly.
+existing array using @code{set_array_element()}. We show example code shortly.
@item
Due to gawk internals, after using @code{sym_update()} to install an array
@@ -31413,7 +31418,7 @@ of the array cookie after the call to @code{set_element()}.
@end enumerate
The following C code is a simple test extension to create an array
-with two regular elements and with a subarray. The leading @samp{#include}
+with two regular elements and with a subarray. The leading @code{#include}
directives and boilerplate variable declarations are omitted for brevity.
The first step is to create a new array and then install it
in the symbol table:
@@ -31639,12 +31644,15 @@ whether the corresponding command-line options were enabled when
@command{gawk} was invoked. The variables are:
@table @code
+@item do_debug
+This variable is true if @command{gawk} was invoked with @option{--debug} option.
+
@item do_lint
This variable is true if @command{gawk} was invoked with @option{--lint} option
(@pxref{Options}).
-@item do_traditional
-This variable is true if @command{gawk} was invoked with @option{--traditional} option.
+@item do_mpfr
+This variable is true if @command{gawk} was invoked with @option{--bignum} option.
@item do_profile
This variable is true if @command{gawk} was invoked with @option{--profile} option.
@@ -31652,11 +31660,8 @@ This variable is true if @command{gawk} was invoked with @option{--profile} opti
@item do_sandbox
This variable is true if @command{gawk} was invoked with @option{--sandbox} option.
-@item do_debug
-This variable is true if @command{gawk} was invoked with @option{--debug} option.
-
-@item do_mpfr
-This variable is true if @command{gawk} was invoked with @option{--bignum} option.
+@item do_traditional
+This variable is true if @command{gawk} was invoked with @option{--traditional} option.
@end table
The value of @code{do_lint} can change if @command{awk} code
@@ -32340,7 +32345,9 @@ structures for loading each function into @command{gawk}:
static awk_ext_func_t func_table[] = @{
@{ "chdir", do_chdir, 1 @},
@{ "stat", do_stat, 2 @},
+#ifndef __MINGW32__
@{ "fts", do_fts, 3 @},
+#endif
@};
@end example
@@ -32498,69 +32505,27 @@ In all cases, it clears the @code{statdata} array.
When the call is successful, @code{stat()} fills the @code{statdata}
array with information retrieved from the filesystem, as follows:
-@c nested table
-@multitable @columnfractions .25 .60
-@item @code{statdata["name"]} @tab
-The name of the file.
-
-@item @code{statdata["dev"]} @tab
-Corresponds to the @code{st_dev} field in the @code{struct stat}.
-
-@item @code{statdata["ino"]} @tab
-Corresponds to the @code{st_ino} field in the @code{struct stat}.
-
-@item @code{statdata["mode"]} @tab
-Corresponds to the @code{st_mode} field in the @code{struct stat}.
-
-@item @code{statdata["nlink"]} @tab
-Corresponds to the @code{st_nlink} field in the @code{struct stat}.
-
-@item @code{statdata["uid"]} @tab
-Corresponds to the @code{st_uid} field in the @code{struct stat}.
-
-@item @code{statdata["gid"]} @tab
-Corresponds to the @code{st_gid} field in the @code{struct stat}.
-
-@item @code{statdata["size"]} @tab
-Corresponds to the @code{st_size} field in the @code{struct stat}.
-
-@item @code{statdata["atime"]} @tab
-Corresponds to the @code{st_atime} field in the @code{struct stat}.
-
-@item @code{statdata["mtime"]} @tab
-Corresponds to the @code{st_mtime} field in the @code{struct stat}.
-
-@item @code{statdata["ctime"]} @tab
-Corresponds to the @code{st_ctime} field in the @code{struct stat}.
-
-@item @code{statdata["rdev"]} @tab
-Corresponds to the @code{st_rdev} field in the @code{struct stat}.
-This element is only present for device files.
-
-@item @code{statdata["major"]} @tab
-Corresponds to the @code{st_major} field in the @code{struct stat}.
-This element is only present for device files.
-
-@item @code{statdata["minor"]} @tab
-Corresponds to the @code{st_minor} field in the @code{struct stat}.
-This element is only present for device files.
-
-@item @code{statdata["blksize"]} @tab
-Corresponds to the @code{st_blksize} field in the @code{struct stat},
-if this field is present on your system.
-(It is present on all modern systems that we know of.)
-
-@item @code{statdata["pmode"]} @tab
-A human-readable version of the mode value, such as printed by
-@command{ls}. For example, @code{"-rwxr-xr-x"}.
-
-@item @code{statdata["linkval"]} @tab
-If the named file is a symbolic link, this element will exist
-and its value is the value of the symbolic link (where the
-symbolic link points to).
-
-@item @code{statdata["type"]} @tab
-The type of the file as a string. One of
+@multitable @columnfractions .15 .50 .20
+@headitem Subscript @tab Field in @code{struct stat} @tab File type
+@item @code{"name"} @tab The file name @tab All
+@item @code{"dev"} @tab @code{st_dev} @tab All
+@item @code{"ino"} @tab @code{st_ino} @tab All
+@item @code{"mode"} @tab @code{st_mode} @tab All
+@item @code{"nlink"} @tab @code{st_nlink} @tab All
+@item @code{"uid"} @tab @code{st_uid} @tab All
+@item @code{"gid"} @tab @code{st_gid} @tab All
+@item @code{"size"} @tab @code{st_size} @tab All
+@item @code{"atime"} @tab @code{st_atime} @tab All
+@item @code{"mtime"} @tab @code{st_mtime} @tab All
+@item @code{"ctime"} @tab @code{st_ctime} @tab All
+@item @code{"rdev"} @tab @code{st_rdev} @tab Device files
+@item @code{"major"} @tab @code{st_major} @tab Device files
+@item @code{"minor"} @tab @code{st_minor} @tab Device files
+@item @code{"blksize"} @tab @code{st_blksize} @tab All
+@item @code{"pmode"} @tab A human-readable version of the mode value, such as printed by
+@command{ls}. For example, @code{"-rwxr-xr-x"} @tab All
+@item @code{"linkval"} @tab The value of the symbolic link @tab Symbolic links
+@item @code{"type"} @tab The type of the file as a string. One of
@code{"file"},
@code{"blockdev"},
@code{"chardev"},
@@ -32571,7 +32536,7 @@ The type of the file as a string. One of
@code{"door"},
or
@code{"unknown"}.
-Not all systems support all file types.
+Not all systems support all file types. @tab All
@end multitable
@cindex @code{fts()} extension function
@@ -32730,23 +32695,13 @@ flags in the @code{FNM} array.
The flags are follows:
@multitable @columnfractions .25 .75
-@item @code{FNM["CASEFOLD"]} @tab
-Corresponds to the @code{FNM_CASEFOLD} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["FILE_NAME"]} @tab
-Corresponds to the @code{FNM_FILE_NAME} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["LEADING_DIR"]} @tab
-Corresponds to the @code{FNM_LEADING_DIR} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["NOESCAPE"]} @tab
-Corresponds to the @code{FNM_NOESCAPE} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["PATHNAME"]} @tab
-Corresponds to the @code{FNM_PATHNAME} flag as defined in @code{fnmatch()}.
-
-@item @code{FNM["PERIOD"]} @tab
-Corresponds to the @code{FNM_PERIOD} flag as defined in @code{fnmatch()}.
+@headitem Array element @tab Corresponding lag defined by @code{fnmatch()}
+@item @code{FNM["CASEFOLD"]} @tab @code{FNM_CASEFOLD}
+@item @code{FNM["FILE_NAME"]} @tab @code{FNM_FILE_NAME}
+@item @code{FNM["LEADING_DIR"]} @tab @code{FNM_LEADING_DIR}
+@item @code{FNM["NOESCAPE"]} @tab @code{FNM_NOESCAPE}
+@item @code{FNM["PATHNAME"]} @tab @code{FNM_PATHNAME}
+@item @code{FNM["PERIOD"]} @tab @code{FNM_PERIOD}
@end multitable
Here is an example:
@@ -32907,8 +32862,11 @@ The record consists of three fields. The first two are the inode number and the
filename, separated by a forward slash character.
On systems where the directory entry contains the file type, the record
has a third field (also separated by a slash) which is a single letter
-indicating the type of the file:
+indicating the type of the file. The letters are file types are shown
+in @ref{table-readdir-file-types}.
+@float Table,table-readdir-file-types
+@caption{File types returned by @code{readdir()}}
@multitable @columnfractions .1 .9
@headitem Letter @tab File Type
@item @code{b} @tab Block device
@@ -32920,6 +32878,7 @@ indicating the type of the file:
@item @code{s} @tab Socket
@item @code{u} @tab Anything else (unknown)
@end multitable
+@end float
On systems without the file type information, the third field is always
@samp{u}.
@@ -32954,12 +32913,12 @@ Here is an example:
BEGIN @{
REVOUT = 1
- print "hello, world" > "/dev/stdout"
+ print "don't panic" > "/dev/stdout"
@}
@end example
The output from this program is:
-@samp{dlrow ,olleh}.
+@samp{cinap t'nod}.
@node Extension Sample Rev2way
@subsection Two-Way I/O Example
@@ -32976,13 +32935,22 @@ The following example shows how to use it:
BEGIN @{
cmd = "/magic/mirror"
- print "hello, world" |& cmd
+ print "don't panic" |& cmd
cmd |& getline result
print result
close(cmd)
@}
@end example
+The output from this program
+@ifnotinfo
+also is:
+@end ifnotinfo
+@ifinfo
+is:
+@end ifinfo
+@samp{cinap t'nod}.
+
@node Extension Sample Read write array
@subsection Dumping and Restoring An Array
@@ -32993,8 +32961,8 @@ named @code{writea()} and @code{reada()}, as follows:
@cindex @code{writea()} extension function
@item ret = writea(file, array)
This function takes a string argument, which is the name of the file
-to which dump the array, and the array itself as the second argument.
-@code{writea()} understands multidimensional arrays. It returns one on
+to which to dump the array, and the array itself as the second argument.
+@code{writea()} understands arrays of arrays. It returns one on
success, or zero upon failure.
@cindex @code{reada()} extension function
@@ -33079,9 +33047,8 @@ for more information.
@node Extension Sample Time
@subsection Extension Time Functions
-These functions can be used either by invoking @command{gawk}
-with a command-line argument of @samp{-l time} or by
-inserting @samp{@@load "time"} in your script.
+The @code{time} extension adds two functions, named @code{gettimeofday()}
+and @code{sleep()}, as follows:
@table @code
@item @@load "time"
@@ -33094,7 +33061,7 @@ floating point value. If the time is unavailable on this platform, return
@minus{}1 and set @code{ERRNO}. The returned time should have sub-second
precision, but the actual precision may vary based on the platform.
If the standard C @code{gettimeofday()} system call is available on this
-platform, then it simply returns the value. Otherwise, if on Windows,
+platform, then it simply returns the value. Otherwise, if on MS-Windows,
it tries to use @code{GetSystemTimeAsFileTime()}.
@cindex @code{sleep()} extension function