aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--NEWS3
-rw-r--r--TODO4
-rw-r--r--command.c2
-rw-r--r--command.y2
-rw-r--r--dfa.c105
-rw-r--r--doc/ChangeLog10
-rw-r--r--doc/gawk.info1987
-rw-r--r--doc/gawk.texi913
-rw-r--r--doc/gawktexi.in911
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/filefuncs.c4
-rw-r--r--extension/testext.c6
-rw-r--r--gawkapi.h12
-rw-r--r--test/ChangeLog4
-rw-r--r--test/testext.ok1
16 files changed, 2073 insertions, 1912 deletions
diff --git a/ChangeLog b/ChangeLog
index a128ba22..6d5cb9d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2014-09-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawkapi.h: Minor edits to sync with documentation. Does not
+ influence the behavior of the API.
+
+2014-09-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * command.y (cmdtab): Add "where" as an alias for "backtrace".
+ Finally!
+
+ Unrelated:
+
+ * dfa.c: Sync with GNU grep.
+
2014-09-27 Arnold D. Robbins <arnold@skeeve.com>
* awkgram.y (check_for_bad): Bitwise-and the bad character with 0xFF
@@ -19,7 +33,7 @@
* awkgram.y (yylex): Don't check for junk characters inside
quoted strings. Caused issues on DJGPP and Solaris.
- Unrelated
+ Unrelated:
* io.c (devopen): Straighten things out with respect to
compatibility with BWK awk.
diff --git a/NEWS b/NEWS
index 1c1acf07..715d16a1 100644
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,9 @@ Changes from 4.1.1 to 4.1.2
If you feel that you must have this misfeature, use `configure --help'
to see what option to use when configuring gawk to reenable it.
+7. The "where" command has been added to the debugger as an alias
+ for "backtrace". This will make life easier for long-time GDB users.
+
XX. A number of bugs have been fixed. See the ChangeLog.
Changes from 4.1.0 to 4.1.1
diff --git a/TODO b/TODO
index 3979cd11..235ded0e 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-Wed Sep 10 08:18:38 IDT 2014
+Sun Sep 28 22:19:10 IDT 2014
============================
There were too many files tracking different thoughts and ideas for
@@ -36,6 +36,8 @@ Minor Cleanups and Code Improvements
Minor New Features
------------------
+ Enable command line source text in the debugger.
+
Enhance extension/fork.c waitpid to allow the caller to specify
the options. And add an optional array argument to wait and
waitpid in which to return exit status information.
diff --git a/command.c b/command.c
index ad0dc372..2d4bc814 100644
--- a/command.c
+++ b/command.c
@@ -2648,6 +2648,8 @@ struct cmdtoken cmdtab[] = {
gettext_noop("up [N] - move N frames up the stack.") },
{ "watch", "w", D_watch, D_WATCH, do_watch,
gettext_noop("watch var - set a watchpoint for a variable.") },
+{ "where", "", D_backtrace, D_BACKTRACE, do_backtrace,
+ gettext_noop("where [N] - (same as backtrace) print trace of all or N innermost (outermost if N < 0) frames.") },
{ NULL, NULL, D_illegal, 0, (Func_cmd) 0,
NULL },
};
diff --git a/command.y b/command.y
index c67753b7..08893743 100644
--- a/command.y
+++ b/command.y
@@ -897,6 +897,8 @@ struct cmdtoken cmdtab[] = {
gettext_noop("up [N] - move N frames up the stack.") },
{ "watch", "w", D_watch, D_WATCH, do_watch,
gettext_noop("watch var - set a watchpoint for a variable.") },
+{ "where", "", D_backtrace, D_BACKTRACE, do_backtrace,
+ gettext_noop("where [N] - (same as backtrace) print trace of all or N innermost (outermost if N < 0) frames.") },
{ NULL, NULL, D_illegal, 0, (Func_cmd) 0,
NULL },
};
diff --git a/dfa.c b/dfa.c
index 2d0e7f20..6179a3d3 100644
--- a/dfa.c
+++ b/dfa.c
@@ -367,6 +367,9 @@ struct dfa
token utf8_anychar_classes[5]; /* To lower ANYCHAR in UTF-8 locales. */
mbstate_t mbs; /* Multibyte conversion state. */
+ /* dfaexec implementation. */
+ char *(*dfaexec) (struct dfa *, char const *, char *, int, size_t *, int *);
+
/* The following are valid only if MB_CUR_MAX > 1. */
/* The value of multibyte_prop[i] is defined by following rule.
@@ -3309,6 +3312,24 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
return s1;
}
+/* The initial state may encounter a byte which is not a single byte character
+ nor the first byte of a multibyte character. But it is incorrect for the
+ initial state to accept such a byte. For example, in Shift JIS the regular
+ expression "\\" accepts the codepoint 0x5c, but should not accept the second
+ byte of the codepoint 0x815c. Then the initial state must skip the bytes
+ that are not a single byte character nor the first byte of a multibyte
+ character. */
+static unsigned char const *
+skip_remains_mb (struct dfa *d, unsigned char const *p,
+ unsigned char const *mbp, char const *end)
+{
+ wint_t wc;
+ while (mbp < p)
+ mbp += mbs_to_wchar (&wc, (char const *) mbp,
+ end - (char const *) mbp, d);
+ return mbp;
+}
+
/* Search through a buffer looking for a match to the given struct dfa.
Find the first occurrence of a string matching the regexp in the
buffer, and the shortest possible version thereof. Return a pointer to
@@ -3320,10 +3341,14 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
If COUNT is non-NULL, increment *COUNT once for each newline processed.
Finally, if BACKREF is non-NULL set *BACKREF to indicate whether we
encountered a back-reference (1) or not (0). The caller may use this
- to decide whether to fall back on a backtracking matcher. */
-char *
-dfaexec (struct dfa *d, char const *begin, char *end,
- int allow_nl, size_t *count, int *backref)
+ to decide whether to fall back on a backtracking matcher.
+
+ If MULTIBYTE, the input consists of multibyte characters and/or
+ encoding-error bytes. Otherwise, the input consists of single-byte
+ characters. */
+static inline char *
+dfaexec_main (struct dfa *d, char const *begin, char *end,
+ int allow_nl, size_t *count, int *backref, bool multibyte)
{
state_num s, s1; /* Current state. */
unsigned char const *p, *mbp; /* Current input character. */
@@ -3345,7 +3370,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
saved_end = *(unsigned char *) end;
*end = eol;
- if (d->multibyte)
+ if (multibyte)
{
memset (&d->mbs, 0, sizeof d->mbs);
if (! d->mb_match_lens)
@@ -3357,7 +3382,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
for (;;)
{
- if (d->multibyte)
+ if (multibyte)
{
while ((t = trans[s]) != NULL)
{
@@ -3365,27 +3390,18 @@ dfaexec (struct dfa *d, char const *begin, char *end,
if (s == 0)
{
- /* The initial state may encounter a byte which is not
- a single byte character nor the first byte of a
- multibyte character. But it is incorrect for the
- initial state to accept such a byte. For example,
- in Shift JIS the regular expression "\\" accepts
- the codepoint 0x5c, but should not accept the second
- byte of the codepoint 0x815c. Then the initial
- state must skip the bytes that are not a single
- byte character nor the first byte of a multibyte
- character. */
- wint_t wc;
- while (mbp < p)
- mbp += mbs_to_wchar (&wc, (char const *) mbp,
- end - (char const *) mbp, d);
- p = mbp;
-
- if ((char *) p > end)
+ if (d->states[s].mbps.nelem == 0)
{
- p = NULL;
- goto done;
+ do
+ {
+ while (t[*p] == 0)
+ p++;
+ p = mbp = skip_remains_mb (d, p, mbp, end);
+ }
+ while (t[*p] == 0);
}
+ else
+ p = mbp = skip_remains_mb (d, p, mbp, end);
}
if (d->states[s].mbps.nelem == 0)
@@ -3413,6 +3429,13 @@ dfaexec (struct dfa *d, char const *begin, char *end,
}
else
{
+ if (s == 0 && (t = trans[s]) != NULL)
+ {
+ while (t[*p] == 0)
+ p++;
+ s = t[*p++];
+ }
+
while ((t = trans[s]) != NULL)
{
s1 = t[*p++];
@@ -3443,7 +3466,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
}
s1 = s;
- if (d->multibyte)
+ if (multibyte)
{
/* Can match with a multibyte character (and multicharacter
collating element). Transition table might be updated. */
@@ -3488,6 +3511,33 @@ dfaexec (struct dfa *d, char const *begin, char *end,
return (char *) p;
}
+/* Specialized versions of dfaexec_main for multibyte and single-byte
+ cases. This is for performance. */
+
+static char *
+dfaexec_mb (struct dfa *d, char const *begin, char *end,
+ int allow_nl, size_t *count, int *backref)
+{
+ return dfaexec_main (d, begin, end, allow_nl, count, backref, true);
+}
+
+static char *
+dfaexec_sb (struct dfa *d, char const *begin, char *end,
+ int allow_nl, size_t *count, int *backref)
+{
+ return dfaexec_main (d, begin, end, allow_nl, count, backref, false);
+}
+
+/* Like dfaexec_main (D, BEGIN, END, ALLOW_NL, COUNT, BACKREF, D->multibyte),
+ but faster. */
+
+char *
+dfaexec (struct dfa *d, char const *begin, char *end,
+ int allow_nl, size_t *count, int *backref)
+{
+ return d->dfaexec (d, begin, end, allow_nl, count, backref);
+}
+
struct dfa *
dfasuperset (struct dfa const *d)
{
@@ -3537,6 +3587,7 @@ dfainit (struct dfa *d)
{
memset (d, 0, sizeof *d);
d->multibyte = MB_CUR_MAX > 1;
+ d->dfaexec = d->multibyte ? dfaexec_mb : dfaexec_sb;
d->fast = !d->multibyte;
}
@@ -3577,6 +3628,7 @@ dfaoptimize (struct dfa *d)
free_mbdata (d);
d->multibyte = false;
+ d->dfaexec = dfaexec_sb;
}
static void
@@ -3590,6 +3642,7 @@ dfassbuild (struct dfa *d)
*sup = *d;
sup->multibyte = false;
+ sup->dfaexec = dfaexec_sb;
sup->multibyte_prop = NULL;
sup->mbcsets = NULL;
sup->superset = NULL;
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 7693f5e5..dc2c6484 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,13 @@
+2014-09-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: More fixes after reading through the MS.
+ And still more fixes.
+
+2014-09-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: More fixes after reading through the MS.
+ Document the debugger's "where" command.
+
2014-09-27 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Lots more fixes after reading through the MS.
diff --git a/doc/gawk.info b/doc/gawk.info
index c41ef683..326c80cf 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -332,7 +332,7 @@ entitled "GNU Free Documentation License".
record.
* Nextfile Statement:: Stop processing the current file.
* Exit Statement:: Stop execution of `awk'.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* User-modified:: Built-in variables that you change to
control `awk'.
* Auto-set:: Built-in variables where `awk'
@@ -530,7 +530,6 @@ entitled "GNU Free Documentation License".
* Extension API Description:: A full description of the API.
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
@@ -543,6 +542,7 @@ entitled "GNU Free Documentation License".
* Two-way processors:: Registering a two-way processor.
* Printing Messages:: Functions for printing messages.
* Updating `ERRNO':: Functions for updating `ERRNO'.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -581,9 +581,9 @@ entitled "GNU Free Documentation License".
processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to `gettimeofday()'
and `sleep()'.
+* Extension Sample API Tests:: Tests for the API.
* gawkextlib:: The `gawkextlib' project.
* Extension summary:: Extension summary.
* Extension Exercises:: Exercises.
@@ -998,7 +998,7 @@ building blocks for getting most things done in a program.
*note Patterns and Actions::, describes how to write patterns for
matching records, actions for doing something when a record is matched,
-and the built-in variables `awk' and `gawk' use.
+and the predefined variables `awk' and `gawk' use.
*note Arrays::, covers `awk''s one-and-only data structure:
associative arrays. Deleting array elements and whole arrays is also
@@ -4065,8 +4065,8 @@ standard input (by default, this is the keyboard, but often it is a
pipe from another command) or from files whose names you specify on the
`awk' command line. If you specify input files, `awk' reads them in
order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
-`FILENAME' (*note Built-in Variables::).
+The name of the current input file can be found in the predefined
+variable `FILENAME' (*note Built-in Variables::).
The input is read in units called "records", and is processed by the
rules of your program one record at a time. By default, each record is
@@ -4105,9 +4105,9 @@ File: gawk.info, Node: Records, Next: Fields, Up: Reading Files
`awk' divides the input for your program into records and fields. It
keeps track of the number of records that have been read so far from
-the current input file. This value is stored in a built-in variable
+the current input file. This value is stored in a predefined variable
called `FNR' which is reset to zero every time a new file is started.
-Another built-in variable, `NR', records the total number of input
+Another predefined variable, `NR', records the total number of input
records read so far from all data files. It starts at zero, but is
never automatically reset to zero.
@@ -4126,7 +4126,7 @@ Records are separated by a character called the "record separator". By
default, the record separator is the newline character. This is why
records are, by default, single lines. A different character can be
used for the record separator by assigning the character to the
-built-in variable `RS'.
+predefined variable `RS'.
Like any other variable, the value of `RS' can be changed in the
`awk' program with the assignment operator, `=' (*note Assignment
@@ -4378,7 +4378,7 @@ Here the first field, or `$1', is `This', the second field, or `$2', is
Because there is no space between the `e' and the `.', the period is
considered part of the seventh field.
- `NF' is a built-in variable whose value is the number of fields in
+ `NF' is a predefined variable whose value is the number of fields in
the current record. `awk' automatically updates the value of `NF' each
time it reads a record. No matter how many fields there are, the last
field in a record can be represented by `$NF'. So, `$NF' is the same
@@ -4644,7 +4644,7 @@ the following line:
is split into three fields: `m', `*g', and `*gai*pan'. Note the
leading spaces in the values of the second and third fields.
- The field separator is represented by the built-in variable `FS'.
+ The field separator is represented by the predefined variable `FS'.
Shell programmers take note: `awk' does _not_ use the name `IFS' that
is used by the POSIX-compliant shells (such as the Unix Bourne shell,
`sh', or Bash).
@@ -4822,7 +4822,7 @@ uppercase `F' instead of a lowercase `f'. The latter option (`-f')
specifies a file containing an `awk' program.
The value used for the argument to `-F' is processed in exactly the
-same way as assignments to the built-in variable `FS'. Any special
+same way as assignments to the predefined variable `FS'. Any special
characters in the field separator must be escaped appropriately. For
example, to use a `\' as the field separator on the command line, you
would have to type:
@@ -5536,7 +5536,7 @@ Use `getline VAR < FILE' to read input from the file FILE, and put it
in the variable VAR. As above, FILE is a string-valued expression that
specifies the file from which to read.
- In this version of `getline', none of the built-in variables are
+ In this version of `getline', none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is VAR.(1) For example, the following program copies all the
input files to the output, except for records that say
@@ -5657,7 +5657,7 @@ following program reads the current date and time into the variable
print "Report printed on " current_time
}
- In this version of `getline', none of the built-in variables are
+ In this version of `getline', none of the predefined variables are
changed and the record is not split into fields. However, `RT' is set.
According to POSIX, `EXPRESSION | getline VAR' is ambiguous if
@@ -5707,7 +5707,7 @@ When you use `COMMAND |& getline VAR', the output from the coprocess
COMMAND is sent through a two-way pipe to `getline' and into the
variable VAR.
- In this version of `getline', none of the built-in variables are
+ In this version of `getline', none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is VAR. However, `RT' is set.
@@ -5782,9 +5782,9 @@ File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline
------------------------------------
*note table-getline-variants:: summarizes the eight variants of
-`getline', listing which built-in variables are set by each one, and
+`getline', listing which predefined variables are set by each one, and
whether the variant is standard or a `gawk' extension. Note: for each
-variant, `gawk' sets the `RT' built-in variable.
+variant, `gawk' sets the `RT' predefined variable.
Variant Effect `awk' / `gawk'
-------------------------------------------------------------------------
@@ -6172,7 +6172,7 @@ As mentioned previously, a `print' statement contains a list of items
separated by commas. In the output, the items are normally separated
by single spaces. However, this doesn't need to be the case; a single
space is simply the default. Any string of characters may be used as
-the "output field separator" by setting the built-in variable `OFS'.
+the "output field separator" by setting the predefined variable `OFS'.
The initial value of this variable is the string `" "'--that is, a
single space.
@@ -6234,11 +6234,11 @@ to format numbers (or strings), and that there are a number of
different ways in which numbers can be formatted. The different format
specifications are discussed more fully in *note Control Letters::.
- The built-in variable `OFMT' contains the format specification that
-`print' uses with `sprintf()' when it wants to convert a number to a
-string for printing. The default value of `OFMT' is `"%.6g"'. The way
-`print' prints numbers can be changed by supplying a different format
-specification for the value of `OFMT', as shown in the following
+ The predefined variable `OFMT' contains the format specification
+that `print' uses with `sprintf()' when it wants to convert a number to
+a string for printing. The default value of `OFMT' is `"%.6g"'. The
+way `print' prints numbers can be changed by supplying a different
+format specification for the value of `OFMT', as shown in the following
example:
$ awk 'BEGIN {
@@ -7095,8 +7095,8 @@ value from `close()': (d.c.)
`gawk' treats `close()' as a function. The return value is -1 if
the argument names something that was never opened with a redirection,
or if there is a system problem closing the file or process. In these
-cases, `gawk' sets the built-in variable `ERRNO' to a string describing
-the problem.
+cases, `gawk' sets the predefined variable `ERRNO' to a string
+describing the problem.
In `gawk', when closing a pipe or coprocess (input or output), the
return value is the exit status of the command.(2) Otherwise, it is the
@@ -7477,10 +7477,10 @@ array parameters. *Note String Functions::.
A few variables have special built-in meanings, such as `FS' (the
field separator), and `NF' (the number of fields in the current input
-record). *Note Built-in Variables::, for a list of the built-in
-variables. These built-in variables can be used and assigned just like
-all other variables, but their values are also used or changed
-automatically by `awk'. All built-in variables' names are entirely
+record). *Note Built-in Variables::, for a list of the predefined
+variables. These predefined variables can be used and assigned just
+like all other variables, but their values are also used or changed
+automatically by `awk'. All predefined variables' names are entirely
uppercase.
Variables in `awk' can be assigned either numeric or string values.
@@ -7584,7 +7584,7 @@ the string as numerals: `"2.5"' converts to 2.5, `"1e3"' converts to
interpreted as valid numbers convert to zero.
The exact manner in which numbers are converted into strings is
-controlled by the `awk' built-in variable `CONVFMT' (*note Built-in
+controlled by the `awk' predefined variable `CONVFMT' (*note Built-in
Variables::). Numbers are converted using the `sprintf()' function
with `CONVFMT' as the format specifier (*note String Functions::).
@@ -8878,7 +8878,7 @@ File: gawk.info, Node: Patterns and Actions, Next: Arrays, Prev: Expressions,
As you have already seen, each `awk' statement consists of a pattern
with an associated action. This major node describes how you build
patterns and actions, what kinds of things you can do within actions,
-and `awk''s built-in variables.
+and `awk''s predefined variables.
The pattern-action rules and the statements available for use within
actions form the core of `awk' programming. In a sense, everything
@@ -8892,7 +8892,7 @@ top of. Now it's time to start building something useful.
* Action Overview:: What goes into an action.
* Statements:: Describes the various control statements in
detail.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* Pattern Action Summary:: Patterns and Actions summary.

@@ -9996,8 +9996,8 @@ statement with a nonzero argument, as shown in the following example:

File: gawk.info, Node: Built-in Variables, Next: Pattern Action Summary, Prev: Statements, Up: Patterns and Actions
-7.5 Built-in Variables
-======================
+7.5 Predefined Variables
+========================
Most `awk' variables are available to use for your own purposes; they
never change unless your program assigns values to them, and they never
@@ -10007,7 +10007,7 @@ of these automatically, so that they enable you to tell `awk' how to do
certain things. Others are set automatically by `awk', so that they
carry information from the internal workings of `awk' to your program.
- This minor node documents all of `gawk''s built-in variables, most
+ This minor node documents all of `gawk''s predefined variables, most
of which are also documented in the major nodes describing their areas
of activity.
@@ -10680,8 +10680,9 @@ File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up:
You may pass an optional numeric value to be used as `awk''s exit
status.
- * Some built-in variables provide control over `awk', mainly for I/O.
- Other variables convey information from `awk' to your program.
+ * Some predefined variables provide control over `awk', mainly for
+ I/O. Other variables convey information from `awk' to your
+ program.
* `ARGC' and `ARGV' make the command-line arguments available to
your program. Manipulating them from a `BEGIN' rule lets you
@@ -11224,7 +11225,7 @@ File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscript
An important aspect to remember about arrays is that _array subscripts
are always strings_. When a numeric value is used as a subscript, it
is converted to a string value before being used for subscripting
-(*note Conversion::). This means that the value of the built-in
+(*note Conversion::). This means that the value of the predefined
variable `CONVFMT' can affect how your program accesses elements of an
array. For example:
@@ -12148,10 +12149,10 @@ Options::):
`match()', the order is the same as for the `~' operator: `STRING
~ REGEXP'.
- The `match()' function sets the built-in variable `RSTART' to the
- index. It also sets the built-in variable `RLENGTH' to the length
- in characters of the matched substring. If no match is found,
- `RSTART' is set to zero, and `RLENGTH' to -1.
+ The `match()' function sets the predefined variable `RSTART' to
+ the index. It also sets the predefined variable `RLENGTH' to the
+ length in characters of the matched substring. If no match is
+ found, `RSTART' is set to zero, and `RLENGTH' to -1.
For example:
@@ -13382,7 +13383,7 @@ call.
A function cannot have two parameters with the same name, nor may it
have a parameter with the same name as the function itself. In
addition, according to the POSIX standard, function parameters cannot
-have the same name as one of the special built-in variables (*note
+have the same name as one of the special predefined variables (*note
Built-in Variables::). Not all versions of `awk' enforce this
restriction.
@@ -14408,7 +14409,7 @@ to start that variable's name with a capital letter--for example,
`getopt()''s `Opterr' and `Optind' variables (*note Getopt Function::).
The leading capital letter indicates that it is global, while the fact
that the variable name is not all capital letters indicates that the
-variable is not one of `awk''s built-in variables, such as `FS'.
+variable is not one of `awk''s predefined variables, such as `FS'.
It is also important that _all_ variables in library functions that
do not need to save state are, in fact, declared local.(2) If this is
@@ -16564,7 +16565,7 @@ Function::).
The program begins with a descriptive comment and then a `BEGIN' rule
that processes the command-line arguments with `getopt()'. The `-i'
(ignore case) option is particularly easy with `gawk'; we just use the
-`IGNORECASE' built-in variable (*note Built-in Variables::):
+`IGNORECASE' predefined variable (*note Built-in Variables::):
# egrep.awk --- simulate egrep in awk
#
@@ -19466,7 +19467,7 @@ File: gawk.info, Node: TCP/IP Networking, Next: Profiling, Prev: Two-way I/O,
A host is a host from coast to coast,
and no-one can talk to host that's close,
unless the host that isn't close
- is busy, hung, or dead.
+ is busy, hung, or dead. -- Mike O'Brien (aka Mr. Protocol)
In addition to being able to open a two-way pipeline to a coprocess on
the same system (*note Two-way I/O::), it is possible to make a two-way
@@ -19595,9 +19596,9 @@ First, the `awk' program:
profiler on this program and data. (This example also illustrates that
`awk' programmers sometimes get up very early in the morning to work.)
- # gawk profile, created Thu Feb 27 05:16:21 2014
+ # gawk profile, created Mon Sep 29 05:16:21 2014
- # BEGIN block(s)
+ # BEGIN rule(s)
BEGIN {
1 print "First BEGIN rule"
@@ -19624,7 +19625,7 @@ profiler on this program and data. (This example also illustrates that
}
}
- # END block(s)
+ # END rule(s)
END {
1 print "First END rule"
@@ -19710,7 +19711,7 @@ come out as:
print $0
}
-which is correct, but possibly surprising.
+which is correct, but possibly unexpected.
Besides creating profiles when a program has completed, `gawk' can
produce a profile while it is running. This is useful if your `awk'
@@ -19727,7 +19728,7 @@ The shell prints a job number and process ID number; in this case,
$ kill -USR1 13992
As usual, the profiled version of the program is written to
-`awkprof.out', or to a different file if one specified with the
+`awkprof.out', or to a different file if one was specified with the
`--profile' option.
Along with the regular profile, as shown earlier, the profile file
@@ -19771,7 +19772,8 @@ File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanc
* The `--non-decimal-data' option causes `gawk' to treat octal- and
hexadecimal-looking input data as octal and hexadecimal. This
option should be used with caution or not at all; use of
- `strtonum()' is preferable.
+ `strtonum()' is preferable. Note that this option may disappear
+ in a future version of `gawk'.
* You can take over complete control of sorting in `for (INDX in
ARRAY)' array traversal by setting `PROCINFO["sorted_in"]' to the
@@ -19790,9 +19792,9 @@ File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanc
coprocess completely, or optionally, close off one side of the
two-way communications.
- * By using special "file names" with the `|&' operator, you can open
- a TCP/IP (or UDP/IP) connection to remote hosts in the Internet.
- `gawk' supports both IPv4 an IPv6.
+ * By using special file names with the `|&' operator, you can open a
+ TCP/IP (or UDP/IP) connection to remote hosts in the Internet.
+ `gawk' supports both IPv4 and IPv6.
* You can generate statement count profiles of your program. This
can help you determine which parts of your program may be taking
@@ -19953,7 +19955,7 @@ are:
Character-type information (alphabetic, digit, upper- or
lowercase, and so on) as well as character encoding. This
information is accessed via the POSIX character classes in regular
- expressions, such as `/[[:alnum:]]/' (*note Regexp Operators::).
+ expressions, such as `/[[:alnum:]]/' (*note Bracket Expressions::).
`LC_MONETARY'
Monetary information, such as the currency symbol, and whether the
@@ -20021,8 +20023,8 @@ internationalization:
Return the plural form used for NUMBER of the translation of
STRING1 and STRING2 in text domain DOMAIN for locale category
CATEGORY. STRING1 is the English singular variant of a message,
- and STRING2 the English plural variant of the same message. The
- default value for DOMAIN is the current value of `TEXTDOMAIN'.
+ and STRING2 is the English plural variant of the same message.
+ The default value for DOMAIN is the current value of `TEXTDOMAIN'.
The default value for CATEGORY is `"LC_MESSAGES"'.
The same remarks about argument order as for the `dcgettext()'
@@ -20075,9 +20077,11 @@ outlined in *note Explaining gettext::, like so:
one. This example would be better done with `dcngettext()':
if (groggy)
- message = dcngettext("%d customer disturbing me\n", "%d customers disturbing me\n", "adminprog")
+ message = dcngettext("%d customer disturbing me\n",
+ "%d customers disturbing me\n", "adminprog")
else
- message = dcngettext("enjoying %d customer\n", "enjoying %d customers\n", "adminprog")
+ message = dcngettext("enjoying %d customer\n",
+ "enjoying %d customers\n", "adminprog")
printf(message, ncustomers)
4. During development, you might want to put the `.gmo' file in a
@@ -20135,7 +20139,7 @@ marked and you've set (and perhaps bound) the text domain, it is time
to produce translations. First, use the `--gen-pot' command-line
option to create the initial `.pot' file:
- $ gawk --gen-pot -f guide.awk > guide.pot
+ gawk --gen-pot -f guide.awk > guide.pot
When run with `--gen-pot', `gawk' does not execute your program.
Instead, it parses it as usual and prints all marked strings to
@@ -20187,11 +20191,11 @@ example, `string' is the first argument and `length(string)' is the
second:
$ gawk 'BEGIN {
- > string = "Dont Panic"
+ > string = "Don\47t Panic"
> printf "%2$d characters live in \"%1$s\"\n",
> string, length(string)
> }'
- -| 10 characters live in "Dont Panic"
+ -| 11 characters live in "Don't Panic"
If present, positional specifiers come first in the format
specification, before the flags, the field width, and/or the precision.
@@ -20352,7 +20356,8 @@ Following are the translations:
The next step is to make the directory to hold the binary message
object file and then to create the `guide.mo' file. We pretend that
-our file is to be used in the `en_US.UTF-8' locale. The directory
+our file is to be used in the `en_US.UTF-8' locale, since we have to
+use a locale name known to the C `gettext' routines. The directory
layout shown here is standard for GNU `gettext' on GNU/Linux systems.
Other versions of `gettext' may use a different layout:
@@ -20361,7 +20366,7 @@ Other versions of `gettext' may use a different layout:
The `msgfmt' utility does the conversion from human-readable `.po'
file to machine-readable `.mo' file. By default, `msgfmt' creates a
file named `messages'. This file must be renamed and placed in the
-proper directory so that `gawk' can find it:
+proper directory (using the `-o' option) so that `gawk' can find it:
$ msgfmt guide-mellow.po -o en_US.UTF-8/LC_MESSAGES/guide.mo
@@ -20394,8 +20399,8 @@ File: gawk.info, Node: Gawk I18N, Next: I18N Summary, Prev: I18N Example, Up
`gawk' itself has been internationalized using the GNU `gettext'
package. (GNU `gettext' is described in complete detail in *note (GNU
`gettext' utilities)Top:: gettext, GNU gettext tools.) As of this
-writing, the latest version of GNU `gettext' is version 0.19.1
-(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz).
+writing, the latest version of GNU `gettext' is version 0.19.2
+(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.2.tar.gz).
If a translation of `gawk''s messages exists, then `gawk' produces
usage messages, warnings, and fatal errors in the local language.
@@ -20480,7 +20485,7 @@ File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debuggi
---------------------------
(If you have used debuggers in other languages, you may want to skip
-ahead to the next section on the specific features of the `awk'
+ahead to the next section on the specific features of the `gawk'
debugger.)
Of course, a debugging program cannot remove bugs for you, since it
@@ -20516,8 +20521,8 @@ functional program that you or someone else wrote).

File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging Concepts, Up: Debugging
-14.1.2 Additional Debugging Concepts
-------------------------------------
+14.1.2 Debugging Concepts
+-------------------------
Before diving in to the details, we need to introduce several important
concepts that apply to just about all debuggers. The following list
@@ -20609,13 +20614,13 @@ File: gawk.info, Node: Debugger Invocation, Next: Finding The Bug, Up: Sample
14.2.1 How to Start the Debugger
--------------------------------
-Starting the debugger is almost exactly like running `gawk', except you
-have to pass an additional option `--debug' or the corresponding short
-option `-D'. The file(s) containing the program and any supporting
-code are given on the command line as arguments to one or more `-f'
-options. (`gawk' is not designed to debug command-line programs, only
-programs contained in files.) In our case, we invoke the debugger like
-this:
+Starting the debugger is almost exactly like running `gawk' normally,
+except you have to pass an additional option `--debug', or the
+corresponding short option `-D'. The file(s) containing the program
+and any supporting code are given on the command line as arguments to
+one or more `-f' options. (`gawk' is not designed to debug command-line
+programs, only programs contained in files.) In our case, we invoke
+the debugger like this:
$ gawk -D -f getopt.awk -f join.awk -f uniq.awk -1 inputfile
@@ -20624,7 +20629,7 @@ users of GDB or similar debuggers should note that this syntax is
slightly different from what they are used to. With the `gawk'
debugger, you give the arguments for running the program in the command
line to the debugger rather than as part of the `run' command at the
-debugger prompt.)
+debugger prompt.) The `-1' is an option to `uniq.awk'.
Instead of immediately running the program on `inputfile', as `gawk'
would ordinarily do, the debugger merely loads all the program source
@@ -20772,9 +20777,9 @@ split into, so we try to look:
This is kind of disappointing, though. All we found out is that
there are five elements in `alast'; `m' and `aline' don't have values
-yet since we are at line 68 but haven't executed it yet. This
-information is useful enough (we now know that none of the words were
-accidentally left out), but what if we want to see inside the array?
+since we are at line 68 but haven't executed it yet. This information
+is useful enough (we now know that none of the words were accidentally
+left out), but what if we want to see inside the array?
The first choice would be to use subscripts:
@@ -20924,13 +20929,13 @@ controlling breakpoints are:
`condition' N `"EXPRESSION"'
Add a condition to existing breakpoint or watchpoint N. The
- condition is an `awk' expression that the debugger evaluates
- whenever the breakpoint or watchpoint is reached. If the condition
- is true, then the debugger stops execution and prompts for a
- command. Otherwise, the debugger continues executing the program.
- If the condition expression is not specified, any existing
- condition is removed; i.e., the breakpoint or watchpoint is made
- unconditional.
+ condition is an `awk' expression _enclosed in double quotes_ that
+ the debugger evaluates whenever the breakpoint or watchpoint is
+ reached. If the condition is true, then the debugger stops
+ execution and prompts for a command. Otherwise, the debugger
+ continues executing the program. If the condition expression is
+ not specified, any existing condition is removed; i.e., the
+ breakpoint or watchpoint is made unconditional.
`delete' [N1 N2 ...] [N-M]
`d' [N1 N2 ...] [N-M]
@@ -21049,9 +21054,9 @@ execution of the program than we saw in our earlier example:
`until' [[FILENAME`:']N | FUNCTION]
`u' [[FILENAME`:']N | FUNCTION]
Without any argument, continue execution until a line past the
- current line in current stack frame is reached. With an argument,
- continue execution until the specified location is reached, or the
- current stack frame returns.
+ current line in the current stack frame is reached. With an
+ argument, continue execution until the specified location is
+ reached, or the current stack frame returns.

File: gawk.info, Node: Viewing And Changing Data, Next: Execution Stack, Prev: Debugger Execution Control, Up: List of Debugger Commands
@@ -21098,9 +21103,9 @@ AWK STATEMENTS
This prints the third field in the input record (if the specified
field does not exist, it prints `Null field'). A variable can be
- an array element, with the subscripts being constant values. To
- print the contents of an array, prefix the name of the array with
- the `@' symbol:
+ an array element, with the subscripts being constant string
+ values. To print the contents of an array, prefix the name of the
+ array with the `@' symbol:
gawk> print @a
@@ -21145,7 +21150,7 @@ AWK STATEMENTS

File: gawk.info, Node: Execution Stack, Next: Debugger Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands
-14.3.4 Dealing with the Stack
+14.3.4 Working with the Stack
-----------------------------
Whenever you run a program which contains any function calls, `gawk'
@@ -21157,11 +21162,13 @@ are:
`backtrace' [COUNT]
`bt' [COUNT]
+`where' [COUNT]
Print a backtrace of all function calls (stack frames), or
innermost COUNT frames if COUNT > 0. Print the outermost COUNT
frames if COUNT < 0. The backtrace displays the name and
arguments to each function, the source file name, and the line
- number.
+ number. The alias `where' for `backtrace' is provided for
+ long-time GDB users who may be used to that command.
`down' [COUNT]
Move COUNT (default 1) frames down the stack toward the innermost
@@ -21198,7 +21205,7 @@ know:
The value for WHAT should be one of the following:
`args'
- Arguments of the selected frame.
+ List arguments of the selected frame.
`break'
List all currently set breakpoints.
@@ -21207,19 +21214,19 @@ know:
List all items in the automatic display list.
`frame'
- Description of the selected stack frame.
+ Give a description of the selected stack frame.
`functions'
List all function definitions including source file names and
line numbers.
`locals'
- Local variables of the selected frame.
+ List local variables of the selected frame.
`source'
- The name of the current source file. Each time the program
- stops, the current source file is the file containing the
- current instruction. When the debugger first starts, the
+ Print the name of the current source file. Each time the
+ program stops, the current source file is the file containing
+ the current instruction. When the debugger first starts, the
current source file is the first file included via the `-f'
option. The `list FILENAME:LINENO' command can be used at any
time to change the current source.
@@ -21367,7 +21374,7 @@ categories, as follows:
or the file named FILENAME. The possible arguments to `list' are
as follows:
- `-'
+ `-' (Minus)
Print lines before the lines last printed.
`+'
@@ -21438,8 +21445,8 @@ Variable name completion

File: gawk.info, Node: Limitations, Next: Debugging Summary, Prev: Readline Support, Up: Debugger
-14.5 Limitations and Future Plans
-=================================
+14.5 Limitations
+================
We hope you find the `gawk' debugger useful and enjoyable to work with,
but as with any program, especially in its early releases, it still has
@@ -21478,10 +21485,6 @@ some limitations. A few which are worth being aware of are:
* The `gawk' debugger only accepts source supplied with the `-f'
option.
- Look forward to a future release when these and other missing
-features may be added, and of course feel free to try to add them
-yourself!
-

File: gawk.info, Node: Debugging Summary, Prev: Limitations, Up: Debugger
@@ -21518,8 +21521,7 @@ File: gawk.info, Node: Arbitrary Precision Arithmetic, Next: Dynamic Extension
************************************************************
This major node introduces some basic concepts relating to how
-computers do arithmetic and briefly lists the features in `gawk' for
-performing arbitrary precision floating point computations. It then
+computers do arithmetic and defines some important terms. It then
proceeds to describe floating-point arithmetic, which is what `awk'
uses for all its computations, including a discussion of arbitrary
precision floating point arithmetic, which is a feature available only
@@ -21614,7 +21616,8 @@ Floating point arithmetic
ranges. Integer values are usually either 32 or 64 bits in size. Single
precision floating point values occupy 32 bits, whereas double precision
floating point values occupy 64 bits. Floating point values are always
-signed. The possible ranges of values are shown in the following table.
+signed. The possible ranges of values are shown in *note
+table-numeric-ranges::.
Numeric representation Miniumum value Maximum value
---------------------------------------------------------------------------
@@ -21629,6 +21632,8 @@ Double precision `2.225074e-308' `1.797693e+308'
floating point
(approximate)
+Table 15.1: Value Ranges for Different Numeric Representations
+
---------- Footnotes ----------
(1) We don't know why they expect this, but they do.
@@ -21661,7 +21666,7 @@ material here.
number and infinity produce infinity.
"NaN"
- "Not A Number."(1). A special value that results from attempting a
+ "Not A Number."(1) A special value that results from attempting a
calculation that has no answer as a real number. In such a case,
programs can either receive a floating-point exception, or get
`NaN' back as the result. The IEEE 754 standard recommends that
@@ -21719,21 +21724,22 @@ ranges. (`awk' uses only the 64-bit double precision format.)
*note table-ieee-formats:: lists the precision and exponent field
values for the basic IEEE 754 binary formats:
-Name Total bits Precision emin emax
+Name Total bits Precision Minimum Maximum
+ exponent exponent
---------------------------------------------------------------------------
Single 32 24 -126 +127
Double 64 53 -1022 +1023
Quadruple 128 113 -16382 +16383
-Table 15.1: Basic IEEE Format Context Values
+Table 15.2: Basic IEEE Format Values
NOTE: The precision numbers include the implied leading one that
gives them one extra bit of significand.
---------- Footnotes ----------
- (1) Thanks to Michael Brennan for this description, which I have
-paraphrased, and for the examples
+ (1) Thanks to Michael Brennan for this description, which we have
+paraphrased, and for the examples.

File: gawk.info, Node: MPFR features, Next: FP Math Caution, Prev: Math Definitions, Up: Arbitrary Precision Arithmetic
@@ -21741,15 +21747,15 @@ File: gawk.info, Node: MPFR features, Next: FP Math Caution, Prev: Math Defin
15.3 Arbitrary Precison Arithmetic Features In `gawk'
=====================================================
-By default, `gawk' uses the double precision floating point values
+By default, `gawk' uses the double precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do, `gawk' uses the GNU MPFR (http://www.mpfr.org) and GNU
-MP (http://gmplib.org) (GMP) libraries for arbitrary precision
+compiled to do so, `gawk' uses the `http://www.mpfr.org GNU MPFR' and
+GNU MP (http://gmplib.org) (GMP) libraries for arbitrary precision
arithmetic on numbers. You can see if MPFR support is available like
so:
$ gawk --version
- -| GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
+ -| GNU Awk 4.1.2, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
-| Copyright (C) 1989, 1991-2014 Free Software Foundation.
...
@@ -21767,10 +21773,11 @@ platform-independent results. With the `-M' command-line option, all
floating-point arithmetic operators and numeric functions can yield
results to any desired precision level supported by MPFR.
- Two built-in variables, `PREC' and `ROUNDMODE', provide control over
-the working precision and the rounding mode. The precision and the
-rounding mode are set globally for every operation to follow. *Note
-Auto-set::, for more information.
+ Two predefined variables, `PREC' and `ROUNDMODE', provide control
+over the working precision and the rounding mode. The precision and
+the rounding mode are set globally for every operation to follow.
+*Note Setting precision::, and *note Setting the rounding mode::, for
+more information.

File: gawk.info, Node: FP Math Caution, Next: Arbitrary Precision Integers, Prev: MPFR features, Up: Arbitrary Precision Arithmetic
@@ -21884,6 +21891,9 @@ you. Code to do this looks something like this:
else
# not ok
+(We assume that you have a simple absolute value function named `abs()'
+defined elsewhere in your program.)
+

File: gawk.info, Node: Errors accumulate, Prev: Comparing FP Values, Up: Inexactness of computations
@@ -21966,7 +21976,7 @@ forget that the finite number of bits used to store the value is often
just an approximation after proper rounding. The test for equality
succeeds if and only if _all_ bits in the two operands are exactly the
same. Since this is not necessarily true after floating-point
-computations with a particular precision and effective rounding rule, a
+computations with a particular precision and effective rounding mode, a
straight test for equality may not work. Instead, compare the two
numbers to see if they are within the desirable delta of each other.
@@ -22029,7 +22039,7 @@ File: gawk.info, Node: Setting precision, Next: Setting the rounding mode, Pr
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 you can modify using the built-in variable `PREC'. You can also
+which you can modify using the predefined 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.
@@ -22042,7 +22052,7 @@ binary format.
`"quad"' Basic 128-bit quadruple precision.
`"oct"' 256-bit octuple precision.
-Table 15.2: Predefined Precision Strings For `PREC'
+Table 15.3: Predefined Precision Strings For `PREC'
The following example illustrates the effects of changing precision
on arithmetic operations:
@@ -22056,7 +22066,7 @@ on arithmetic operations:
floating-point 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
+ store it internally as an MPFR number. Changing the precision
using `PREC' in the program text does _not_ change the precision
of a constant.
@@ -22095,10 +22105,10 @@ Round toward zero `roundTowardZero' `"Z"' or `"z"'
Round to nearest, ties away `roundTiesToAway' `"A"' or `"a"'
from zero
-Table 15.3: `gawk' Rounding Modes
+Table 15.4: `gawk' Rounding Modes
`ROUNDMODE' has the default value `"N"', which selects the IEEE 754
-rounding mode `roundTiesToEven'. In *note Table 15.3:
+rounding mode `roundTiesToEven'. In *note Table 15.4:
table-gawk-rounding-modes, the value `"A"' selects `roundTiesToAway'.
This is only available if your version of the MPFR library supports it;
otherwise setting `ROUNDMODE' to `"A"' has no effect.
@@ -22177,15 +22187,15 @@ using GMP arbitrary precision integers. Any number that looks like an
integer in a source or data file is stored as an arbitrary precision
integer. The size of the integer is limited only by the available
memory. For example, the following computes 5^4^3^2, the result of
-which is beyond the limits of ordinary hardware double-precision
+which is beyond the limits of ordinary hardware double precision
floating point values:
$ gawk -M 'BEGIN {
> x = 5^4^3^2
- > print "# of digits =", length(x)
+ > print "number of digits =", length(x)
> print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20)
> }'
- -| # of digits = 183231
+ -| number of digits = 183231
-| 62060698786608744707 ... 92256259918212890625
If instead you were to compute the same value using arbitrary
@@ -22360,8 +22370,8 @@ File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Prob
============
* Most computer arithmetic is done using either integers or
- floating-point values. The default for `awk' is to use
- double-precision floating-point values.
+ floating-point values. Standard `awk' uses double precision
+ floating-point values.
* In the early 1990's, Barbie mistakenly said "Math class is tough!"
While math isn't tough, floating-point arithmetic isn't the same
@@ -22462,7 +22472,7 @@ write in C or C++, you can write an extension to do it!
Extensions are written in C or C++, using the "Application
Programming Interface" (API) defined for this purpose by the `gawk'
developers. The rest of this major node explains the facilities that
-the API provides and how to use them, and presents a small sample
+the API provides and how to use them, and presents a small example
extension. In addition, it documents the sample extensions included in
the `gawk' distribution, and describes the `gawkextlib' project. *Note
Extension Design::, for a discussion of the extension mechanism goals
@@ -22474,10 +22484,13 @@ File: gawk.info, Node: Plugin License, Next: Extension Mechanism Outline, Pre
16.2 Extension Licensing
========================
-Every dynamic extension should define the global symbol
-`plugin_is_GPL_compatible' to assert that it has been licensed under a
-GPL-compatible license. If this symbol does not exist, `gawk' emits a
-fatal error and exits when it tries to load your extension.
+Every dynamic extension must be distributed under a license that is
+compatible with the GNU GPL (*note Copying::).
+
+ In order for the extension to tell `gawk' that it is properly
+licensed, the extension must define the global symbol
+`plugin_is_GPL_compatible'. If this symbol does not exist, `gawk'
+emits a fatal error and exits when it tries to load your extension.
The declared type of the symbol should be `int'. It does not need
to be in any allocated section, though. The code merely asserts that
@@ -22492,7 +22505,7 @@ File: gawk.info, Node: Extension Mechanism Outline, Next: Extension API Descri
=================================
Communication between `gawk' and an extension is two-way. First, when
-an extension is loaded, it is passed a pointer to a `struct' whose
+an extension is loaded, `gawk' passes it a pointer to a `struct' whose
fields are function pointers. This is shown in *note
figure-load-extension::.
@@ -22525,8 +22538,8 @@ Figure 16.1: Loading The Extension
The extension can call functions inside `gawk' through these
function pointers, at runtime, without needing (link-time) access to
`gawk''s symbols. One of these function pointers is to a function for
-"registering" new built-in functions. This is shown in *note
-figure-load-new-function::.
+"registering" new functions. This is shown in *note
+figure-register-new-function::.
register_ext_func({ "chdir", do_chdir, 1 });
@@ -22540,7 +22553,7 @@ figure-load-new-function::.
+-------+-+---+-+---+-+------------------+--------------+-+---+
gawk Main Program Address Space Extension
-Figure 16.2: Loading The New Function
+Figure 16.2: Registering A New Function
In the other direction, the extension registers its new functions
with `gawk' by passing function pointers to the functions that provide
@@ -22573,8 +22586,8 @@ 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
-see this in the sample extensions `filefuncs.c' (*note Extension
-Example::) and also the `testext.c' code for testing the APIs.
+see this in the sample extension `filefuncs.c' (*note Extension
+Example::) and also in the `testext.c' code for testing the APIs.
Some other bits and pieces:
@@ -22605,13 +22618,13 @@ describes the API in detail.
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
`gawk'.
* Printing Messages:: Functions for printing messages.
* Updating `ERRNO':: Functions for updating `ERRNO'.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -22631,6 +22644,8 @@ through function pointers passed into your extension.
API function pointers are provided for the following kinds of
operations:
+ * Allocating, reallocating, and releasing memory.
+
* Registration functions. You may register:
- extension functions,
@@ -22655,8 +22670,6 @@ operations:
* Symbol table access: retrieving a global variable, creating one,
or changing one.
- * Allocating, reallocating, and releasing memory.
-
* Creating and releasing cached values; this provides an efficient
way to use values for multiple variables and can be a big
performance win.
@@ -22710,9 +22723,8 @@ operations:
* All pointers filled in by `gawk' point to memory managed by `gawk'
and should be treated by the extension as read-only. Memory for
_all_ strings passed into `gawk' from the extension _must_ come
- from calling the API-provided function pointers `api_malloc()',
- `api_calloc()' or `api_realloc()', and is managed by `gawk' from
- then on.
+ from calling one of `gawk_malloc()', `gawk_calloc()' or
+ `gawk_realloc()', and is managed by `gawk' from then on.
* 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
@@ -22728,7 +22740,7 @@ operations:
* When retrieving a value (such as a parameter or that of a global
variable or array element), the extension requests a specific type
- (number, string, scalars, value cookie, array, or "undefined").
+ (number, string, scalar, value cookie, array, or "undefined").
When the request is "undefined," the returned value will have the
real underlying type.
@@ -22745,7 +22757,7 @@ macros that you should use in your code. This minor node presents the
macros as if they were functions.

-File: gawk.info, Node: General Data Types, Next: Requesting Values, Prev: Extension API Functions Introduction, Up: Extension API Description
+File: gawk.info, Node: General Data Types, Next: Memory Allocation Functions, Prev: Extension API Functions Introduction, Up: Extension API Description
16.4.2 General Purpose Data Types
---------------------------------
@@ -22784,9 +22796,8 @@ that use them.
`} awk_string_t;'
This represents a mutable string. `gawk' owns the memory pointed
to if it supplied the value. Otherwise, it takes ownership of the
- memory pointed to. *Such memory must come from calling the
- API-provided function pointers `api_malloc()', `api_calloc()', or
- `api_realloc()'!*
+ memory pointed to. *Such memory must come from calling one of the
+ `gawk_malloc()', `gawk_calloc()', or `gawk_realloc()' functions!*
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -22872,7 +22883,7 @@ can obtain a "scalar cookie"(1) object for that variable, and then use
the cookie for getting the variable's value or for changing the
variable's value. This is the `awk_scalar_t' type and `scalar_cookie'
macro. Given a scalar cookie, `gawk' can directly retrieve or modify
-the value, as required, without having to first find it.
+the value, as required, without having to find it first.
The `awk_value_cookie_t' type and `value_cookie' macro are similar.
If you know that you wish to use the same numeric or string _value_ for
@@ -22891,62 +22902,30 @@ the value.
See also the entry for "Cookie" in the *note Glossary::.

-File: gawk.info, Node: Requesting Values, Next: Memory Allocation Functions, Prev: General Data Types, Up: Extension API Description
-
-16.4.3 Requesting Values
-------------------------
-
-All of the functions that return values from `gawk' work in the same
-way. You pass in an `awk_valtype_t' value to indicate what kind of
-value you expect. If the actual value matches what you requested, the
-function returns true and fills in the `awk_value_t' result.
-Otherwise, the function returns false, and the `val_type' member
-indicates the type of the actual value. You may then print an error
-message, or reissue the request for the actual value type, as
-appropriate. This behavior is summarized in *note
-table-value-types-returned::.
-
- Type of Actual Value:
---------------------------------------------------------------------------
-
- String Number Array Undefined
-------------------------------------------------------------------------------
- String String String false false
- Number Number if can Number false false
- be converted,
- else false
-Type Array false false Array false
-Requested: Scalar Scalar Scalar false false
- Undefined String Number Array Undefined
- Value false false false false
- Cookie
-
-Table 16.1: API Value Types Returned
-
-
-File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Functions, Prev: Requesting Values, Up: Extension API Description
+File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Functions, Prev: General Data Types, Up: Extension API Description
-16.4.4 Memory Allocation Functions and Convenience Macros
+16.4.3 Memory Allocation Functions and Convenience Macros
---------------------------------------------------------
The API provides a number of "memory allocation" functions for
allocating memory that can be passed to `gawk', as well as a number of
-convenience macros.
+convenience macros. This node presents them all as function
+prototypes, in the way that extension code would use them.
`void *gawk_malloc(size_t size);'
- Call `gawk'-provided `api_malloc()' to allocate storage that may
+ Call the correct version of `malloc()' to allocate storage that may
be passed to `gawk'.
`void *gawk_calloc(size_t nmemb, size_t size);'
- Call `gawk'-provided `api_calloc()' to allocate storage that may
+ Call the correct version of `calloc()' to allocate storage that may
be passed to `gawk'.
`void *gawk_realloc(void *ptr, size_t size);'
- Call `gawk'-provided `api_realloc()' to allocate storage that may
- be passed to `gawk'.
+ Call the correct version of `realloc()' to allocate storage that
+ may be passed to `gawk'.
`void gawk_free(void *ptr);'
- Call `gawk'-provided `api_free()' to release storage that was
+ Call the correct version of `free()' to release storage that was
allocated with `gawk_malloc()', `gawk_calloc()' or
`gawk_realloc()'.
@@ -22956,11 +22935,10 @@ C library than was used for the `gawk' executable.(1) If `gawk' were to
use its version of `free()' when the memory came from an unrelated
version of `malloc()', unexpected behavior would likely result.
- Two convenience macros may be used for allocating storage from the
-API-provided function pointers `api_malloc()' and `api_realloc()'. If
-the allocation fails, they cause `gawk' to exit with a fatal error
-message. They should be used as if they were procedure calls that do
-not return a value.
+ Two convenience macros may be used for allocating storage from
+`gawk_malloc()' and `gawk_realloc()'. If the allocation fails, they
+cause `gawk' to exit with a fatal error message. They should be used
+as if they were procedure calls that do not return a value.
`#define emalloc(pointer, type, size, message) ...'
The arguments to this macro are as follows:
@@ -22970,7 +22948,7 @@ not return a value.
`type'
The type of the pointer variable, used to create a cast for
- the call to `api_malloc()'.
+ the call to `gawk_malloc()'.
`size'
The total number of bytes to be allocated.
@@ -22990,9 +22968,9 @@ not return a value.
make_malloced_string(message, strlen(message), & result);
`#define erealloc(pointer, type, size, message) ...'
- This is like `emalloc()', but it calls `api_realloc()', instead of
- `api_malloc()'. The arguments are the same as for the `emalloc()'
- macro.
+ This is like `emalloc()', but it calls `gawk_realloc()', instead
+ of `gawk_malloc()'. The arguments are the same as for the
+ `emalloc()' macro.
---------- Footnotes ----------
@@ -23002,7 +22980,7 @@ Unix-like systems as well.

File: gawk.info, Node: Constructor Functions, Next: Registration Functions, Prev: Memory Allocation Functions, Up: Extension API Description
-16.4.5 Constructor Functions
+16.4.4 Constructor Functions
----------------------------
The API provides a number of "constructor" functions for creating
@@ -23021,10 +22999,10 @@ extension code would use them.
`make_malloced_string(const char *string, size_t length, awk_value_t *result)'
This function creates a string value in the `awk_value_t' variable
pointed to by `result'. It expects `string' to be a `char *' value
- pointing to data previously obtained from the api-provided
- functions `api_malloc()', `api_calloc()' or `api_realloc()'. The
- idea here is that the data is passed directly to `gawk', which
- assumes responsibility for it. It returns `result'.
+ pointing to data previously obtained from `gawk_malloc()',
+ `gawk_calloc()' or `gawk_realloc()'. The idea here is that the
+ data is passed directly to `gawk', which assumes responsibility
+ for it. It returns `result'.
`static inline awk_value_t *'
`make_null_string(awk_value_t *result)'
@@ -23040,7 +23018,7 @@ extension code would use them.

File: gawk.info, Node: Registration Functions, Next: Printing Messages, Prev: Constructor Functions, Up: Extension API Description
-16.4.6 Registration Functions
+16.4.5 Registration Functions
-----------------------------
This minor node describes the API functions for registering parts of
@@ -23058,7 +23036,7 @@ your extension with `gawk'.

File: gawk.info, Node: Extension Functions, Next: Exit Callback Functions, Up: Registration Functions
-16.4.6.1 Registering An Extension Function
+16.4.5.1 Registering An Extension Function
..........................................
Extension functions are described by the following record:
@@ -23076,17 +23054,16 @@ Extension functions are described by the following record:
by this name. This is a regular C string.
Function names must obey the rules for `awk' identifiers. That is,
- they must begin with either a letter or an underscore, which may
- be followed by any number of letters, digits, and underscores.
- Letter case in function names is significant.
+ they must begin with either an English letter or an underscore,
+ which may be followed by any number of letters, digits, and
+ underscores. Letter case in function names is significant.
`awk_value_t *(*function)(int num_actual_args, awk_value_t *result);'
- This is a pointer to the C function that provides the desired
- functionality. The function must fill in the result with either a
+ This is a pointer to the C function that provides the extension's
+ functionality. The function must fill in `*result' with either a
number or a string. `gawk' takes ownership of any string memory.
- As mentioned earlier, string memory *must* come from the
- api-provided functions `api_malloc()', `api_calloc()' or
- `api_realloc()'.
+ As mentioned earlier, string memory *must* come from one of
+ `gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'.
The `num_actual_args' argument tells the C function how many
actual parameters were passed from the calling `awk' code.
@@ -23097,7 +23074,7 @@ Extension functions are described by the following record:
`size_t num_expected_args;'
This is the number of arguments the function expects to receive.
Each extension function may decide what to do if the number of
- arguments isn't what it expected. Following `awk' functions, it
+ arguments isn't what it expected. As with real `awk' functions, it
is likely OK to ignore extra arguments.
Once you have a record representing your extension function, you
@@ -23112,7 +23089,7 @@ register it with `gawk' using this API function:

File: gawk.info, Node: Exit Callback Functions, Next: Extension Version String, Prev: Extension Functions, Up: Registration Functions
-16.4.6.2 Registering An Exit Callback Function
+16.4.5.2 Registering An Exit Callback Function
..............................................
An "exit callback" function is a function that `gawk' calls before it
@@ -23142,7 +23119,7 @@ order--that is, in the reverse order in which they are registered with

File: gawk.info, Node: Extension Version String, Next: Input Parsers, Prev: Exit Callback Functions, Up: Registration Functions
-16.4.6.3 Registering An Extension Version String
+16.4.5.3 Registering An Extension Version String
................................................
You can register a version string which indicates the name and version
@@ -23158,7 +23135,7 @@ invoked with the `--version' option.

File: gawk.info, Node: Input Parsers, Next: Output Wrappers, Prev: Extension Version String, Up: Registration Functions
-16.4.6.4 Customized Input Parsers
+16.4.5.4 Customized Input Parsers
.................................
By default, `gawk' reads text files as its input. It uses the value of
@@ -23327,7 +23304,7 @@ records. The parameters are as follows:
`*rt_start' should be set to point to the data to be used for
`RT', and `*rt_len' should be set to the length of the data.
Otherwise, `*rt_len' should be set to zero. `gawk' makes its own
- copy of this data, so the extension must manage the storage.
+ copy of this data, so the extension must manage this storage.
The return value is the length of the buffer pointed to by `*out',
or `EOF' if end-of-file was reached or an error occurred.
@@ -23381,7 +23358,7 @@ whether or not to activate an input parser (*note BEGINFILE/ENDFILE::).

File: gawk.info, Node: Output Wrappers, Next: Two-way processors, Prev: Input Parsers, Up: Registration Functions
-16.4.6.5 Customized Output Wrappers
+16.4.5.5 Customized Output Wrappers
...................................
An "output wrapper" is the mirror image of an input parser. It allows
@@ -23488,7 +23465,7 @@ just use normally.

File: gawk.info, Node: Two-way processors, Prev: Output Wrappers, Up: Registration Functions
-16.4.6.6 Customized Two-way Processors
+16.4.5.6 Customized Two-way Processors
......................................
A "two-way processor" combines an input parser and an output wrapper for
@@ -23541,7 +23518,7 @@ can take this" and "take over for this" functions,

File: gawk.info, Node: Printing Messages, Next: Updating `ERRNO', Prev: Registration Functions, Up: Extension API Description
-16.4.7 Printing Messages
+16.4.6 Printing Messages
------------------------
You can print different kinds of warning messages from your extension,
@@ -23570,9 +23547,9 @@ of the ISO C 99 variadic macro feature to hide that parameter. More's
the pity.

-File: gawk.info, Node: Updating `ERRNO', Next: Accessing Parameters, Prev: Printing Messages, Up: Extension API Description
+File: gawk.info, Node: Updating `ERRNO', Next: Requesting Values, Prev: Printing Messages, Up: Extension API Description
-16.4.8 Updating `ERRNO'
+16.4.7 Updating `ERRNO'
-----------------------
The following functions allow you to update the `ERRNO' variable:
@@ -23587,11 +23564,44 @@ The following functions allow you to update the `ERRNO' variable:
Set `ERRNO' directly to the string value of `ERRNO'. `gawk' makes
a copy of the value of `string'.
-`void unset_ERRNO();'
+`void unset_ERRNO(void);'
Unset `ERRNO'.

-File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Updating `ERRNO', Up: Extension API Description
+File: gawk.info, Node: Requesting Values, Next: Accessing Parameters, Prev: Updating `ERRNO', Up: Extension API Description
+
+16.4.8 Requesting Values
+------------------------
+
+All of the functions that return values from `gawk' work in the same
+way. You pass in an `awk_valtype_t' value to indicate what kind of
+value you expect. If the actual value matches what you requested, the
+function returns true and fills in the `awk_value_t' result.
+Otherwise, the function returns false, and the `val_type' member
+indicates the type of the actual value. You may then print an error
+message, or reissue the request for the actual value type, as
+appropriate. This behavior is summarized in *note
+table-value-types-returned::.
+
+ Type of Actual Value:
+--------------------------------------------------------------------------
+
+ String Number Array Undefined
+------------------------------------------------------------------------------
+ String String String false false
+ Number Number if can Number false false
+ be converted,
+ else false
+Type Array false false Array false
+Requested: Scalar Scalar Scalar false false
+ Undefined String Number Array Undefined
+ Value false false false false
+ Cookie
+
+Table 16.1: API Value Types Returned
+
+
+File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Requesting Values, Up: Extension API Description
16.4.9 Accessing and Updating Parameters
----------------------------------------
@@ -23649,7 +23659,7 @@ termed a "symbol table".
Fill in the `awk_value_t' structure pointed to by `result' with
the value of the variable named by the string `name', which is a
regular C string. `wanted' indicates the type of value expected.
- Return true if the actual type matches `wanted', false otherwise
+ Return true if the actual type matches `wanted', false otherwise.
In the latter case, `result->val_type' indicates the actual type
(*note Table 16.1: table-value-types-returned.).
@@ -23667,7 +23677,7 @@ termed a "symbol table".
However, with the exception of the `PROCINFO' array, an extension
cannot change any of those variables.
- NOTE: It is possible for the lookup of `PROCINFO' to fail. This
+ CAUTION: It is possible for the lookup of `PROCINFO' to fail. This
happens if the `awk' program being run does not reference
`PROCINFO'; in this case `gawk' doesn't bother to create the array
and populate it.
@@ -23689,14 +23699,14 @@ was discussed earlier, in *note General Data Types::.
` awk_valtype_t wanted,'
` awk_value_t *result);'
Retrieve the current value of a scalar cookie. Once you have
- obtained a scalar_cookie using `sym_lookup()', you can use this
+ obtained a scalar cookie using `sym_lookup()', you can use this
function to get its value more efficiently. Return false if the
value cannot be retrieved.
`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 of type `AWK_STRING' or `AWK_NUMBER'. Here
- too, the built-in variables may not be updated.
+ too, the predefined variables may not be updated.
It is not obvious at first glance how to work with scalar cookies or
what their raison d'e^tre really is. In theory, the `sym_lookup()' and
@@ -23748,7 +23758,7 @@ usual. Then get a scalar cookie for the variable using `sym_lookup()':
/* install initial value */
sym_update("MAGIC_VAR", make_number(42.0, & value));
- /* get cookie */
+ /* get the cookie */
sym_lookup("MAGIC_VAR", AWK_SCALAR, & value);
/* save the cookie */
@@ -23799,7 +23809,7 @@ variables using `sym_update()' or `sym_update_scalar()', as you like.
However, you can understand the point of cached values if you
remember that _every_ string value's storage _must_ come from
-`api_malloc()', `api_calloc()' or `api_realloc()'. If you have 20
+`gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'. If you have 20
variables, all of which have the same string value, you must create 20
identical copies of the string.(1)
@@ -23863,8 +23873,8 @@ Using value cookies in this way saves considerable storage, since all of
`VAR1' through `VAR100' share the same value.
You might be wondering, "Is this sharing problematic? What happens
-if `awk' code assigns a new value to `VAR1', are all the others be
-changed too?"
+if `awk' code assigns a new value to `VAR1', are all the others 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
@@ -23930,7 +23940,7 @@ The data types associated with arrays are listed below.
` struct awk_element *next;'
` enum {'
` AWK_ELEMENT_DEFAULT = 0, /* set by gawk */'
-` AWK_ELEMENT_DELETE = 1 /* set by extension if should be deleted */'
+` AWK_ELEMENT_DELETE = 1 /* set by extension */'
` } flags;'
` awk_value_t index;'
` awk_value_t value;'
@@ -23948,8 +23958,8 @@ The data types associated with arrays are listed below.
the list.
`enum { ... } flags;'
- A set of flag values that convey information between `gawk'
- and the extension. Currently there is only one:
+ A set of flag values that convey information between the
+ extension and `gawk'. Currently there is only one:
`AWK_ELEMENT_DELETE'. Setting it causes `gawk' to delete the
element from the original array upon release of the flattened
array.
@@ -23960,8 +23970,8 @@ The data types associated with arrays are listed below.
memory pointed to by `index' and `value' belongs to `gawk'.
`typedef struct awk_flat_array {'
-` awk_const void *awk_const opaque1; /* private data for use by gawk */'
-` awk_const void *awk_const opaque2; /* private data for use by gawk */'
+` awk_const void *awk_const opaque1; /* for use by gawk */'
+` awk_const void *awk_const opaque2; /* for use by gawk */'
` awk_const size_t count; /* how many elements */'
` awk_element_t elements[1]; /* will be extended */'
`} awk_flat_array_t;'
@@ -23985,7 +23995,7 @@ File: gawk.info, Node: Array Functions, Next: Flattening Arrays, Prev: Array
The following functions relate to individual array elements.
`awk_bool_t get_element_count(awk_array_t a_cookie, size_t *count);'
- For the array represented by `a_cookie', return in `*count' the
+ For the array represented by `a_cookie', place in `*count' the
number of elements it contains. A subarray counts as a single
element. Return false if there is an error.
@@ -24005,9 +24015,9 @@ The following functions relate to individual array elements.
strings (*note Conversion::); thus using integral values is safest.
As with _all_ strings passed into `gawk' from an extension, the
- string value of `index' must come from the API-provided functions
- `api_malloc()', `api_calloc()' or `api_realloc()' and `gawk'
- releases the storage.
+ string value of `index' must come from `gawk_malloc()',
+ `gawk_calloc()' or `gawk_realloc()', and `gawk' releases the
+ storage.
`awk_bool_t set_array_element(awk_array_t a_cookie,'
` const awk_value_t *const index,'
@@ -24029,7 +24039,7 @@ The following functions relate to individual array elements.
The following functions relate to arrays as a whole:
-`awk_array_t create_array();'
+`awk_array_t create_array(void);'
Create a new array to which elements may be added. *Note Creating
Arrays::, for a discussion of how to create a new array and add
elements to it.
@@ -24065,7 +24075,8 @@ array in a fashion that makes it easy for C code to traverse the entire
array. Test code in `extension/testext.c' does this, and also serves
as a nice example showing how to use the APIs.
- First, the `gawk' script that drives the test extension:
+ We walk through that part of the code one step at a time. First,
+the `gawk' script that drives the test extension:
@load "testext"
BEGIN {
@@ -24186,8 +24197,7 @@ flag bit set:
valrep2str(& flat_array->elements[i].value));
if (strcmp(value3.str_value.str,
- flat_array->elements[i].index.str_value.str)
- == 0) {
+ flat_array->elements[i].index.str_value.str) == 0) {
flat_array->elements[i].flags |= AWK_ELEMENT_DELETE;
printf("dump_array_and_delete: marking element \"%s\" "
"for deletion\n",
@@ -24277,9 +24287,9 @@ code:
The following C code is a simple test extension to create an array
with two regular elements and with a subarray. The leading `#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:
+directives and boilerplate variable declarations (*note Extension API
+Boilerplate::) are omitted for brevity. The first step is to create a
+new array and then install it in the symbol table:
/* create_new_array --- create a named array */
@@ -24466,8 +24476,8 @@ invoked. The variables are:
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
-change during execution.
+predefined variable (*note Built-in Variables::). The others should
+not change during execution.

File: gawk.info, Node: Extension API Boilerplate, Prev: Extension API Variables, Up: Extension API Description
@@ -24501,12 +24511,12 @@ in the `gawkapi.h' header file:
/* OR: */
static awk_bool_t
- init_my_module(void)
+ init_my_extension(void)
{
...
}
- static awk_bool_t (*init_func)(void) = init_my_module;
+ static awk_bool_t (*init_func)(void) = init_my_extension;
dl_load_func(func_table, some_name, "name_space_in_quotes")
@@ -24538,8 +24548,8 @@ in the `gawkapi.h' header file:
`static awk_bool_t (*init_func)(void) = NULL;'
` OR'
-`static awk_bool_t init_my_module(void) { ... }'
-`static awk_bool_t (*init_func)(void) = init_my_module;'
+`static awk_bool_t init_my_extension(void) { ... }'
+`static awk_bool_t (*init_func)(void) = init_my_extension;'
If you need to do some initialization work, you should define a
function that does it (creates variables, opens files, etc.) and
then define the `init_func' pointer to point to your function.
@@ -24593,8 +24603,9 @@ File: gawk.info, Node: Extension Example, Next: Extension Samples, Prev: Find
Two useful functions that are not in `awk' are `chdir()' (so that an
`awk' program can change its directory) and `stat()' (so that an `awk'
-program can gather information about a file). This minor node
-implements these functions for `gawk' in an extension.
+program can gather information about a file). In order to illustrate
+the API in action, this minor node implements these functions for
+`gawk' in an extension.
* Menu:
@@ -24618,8 +24629,7 @@ directory to change to:
newdir = "/home/arnold/funstuff"
ret = chdir(newdir)
if (ret < 0) {
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
+ printf("could not change to %s: %s\n", newdir, ERRNO) > "/dev/stderr"
exit 1
}
...
@@ -24784,7 +24794,7 @@ arguments: the first is an `int' usually called `nargs', that
represents the number of actual arguments for the function. The second
is a pointer to an `awk_value_t', usually named `result'.
- /* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+ /* do_chdir --- provide dynamically loaded chdir() function for gawk */
static awk_value_t *
do_chdir(int nargs, awk_value_t *result)
@@ -24972,12 +24982,20 @@ and/or the type of the file. It then returns zero, for success:
}
}
- array_set(array, "type", make_const_string(type, strlen(type), &tmp));
+ array_set(array, "type", make_const_string(type, strlen(type), & tmp));
return 0;
}
- Finally, here is the `do_stat()' function. It starts with variable
+ The third argument to `stat()' was not discussed previously. This
+argument is optional. If present, it causes `do_stat()' to use the
+`stat()' system call instead of the `lstat()' system call. This is
+done by using a function pointer: `statfunc'. `statfunc' is
+initialized to point to `lstat()' (instead of `stat()') to get the file
+information, in case the file is a symbolic link. However, if there
+were three arguments, `statfunc' is set point to `stat()', instead.
+
+ Here is the `do_stat()' function. It starts with variable
declarations and argument checking:
/* do_stat --- provide a stat() function for gawk */
@@ -25002,14 +25020,10 @@ declarations and argument checking:
return make_number(-1, result);
}
- The third argument to `stat()' was not discussed previously. This
-argument is optional. If present, it causes `stat()' to use the `stat()'
-system call instead of the `lstat()' system call.
-
Then comes the actual work. First, the function gets the arguments.
-Next, it gets the information for the file. The code use `lstat()'
-(instead of `stat()') to get the file information, in case the file is
-a symbolic link. If there's an error, it sets `ERRNO' and returns:
+Next, it gets the information for the file. If the called function
+(`lstat()' or `stat()') returns an error, the code sets `ERRNO' and
+returns:
/* file is first arg, array to hold results is second */
if ( ! get_argument(0, AWK_STRING, & file_param)
@@ -25036,7 +25050,7 @@ a symbolic link. If there's an error, it sets `ERRNO' and returns:
}
The tedious work is done by `fill_stat_array()', shown earlier.
-When done, return the result from `fill_stat_array()':
+When done, the function returns the result from `fill_stat_array()':
ret = fill_stat_array(name, array, & sbuf);
@@ -25118,14 +25132,14 @@ create a GNU/Linux shared library:
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
+ strftime("%m %d %Y %H:%M:%S", data["mtime"])
print "\nInfo for JUNK"
ret = stat("JUNK", data)
print "ret =", ret
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
- print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
+ print "JUNK modified:", strftime("%m %d %Y %H:%M:%S", data["mtime"])
}
The `AWKLIBPATH' environment variable tells `gawk' where to find
@@ -25137,32 +25151,33 @@ directory and run the program:
-| Info for testff.awk
-| ret = 0
-| data["blksize"] = 4096
- -| data["mtime"] = 1350838628
+ -| data["devbsize"] = 512
+ -| data["mtime"] = 1412004710
-| data["mode"] = 33204
-| data["type"] = file
-| data["dev"] = 2053
-| data["gid"] = 1000
- -| data["ino"] = 1719496
- -| data["ctime"] = 1350838628
+ -| data["ino"] = 10358899
+ -| data["ctime"] = 1412004710
-| data["blocks"] = 8
-| data["nlink"] = 1
-| data["name"] = testff.awk
- -| data["atime"] = 1350838632
+ -| data["atime"] = 1412004716
-| data["pmode"] = -rw-rw-r--
- -| data["size"] = 662
+ -| data["size"] = 666
-| data["uid"] = 1000
- -| testff.awk modified: 10 21 12 18:57:08
+ -| testff.awk modified: 09 29 2014 18:31:50
-|
-| Info for JUNK
-| ret = -1
- -| JUNK modified: 01 01 70 02:00:00
+ -| JUNK modified: 01 01 1970 02:00:00
---------- Footnotes ----------
(1) In practice, you would probably want to use the GNU
Autotools--Automake, Autoconf, Libtool, and `gettext'--to configure and
build your libraries. Instructions for doing so are beyond the scope of
-this Info file. *Note gawkextlib::, for WWW links to the tools.
+this Info file. *Note gawkextlib::, for Internet links to the tools.

File: gawk.info, Node: Extension Samples, Next: gawkextlib, Prev: Extension Example, Up: Dynamic Extensions
@@ -25190,9 +25205,9 @@ the extension API.
* Extension Sample Rev2way:: Reversing data sample two-way processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to `gettimeofday()'
and `sleep()'.
+* Extension Sample API Tests:: Tests for the API.

File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample Fnmatch, Up: Extension Samples
@@ -25203,7 +25218,7 @@ File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample
The `filefuncs' extension provides three different functions, as
follows: The usage is:
-@load "filefuncs"
+`@load "filefuncs"'
This is how you load the extension.
`result = chdir("/some/directory")'
@@ -25259,8 +25274,8 @@ follows: The usage is:
`result = fts(pathlist, flags, filedata)'
Walk the file trees provided in `pathlist' and fill in the
`filedata' array as described below. `flags' is the bitwise OR of
- several predefined constant values, also described below. Return
- zero if there were no errors, otherwise return -1.
+ several predefined values, also described below. Return zero if
+ there were no errors, otherwise return -1.
The `fts()' function provides a hook to the C library `fts()'
routines for traversing file hierarchies. Instead of returning data
@@ -25301,10 +25316,10 @@ requested hierarchies.
whether or not `FTS_LOGICAL' is set.
`FTS_SEEDOT'
- By default, the `fts()' routines do not return entries for
- `.' (dot) and `..' (dot-dot). This option causes entries for
- dot-dot to also be included. (The extension always includes
- an entry for dot, see below.)
+ By default, the C library `fts()' routines do not return
+ entries for `.' (dot) and `..' (dot-dot). This option causes
+ entries for dot-dot to also be included. (The extension
+ always includes an entry for dot, see below.)
`FTS_XDEV'
During a traversal, do not cross onto a different mounted
@@ -25354,15 +25369,16 @@ Otherwise it returns -1.
NOTE: The `fts()' extension does not exactly mimic the interface
of the C library `fts()' routines, choosing instead to provide an
- interface that is based on associative arrays, which should be
- more comfortable to use from an `awk' program. This includes the
- lack of a comparison function, since `gawk' already provides
- powerful array sorting facilities. While an `fts_read()'-like
- interface could have been provided, this felt less natural than
- simply creating a multidimensional array to represent the file
- hierarchy and its information.
+ interface that is based on associative arrays, which is more
+ comfortable to use from an `awk' program. This includes the lack
+ of a comparison function, since `gawk' already provides powerful
+ array sorting facilities. While an `fts_read()'-like interface
+ could have been provided, this felt less natural than simply
+ creating a multidimensional array to represent the file hierarchy
+ and its information.
- See `test/fts.awk' in the `gawk' distribution for an example.
+ See `test/fts.awk' in the `gawk' distribution for an example use of
+the `fts()' extension function.

File: gawk.info, Node: Extension Sample Fnmatch, Next: Extension Sample Fork, Prev: Extension Sample File Functions, Up: Extension Samples
@@ -25557,7 +25573,7 @@ Letter File Type
`s' Socket
`u' Anything else (unknown)
-Table 16.2: File Types Returned By `readdir()'
+Table 16.2: File Types Returned By The `readdir' Extension
On systems without the file type information, the third field is
always `u'.
@@ -25628,6 +25644,9 @@ File: gawk.info, Node: Extension Sample Read write array, Next: Extension Samp
The `rwarray' extension adds two functions, named `writea()' and
`reada()', as follows:
+`@load "rwarray"'
+ This is how you load the extension.
+
`ret = writea(file, array)'
This function takes a string argument, which is the name of the
file to which to dump the array, and the array itself as the
@@ -25664,7 +25683,7 @@ restored on systems with a different one, but this has not been tried.
ret = reada("arraydump.bin", array)

-File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample API Tests, Prev: Extension Sample Read write array, Up: Extension Samples
+File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample Time, Prev: Extension Sample Read write array, Up: Extension Samples
16.7.10 Reading An Entire File
------------------------------
@@ -25697,21 +25716,9 @@ an input parser:
}

-File: gawk.info, Node: Extension Sample API Tests, Next: Extension Sample Time, Prev: Extension Sample Readfile, Up: Extension Samples
-
-16.7.11 API Tests
------------------
-
-The `testext' extension exercises parts of the extension API that are
-not tested by the other samples. The `extension/testext.c' file
-contains both the C code for the extension and `awk' test code inside C
-comments that run the tests. The testing framework extracts the `awk'
-code and runs the tests. See the source file for more information.
+File: gawk.info, Node: Extension Sample Time, Next: Extension Sample API Tests, Prev: Extension Sample Readfile, Up: Extension Samples
-
-File: gawk.info, Node: Extension Sample Time, Prev: Extension Sample API Tests, Up: Extension Samples
-
-16.7.12 Extension Time Functions
+16.7.11 Extension Time Functions
--------------------------------
The `time' extension adds two functions, named `gettimeofday()' and
@@ -25740,6 +25747,18 @@ The `time' extension adds two functions, named `gettimeofday()' and
delay.

+File: gawk.info, Node: Extension Sample API Tests, Prev: Extension Sample Time, Up: Extension Samples
+
+16.7.12 API Tests
+-----------------
+
+The `testext' extension exercises parts of the extension API that are
+not tested by the other samples. The `extension/testext.c' file
+contains both the C code for the extension and `awk' test code inside C
+comments that run the tests. The testing framework extracts the `awk'
+code and runs the tests. See the source file for more information.
+
+
File: gawk.info, Node: gawkextlib, Next: Extension summary, Prev: Extension Samples, Up: Dynamic Extensions
16.8 The `gawkextlib' Project
@@ -25752,21 +25771,17 @@ project.
As of this writing, there are five extensions:
- * XML parser extension, using the Expat
- (http://expat.sourceforge.net) XML parsing library.
+ * GD graphics library extension.
* PDF extension.
* PostgreSQL extension.
- * GD graphics library extension.
-
* MPFR library extension. This provides access to a number of MPFR
functions which `gawk''s native MPFR support does not.
- The `time' extension described earlier (*note Extension Sample
-Time::) was originally from this project but has been moved in to the
-main `gawk' distribution.
+ * XML parser extension, using the Expat
+ (http://expat.sourceforge.net) XML parsing library.
You can check out the code for the `gawkextlib' project using the
Git (http://git-scm.com) distributed source code control system. The
@@ -25842,6 +25857,8 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* API function pointers are provided for the following kinds of
operations:
+ * Allocating, reallocating, and releasing memory.
+
* Registration functions. You may register extension functions,
exit callbacks, a version string, input parsers, output
wrappers, and two-way processors.
@@ -25856,8 +25873,6 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* Symbol table access: retrieving a global variable, creating
one, or changing one.
- * Allocating, reallocating, and releasing memory.
-
* Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and can be
a big performance win.
@@ -25881,7 +25896,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* _All_ memory passed from an extension to `gawk' must come from the
API's memory allocation functions. `gawk' takes responsibility for
- the memory and will release it when appropriate.
+ the memory and releases it when appropriate.
* The API provides information about the running version of `gawk' so
that an extension can make sure it is compatible with the `gawk'
@@ -25895,7 +25910,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
sample extensions. The `gawkextlib' project includes several more,
larger, extensions. If you wish to write an extension and
contribute it to the community of `gawk' users, the `gawkextlib'
- project should be the place to do so.
+ project is the place to do so.

@@ -25928,11 +25943,11 @@ This Info file describes the GNU implementation of `awk', which follows
the POSIX specification. Many long-time `awk' users learned `awk'
programming with the original `awk' implementation in Version 7 Unix.
(This implementation was the basis for `awk' in Berkeley Unix, through
-4.3-Reno. Subsequent versions of Berkeley Unix, and some systems
-derived from 4.4BSD-Lite, used various versions of `gawk' for their
-`awk'.) This major node briefly describes the evolution of the `awk'
-language, with cross-references to other parts of the Info file where
-you can find more information.
+4.3-Reno. Subsequent versions of Berkeley Unix, and, for a while, some
+systems derived from 4.4BSD-Lite, used various versions of `gawk' for
+their `awk'.) This major node briefly describes the evolution of the
+`awk' language, with cross-references to other parts of the Info file
+where you can find more information.
* Menu:
@@ -25982,7 +25997,7 @@ the changes, with cross-references to further details:
Functions::).
* The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP'
- built-in variables (*note Built-in Variables::).
+ predefined variables (*note Built-in Variables::).
* Assignable `$0' (*note Changing Fields::).
@@ -26003,12 +26018,10 @@ the changes, with cross-references to further details:
Functions::), rather than using only the first character of `FS'.
* Dynamic regexps as operands of the `~' and `!~' operators (*note
- Regexp Usage::).
+ Computed Regexps::).
* The escape sequences `\b', `\f', and `\r' (*note Escape
- Sequences::). (Some vendors have updated their old versions of
- `awk' to recognize `\b', `\f', and `\r', but this is not something
- you can rely on.)
+ Sequences::).
* Redirection of input for the `getline' function (*note Getline::).
@@ -26032,7 +26045,7 @@ The System V Release 4 (1989) version of Unix `awk' added these features
* The `-v' option for assigning variables before program execution
begins (*note Options::).
- * The `--' option for terminating command-line options.
+ * The `--' signal for terminating command-line options.
* The `\a', `\v', and `\x' escape sequences (*note Escape
Sequences::).
@@ -26047,8 +26060,8 @@ The System V Release 4 (1989) version of Unix `awk' added these features
`printf' function (*note Control Letters::).
* The ability to dynamically pass the field width and precision
- (`"%*.*d"') in the argument list of the `printf' function (*note
- Control Letters::).
+ (`"%*.*d"') in the argument list of `printf' and `sprintf()'
+ (*note Control Letters::).
* The use of regexp constants, such as `/foo/', as expressions, where
they are equivalent to using the matching operator, as in `$0 ~
@@ -26075,8 +26088,8 @@ introduced the following changes into the language:
* The concept of a numeric string and tighter comparison rules to go
with it (*note Typing and Comparison::).
- * The use of built-in variables as function parameter names is
- forbidden (*note Definition Syntax::.
+ * The use of predefined variables as function parameter names is
+ forbidden (*note Definition Syntax::).
* More complete documentation of many of the previously undocumented
features of the language.
@@ -26138,7 +26151,7 @@ can all be disabled with either the `--traditional' or `--posix' options
node summarizes the additional features over POSIX `awk' that are in
the current version of `gawk'.
- * Additional built-in variables:
+ * Additional predefined variables:
- The `ARGIND' `BINMODE', `ERRNO', `FIELDWIDTHS', `FPAT',
`IGNORECASE', `LINT', `PROCINFO', `RT', and `TEXTDOMAIN'
@@ -26180,11 +26193,6 @@ the current version of `gawk'.
- The `BEGINFILE' and `ENDFILE' special patterns. (*note
BEGINFILE/ENDFILE::).
- - The ability to delete all of an array at once with `delete
- ARRAY' (*note Delete::).
-
- - The `nextfile' statement (*note Nextfile Statement::).
-
- The `switch' statement (*note Switch Statement::).
* Changes to standard `awk' functions:
@@ -26193,7 +26201,7 @@ the current version of `gawk'.
one end of a two-way pipe to a coprocess (*note Two-way
I/O::).
- - POSIX compliance for `gsub()' and `sub()'.
+ - POSIX compliance for `gsub()' and `sub()' with `--posix'.
- The `length()' function accepts an array argument and returns
the number of elements in the array (*note String
@@ -26212,24 +26220,24 @@ the current version of `gawk'.
* Additional functions only in `gawk':
- - The `and()', `compl()', `lshift()', `or()', `rshift()', and
- `xor()' functions for bit manipulation (*note Bitwise
- Functions::).
+ - The `gensub()', `patsplit()', and `strtonum()' functions for
+ more powerful text manipulation (*note String Functions::).
- The `asort()' and `asorti()' functions for sorting arrays
(*note Array Sorting::).
- - The `bindtextdomain()', `dcgettext()' and `dcngettext()'
- functions for internationalization (*note Programmer i18n::).
+ - The `mktime()', `systime()', and `strftime()' functions for
+ working with timestamps (*note Time Functions::).
- - The `fflush()' function from BWK `awk' (*note I/O
+ - The `and()', `compl()', `lshift()', `or()', `rshift()', and
+ `xor()' functions for bit manipulation (*note Bitwise
Functions::).
- - The `gensub()', `patsplit()', and `strtonum()' functions for
- more powerful text manipulation (*note String Functions::).
+ - The `isarray()' function to check if a variable is an array
+ or not (*note Type Functions::).
- - The `mktime()', `systime()', and `strftime()' functions for
- working with timestamps (*note Time Functions::).
+ - The `bindtextdomain()', `dcgettext()' and `dcngettext()'
+ functions for internationalization (*note Programmer i18n::).
* Changes and/or additions in the command-line options:
@@ -26281,7 +26289,7 @@ the current version of `gawk'.
* Support for the following obsolete systems was removed from the
- code and the documentation for `gawk' version 4.1:
+ code for `gawk' version 4.1:
- Ultrix
@@ -26679,30 +26687,26 @@ File: gawk.info, Node: Common Extensions, Next: Ranges and Locales, Prev: Fea
A.7 Common Extensions Summary
=============================
-This minor node summarizes the common extensions supported by `gawk',
-Brian Kernighan's `awk', and `mawk', the three most widely-used freely
-available versions of `awk' (*note Other Versions::).
-
-Feature BWK Awk Mawk GNU Awk
---------------------------------------------------------
-`\x' Escape sequence X X X
-`FS' as null string X X X
-`/dev/stdin' special file X X X
-`/dev/stdout' special file X X X
-`/dev/stderr' special file X X X
-`delete' without subscript X X X
-`fflush()' function X X X
-`length()' of an array X X X
-`nextfile' statement X X X
-`**' and `**=' operators X X
-`func' keyword X X
-`BINMODE' variable X X
-`RS' as regexp X X
-Time related functions X X
-
- (Technically speaking, as of late 2012, `fflush()', `delete ARRAY',
-and `nextfile' are no longer extensions, since they have been added to
-POSIX.)
+The following table summarizes the common extensions supported by
+`gawk', Brian Kernighan's `awk', and `mawk', the three most widely-used
+freely available versions of `awk' (*note Other Versions::).
+
+Feature BWK Awk Mawk GNU Awk Now standard
+-----------------------------------------------------------------------
+`\x' Escape sequence X X X
+`FS' as null string X X X
+`/dev/stdin' special file X X X
+`/dev/stdout' special file X X X
+`/dev/stderr' special file X X X
+`delete' without subscript X X X X
+`fflush()' function X X X X
+`length()' of an array X X X
+`nextfile' statement X X X X
+`**' and `**=' operators X X
+`func' keyword X X
+`BINMODE' variable X X
+`RS' as regexp X X
+Time related functions X X

File: gawk.info, Node: Ranges and Locales, Next: Contributors, Prev: Common Extensions, Up: Language History
@@ -26743,14 +26747,14 @@ like `[a-dx-z]' is still equivalent to `[abcdxyz]', as in ASCII. But
outside those locales, the ordering was defined to be based on
"collation order".
- In many locales, `A' and `a' are both less than `B'. In other
-words, these locales sort characters in dictionary order, and
-`[a-dx-z]' is typically not equivalent to `[abcdxyz]'; instead it might
-be equivalent to `[ABCXYabcdxyz]', for example.
+ What does that mean? In many locales, `A' and `a' are both less
+than `B'. In other words, these locales sort characters in dictionary
+order, and `[a-dx-z]' is typically not equivalent to `[abcdxyz]';
+instead it might be equivalent to `[ABCXYabcdxyz]', for example.
This point needs to be emphasized: Much literature teaches that you
should use `[a-z]' to match a lowercase character. But on systems with
-non-ASCII locales, this also matched all of the uppercase characters
+non-ASCII locales, this also matches all of the uppercase characters
except `A' or `Z'! This was a continuous cause of confusion, even well
into the twenty-first century.
@@ -26877,7 +26881,7 @@ Info file, in approximate chronological order:
various PC platforms.
* Christos Zoulas provided the `extension()' built-in function for
- dynamically adding new modules. (This was obsoleted at `gawk'
+ dynamically adding new functions. (This was obsoleted at `gawk'
4.1.)
* Ju"rgen Kahrs contributed the initial version of the TCP/IP
@@ -26947,6 +26951,9 @@ Info file, in approximate chronological order:
4.1 was driven primarily by Arnold Robbins and Andrew Schorr, with
notable contributions from the rest of the development team.
+ * John Malmberg contributed significant improvements to the OpenVMS
+ port and the related documentation.
+
* Antonio Giovanni Colombo rewrote a number of examples in the early
chapters that were severely dated, for which I am incredibly
grateful.
@@ -28374,9 +28381,9 @@ there are several steps that you need to take in order to make it
possible to include them:
1. Before building the new feature into `gawk' itself, consider
- writing it as an extension module (*note Dynamic Extensions::).
- If that's not possible, continue with the rest of the steps in
- this list.
+ writing it as an extension (*note Dynamic Extensions::). If
+ that's not possible, continue with the rest of the steps in this
+ list.
2. Be prepared to sign the appropriate paperwork. In order for the
FSF to distribute your changes, you must either place those
@@ -28932,7 +28939,7 @@ C.5.3 Other Design Decisions
----------------------------
As an arbitrary design decision, extensions can read the values of
-built-in variables and arrays (such as `ARGV' and `FS'), but cannot
+predefined variables and arrays (such as `ARGV' and `FS'), but cannot
change them, with the exception of `PROCINFO'.
The reason for this is to prevent an extension function from
@@ -29499,11 +29506,11 @@ FDL
Field
When `awk' reads an input record, it splits the record into pieces
separated by whitespace (or by a separator regexp that you can
- change by setting the built-in variable `FS'). Such pieces are
+ change by setting the predefined variable `FS'). Such pieces are
called fields. If the pieces are of fixed length, you can use the
built-in variable `FIELDWIDTHS' to describe their lengths. If you
wish to specify the contents of fields instead of the field
- separator, you can use the built-in variable `FPAT' to do so.
+ separator, you can use the predefined variable `FPAT' to do so.
(*Note Field Separators::, *note Constant Size::, and *note
Splitting By Content::.)
@@ -29520,7 +29527,7 @@ Format
Format strings control the appearance of output in the
`strftime()' and `sprintf()' functions, and in the `printf'
statement as well. Also, data conversions from numbers to strings
- are controlled by the format strings contained in the built-in
+ are controlled by the format strings contained in the predefined
variables `CONVFMT' and `OFMT'. (*Note Control Letters::.)
Free Documentation License
@@ -31239,10 +31246,10 @@ Index
* .gmo files: Explaining gettext. (line 42)
* .gmo files, specifying directory of <1>: Programmer i18n. (line 47)
* .gmo files, specifying directory of: Explaining gettext. (line 54)
-* .mo files, converting from .po: I18N Example. (line 63)
+* .mo files, converting from .po: I18N Example. (line 64)
* .po files <1>: Translator i18n. (line 6)
* .po files: Explaining gettext. (line 37)
-* .po files, converting to .mo: I18N Example. (line 63)
+* .po files, converting to .mo: I18N Example. (line 64)
* .pot files: Explaining gettext. (line 31)
* / (forward slash) to enclose regular expressions: Regexp. (line 10)
* / (forward slash), / operator: Precedence. (line 55)
@@ -31734,10 +31741,6 @@ Index
* bug-gawk@gnu.org bug reporting address: Bugs. (line 30)
* built-in functions: Functions. (line 6)
* built-in functions, evaluation order: Calling Built-in. (line 30)
-* built-in variables: Built-in Variables. (line 6)
-* built-in variables, -v option, setting with: Options. (line 40)
-* built-in variables, conveying information: Auto-set. (line 6)
-* built-in variables, user-modifiable: User-modified. (line 6)
* Busybox Awk: Other Versions. (line 88)
* c.e., See common extensions: Conventions. (line 51)
* call by reference: Pass By Value/Reference.
@@ -31799,7 +31802,7 @@ Index
* Collado, Manuel: Acknowledgments. (line 60)
* collating elements: Bracket Expressions. (line 79)
* collating symbols: Bracket Expressions. (line 86)
-* Colombo, Antonio <1>: Contributors. (line 137)
+* Colombo, Antonio <1>: Contributors. (line 140)
* Colombo, Antonio: Acknowledgments. (line 60)
* columns, aligning: Print Examples. (line 70)
* columns, cutting: Cut Program. (line 6)
@@ -32005,7 +32008,7 @@ Index
* debugger commands, disable: Breakpoint Control. (line 69)
* debugger commands, display: Viewing And Changing Data.
(line 8)
-* debugger commands, down: Execution Stack. (line 21)
+* debugger commands, down: Execution Stack. (line 23)
* debugger commands, dump: Miscellaneous Debugger Commands.
(line 9)
* debugger commands, e (enable): Breakpoint Control. (line 73)
@@ -32014,10 +32017,10 @@ Index
(line 10)
* debugger commands, eval: Viewing And Changing Data.
(line 23)
-* debugger commands, f (frame): Execution Stack. (line 25)
+* debugger commands, f (frame): Execution Stack. (line 27)
* debugger commands, finish: Debugger Execution Control.
(line 39)
-* debugger commands, frame: Execution Stack. (line 25)
+* debugger commands, frame: Execution Stack. (line 27)
* debugger commands, h (help): Miscellaneous Debugger Commands.
(line 66)
* debugger commands, help: Miscellaneous Debugger Commands.
@@ -32079,11 +32082,12 @@ Index
(line 83)
* debugger commands, unwatch: Viewing And Changing Data.
(line 84)
-* debugger commands, up: Execution Stack. (line 34)
+* debugger commands, up: Execution Stack. (line 36)
* debugger commands, w (watch): Viewing And Changing Data.
(line 67)
* debugger commands, watch: Viewing And Changing Data.
(line 67)
+* debugger commands, where (backtrace): Execution Stack. (line 13)
* debugger default list amount: Debugger Info. (line 69)
* debugger history file: Debugger Info. (line 80)
* debugger history size: Debugger Info. (line 65)
@@ -32208,7 +32212,7 @@ Index
* dollar sign ($), regexp operator: Regexp Operators. (line 35)
* double quote ("), in regexp constants: Computed Regexps. (line 29)
* double quote ("), in shell commands: Quoting. (line 54)
-* down debugger command: Execution Stack. (line 21)
+* down debugger command: Execution Stack. (line 23)
* Drepper, Ulrich: Acknowledgments. (line 52)
* dump all variables of a program: Options. (line 93)
* dump debugger command: Miscellaneous Debugger Commands.
@@ -32315,7 +32319,7 @@ Index
(line 99)
* exp: Numeric Functions. (line 33)
* expand utility: Very Simple. (line 72)
-* Expat XML parser library: gawkextlib. (line 35)
+* Expat XML parser library: gawkextlib. (line 31)
* exponent: Numeric Functions. (line 33)
* expressions: Expressions. (line 6)
* expressions, as patterns: Expression Patterns. (line 6)
@@ -32367,7 +32371,7 @@ Index
* extract.awk program: Extract Program. (line 79)
* extraction, of marked strings (internationalization): String Extraction.
(line 6)
-* f debugger command (alias for frame): Execution Stack. (line 25)
+* f debugger command (alias for frame): Execution Stack. (line 27)
* false, logical: Truth Values. (line 6)
* FDL (Free Documentation License): GNU Free Documentation License.
(line 7)
@@ -32423,10 +32427,10 @@ Index
* files, .gmo: Explaining gettext. (line 42)
* files, .gmo, specifying directory of <1>: Programmer i18n. (line 47)
* files, .gmo, specifying directory of: Explaining gettext. (line 54)
-* files, .mo, converting from .po: I18N Example. (line 63)
+* files, .mo, converting from .po: I18N Example. (line 64)
* files, .po <1>: Translator i18n. (line 6)
* files, .po: Explaining gettext. (line 37)
-* files, .po, converting to .mo: I18N Example. (line 63)
+* files, .po, converting to .mo: I18N Example. (line 64)
* files, .pot: Explaining gettext. (line 31)
* files, /dev/... special files: Special FD. (line 48)
* files, /inet/... (gawk): TCP/IP Networking. (line 6)
@@ -32446,7 +32450,7 @@ Index
* files, managing, data file boundaries: Filetrans Function. (line 6)
* files, message object: Explaining gettext. (line 42)
* files, message object, converting from portable object files: I18N Example.
- (line 63)
+ (line 64)
* files, message object, specifying directory of <1>: Programmer i18n.
(line 47)
* files, message object, specifying directory of: Explaining gettext.
@@ -32460,7 +32464,7 @@ Index
* files, portable object: Explaining gettext. (line 37)
* files, portable object template: Explaining gettext. (line 31)
* files, portable object, converting to message object files: I18N Example.
- (line 63)
+ (line 64)
* files, portable object, generating: Options. (line 147)
* files, processing, ARGIND variable and: Auto-set. (line 51)
* files, reading: Rewind Function. (line 6)
@@ -32511,7 +32515,7 @@ Index
* FPAT variable <1>: User-modified. (line 43)
* FPAT variable: Splitting By Content.
(line 27)
-* frame debugger command: Execution Stack. (line 25)
+* frame debugger command: Execution Stack. (line 27)
* Free Documentation License (FDL): GNU Free Documentation License.
(line 7)
* Free Software Foundation (FSF) <1>: Glossary. (line 296)
@@ -32592,7 +32596,6 @@ Index
* gawk, awk and: Preface. (line 21)
* gawk, bitwise operations in: Bitwise Functions. (line 40)
* gawk, break statement in: Break Statement. (line 51)
-* gawk, built-in variables and: Built-in Variables. (line 14)
* gawk, character classes and: Bracket Expressions. (line 100)
* gawk, coding style in: Adding Code. (line 39)
* gawk, command-line options, and regular expressions: GNU Regexp Operators.
@@ -32651,6 +32654,7 @@ Index
* gawk, newlines in: Statements/Lines. (line 12)
* gawk, octal numbers and: Nondecimal-numbers. (line 42)
* gawk, OS/2 version of: PC Using. (line 16)
+* gawk, predefined variables and: Built-in Variables. (line 14)
* gawk, PROCINFO array in <1>: Two-way I/O. (line 99)
* gawk, PROCINFO array in <2>: Time Functions. (line 47)
* gawk, PROCINFO array in: Auto-set. (line 137)
@@ -32730,7 +32734,7 @@ Index
* git utility <2>: Accessing The Source.
(line 10)
* git utility <3>: Other Versions. (line 29)
-* git utility: gawkextlib. (line 29)
+* git utility: gawkextlib. (line 25)
* Git, use of for gawk source code: Derived Files. (line 6)
* GNITS mailing list: Acknowledgments. (line 52)
* GNU awk, See gawk: Preface. (line 51)
@@ -32925,7 +32929,7 @@ Index
* LC_CTYPE locale category: Explaining gettext. (line 98)
* LC_MESSAGES locale category: Explaining gettext. (line 88)
* LC_MESSAGES locale category, bindtextdomain() function (gawk): Programmer i18n.
- (line 99)
+ (line 101)
* LC_MONETARY locale category: Explaining gettext. (line 104)
* LC_NUMERIC locale category: Explaining gettext. (line 108)
* LC_TIME locale category: Explaining gettext. (line 112)
@@ -33030,6 +33034,7 @@ Index
* mailing list, GNITS: Acknowledgments. (line 52)
* Malmberg, John <1>: Bugs. (line 71)
* Malmberg, John: Acknowledgments. (line 60)
+* Malmberg, John E.: Contributors. (line 137)
* mark parity: Ordinal Functions. (line 45)
* marked string extraction (internationalization): String Extraction.
(line 6)
@@ -33053,7 +33058,7 @@ Index
* McPhee, Patrick: Contributors. (line 100)
* message object files: Explaining gettext. (line 42)
* message object files, converting from portable object files: I18N Example.
- (line 63)
+ (line 64)
* message object files, specifying directory of <1>: Programmer i18n.
(line 47)
* message object files, specifying directory of: Explaining gettext.
@@ -33066,7 +33071,7 @@ Index
* modifiers, in format specifiers: Format Modifiers. (line 6)
* monetary information, localization: Explaining gettext. (line 104)
* Moore, Duncan: Getline Notes. (line 40)
-* msgfmt utility: I18N Example. (line 63)
+* msgfmt utility: I18N Example. (line 64)
* multiple precision: Arbitrary Precision Arithmetic.
(line 6)
* multiple-line records: Multiple Line. (line 6)
@@ -33307,7 +33312,7 @@ Index
* portable object files <1>: Translator i18n. (line 6)
* portable object files: Explaining gettext. (line 37)
* portable object files, converting to message object files: I18N Example.
- (line 63)
+ (line 64)
* portable object files, generating: Options. (line 147)
* portable object template files: Explaining gettext. (line 31)
* porting gawk: New Ports. (line 6)
@@ -33360,6 +33365,10 @@ Index
* precedence <1>: Precedence. (line 6)
* precedence: Increment Ops. (line 60)
* precedence, regexp operators: Regexp Operators. (line 156)
+* predefined variables: Built-in Variables. (line 6)
+* predefined variables, -v option, setting with: Options. (line 40)
+* predefined variables, conveying information: Auto-set. (line 6)
+* predefined variables, user-modifiable: User-modified. (line 6)
* print debugger command: Viewing And Changing Data.
(line 36)
* print statement: Printing. (line 16)
@@ -33473,7 +33482,7 @@ Index
* Rankin, Pat <3>: Assignment Ops. (line 100)
* Rankin, Pat: Acknowledgments. (line 60)
* reada() extension function: Extension Sample Read write array.
- (line 15)
+ (line 18)
* readable data files, checking: File Checking. (line 6)
* readable.awk program: File Checking. (line 11)
* readdir extension: Extension Sample Readdir.
@@ -33578,7 +33587,7 @@ Index
* RLENGTH variable, match() function and: String Functions. (line 227)
* Robbins, Arnold <1>: Future Extensions. (line 6)
* Robbins, Arnold <2>: Bugs. (line 32)
-* Robbins, Arnold <3>: Contributors. (line 141)
+* Robbins, Arnold <3>: Contributors. (line 144)
* Robbins, Arnold <4>: General Data Types. (line 6)
* Robbins, Arnold <5>: Alarm Program. (line 6)
* Robbins, Arnold <6>: Passwd Functions. (line 90)
@@ -34006,7 +34015,7 @@ Index
(line 83)
* unwatch debugger command: Viewing And Changing Data.
(line 84)
-* up debugger command: Execution Stack. (line 34)
+* up debugger command: Execution Stack. (line 36)
* user database, reading: Passwd Functions. (line 6)
* user-defined functions: User-defined. (line 6)
* user-defined, functions, counts, in a profile: Profiling. (line 137)
@@ -34023,10 +34032,7 @@ Index
* variables <1>: Basic Data Typing. (line 6)
* variables: Other Features. (line 6)
* variables, assigning on command line: Assignment Options. (line 6)
-* variables, built-in <1>: Built-in Variables. (line 6)
* variables, built-in: Using Variables. (line 23)
-* variables, built-in, -v option, setting with: Options. (line 40)
-* variables, built-in, conveying information: Auto-set. (line 6)
* variables, flag: Boolean Ops. (line 69)
* variables, getline command into, using <1>: Getline/Variable/Coprocess.
(line 6)
@@ -34039,6 +34045,9 @@ Index
* variables, global, printing list of: Options. (line 93)
* variables, initializing: Using Variables. (line 23)
* variables, local to a function: Variable Scope. (line 6)
+* variables, predefined: Built-in Variables. (line 6)
+* variables, predefined -v option, setting with: Options. (line 40)
+* variables, predefined conveying information: Auto-set. (line 6)
* variables, private: Library Names. (line 11)
* variables, setting: Options. (line 32)
* variables, shadowing: Definition Syntax. (line 71)
@@ -34080,6 +34089,9 @@ Index
* wc.awk program: Wc Program. (line 46)
* Weinberger, Peter <1>: Contributors. (line 11)
* Weinberger, Peter: History. (line 17)
+* where debugger command: Execution Stack. (line 13)
+* where debugger command (alias for backtrace): Execution Stack.
+ (line 13)
* while statement: While Statement. (line 6)
* while statement, use of regexps in: Regexp Usage. (line 19)
* whitespace, as field separators: Default Field Splitting.
@@ -34100,7 +34112,7 @@ Index
* words, duplicate, searching for: Dupword Program. (line 6)
* words, usage counts, generating: Word Sorting. (line 6)
* writea() extension function: Extension Sample Read write array.
- (line 9)
+ (line 12)
* xgettext utility: String Extraction. (line 13)
* xor: Bitwise Functions. (line 56)
* XOR bitwise operation: Bitwise Functions. (line 6)
@@ -34138,556 +34150,557 @@ Index

Tag Table:
Node: Top1204
-Node: Foreword41978
-Node: Preface46325
-Ref: Preface-Footnote-149220
-Ref: Preface-Footnote-249327
-Ref: Preface-Footnote-349560
-Node: History49702
-Node: Names52076
-Ref: Names-Footnote-153170
-Node: This Manual53316
-Ref: This Manual-Footnote-159151
-Node: Conventions59251
-Node: Manual History61596
-Ref: Manual History-Footnote-164672
-Ref: Manual History-Footnote-264713
-Node: How To Contribute64787
-Node: Acknowledgments66026
-Node: Getting Started70774
-Node: Running gawk73208
-Node: One-shot74398
-Node: Read Terminal75623
-Node: Long77650
-Node: Executable Scripts79166
-Ref: Executable Scripts-Footnote-181955
-Node: Comments82057
-Node: Quoting84530
-Node: DOS Quoting90040
-Node: Sample Data Files90715
-Node: Very Simple93308
-Node: Two Rules98199
-Node: More Complex100085
-Node: Statements/Lines102947
-Ref: Statements/Lines-Footnote-1107403
-Node: Other Features107668
-Node: When108599
-Ref: When-Footnote-1110355
-Node: Intro Summary110420
-Node: Invoking Gawk111303
-Node: Command Line112818
-Node: Options113609
-Ref: Options-Footnote-1129375
-Node: Other Arguments129400
-Node: Naming Standard Input132361
-Node: Environment Variables133454
-Node: AWKPATH Variable134012
-Ref: AWKPATH Variable-Footnote-1136864
-Ref: AWKPATH Variable-Footnote-2136909
-Node: AWKLIBPATH Variable137169
-Node: Other Environment Variables137928
-Node: Exit Status141401
-Node: Include Files142076
-Node: Loading Shared Libraries145654
-Node: Obsolete147081
-Node: Undocumented147778
-Node: Invoking Summary148045
-Node: Regexp149711
-Node: Regexp Usage151170
-Node: Escape Sequences153203
-Node: Regexp Operators159303
-Ref: Regexp Operators-Footnote-1166738
-Ref: Regexp Operators-Footnote-2166885
-Node: Bracket Expressions166983
-Ref: table-char-classes169000
-Node: Leftmost Longest171940
-Node: Computed Regexps173242
-Node: GNU Regexp Operators176639
-Node: Case-sensitivity180345
-Ref: Case-sensitivity-Footnote-1183235
-Ref: Case-sensitivity-Footnote-2183470
-Node: Regexp Summary183578
-Node: Reading Files185047
-Node: Records187139
-Node: awk split records187867
-Node: gawk split records192779
-Ref: gawk split records-Footnote-1197318
-Node: Fields197355
-Ref: Fields-Footnote-1200151
-Node: Nonconstant Fields200237
-Ref: Nonconstant Fields-Footnote-1202467
-Node: Changing Fields202669
-Node: Field Separators208601
-Node: Default Field Splitting211303
-Node: Regexp Field Splitting212420
-Node: Single Character Fields215770
-Node: Command Line Field Separator216829
-Node: Full Line Fields220039
-Ref: Full Line Fields-Footnote-1220547
-Node: Field Splitting Summary220593
-Ref: Field Splitting Summary-Footnote-1223724
-Node: Constant Size223825
-Node: Splitting By Content228431
-Ref: Splitting By Content-Footnote-1232504
-Node: Multiple Line232544
-Ref: Multiple Line-Footnote-1238433
-Node: Getline238612
-Node: Plain Getline240823
-Node: Getline/Variable243463
-Node: Getline/File244610
-Node: Getline/Variable/File245994
-Ref: Getline/Variable/File-Footnote-1247593
-Node: Getline/Pipe247680
-Node: Getline/Variable/Pipe250363
-Node: Getline/Coprocess251492
-Node: Getline/Variable/Coprocess252744
-Node: Getline Notes253481
-Node: Getline Summary256273
-Ref: table-getline-variants256681
-Node: Read Timeout257510
-Ref: Read Timeout-Footnote-1261324
-Node: Command-line directories261382
-Node: Input Summary262286
-Node: Input Exercises265538
-Node: Printing266266
-Node: Print268043
-Node: Print Examples269500
-Node: Output Separators272279
-Node: OFMT274295
-Node: Printf275647
-Node: Basic Printf276432
-Node: Control Letters278003
-Node: Format Modifiers281987
-Node: Printf Examples287994
-Node: Redirection290476
-Node: Special FD297207
-Ref: Special FD-Footnote-1300364
-Node: Special Files300438
-Node: Other Inherited Files301054
-Node: Special Network302054
-Node: Special Caveats302915
-Node: Close Files And Pipes303866
-Ref: Close Files And Pipes-Footnote-1311043
-Ref: Close Files And Pipes-Footnote-2311191
-Node: Output Summary311341
-Node: Output Exercises312337
-Node: Expressions313017
-Node: Values314202
-Node: Constants314878
-Node: Scalar Constants315558
-Ref: Scalar Constants-Footnote-1316417
-Node: Nondecimal-numbers316667
-Node: Regexp Constants319667
-Node: Using Constant Regexps320192
-Node: Variables323330
-Node: Using Variables323985
-Node: Assignment Options325889
-Node: Conversion327764
-Node: Strings And Numbers328288
-Ref: Strings And Numbers-Footnote-1331350
-Node: Locale influences conversions331459
-Ref: table-locale-affects334174
-Node: All Operators334762
-Node: Arithmetic Ops335392
-Node: Concatenation337897
-Ref: Concatenation-Footnote-1340716
-Node: Assignment Ops340822
-Ref: table-assign-ops345805
-Node: Increment Ops347083
-Node: Truth Values and Conditions350521
-Node: Truth Values351604
-Node: Typing and Comparison352653
-Node: Variable Typing353446
-Node: Comparison Operators357098
-Ref: table-relational-ops357508
-Node: POSIX String Comparison361023
-Ref: POSIX String Comparison-Footnote-1362095
-Node: Boolean Ops362233
-Ref: Boolean Ops-Footnote-1366712
-Node: Conditional Exp366803
-Node: Function Calls368530
-Node: Precedence372410
-Node: Locales376078
-Node: Expressions Summary377709
-Node: Patterns and Actions380283
-Node: Pattern Overview381399
-Node: Regexp Patterns383078
-Node: Expression Patterns383621
-Node: Ranges387401
-Node: BEGIN/END390507
-Node: Using BEGIN/END391269
-Ref: Using BEGIN/END-Footnote-1394006
-Node: I/O And BEGIN/END394112
-Node: BEGINFILE/ENDFILE396426
-Node: Empty399327
-Node: Using Shell Variables399644
-Node: Action Overview401920
-Node: Statements404247
-Node: If Statement406095
-Node: While Statement407593
-Node: Do Statement409621
-Node: For Statement410763
-Node: Switch Statement413918
-Node: Break Statement416306
-Node: Continue Statement418347
-Node: Next Statement420172
-Node: Nextfile Statement422552
-Node: Exit Statement425182
-Node: Built-in Variables427585
-Node: User-modified428712
-Ref: User-modified-Footnote-1436392
-Node: Auto-set436454
-Ref: Auto-set-Footnote-1449648
-Ref: Auto-set-Footnote-2449853
-Node: ARGC and ARGV449909
-Node: Pattern Action Summary454113
-Node: Arrays456532
-Node: Array Basics457861
-Node: Array Intro458705
-Ref: figure-array-elements460678
-Ref: Array Intro-Footnote-1463202
-Node: Reference to Elements463330
-Node: Assigning Elements465780
-Node: Array Example466271
-Node: Scanning an Array468029
-Node: Controlling Scanning471045
-Ref: Controlling Scanning-Footnote-1476234
-Node: Numeric Array Subscripts476550
-Node: Uninitialized Subscripts478733
-Node: Delete480350
-Ref: Delete-Footnote-1483094
-Node: Multidimensional483151
-Node: Multiscanning486246
-Node: Arrays of Arrays487835
-Node: Arrays Summary492596
-Node: Functions494701
-Node: Built-in495574
-Node: Calling Built-in496652
-Node: Numeric Functions498640
-Ref: Numeric Functions-Footnote-1503464
-Ref: Numeric Functions-Footnote-2503821
-Ref: Numeric Functions-Footnote-3503869
-Node: String Functions504138
-Ref: String Functions-Footnote-1527598
-Ref: String Functions-Footnote-2527727
-Ref: String Functions-Footnote-3527975
-Node: Gory Details528062
-Ref: table-sub-escapes529843
-Ref: table-sub-proposed531363
-Ref: table-posix-sub532727
-Ref: table-gensub-escapes534267
-Ref: Gory Details-Footnote-1535099
-Node: I/O Functions535250
-Ref: I/O Functions-Footnote-1542351
-Node: Time Functions542498
-Ref: Time Functions-Footnote-1552967
-Ref: Time Functions-Footnote-2553035
-Ref: Time Functions-Footnote-3553193
-Ref: Time Functions-Footnote-4553304
-Ref: Time Functions-Footnote-5553416
-Ref: Time Functions-Footnote-6553643
-Node: Bitwise Functions553909
-Ref: table-bitwise-ops554471
-Ref: Bitwise Functions-Footnote-1558779
-Node: Type Functions558948
-Node: I18N Functions560097
-Node: User-defined561742
-Node: Definition Syntax562546
-Ref: Definition Syntax-Footnote-1567950
-Node: Function Example568019
-Ref: Function Example-Footnote-1570936
-Node: Function Caveats570958
-Node: Calling A Function571476
-Node: Variable Scope572431
-Node: Pass By Value/Reference575419
-Node: Return Statement578929
-Node: Dynamic Typing581913
-Node: Indirect Calls582842
-Ref: Indirect Calls-Footnote-1592563
-Node: Functions Summary592691
-Node: Library Functions595390
-Ref: Library Functions-Footnote-1599008
-Ref: Library Functions-Footnote-2599151
-Node: Library Names599322
-Ref: Library Names-Footnote-1602780
-Ref: Library Names-Footnote-2603000
-Node: General Functions603086
-Node: Strtonum Function604114
-Node: Assert Function607134
-Node: Round Function610458
-Node: Cliff Random Function611999
-Node: Ordinal Functions613015
-Ref: Ordinal Functions-Footnote-1616080
-Ref: Ordinal Functions-Footnote-2616332
-Node: Join Function616543
-Ref: Join Function-Footnote-1618314
-Node: Getlocaltime Function618514
-Node: Readfile Function622255
-Node: Data File Management624203
-Node: Filetrans Function624835
-Node: Rewind Function628894
-Node: File Checking630279
-Ref: File Checking-Footnote-1631607
-Node: Empty Files631808
-Node: Ignoring Assigns633787
-Node: Getopt Function635338
-Ref: Getopt Function-Footnote-1646798
-Node: Passwd Functions647001
-Ref: Passwd Functions-Footnote-1655852
-Node: Group Functions655940
-Ref: Group Functions-Footnote-1663843
-Node: Walking Arrays664056
-Node: Library Functions Summary665659
-Node: Library Exercises667060
-Node: Sample Programs668340
-Node: Running Examples669110
-Node: Clones669838
-Node: Cut Program671062
-Node: Egrep Program680792
-Ref: Egrep Program-Footnote-1688294
-Node: Id Program688404
-Node: Split Program692048
-Ref: Split Program-Footnote-1695494
-Node: Tee Program695622
-Node: Uniq Program698409
-Node: Wc Program705830
-Ref: Wc Program-Footnote-1710078
-Node: Miscellaneous Programs710170
-Node: Dupword Program711383
-Node: Alarm Program713414
-Node: Translate Program718218
-Ref: Translate Program-Footnote-1722791
-Ref: Translate Program-Footnote-2723061
-Node: Labels Program723200
-Ref: Labels Program-Footnote-1726549
-Node: Word Sorting726633
-Node: History Sorting730703
-Node: Extract Program732539
-Node: Simple Sed740071
-Node: Igawk Program743133
-Ref: Igawk Program-Footnote-1757459
-Ref: Igawk Program-Footnote-2757660
-Ref: Igawk Program-Footnote-3757782
-Node: Anagram Program757897
-Node: Signature Program760959
-Node: Programs Summary762206
-Node: Programs Exercises763399
-Ref: Programs Exercises-Footnote-1767530
-Node: Advanced Features767621
-Node: Nondecimal Data769569
-Node: Array Sorting771159
-Node: Controlling Array Traversal771856
-Ref: Controlling Array Traversal-Footnote-1780187
-Node: Array Sorting Functions780305
-Ref: Array Sorting Functions-Footnote-1784197
-Node: Two-way I/O784391
-Ref: Two-way I/O-Footnote-1789335
-Ref: Two-way I/O-Footnote-2789521
-Node: TCP/IP Networking789603
-Node: Profiling792444
-Node: Advanced Features Summary799995
-Node: Internationalization801856
-Node: I18N and L10N803336
-Node: Explaining gettext804022
-Ref: Explaining gettext-Footnote-1809048
-Ref: Explaining gettext-Footnote-2809232
-Node: Programmer i18n809397
-Ref: Programmer i18n-Footnote-1814191
-Node: Translator i18n814240
-Node: String Extraction815034
-Ref: String Extraction-Footnote-1816167
-Node: Printf Ordering816253
-Ref: Printf Ordering-Footnote-1819035
-Node: I18N Portability819099
-Ref: I18N Portability-Footnote-1821548
-Node: I18N Example821611
-Ref: I18N Example-Footnote-1824317
-Node: Gawk I18N824389
-Node: I18N Summary825027
-Node: Debugger826366
-Node: Debugging827388
-Node: Debugging Concepts827829
-Node: Debugging Terms829685
-Node: Awk Debugging832282
-Node: Sample Debugging Session833174
-Node: Debugger Invocation833694
-Node: Finding The Bug835030
-Node: List of Debugger Commands841509
-Node: Breakpoint Control842841
-Node: Debugger Execution Control846505
-Node: Viewing And Changing Data849865
-Node: Execution Stack853223
-Node: Debugger Info854736
-Node: Miscellaneous Debugger Commands858730
-Node: Readline Support863914
-Node: Limitations864806
-Node: Debugging Summary867079
-Node: Arbitrary Precision Arithmetic868247
-Node: Computer Arithmetic869734
-Ref: Computer Arithmetic-Footnote-1874121
-Node: Math Definitions874178
-Ref: table-ieee-formats877467
-Ref: Math Definitions-Footnote-1878007
-Node: MPFR features878110
-Node: FP Math Caution879727
-Ref: FP Math Caution-Footnote-1880777
-Node: Inexactness of computations881146
-Node: Inexact representation882094
-Node: Comparing FP Values883449
-Node: Errors accumulate884413
-Node: Getting Accuracy885846
-Node: Try To Round888505
-Node: Setting precision889404
-Ref: table-predefined-precision-strings890086
-Node: Setting the rounding mode891879
-Ref: table-gawk-rounding-modes892243
-Ref: Setting the rounding mode-Footnote-1895697
-Node: Arbitrary Precision Integers895876
-Ref: Arbitrary Precision Integers-Footnote-1899649
-Node: POSIX Floating Point Problems899798
-Ref: POSIX Floating Point Problems-Footnote-1903674
-Node: Floating point summary903712
-Node: Dynamic Extensions905916
-Node: Extension Intro907468
-Node: Plugin License908733
-Node: Extension Mechanism Outline909418
-Ref: figure-load-extension909842
-Ref: figure-load-new-function911327
-Ref: figure-call-new-function912329
-Node: Extension API Description914313
-Node: Extension API Functions Introduction915763
-Node: General Data Types920630
-Ref: General Data Types-Footnote-1926323
-Node: Requesting Values926622
-Ref: table-value-types-returned927359
-Node: Memory Allocation Functions928317
-Ref: Memory Allocation Functions-Footnote-1931064
-Node: Constructor Functions931160
-Node: Registration Functions932918
-Node: Extension Functions933603
-Node: Exit Callback Functions935905
-Node: Extension Version String937153
-Node: Input Parsers937803
-Node: Output Wrappers947617
-Node: Two-way processors952133
-Node: Printing Messages954337
-Ref: Printing Messages-Footnote-1955414
-Node: Updating `ERRNO'955566
-Node: Accessing Parameters956305
-Node: Symbol Table Access957535
-Node: Symbol table by name958049
-Node: Symbol table by cookie960025
-Ref: Symbol table by cookie-Footnote-1964158
-Node: Cached values964221
-Ref: Cached values-Footnote-1967725
-Node: Array Manipulation967816
-Ref: Array Manipulation-Footnote-1968914
-Node: Array Data Types968953
-Ref: Array Data Types-Footnote-1971656
-Node: Array Functions971748
-Node: Flattening Arrays975622
-Node: Creating Arrays982474
-Node: Extension API Variables987205
-Node: Extension Versioning987841
-Node: Extension API Informational Variables989742
-Node: Extension API Boilerplate990828
-Node: Finding Extensions994632
-Node: Extension Example995192
-Node: Internal File Description995922
-Node: Internal File Ops1000013
-Ref: Internal File Ops-Footnote-11011445
-Node: Using Internal File Ops1011585
-Ref: Using Internal File Ops-Footnote-11013932
-Node: Extension Samples1014200
-Node: Extension Sample File Functions1015724
-Node: Extension Sample Fnmatch1023292
-Node: Extension Sample Fork1024774
-Node: Extension Sample Inplace1025987
-Node: Extension Sample Ord1027662
-Node: Extension Sample Readdir1028498
-Ref: table-readdir-file-types1029354
-Node: Extension Sample Revout1030153
-Node: Extension Sample Rev2way1030744
-Node: Extension Sample Read write array1031485
-Node: Extension Sample Readfile1033364
-Node: Extension Sample API Tests1034464
-Node: Extension Sample Time1034989
-Node: gawkextlib1036304
-Node: Extension summary1039117
-Node: Extension Exercises1042810
-Node: Language History1043532
-Node: V7/SVR3.11045175
-Node: SVR41047495
-Node: POSIX1048937
-Node: BTL1050323
-Node: POSIX/GNU1051057
-Node: Feature History1056833
-Node: Common Extensions1069924
-Node: Ranges and Locales1071236
-Ref: Ranges and Locales-Footnote-11075853
-Ref: Ranges and Locales-Footnote-21075880
-Ref: Ranges and Locales-Footnote-31076114
-Node: Contributors1076335
-Node: History summary1081760
-Node: Installation1083129
-Node: Gawk Distribution1084080
-Node: Getting1084564
-Node: Extracting1085388
-Node: Distribution contents1087030
-Node: Unix Installation1092800
-Node: Quick Installation1093417
-Node: Additional Configuration Options1095859
-Node: Configuration Philosophy1097597
-Node: Non-Unix Installation1099948
-Node: PC Installation1100406
-Node: PC Binary Installation1101717
-Node: PC Compiling1103565
-Ref: PC Compiling-Footnote-11106564
-Node: PC Testing1106669
-Node: PC Using1107845
-Node: Cygwin1111997
-Node: MSYS1112806
-Node: VMS Installation1113304
-Node: VMS Compilation1114100
-Ref: VMS Compilation-Footnote-11115322
-Node: VMS Dynamic Extensions1115380
-Node: VMS Installation Details1116753
-Node: VMS Running1119005
-Node: VMS GNV1121839
-Node: VMS Old Gawk1122562
-Node: Bugs1123032
-Node: Other Versions1127036
-Node: Installation summary1133260
-Node: Notes1134316
-Node: Compatibility Mode1135181
-Node: Additions1135963
-Node: Accessing The Source1136888
-Node: Adding Code1138324
-Node: New Ports1144502
-Node: Derived Files1148983
-Ref: Derived Files-Footnote-11154458
-Ref: Derived Files-Footnote-21154492
-Ref: Derived Files-Footnote-31155088
-Node: Future Extensions1155202
-Node: Implementation Limitations1155808
-Node: Extension Design1157056
-Node: Old Extension Problems1158210
-Ref: Old Extension Problems-Footnote-11159727
-Node: Extension New Mechanism Goals1159784
-Ref: Extension New Mechanism Goals-Footnote-11163144
-Node: Extension Other Design Decisions1163333
-Node: Extension Future Growth1165439
-Node: Old Extension Mechanism1166275
-Node: Notes summary1168037
-Node: Basic Concepts1169223
-Node: Basic High Level1169904
-Ref: figure-general-flow1170176
-Ref: figure-process-flow1170775
-Ref: Basic High Level-Footnote-11174004
-Node: Basic Data Typing1174189
-Node: Glossary1177517
-Node: Copying1202669
-Node: GNU Free Documentation License1240225
-Node: Index1265361
+Node: Foreword41980
+Node: Preface46327
+Ref: Preface-Footnote-149222
+Ref: Preface-Footnote-249329
+Ref: Preface-Footnote-349562
+Node: History49704
+Node: Names52078
+Ref: Names-Footnote-153172
+Node: This Manual53318
+Ref: This Manual-Footnote-159155
+Node: Conventions59255
+Node: Manual History61600
+Ref: Manual History-Footnote-164676
+Ref: Manual History-Footnote-264717
+Node: How To Contribute64791
+Node: Acknowledgments66030
+Node: Getting Started70778
+Node: Running gawk73212
+Node: One-shot74402
+Node: Read Terminal75627
+Node: Long77654
+Node: Executable Scripts79170
+Ref: Executable Scripts-Footnote-181959
+Node: Comments82061
+Node: Quoting84534
+Node: DOS Quoting90044
+Node: Sample Data Files90719
+Node: Very Simple93312
+Node: Two Rules98203
+Node: More Complex100089
+Node: Statements/Lines102951
+Ref: Statements/Lines-Footnote-1107407
+Node: Other Features107672
+Node: When108603
+Ref: When-Footnote-1110359
+Node: Intro Summary110424
+Node: Invoking Gawk111307
+Node: Command Line112822
+Node: Options113613
+Ref: Options-Footnote-1129379
+Node: Other Arguments129404
+Node: Naming Standard Input132365
+Node: Environment Variables133458
+Node: AWKPATH Variable134016
+Ref: AWKPATH Variable-Footnote-1136868
+Ref: AWKPATH Variable-Footnote-2136913
+Node: AWKLIBPATH Variable137173
+Node: Other Environment Variables137932
+Node: Exit Status141405
+Node: Include Files142080
+Node: Loading Shared Libraries145658
+Node: Obsolete147085
+Node: Undocumented147782
+Node: Invoking Summary148049
+Node: Regexp149715
+Node: Regexp Usage151174
+Node: Escape Sequences153207
+Node: Regexp Operators159307
+Ref: Regexp Operators-Footnote-1166742
+Ref: Regexp Operators-Footnote-2166889
+Node: Bracket Expressions166987
+Ref: table-char-classes169004
+Node: Leftmost Longest171944
+Node: Computed Regexps173246
+Node: GNU Regexp Operators176643
+Node: Case-sensitivity180349
+Ref: Case-sensitivity-Footnote-1183239
+Ref: Case-sensitivity-Footnote-2183474
+Node: Regexp Summary183582
+Node: Reading Files185051
+Node: Records187145
+Node: awk split records187877
+Node: gawk split records192791
+Ref: gawk split records-Footnote-1197330
+Node: Fields197367
+Ref: Fields-Footnote-1200165
+Node: Nonconstant Fields200251
+Ref: Nonconstant Fields-Footnote-1202481
+Node: Changing Fields202683
+Node: Field Separators208615
+Node: Default Field Splitting211319
+Node: Regexp Field Splitting212436
+Node: Single Character Fields215786
+Node: Command Line Field Separator216845
+Node: Full Line Fields220057
+Ref: Full Line Fields-Footnote-1220565
+Node: Field Splitting Summary220611
+Ref: Field Splitting Summary-Footnote-1223742
+Node: Constant Size223843
+Node: Splitting By Content228449
+Ref: Splitting By Content-Footnote-1232522
+Node: Multiple Line232562
+Ref: Multiple Line-Footnote-1238451
+Node: Getline238630
+Node: Plain Getline240841
+Node: Getline/Variable243481
+Node: Getline/File244628
+Node: Getline/Variable/File246012
+Ref: Getline/Variable/File-Footnote-1247613
+Node: Getline/Pipe247700
+Node: Getline/Variable/Pipe250383
+Node: Getline/Coprocess251514
+Node: Getline/Variable/Coprocess252766
+Node: Getline Notes253505
+Node: Getline Summary256297
+Ref: table-getline-variants256709
+Node: Read Timeout257538
+Ref: Read Timeout-Footnote-1261352
+Node: Command-line directories261410
+Node: Input Summary262314
+Node: Input Exercises265566
+Node: Printing266294
+Node: Print268071
+Node: Print Examples269528
+Node: Output Separators272307
+Node: OFMT274325
+Node: Printf275679
+Node: Basic Printf276464
+Node: Control Letters278035
+Node: Format Modifiers282019
+Node: Printf Examples288026
+Node: Redirection290508
+Node: Special FD297239
+Ref: Special FD-Footnote-1300396
+Node: Special Files300470
+Node: Other Inherited Files301086
+Node: Special Network302086
+Node: Special Caveats302947
+Node: Close Files And Pipes303898
+Ref: Close Files And Pipes-Footnote-1311077
+Ref: Close Files And Pipes-Footnote-2311225
+Node: Output Summary311375
+Node: Output Exercises312371
+Node: Expressions313051
+Node: Values314236
+Node: Constants314912
+Node: Scalar Constants315592
+Ref: Scalar Constants-Footnote-1316451
+Node: Nondecimal-numbers316701
+Node: Regexp Constants319701
+Node: Using Constant Regexps320226
+Node: Variables323364
+Node: Using Variables324019
+Node: Assignment Options325929
+Node: Conversion327804
+Node: Strings And Numbers328328
+Ref: Strings And Numbers-Footnote-1331392
+Node: Locale influences conversions331501
+Ref: table-locale-affects334216
+Node: All Operators334804
+Node: Arithmetic Ops335434
+Node: Concatenation337939
+Ref: Concatenation-Footnote-1340758
+Node: Assignment Ops340864
+Ref: table-assign-ops345847
+Node: Increment Ops347125
+Node: Truth Values and Conditions350563
+Node: Truth Values351646
+Node: Typing and Comparison352695
+Node: Variable Typing353488
+Node: Comparison Operators357140
+Ref: table-relational-ops357550
+Node: POSIX String Comparison361065
+Ref: POSIX String Comparison-Footnote-1362137
+Node: Boolean Ops362275
+Ref: Boolean Ops-Footnote-1366754
+Node: Conditional Exp366845
+Node: Function Calls368572
+Node: Precedence372452
+Node: Locales376120
+Node: Expressions Summary377751
+Node: Patterns and Actions380325
+Node: Pattern Overview381445
+Node: Regexp Patterns383124
+Node: Expression Patterns383667
+Node: Ranges387447
+Node: BEGIN/END390553
+Node: Using BEGIN/END391315
+Ref: Using BEGIN/END-Footnote-1394052
+Node: I/O And BEGIN/END394158
+Node: BEGINFILE/ENDFILE396472
+Node: Empty399373
+Node: Using Shell Variables399690
+Node: Action Overview401966
+Node: Statements404293
+Node: If Statement406141
+Node: While Statement407639
+Node: Do Statement409667
+Node: For Statement410809
+Node: Switch Statement413964
+Node: Break Statement416352
+Node: Continue Statement418393
+Node: Next Statement420218
+Node: Nextfile Statement422598
+Node: Exit Statement425228
+Node: Built-in Variables427631
+Node: User-modified428764
+Ref: User-modified-Footnote-1436444
+Node: Auto-set436506
+Ref: Auto-set-Footnote-1449700
+Ref: Auto-set-Footnote-2449905
+Node: ARGC and ARGV449961
+Node: Pattern Action Summary454165
+Node: Arrays456592
+Node: Array Basics457921
+Node: Array Intro458765
+Ref: figure-array-elements460738
+Ref: Array Intro-Footnote-1463262
+Node: Reference to Elements463390
+Node: Assigning Elements465840
+Node: Array Example466331
+Node: Scanning an Array468089
+Node: Controlling Scanning471105
+Ref: Controlling Scanning-Footnote-1476294
+Node: Numeric Array Subscripts476610
+Node: Uninitialized Subscripts478795
+Node: Delete480412
+Ref: Delete-Footnote-1483156
+Node: Multidimensional483213
+Node: Multiscanning486308
+Node: Arrays of Arrays487897
+Node: Arrays Summary492658
+Node: Functions494763
+Node: Built-in495636
+Node: Calling Built-in496714
+Node: Numeric Functions498702
+Ref: Numeric Functions-Footnote-1503526
+Ref: Numeric Functions-Footnote-2503883
+Ref: Numeric Functions-Footnote-3503931
+Node: String Functions504200
+Ref: String Functions-Footnote-1527664
+Ref: String Functions-Footnote-2527793
+Ref: String Functions-Footnote-3528041
+Node: Gory Details528128
+Ref: table-sub-escapes529909
+Ref: table-sub-proposed531429
+Ref: table-posix-sub532793
+Ref: table-gensub-escapes534333
+Ref: Gory Details-Footnote-1535165
+Node: I/O Functions535316
+Ref: I/O Functions-Footnote-1542417
+Node: Time Functions542564
+Ref: Time Functions-Footnote-1553033
+Ref: Time Functions-Footnote-2553101
+Ref: Time Functions-Footnote-3553259
+Ref: Time Functions-Footnote-4553370
+Ref: Time Functions-Footnote-5553482
+Ref: Time Functions-Footnote-6553709
+Node: Bitwise Functions553975
+Ref: table-bitwise-ops554537
+Ref: Bitwise Functions-Footnote-1558845
+Node: Type Functions559014
+Node: I18N Functions560163
+Node: User-defined561808
+Node: Definition Syntax562612
+Ref: Definition Syntax-Footnote-1568018
+Node: Function Example568087
+Ref: Function Example-Footnote-1571004
+Node: Function Caveats571026
+Node: Calling A Function571544
+Node: Variable Scope572499
+Node: Pass By Value/Reference575487
+Node: Return Statement578997
+Node: Dynamic Typing581981
+Node: Indirect Calls582910
+Ref: Indirect Calls-Footnote-1592631
+Node: Functions Summary592759
+Node: Library Functions595458
+Ref: Library Functions-Footnote-1599076
+Ref: Library Functions-Footnote-2599219
+Node: Library Names599390
+Ref: Library Names-Footnote-1602850
+Ref: Library Names-Footnote-2603070
+Node: General Functions603156
+Node: Strtonum Function604184
+Node: Assert Function607204
+Node: Round Function610528
+Node: Cliff Random Function612069
+Node: Ordinal Functions613085
+Ref: Ordinal Functions-Footnote-1616150
+Ref: Ordinal Functions-Footnote-2616402
+Node: Join Function616613
+Ref: Join Function-Footnote-1618384
+Node: Getlocaltime Function618584
+Node: Readfile Function622325
+Node: Data File Management624273
+Node: Filetrans Function624905
+Node: Rewind Function628964
+Node: File Checking630349
+Ref: File Checking-Footnote-1631677
+Node: Empty Files631878
+Node: Ignoring Assigns633857
+Node: Getopt Function635408
+Ref: Getopt Function-Footnote-1646868
+Node: Passwd Functions647071
+Ref: Passwd Functions-Footnote-1655922
+Node: Group Functions656010
+Ref: Group Functions-Footnote-1663913
+Node: Walking Arrays664126
+Node: Library Functions Summary665729
+Node: Library Exercises667130
+Node: Sample Programs668410
+Node: Running Examples669180
+Node: Clones669908
+Node: Cut Program671132
+Node: Egrep Program680862
+Ref: Egrep Program-Footnote-1688366
+Node: Id Program688476
+Node: Split Program692120
+Ref: Split Program-Footnote-1695566
+Node: Tee Program695694
+Node: Uniq Program698481
+Node: Wc Program705902
+Ref: Wc Program-Footnote-1710150
+Node: Miscellaneous Programs710242
+Node: Dupword Program711455
+Node: Alarm Program713486
+Node: Translate Program718290
+Ref: Translate Program-Footnote-1722863
+Ref: Translate Program-Footnote-2723133
+Node: Labels Program723272
+Ref: Labels Program-Footnote-1726621
+Node: Word Sorting726705
+Node: History Sorting730775
+Node: Extract Program732611
+Node: Simple Sed740143
+Node: Igawk Program743205
+Ref: Igawk Program-Footnote-1757531
+Ref: Igawk Program-Footnote-2757732
+Ref: Igawk Program-Footnote-3757854
+Node: Anagram Program757969
+Node: Signature Program761031
+Node: Programs Summary762278
+Node: Programs Exercises763471
+Ref: Programs Exercises-Footnote-1767602
+Node: Advanced Features767693
+Node: Nondecimal Data769641
+Node: Array Sorting771231
+Node: Controlling Array Traversal771928
+Ref: Controlling Array Traversal-Footnote-1780259
+Node: Array Sorting Functions780377
+Ref: Array Sorting Functions-Footnote-1784269
+Node: Two-way I/O784463
+Ref: Two-way I/O-Footnote-1789407
+Ref: Two-way I/O-Footnote-2789593
+Node: TCP/IP Networking789675
+Node: Profiling792552
+Node: Advanced Features Summary800105
+Node: Internationalization802038
+Node: I18N and L10N803518
+Node: Explaining gettext804204
+Ref: Explaining gettext-Footnote-1809233
+Ref: Explaining gettext-Footnote-2809417
+Node: Programmer i18n809582
+Ref: Programmer i18n-Footnote-1814448
+Node: Translator i18n814497
+Node: String Extraction815291
+Ref: String Extraction-Footnote-1816422
+Node: Printf Ordering816508
+Ref: Printf Ordering-Footnote-1819294
+Node: I18N Portability819358
+Ref: I18N Portability-Footnote-1821807
+Node: I18N Example821870
+Ref: I18N Example-Footnote-1824670
+Node: Gawk I18N824742
+Node: I18N Summary825380
+Node: Debugger826719
+Node: Debugging827741
+Node: Debugging Concepts828182
+Node: Debugging Terms830039
+Node: Awk Debugging832614
+Node: Sample Debugging Session833506
+Node: Debugger Invocation834026
+Node: Finding The Bug835410
+Node: List of Debugger Commands841885
+Node: Breakpoint Control843217
+Node: Debugger Execution Control846909
+Node: Viewing And Changing Data850273
+Node: Execution Stack853638
+Node: Debugger Info855276
+Node: Miscellaneous Debugger Commands859293
+Node: Readline Support864485
+Node: Limitations865377
+Node: Debugging Summary867474
+Node: Arbitrary Precision Arithmetic868642
+Node: Computer Arithmetic870058
+Ref: table-numeric-ranges873659
+Ref: Computer Arithmetic-Footnote-1874518
+Node: Math Definitions874575
+Ref: table-ieee-formats877862
+Ref: Math Definitions-Footnote-1878466
+Node: MPFR features878571
+Node: FP Math Caution880240
+Ref: FP Math Caution-Footnote-1881290
+Node: Inexactness of computations881659
+Node: Inexact representation882607
+Node: Comparing FP Values883962
+Node: Errors accumulate885035
+Node: Getting Accuracy886468
+Node: Try To Round889127
+Node: Setting precision890026
+Ref: table-predefined-precision-strings890710
+Node: Setting the rounding mode892504
+Ref: table-gawk-rounding-modes892868
+Ref: Setting the rounding mode-Footnote-1896322
+Node: Arbitrary Precision Integers896501
+Ref: Arbitrary Precision Integers-Footnote-1900284
+Node: POSIX Floating Point Problems900433
+Ref: POSIX Floating Point Problems-Footnote-1904309
+Node: Floating point summary904347
+Node: Dynamic Extensions906539
+Node: Extension Intro908091
+Node: Plugin License909357
+Node: Extension Mechanism Outline910154
+Ref: figure-load-extension910582
+Ref: figure-register-new-function912062
+Ref: figure-call-new-function913066
+Node: Extension API Description915052
+Node: Extension API Functions Introduction916502
+Node: General Data Types921338
+Ref: General Data Types-Footnote-1927025
+Node: Memory Allocation Functions927324
+Ref: Memory Allocation Functions-Footnote-1930154
+Node: Constructor Functions930250
+Node: Registration Functions931984
+Node: Extension Functions932669
+Node: Exit Callback Functions934965
+Node: Extension Version String936213
+Node: Input Parsers936863
+Node: Output Wrappers946678
+Node: Two-way processors951194
+Node: Printing Messages953398
+Ref: Printing Messages-Footnote-1954475
+Node: Updating `ERRNO'954627
+Node: Requesting Values955367
+Ref: table-value-types-returned956095
+Node: Accessing Parameters957053
+Node: Symbol Table Access958284
+Node: Symbol table by name958798
+Node: Symbol table by cookie960778
+Ref: Symbol table by cookie-Footnote-1964917
+Node: Cached values964980
+Ref: Cached values-Footnote-1968484
+Node: Array Manipulation968575
+Ref: Array Manipulation-Footnote-1969673
+Node: Array Data Types969712
+Ref: Array Data Types-Footnote-1972369
+Node: Array Functions972461
+Node: Flattening Arrays976315
+Node: Creating Arrays983202
+Node: Extension API Variables987969
+Node: Extension Versioning988605
+Node: Extension API Informational Variables990506
+Node: Extension API Boilerplate991594
+Node: Finding Extensions995410
+Node: Extension Example995970
+Node: Internal File Description996742
+Node: Internal File Ops1000809
+Ref: Internal File Ops-Footnote-11012467
+Node: Using Internal File Ops1012607
+Ref: Using Internal File Ops-Footnote-11014990
+Node: Extension Samples1015263
+Node: Extension Sample File Functions1016787
+Node: Extension Sample Fnmatch1024389
+Node: Extension Sample Fork1025871
+Node: Extension Sample Inplace1027084
+Node: Extension Sample Ord1028759
+Node: Extension Sample Readdir1029595
+Ref: table-readdir-file-types1030451
+Node: Extension Sample Revout1031262
+Node: Extension Sample Rev2way1031853
+Node: Extension Sample Read write array1032594
+Node: Extension Sample Readfile1034533
+Node: Extension Sample Time1035628
+Node: Extension Sample API Tests1036977
+Node: gawkextlib1037468
+Node: Extension summary1040118
+Node: Extension Exercises1043800
+Node: Language History1044522
+Node: V7/SVR3.11046179
+Node: SVR41048360
+Node: POSIX1049805
+Node: BTL1051194
+Node: POSIX/GNU1051928
+Node: Feature History1057557
+Node: Common Extensions1070648
+Node: Ranges and Locales1071972
+Ref: Ranges and Locales-Footnote-11076611
+Ref: Ranges and Locales-Footnote-21076638
+Ref: Ranges and Locales-Footnote-31076872
+Node: Contributors1077093
+Node: History summary1082633
+Node: Installation1084002
+Node: Gawk Distribution1084953
+Node: Getting1085437
+Node: Extracting1086261
+Node: Distribution contents1087903
+Node: Unix Installation1093673
+Node: Quick Installation1094290
+Node: Additional Configuration Options1096732
+Node: Configuration Philosophy1098470
+Node: Non-Unix Installation1100821
+Node: PC Installation1101279
+Node: PC Binary Installation1102590
+Node: PC Compiling1104438
+Ref: PC Compiling-Footnote-11107437
+Node: PC Testing1107542
+Node: PC Using1108718
+Node: Cygwin1112870
+Node: MSYS1113679
+Node: VMS Installation1114177
+Node: VMS Compilation1114973
+Ref: VMS Compilation-Footnote-11116195
+Node: VMS Dynamic Extensions1116253
+Node: VMS Installation Details1117626
+Node: VMS Running1119878
+Node: VMS GNV1122712
+Node: VMS Old Gawk1123435
+Node: Bugs1123905
+Node: Other Versions1127909
+Node: Installation summary1134133
+Node: Notes1135189
+Node: Compatibility Mode1136054
+Node: Additions1136836
+Node: Accessing The Source1137761
+Node: Adding Code1139197
+Node: New Ports1145369
+Node: Derived Files1149850
+Ref: Derived Files-Footnote-11155325
+Ref: Derived Files-Footnote-21155359
+Ref: Derived Files-Footnote-31155955
+Node: Future Extensions1156069
+Node: Implementation Limitations1156675
+Node: Extension Design1157923
+Node: Old Extension Problems1159077
+Ref: Old Extension Problems-Footnote-11160594
+Node: Extension New Mechanism Goals1160651
+Ref: Extension New Mechanism Goals-Footnote-11164011
+Node: Extension Other Design Decisions1164200
+Node: Extension Future Growth1166308
+Node: Old Extension Mechanism1167144
+Node: Notes summary1168906
+Node: Basic Concepts1170092
+Node: Basic High Level1170773
+Ref: figure-general-flow1171045
+Ref: figure-process-flow1171644
+Ref: Basic High Level-Footnote-11174873
+Node: Basic Data Typing1175058
+Node: Glossary1178386
+Node: Copying1203544
+Node: GNU Free Documentation License1241100
+Node: Index1266236

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 2e7efca5..fd411745 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -708,7 +708,7 @@ particular records in a file and perform operations upon them.
record.
* Nextfile Statement:: Stop processing the current file.
* Exit Statement:: Stop execution of @command{awk}.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* User-modified:: Built-in variables that you change to
control @command{awk}.
* Auto-set:: Built-in variables where @command{awk}
@@ -906,7 +906,6 @@ particular records in a file and perform operations upon them.
* Extension API Description:: A full description of the API.
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
@@ -919,6 +918,7 @@ particular records in a file and perform operations upon them.
* Two-way processors:: Registering a two-way processor.
* Printing Messages:: Functions for printing messages.
* Updating @code{ERRNO}:: Functions for updating @code{ERRNO}.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -957,9 +957,9 @@ particular records in a file and perform operations upon them.
processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to @code{gettimeofday()}
and @code{sleep()}.
+* Extension Sample API Tests:: Tests for the API.
* gawkextlib:: The @code{gawkextlib} project.
* Extension summary:: Extension summary.
* Extension Exercises:: Exercises.
@@ -1570,7 +1570,7 @@ for getting most things done in a program.
@ref{Patterns and Actions},
describes how to write patterns for matching records, actions for
-doing something when a record is matched, and the built-in variables
+doing something when a record is matched, and the predefined variables
@command{awk} and @command{gawk} use.
@ref{Arrays},
@@ -3656,8 +3656,8 @@ The @option{-v} option can only set one variable, but it can be used
more than once, setting another variable each time, like this:
@samp{awk @w{-v foo=1} @w{-v bar=2} @dots{}}.
-@cindex built-in variables, @code{-v} option@comma{} setting with
-@cindex variables, built-in, @code{-v} option@comma{} setting with
+@cindex predefined variables, @code{-v} option@comma{} setting with
+@cindex variables, predefined @code{-v} option@comma{} setting with
@quotation CAUTION
Using @option{-v} to set the values of the built-in
variables may lead to surprising results. @command{awk} will reset the
@@ -6142,7 +6142,7 @@ standard input (by default, this is the keyboard, but often it is a pipe from an
command) or from files whose names you specify on the @command{awk}
command line. If you specify input files, @command{awk} reads them
in order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
+The name of the current input file can be found in the predefined variable
@code{FILENAME}
(@pxref{Built-in Variables}).
@@ -6190,9 +6190,9 @@ used with it do not have to be named on the @command{awk} command line
@cindex @code{FNR} variable
@command{awk} divides the input for your program into records and fields.
It keeps track of the number of records that have been read so far from
-the current input file. This value is stored in a built-in variable
+the current input file. This value is stored in a predefined variable
called @code{FNR} which is reset to zero every time a new file is started.
-Another built-in variable, @code{NR}, records the total number of input
+Another predefined variable, @code{NR}, records the total number of input
records read so far from all @value{DF}s. It starts at zero, but is
never automatically reset to zero.
@@ -6210,7 +6210,7 @@ Records are separated by a character called the @dfn{record separator}.
By default, the record separator is the newline character.
This is why records are, by default, single lines.
A different character can be used for the record separator by
-assigning the character to the built-in variable @code{RS}.
+assigning the character to the predefined variable @code{RS}.
@cindex newlines, as record separators
@cindex @code{RS} variable
@@ -6596,7 +6596,7 @@ field.
@cindex @code{NF} variable
@cindex fields, number of
-@code{NF} is a built-in variable whose value is the number of fields
+@code{NF} is a predefined variable whose value is the number of fields
in the current record. @command{awk} automatically updates the value
of @code{NF} each time it reads a record. No matter how many fields
there are, the last field in a record can be represented by @code{$NF}.
@@ -6954,7 +6954,7 @@ is split into three fields: @samp{m}, @samp{@bullet{}g}, and
Note the leading spaces in the values of the second and third fields.
@cindex troubleshooting, @command{awk} uses @code{FS} not @code{IFS}
-The field separator is represented by the built-in variable @code{FS}.
+The field separator is represented by the predefined variable @code{FS}.
Shell programmers take note: @command{awk} does @emph{not} use the
name @code{IFS} that is used by the POSIX-compliant shells (such as
the Unix Bourne shell, @command{sh}, or Bash).
@@ -7199,7 +7199,7 @@ an uppercase @samp{F} instead of a lowercase @samp{f}. The latter
option (@option{-f}) specifies a file containing an @command{awk} program.
The value used for the argument to @option{-F} is processed in exactly the
-same way as assignments to the built-in variable @code{FS}.
+same way as assignments to the predefined variable @code{FS}.
Any special characters in the field separator must be escaped
appropriately. For example, to use a @samp{\} as the field separator
on the command line, you would have to type:
@@ -8185,7 +8185,7 @@ from the file
@var{file}, and put it in the variable @var{var}. As above, @var{file}
is a string-valued expression that specifies the file from which to read.
-In this version of @code{getline}, none of the built-in variables are
+In this version of @code{getline}, none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is @var{var}.@footnote{This is not quite true. @code{RT} could
be changed if @code{RS} is a regular expression.}
@@ -8347,7 +8347,7 @@ BEGIN @{
@}
@end example
-In this version of @code{getline}, none of the built-in variables are
+In this version of @code{getline}, none of the predefined variables are
changed and the record is not split into fields. However, @code{RT} is set.
@ifinfo
@@ -8409,7 +8409,7 @@ When you use @samp{@var{command} |& getline @var{var}}, the output from
the coprocess @var{command} is sent through a two-way pipe to @code{getline}
and into the variable @var{var}.
-In this version of @code{getline}, none of the built-in variables are
+In this version of @code{getline}, none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is @var{var}.
However, @code{RT} is set.
@@ -8512,9 +8512,9 @@ know that there is a string value to be assigned.
@ref{table-getline-variants}
summarizes the eight variants of @code{getline},
-listing which built-in variables are set by each one,
+listing which predefined variables are set by each one,
and whether the variant is standard or a @command{gawk} extension.
-Note: for each variant, @command{gawk} sets the @code{RT} built-in variable.
+Note: for each variant, @command{gawk} sets the @code{RT} predefined variable.
@float Table,table-getline-variants
@caption{@code{getline} Variants and What They Set}
@@ -8974,7 +8974,7 @@ of items separated by commas. In the output, the items are normally
separated by single spaces. However, this doesn't need to be the case;
a single space is simply the default. Any string of
characters may be used as the @dfn{output field separator} by setting the
-built-in variable @code{OFS}. The initial value of this variable
+predefined variable @code{OFS}. The initial value of this variable
is the string @w{@code{" "}}---that is, a single space.
The output from an entire @code{print} statement is called an
@@ -9050,7 +9050,7 @@ more fully in
@cindexawkfunc{sprintf}
@cindex @code{OFMT} variable
@cindex output, format specifier@comma{} @code{OFMT}
-The built-in variable @code{OFMT} contains the format specification
+The predefined variable @code{OFMT} contains the format specification
that @code{print} uses with @code{sprintf()} when it wants to convert a
number to a string for printing.
The default value of @code{OFMT} is @code{"%.6g"}.
@@ -10227,7 +10227,7 @@ retval = close(command) # syntax error in many Unix awks
The return value is @minus{}1 if the argument names something
that was never opened with a redirection, or if there is
a system problem closing the file or process.
-In these cases, @command{gawk} sets the built-in variable
+In these cases, @command{gawk} sets the predefined variable
@code{ERRNO} to a string describing the problem.
In @command{gawk},
@@ -10283,7 +10283,7 @@ retval = close(command) # syntax error in many Unix awks
The return value is @minus{}1 if the argument names something
that was never opened with a redirection, or if there is
a system problem closing the file or process.
-In these cases, @command{gawk} sets the built-in variable
+In these cases, @command{gawk} sets the predefined variable
@code{ERRNO} to a string describing the problem.
In @command{gawk},
@@ -10776,10 +10776,10 @@ array parameters. @xref{String Functions}.
@cindex variables, initializing
A few variables have special built-in meanings, such as @code{FS} (the
field separator), and @code{NF} (the number of fields in the current input
-record). @xref{Built-in Variables}, for a list of the built-in variables.
-These built-in variables can be used and assigned just like all other
+record). @xref{Built-in Variables}, for a list of the predefined variables.
+These predefined variables can be used and assigned just like all other
variables, but their values are also used or changed automatically by
-@command{awk}. All built-in variables' names are entirely uppercase.
+@command{awk}. All predefined variables' names are entirely uppercase.
Variables in @command{awk} can be assigned either numeric or string values.
The kind of value a variable holds can change over the life of a program.
@@ -10905,7 +10905,7 @@ Strings that can't be interpreted as valid numbers convert to zero.
@cindex @code{CONVFMT} variable
The exact manner in which numbers are converted into strings is controlled
-by the @command{awk} built-in variable @code{CONVFMT} (@pxref{Built-in Variables}).
+by the @command{awk} predefined variable @code{CONVFMT} (@pxref{Built-in Variables}).
Numbers are converted using the @code{sprintf()} function
with @code{CONVFMT} as the format
specifier
@@ -12936,7 +12936,7 @@ program, and occasionally the format for data read as input.
As you have already seen, each @command{awk} statement consists of
a pattern with an associated action. This @value{CHAPTER} describes how
you build patterns and actions, what kinds of things you can do within
-actions, and @command{awk}'s built-in variables.
+actions, and @command{awk}'s predefined variables.
The pattern-action rules and the statements available for use
within actions form the core of @command{awk} programming.
@@ -12951,7 +12951,7 @@ building something useful.
* Action Overview:: What goes into an action.
* Statements:: Describes the various control statements in
detail.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* Pattern Action Summary:: Patterns and Actions summary.
@end menu
@@ -14360,11 +14360,11 @@ results across different operating systems.
@c ENDOFRANGE accs
@node Built-in Variables
-@section Built-in Variables
+@section Predefined Variables
@c STARTOFRANGE bvar
-@cindex built-in variables
+@cindex predefined variables
@c STARTOFRANGE varb
-@cindex variables, built-in
+@cindex variables, predefined
Most @command{awk} variables are available to use for your own
purposes; they never change unless your program assigns values to
@@ -14375,8 +14375,8 @@ to tell @command{awk} how to do certain things. Others are set
automatically by @command{awk}, so that they carry information from the
internal workings of @command{awk} to your program.
-@cindex @command{gawk}, built-in variables and
-This @value{SECTION} documents all of @command{gawk}'s built-in variables,
+@cindex @command{gawk}, predefined variables and
+This @value{SECTION} documents all of @command{gawk}'s predefined variables,
most of which are also documented in the @value{CHAPTER}s describing
their areas of activity.
@@ -14391,7 +14391,7 @@ their areas of activity.
@node User-modified
@subsection Built-in Variables That Control @command{awk}
@c STARTOFRANGE bvaru
-@cindex built-in variables, user-modifiable
+@cindex predefined variables, user-modifiable
@c STARTOFRANGE nmbv
@cindex user-modifiable variables
@@ -14628,9 +14628,9 @@ The default value of @code{TEXTDOMAIN} is @code{"messages"}.
@subsection Built-in Variables That Convey Information
@c STARTOFRANGE bvconi
-@cindex built-in variables, conveying information
+@cindex predefined variables, conveying information
@c STARTOFRANGE vbconi
-@cindex variables, built-in, conveying information
+@cindex variables, predefined conveying information
The following is an alphabetical list of variables that @command{awk}
sets automatically on certain occasions in order to provide
information to your program.
@@ -15305,7 +15305,7 @@ immediately. You may pass an optional numeric value to be used
as @command{awk}'s exit status.
@item
-Some built-in variables provide control over @command{awk}, mainly for I/O.
+Some predefined variables provide control over @command{awk}, mainly for I/O.
Other variables convey information from @command{awk} to your program.
@item
@@ -16099,7 +16099,7 @@ An important aspect to remember about arrays is that @emph{array subscripts
are always strings}. When a numeric value is used as a subscript,
it is converted to a string value before being used for subscripting
(@pxref{Conversion}).
-This means that the value of the built-in variable @code{CONVFMT} can
+This means that the value of the predefined variable @code{CONVFMT} can
affect how your program accesses elements of an array. For example:
@example
@@ -17283,8 +17283,8 @@ for @code{match()}, the order is the same as for the @samp{~} operator:
@cindex @code{RSTART} variable, @code{match()} function and
@cindex @code{RLENGTH} variable, @code{match()} function and
@cindex @code{match()} function, @code{RSTART}/@code{RLENGTH} variables
-The @code{match()} function sets the built-in variable @code{RSTART} to
-the index. It also sets the built-in variable @code{RLENGTH} to the
+The @code{match()} function sets the predefined variable @code{RSTART} to
+the index. It also sets the predefined variable @code{RLENGTH} to the
length in characters of the matched substring. If no match is found,
@code{RSTART} is set to zero, and @code{RLENGTH} to @minus{}1.
@@ -19273,7 +19273,7 @@ the call.
A function cannot have two parameters with the same name, nor may it
have a parameter with the same name as the function itself.
In addition, according to the POSIX standard, function parameters
-cannot have the same name as one of the special built-in variables
+cannot have the same name as one of the special predefined variables
(@pxref{Built-in Variables}). Not all versions of @command{awk} enforce
this restriction.
@@ -20521,7 +20521,7 @@ example, @code{getopt()}'s @code{Opterr} and @code{Optind} variables
(@pxref{Getopt Function}).
The leading capital letter indicates that it is global, while the fact that
the variable name is not all capital letters indicates that the variable is
-not one of @command{awk}'s built-in variables, such as @code{FS}.
+not one of @command{awk}'s predefined variables, such as @code{FS}.
@cindex @option{--dump-variables} option, using for library functions
It is also important that @emph{all} variables in library
@@ -23435,7 +23435,7 @@ and the file transition library program
The program begins with a descriptive comment and then a @code{BEGIN} rule
that processes the command-line arguments with @code{getopt()}. The @option{-i}
(ignore case) option is particularly easy with @command{gawk}; we just use the
-@code{IGNORECASE} built-in variable
+@code{IGNORECASE} predefined variable
(@pxref{Built-in Variables}):
@cindex @code{egrep.awk} program
@@ -27337,11 +27337,13 @@ using regular pipes.
@ @ @ @ and no-one can talk to host that's close,@*
@ @ @ @ unless the host that isn't close@*
@ @ @ @ is busy, hung, or dead.}
+@author Mike O'Brien (aka Mr.@: Protocol)
@end quotation
@end ifnotdocbook
@docbook
<blockquote>
+<attribution>Mike O'Brien (aka Mr.&nbsp;Protocol)</attribution>
<literallayout class="normal"><literal>EMISTERED</literal>:
&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>A host is a host from coast to coast,</emphasis>
&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>and no-one can talk to host that's close,</emphasis>
@@ -27516,9 +27518,9 @@ in the morning to work.)
@cindex @code{BEGIN} pattern, and profiling
@cindex @code{END} pattern, and profiling
@example
- # gawk profile, created Thu Feb 27 05:16:21 2014
+ # gawk profile, created Mon Sep 29 05:16:21 2014
- # BEGIN block(s)
+ # BEGIN rule(s)
BEGIN @{
1 print "First BEGIN rule"
@@ -27545,7 +27547,7 @@ in the morning to work.)
@}
@}
- # END block(s)
+ # END rule(s)
END @{
1 print "First END rule"
@@ -27673,7 +27675,7 @@ come out as:
@end example
@noindent
-which is correct, but possibly surprising.
+which is correct, but possibly unexpected.
@cindex profiling @command{awk} programs, dynamically
@cindex @command{gawk} program, dynamic profiling
@@ -27705,7 +27707,7 @@ $ @kbd{kill -USR1 13992}
@noindent
As usual, the profiled version of the program is written to
-@file{awkprof.out}, or to a different file if one specified with
+@file{awkprof.out}, or to a different file if one was specified with
the @option{--profile} option.
Along with the regular profile, as shown earlier, the profile file
@@ -27765,6 +27767,7 @@ The @option{--non-decimal-data} option causes @command{gawk} to treat
octal- and hexadecimal-looking input data as octal and hexadecimal.
This option should be used with caution or not at all; use of @code{strtonum()}
is preferable.
+Note that this option may disappear in a future version of @command{gawk}.
@item
You can take over complete control of sorting in @samp{for (@var{indx} in @var{array})}
@@ -27784,9 +27787,9 @@ or @code{printf}. Use @code{close()} to close off the coprocess completely, or
optionally, close off one side of the two-way communications.
@item
-By using special ``@value{FN}s'' with the @samp{|&} operator, you can open a
+By using special @value{FN}s with the @samp{|&} operator, you can open a
TCP/IP (or UDP/IP) connection to remote hosts in the Internet. @command{gawk}
-supports both IPv4 an IPv6.
+supports both IPv4 and IPv6.
@item
You can generate statement count profiles of your program. This can help you
@@ -28024,7 +28027,7 @@ In June 2001 Bruno Haible wrote:
This information is accessed via the
POSIX character classes in regular expressions,
such as @code{/[[:alnum:]]/}
-(@pxref{Regexp Operators}).
+(@pxref{Bracket Expressions}).
@cindex monetary information, localization
@cindex currency symbols, localization
@@ -28107,7 +28110,7 @@ default arguments.
Return the plural form used for @var{number} of the
translation of @var{string1} and @var{string2} in text domain
@var{domain} for locale category @var{category}. @var{string1} is the
-English singular variant of a message, and @var{string2} the English plural
+English singular variant of a message, and @var{string2} is the English plural
variant of the same message.
The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
The default value for @var{category} is @code{"LC_MESSAGES"}.
@@ -28195,9 +28198,11 @@ This example would be better done with @code{dcngettext()}:
@example
if (groggy)
- message = dcngettext("%d customer disturbing me\n", "%d customers disturbing me\n", "adminprog")
+ message = dcngettext("%d customer disturbing me\n",
+ "%d customers disturbing me\n", "adminprog")
else
- message = dcngettext("enjoying %d customer\n", "enjoying %d customers\n", "adminprog")
+ message = dcngettext("enjoying %d customer\n",
+ "enjoying %d customers\n", "adminprog")
printf(message, ncustomers)
@end example
@@ -28269,7 +28274,7 @@ First, use the @option{--gen-pot} command-line option to create
the initial @file{.pot} file:
@example
-$ @kbd{gawk --gen-pot -f guide.awk > guide.pot}
+gawk --gen-pot -f guide.awk > guide.pot
@end example
@cindex @code{xgettext} utility
@@ -28333,11 +28338,11 @@ example, @samp{string} is the first argument and @samp{length(string)} is the se
@example
$ @kbd{gawk 'BEGIN @{}
-> @kbd{string = "Dont Panic"}
+> @kbd{string = "Don\47t Panic"}
> @kbd{printf "%2$d characters live in \"%1$s\"\n",}
> @kbd{string, length(string)}
> @kbd{@}'}
-@print{} 10 characters live in "Dont Panic"
+@print{} 11 characters live in "Don't Panic"
@end example
If present, positional specifiers come first in the format specification,
@@ -28549,7 +28554,8 @@ msgstr "Like, the scoop is"
@cindex GNU/Linux
The next step is to make the directory to hold the binary message object
file and then to create the @file{guide.mo} file.
-We pretend that our file is to be used in the @code{en_US.UTF-8} locale.
+We pretend that our file is to be used in the @code{en_US.UTF-8} locale,
+since we have to use a locale name known to the C @command{gettext} routines.
The directory layout shown here is standard for GNU @command{gettext} on
GNU/Linux systems. Other versions of @command{gettext} may use a different
layout:
@@ -28570,8 +28576,8 @@ $ @kbd{mkdir en_US.UTF-8 en_US.UTF-8/LC_MESSAGES}
The @command{msgfmt} utility does the conversion from human-readable
@file{.po} file to machine-readable @file{.mo} file.
By default, @command{msgfmt} creates a file named @file{messages}.
-This file must be renamed and placed in the proper directory so that
-@command{gawk} can find it:
+This file must be renamed and placed in the proper directory (using
+the @option{-o} option) so that @command{gawk} can find it:
@example
$ @kbd{msgfmt guide-mellow.po -o en_US.UTF-8/LC_MESSAGES/guide.mo}
@@ -28614,8 +28620,8 @@ complete detail in
@cite{GNU gettext tools}}.)
@end ifnotinfo
As of this writing, the latest version of GNU @command{gettext} is
-@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz,
-@value{PVERSION} 0.19.1}.
+@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.2.tar.gz,
+@value{PVERSION} 0.19.2}.
If a translation of @command{gawk}'s messages exists,
then @command{gawk} produces usage messages, warnings,
@@ -28703,7 +28709,7 @@ the discussion of debugging in @command{gawk}.
@subsection Debugging in General
(If you have used debuggers in other languages, you may want to skip
-ahead to the next section on the specific features of the @command{awk}
+ahead to the next section on the specific features of the @command{gawk}
debugger.)
Of course, a debugging program cannot remove bugs for you, since it has
@@ -28743,7 +28749,7 @@ is going wrong (or, for that matter, to better comprehend a perfectly
functional program that you or someone else wrote).
@node Debugging Terms
-@subsection Additional Debugging Concepts
+@subsection Debugging Concepts
Before diving in to the details, we need to introduce several
important concepts that apply to just about all debuggers.
@@ -28832,8 +28838,8 @@ as our example.
@cindex starting the debugger
@cindex debugger, how to start
-Starting the debugger is almost exactly like running @command{gawk},
-except you have to pass an additional option @option{--debug} or the
+Starting the debugger is almost exactly like running @command{gawk} normally,
+except you have to pass an additional option @option{--debug}, or the
corresponding short option @option{-D}. The file(s) containing the
program and any supporting code are given on the command line as arguments
to one or more @option{-f} options. (@command{gawk} is not designed
@@ -28851,6 +28857,7 @@ this syntax is slightly different from what they are used to.
With the @command{gawk} debugger, you give the arguments for running the program
in the command line to the debugger rather than as part of the @code{run}
command at the debugger prompt.)
+The @option{-1} is an option to @file{uniq.awk}.
Instead of immediately running the program on @file{inputfile}, as
@command{gawk} would ordinarily do, the debugger merely loads all
@@ -29032,7 +29039,7 @@ gawk> @kbd{p n m alast aline}
This is kind of disappointing, though. All we found out is that there
are five elements in @code{alast}; @code{m} and @code{aline} don't have
-values yet since we are at line 68 but haven't executed it yet.
+values since we are at line 68 but haven't executed it yet.
This information is useful enough (we now know that
none of the words were accidentally left out), but what if we want to see
inside the array?
@@ -29225,7 +29232,8 @@ Delete breakpoint(s) set at entry to function @var{function}.
@cindex breakpoint condition
@item @code{condition} @var{n} @code{"@var{expression}"}
Add a condition to existing breakpoint or watchpoint @var{n}. The
-condition is an @command{awk} expression that the debugger evaluates
+condition is an @command{awk} expression @emph{enclosed in double quotes}
+that the debugger evaluates
whenever the breakpoint or watchpoint is reached. If the condition is true, then
the debugger stops execution and prompts for a command. Otherwise,
the debugger continues executing the program. If the condition expression is
@@ -29413,7 +29421,7 @@ see the output shown under @code{dump} in @ref{Miscellaneous Debugger Commands}.
@item @code{until} [[@var{filename}@code{:}]@var{n} | @var{function}]
@itemx @code{u} [[@var{filename}@code{:}]@var{n} | @var{function}]
Without any argument, continue execution until a line past the current
-line in current stack frame is reached. With an argument,
+line in the current stack frame is reached. With an argument,
continue execution until the specified location is reached, or the current
stack frame returns.
@end table
@@ -29477,7 +29485,7 @@ gawk> @kbd{print $3}
@noindent
This prints the third field in the input record (if the specified field does not
exist, it prints @samp{Null field}). A variable can be an array element, with
-the subscripts being constant values. To print the contents of an array,
+the subscripts being constant string values. To print the contents of an array,
prefix the name of the array with the @samp{@@} symbol:
@example
@@ -29543,7 +29551,7 @@ watch list.
@end table
@node Execution Stack
-@subsection Dealing with the Stack
+@subsection Working with the Stack
Whenever you run a program which contains any function calls,
@command{gawk} maintains a stack of all of the function calls leading up
@@ -29554,16 +29562,22 @@ functions which called the one you are in. The commands for doing this are:
@table @asis
@cindex debugger commands, @code{bt} (@code{backtrace})
@cindex debugger commands, @code{backtrace}
+@cindex debugger commands, @code{where} (@code{backtrace})
@cindex @code{backtrace} debugger command
@cindex @code{bt} debugger command (alias for @code{backtrace})
+@cindex @code{where} debugger command
+@cindex @code{where} debugger command (alias for @code{backtrace})
@cindex call stack, display in debugger
@cindex traceback, display in debugger
@item @code{backtrace} [@var{count}]
@itemx @code{bt} [@var{count}]
+@itemx @code{where} [@var{count}]
Print a backtrace of all function calls (stack frames), or innermost @var{count}
frames if @var{count} > 0. Print the outermost @var{count} frames if
@var{count} < 0. The backtrace displays the name and arguments to each
function, the source @value{FN}, and the line number.
+The alias @code{where} for @code{backtrace} is provided for long-time
+GDB users who may be used to that command.
@cindex debugger commands, @code{down}
@cindex @code{down} debugger command
@@ -29613,7 +29627,7 @@ The value for @var{what} should be one of the following:
@table @code
@item args
@cindex show function arguments, in debugger
-Arguments of the selected frame.
+List arguments of the selected frame.
@item break
@cindex show breakpoints
@@ -29625,7 +29639,7 @@ List all items in the automatic display list.
@item frame
@cindex describe call stack frame, in debugger
-Description of the selected stack frame.
+Give a description of the selected stack frame.
@item functions
@cindex list function definitions, in debugger
@@ -29634,11 +29648,11 @@ line numbers.
@item locals
@cindex show local variables, in debugger
-Local variables of the selected frame.
+List local variables of the selected frame.
@item source
@cindex show name of current source file, in debugger
-The name of the current source file. Each time the program stops, the
+Print the name of the current source file. Each time the program stops, the
current source file is the file containing the current instruction.
When the debugger first starts, the current source file is the first file
included via the @option{-f} option. The
@@ -29755,6 +29769,7 @@ commands in a program. This can be very enlightening, as the following
partial dump of Davide Brini's obfuscated code
(@pxref{Signature Program}) demonstrates:
+@c FIXME: This will need updating if num-handler branch is ever merged in.
@smallexample
gawk> @kbd{dump}
@print{} # BEGIN
@@ -29828,7 +29843,7 @@ are as follows:
@c nested table
@table @asis
-@item @code{-}
+@item @code{-} (Minus)
Print lines before the lines last printed.
@item @code{+}
@@ -29916,7 +29931,7 @@ and
@end table
@node Limitations
-@section Limitations and Future Plans
+@section Limitations
We hope you find the @command{gawk} debugger useful and enjoyable to work with,
but as with any program, especially in its early releases, it still has
@@ -29964,8 +29979,10 @@ executing, short programs.
The @command{gawk} debugger only accepts source supplied with the @option{-f} option.
@end itemize
+@ignore
Look forward to a future release when these and other missing features may
be added, and of course feel free to try to add them yourself!
+@end ignore
@node Debugging Summary
@section Summary
@@ -30008,9 +30025,8 @@ and editing.
@cindex floating-point, numbers@comma{} arbitrary precision
This @value{CHAPTER} introduces some basic concepts relating to
-how computers do arithmetic and briefly lists the features in
-@command{gawk} for performing arbitrary precision floating point
-computations. It then proceeds to describe floating-point arithmetic,
+how computers do arithmetic and defines some important terms.
+It then proceeds to describe floating-point arithmetic,
which is what @command{awk} uses for all its computations, including a
discussion of arbitrary precision floating point arithmetic, which is
a feature available only in @command{gawk}. It continues on to present
@@ -30105,8 +30121,10 @@ Computers work with integer and floating point values of different
ranges. Integer values are usually either 32 or 64 bits in size. Single
precision floating point values occupy 32 bits, whereas double precision
floating point values occupy 64 bits. Floating point values are always
-signed. The possible ranges of values are shown in the following table.
+signed. The possible ranges of values are shown in @ref{table-numeric-ranges}.
+@float Table,table-numeric-ranges
+@caption{Value Ranges for Different Numeric Representations}
@multitable @columnfractions .34 .33 .33
@headitem Numeric representation @tab Miniumum value @tab Maximum value
@item 32-bit signed integer @tab @minus{}2,147,483,648 @tab 2,147,483,647
@@ -30116,6 +30134,7 @@ signed. The possible ranges of values are shown in the following table.
@item Single precision floating point (approximate) @tab @code{1.175494e-38} @tab @code{3.402823e+38}
@item Double precision floating point (approximate) @tab @code{2.225074e-308} @tab @code{1.797693e+308}
@end multitable
+@end float
@node Math Definitions
@section Other Stuff To Know
@@ -30143,14 +30162,12 @@ A special value representing infinity. Operations involving another
number and infinity produce infinity.
@item NaN
-``Not A Number.''@footnote{Thanks
-to Michael Brennan for this description, which I have paraphrased, and
-for the examples}.
-A special value that results from attempting a
-calculation that has no answer as a real number. In such a case,
-programs can either receive a floating-point exception, or get @code{NaN}
-back as the result. The IEEE 754 standard recommends that systems return
-@code{NaN}. Some examples:
+``Not A Number.''@footnote{Thanks to Michael Brennan for this description,
+which we have paraphrased, and for the examples.} A special value that
+results from attempting a calculation that has no answer as a real number.
+In such a case, programs can either receive a floating-point exception,
+or get @code{NaN} back as the result. The IEEE 754 standard recommends
+that systems return @code{NaN}. Some examples:
@table @code
@item sqrt(-1)
@@ -30224,9 +30241,9 @@ to allow greater precisions and larger exponent ranges.
field values for the basic IEEE 754 binary formats:
@float Table,table-ieee-formats
-@caption{Basic IEEE Format Context Values}
+@caption{Basic IEEE Format Values}
@multitable @columnfractions .20 .20 .20 .20 .20
-@headitem Name @tab Total bits @tab Precision @tab emin @tab emax
+@headitem Name @tab Total bits @tab Precision @tab Minimum exponent @tab Maximum exponent
@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
@item Double @tab 64 @tab 53 @tab @minus{}1022 @tab +1023
@item Quadruple @tab 128 @tab 113 @tab @minus{}16382 @tab +16383
@@ -30241,16 +30258,16 @@ one extra bit of significand.
@node MPFR features
@section Arbitrary Precison Arithmetic Features In @command{gawk}
-By default, @command{gawk} uses the double precision floating point values
+By default, @command{gawk} uses the double precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do, @command{gawk} uses the @uref{http://www.mpfr.org, GNU
-MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for arbitrary
+compiled to do so, @command{gawk} uses the @uref{http://www.mpfr.org
+GNU MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for arbitrary
precision arithmetic on numbers. You can see if MPFR support is available
like so:
@example
$ @kbd{gawk --version}
-@print{} GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
+@print{} GNU Awk 4.1.2, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
@print{} Copyright (C) 1989, 1991-2014 Free Software Foundation.
@dots{}
@end example
@@ -30270,11 +30287,12 @@ results. With the @option{-M} command-line option,
all floating-point arithmetic operators and numeric functions
can yield results to any desired precision level supported by MPFR.
-Two built-in variables, @code{PREC} and @code{ROUNDMODE},
+Two predefined variables, @code{PREC} and @code{ROUNDMODE},
provide control over the working precision and the rounding mode.
The precision and the rounding mode are set globally for every operation
to follow.
-@xref{Auto-set}, for more information.
+@xref{Setting precision}, and @ref{Setting the rounding mode},
+for more information.
@node FP Math Caution
@section Floating Point Arithmetic: Caveat Emptor!
@@ -30388,6 +30406,10 @@ else
# not ok
@end example
+@noindent
+(We assume that you have a simple absolute value function named
+@code{abs()} defined elsewhere in your program.)
+
@node Errors accumulate
@subsubsection Errors Accumulate
@@ -30474,7 +30496,7 @@ It is easy to forget that the finite number of bits used to store the value
is often just an approximation after proper rounding.
The test for equality succeeds if and only if @emph{all} bits in the two operands
are exactly the same. Since this is not necessarily true after floating-point
-computations with a particular precision and effective rounding rule,
+computations with a particular precision and effective rounding mode,
a straight test for equality may not work. Instead, compare the
two numbers to see if they are within the desirable delta of each other.
@@ -30541,7 +30563,7 @@ $ @kbd{gawk -f pi2.awk}
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 you can
-modify using the built-in variable @code{PREC}. You can also set the
+modify using the predefined 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.
@@ -30573,7 +30595,7 @@ Be wary of floating-point constants! When reading a floating-point
constant 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}
+internally as an MPFR number. Changing the precision using @code{PREC}
in the program text does @emph{not} change the precision of a constant.
If you need to represent a floating-point constant at a higher precision
@@ -30711,15 +30733,15 @@ the following computes
5<superscript>4<superscript>3<superscript>2</superscript></superscript></superscript>, @c
@end docbook
the result of which is beyond the
-limits of ordinary hardware double-precision floating point values:
+limits of ordinary hardware double precision floating point values:
@example
$ @kbd{gawk -M 'BEGIN @{}
> @kbd{x = 5^4^3^2}
-> @kbd{print "# of digits =", length(x)}
+> @kbd{print "number of digits =", length(x)}
> @kbd{print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20)}
> @kbd{@}'}
-@print{} # of digits = 183231
+@print{} number of digits = 183231
@print{} 62060698786608744707 ... 92256259918212890625
@end example
@@ -30942,7 +30964,7 @@ Thus @samp{+nan} and @samp{+NaN} are the same.
@itemize @value{BULLET}
@item
Most computer arithmetic is done using either integers or floating-point
-values. The default for @command{awk} is to use double-precision
+values. Standard @command{awk} uses double precision
floating-point values.
@item
@@ -31061,7 +31083,7 @@ Extensions are written in C or C++, using the @dfn{Application Programming
Interface} (API) defined for this purpose by the @command{gawk}
developers. The rest of this @value{CHAPTER} explains
the facilities that the API provides and how to use
-them, and presents a small sample extension. In addition, it documents
+them, and presents a small example extension. In addition, it documents
the sample extensions included in the @command{gawk} distribution,
and describes the @code{gawkextlib} project.
@ifclear FOR_PRINT
@@ -31077,10 +31099,14 @@ goals and design.
@node Plugin License
@section Extension Licensing
-Every dynamic extension should define the global symbol
-@code{plugin_is_GPL_compatible} to assert that it has been licensed under
-a GPL-compatible license. If this symbol does not exist, @command{gawk}
-emits a fatal error and exits when it tries to load your extension.
+Every dynamic extension must be distributed under a license that is
+compatible with the GNU GPL (@pxref{Copying}).
+
+In order for the extension to tell @command{gawk} that it is
+properly licensed, the extension must define the global symbol
+@code{plugin_is_GPL_compatible}. If this symbol does not exist,
+@command{gawk} emits a fatal error and exits when it tries to load
+your extension.
The declared type of the symbol should be @code{int}. It does not need
to be in any allocated section, though. The code merely asserts that
@@ -31095,7 +31121,7 @@ int plugin_is_GPL_compatible;
Communication between
@command{gawk} and an extension is two-way. First, when an extension
-is loaded, it is passed a pointer to a @code{struct} whose fields are
+is loaded, @command{gawk} passes it a pointer to a @code{struct} whose fields are
function pointers.
@ifnotdocbook
This is shown in @ref{figure-load-extension}.
@@ -31131,29 +31157,29 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-load-extension"/>}.
The extension can call functions inside @command{gawk} through these
function pointers, at runtime, without needing (link-time) access
to @command{gawk}'s symbols. One of these function pointers is to a
-function for ``registering'' new built-in functions.
+function for ``registering'' new functions.
@ifnotdocbook
-This is shown in @ref{figure-load-new-function}.
+This is shown in @ref{figure-register-new-function}.
@end ifnotdocbook
@ifdocbook
-This is shown in @inlineraw{docbook, <xref linkend="figure-load-new-function"/>}.
+This is shown in @inlineraw{docbook, <xref linkend="figure-register-new-function"/>}.
@end ifdocbook
@ifnotdocbook
-@float Figure,figure-load-new-function
-@caption{Loading The New Function}
+@float Figure,figure-register-new-function
+@caption{Registering A New Function}
@ifinfo
-@center @image{api-figure2, , , Loading The New Function, txt}
+@center @image{api-figure2, , , Registering A New Function, txt}
@end ifinfo
@ifnotinfo
-@center @image{api-figure2, , , Loading The New Function}
+@center @image{api-figure2, , , Registering A New Function}
@end ifnotinfo
@end float
@end ifnotdocbook
@docbook
-<figure id="figure-load-new-function" float="0">
-<title>Loading The New Function</title>
+<figure id="figure-register-new-function" float="0">
+<title>Registering A New Function</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure2.png" format="PNG"/></imageobject>
</mediaobject>
@@ -31203,8 +31229,8 @@ 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
-see this in the sample extensions @file{filefuncs.c} (@pxref{Extension
-Example}) and also the @file{testext.c} code for testing the APIs.
+see this in the sample extension @file{filefuncs.c} (@pxref{Extension
+Example}) and also in the @file{testext.c} code for testing the APIs.
Some other bits and pieces:
@@ -31238,13 +31264,13 @@ This (rather large) @value{SECTION} describes the API in detail.
@menu
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
@command{gawk}.
* Printing Messages:: Functions for printing messages.
* Updating @code{ERRNO}:: Functions for updating @code{ERRNO}.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -31263,6 +31289,9 @@ API function pointers are provided for the following kinds of operations:
@itemize @value{BULLET}
@item
+Allocating, reallocating, and releasing memory.
+
+@item
Registration functions. You may register:
@itemize @value{MINUS}
@item
@@ -31295,9 +31324,6 @@ Symbol table access: retrieving a global variable, creating one,
or changing one.
@item
-Allocating, reallocating, and releasing memory.
-
-@item
Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and
can be a big performance win.
@@ -31365,8 +31391,8 @@ does not support this keyword, you should either place
All pointers filled in by @command{gawk} point to memory
managed by @command{gawk} and should be treated by the extension as
read-only. Memory for @emph{all} strings passed into @command{gawk}
-from the extension @emph{must} come from calling the API-provided function
-pointers @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()},
+from the extension @emph{must} come from calling one of
+@code{gawk_malloc()}, @code{gawk_calloc()} or @code{gawk_realloc()},
and is managed by @command{gawk} from then on.
@item
@@ -31386,7 +31412,7 @@ and also how characters are likely to be input and output from files.
@item
When retrieving a value (such as a parameter or that of a global variable
or array element), the extension requests a specific type (number, string,
-scalars, value cookie, array, or ``undefined''). When the request is
+scalar, value cookie, array, or ``undefined''). When the request is
``undefined,'' the returned value will have the real underlying type.
However, if the request and actual type don't match, the access function
@@ -31449,8 +31475,8 @@ A simple boolean type.
This represents a mutable string. @command{gawk}
owns the memory pointed to if it supplied
the value. Otherwise, it takes ownership of the memory pointed to.
-@strong{Such memory must come from calling the API-provided function
-pointers @code{api_malloc()}, @code{api_calloc()}, or @code{api_realloc()}!}
+@strong{Such memory must come from calling one of the
+@code{gawk_malloc()}, @code{gawk_calloc()}, or @code{gawk_realloc()} functions!}
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -31545,7 +31571,7 @@ the cookie for getting the variable's value or for changing the variable's
value.
This is the @code{awk_scalar_t} type and @code{scalar_cookie} macro.
Given a scalar cookie, @command{gawk} can directly retrieve or
-modify the value, as required, without having to first find it.
+modify the value, as required, without having to find it first.
The @code{awk_value_cookie_t} type and @code{value_cookie} macro are similar.
If you know that you wish to
@@ -31555,149 +31581,6 @@ and then pass in that value cookie whenever you wish to set the value of a
variable. This saves both storage space within the running @command{gawk}
process as well as the time needed to create the value.
-@node Requesting Values
-@subsection Requesting Values
-
-All of the functions that return values from @command{gawk}
-work in the same way. You pass in an @code{awk_valtype_t} value
-to indicate what kind of value you expect. If the actual value
-matches what you requested, the function returns true and fills
-in the @code{awk_value_t} result.
-Otherwise, the function returns false, and the @code{val_type}
-member indicates the type of the actual value. You may then
-print an error message, or reissue the request for the actual
-value type, as appropriate. This behavior is summarized in
-@ref{table-value-types-returned}.
-
-@c FIXME: Try to do this with spans...
-
-@float Table,table-value-types-returned
-@caption{API Value Types Returned}
-@docbook
-<informaltable>
-<tgroup cols="2">
- <colspec colwidth="50*"/><colspec colwidth="50*"/>
- <thead>
- <row><entry></entry><entry><para>Type of Actual Value:</para></entry></row>
- </thead>
- <tbody>
- <row><entry></entry><entry></entry></row>
- </tbody>
-</tgroup>
-<tgroup cols="6">
- <colspec colwidth="16.6*"/>
- <colspec colwidth="16.6*"/>
- <colspec colwidth="19.8*"/>
- <colspec colwidth="15*"/>
- <colspec colwidth="15*"/>
- <colspec colwidth="16.6*"/>
- <thead>
- <row>
- <entry></entry>
- <entry></entry>
- <entry><para>String</para></entry>
- <entry><para>Number</para></entry>
- <entry><para>Array</para></entry>
- <entry><para>Undefined</para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">String</emphasis></para></entry>
- <entry><para>String</para></entry>
- <entry><para>String</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">Number</emphasis></para></entry>
- <entry><para>Number if can be converted, else false</para></entry>
- <entry><para>Number</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry><para><emphasis role="bold">Type</emphasis></para></entry>
- <entry><para><emphasis role="bold">Array</emphasis></para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- <entry><para>Array</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry><para><emphasis role="bold">Requested:</emphasis></para></entry>
- <entry><para><emphasis role="bold">Scalar</emphasis></para></entry>
- <entry><para>Scalar</para></entry>
- <entry><para>Scalar</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">Undefined</emphasis></para></entry>
- <entry><para>String</para></entry>
- <entry><para>Number</para></entry>
- <entry><para>Array</para></entry>
- <entry><para>Undefined</para></entry>
- </row>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">Value Cookie</emphasis></para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para>
- </entry><entry><para>false</para></entry>
- </row>
- </tbody>
-</tgroup>
-</informaltable>
-@end docbook
-
-@ifnotplaintext
-@ifnotdocbook
-@multitable @columnfractions .50 .50
-@headitem @tab Type of Actual Value:
-@end multitable
-@multitable @columnfractions .166 .166 .198 .15 .15 .166
-@headitem @tab @tab String @tab Number @tab Array @tab Undefined
-@item @tab @b{String} @tab String @tab String @tab false @tab false
-@item @tab @b{Number} @tab Number if can be converted, else false @tab Number @tab false @tab false
-@item @b{Type} @tab @b{Array} @tab false @tab false @tab Array @tab false
-@item @b{Requested:} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
-@item @tab @b{Undefined} @tab String @tab Number @tab Array @tab Undefined
-@item @tab @b{Value Cookie} @tab false @tab false @tab false @tab false
-@end multitable
-@end ifnotdocbook
-@end ifnotplaintext
-@ifplaintext
-@example
- +-------------------------------------------------+
- | Type of Actual Value: |
- +------------+------------+-----------+-----------+
- | String | Number | Array | Undefined |
-+-----------+-----------+------------+------------+-----------+-----------+
-| | String | String | String | false | false |
-| |-----------+------------+------------+-----------+-----------+
-| | Number | Number if | Number | false | false |
-| | | can be | | | |
-| | | converted, | | | |
-| | | else false | | | |
-| |-----------+------------+------------+-----------+-----------+
-| Type | Array | false | false | Array | false |
-| Requested |-----------+------------+------------+-----------+-----------+
-| | Scalar | Scalar | Scalar | false | false |
-| |-----------+------------+------------+-----------+-----------+
-| | Undefined | String | Number | Array | Undefined |
-| |-----------+------------+------------+-----------+-----------+
-| | Value | false | false | false | false |
-| | Cookie | | | | |
-+-----------+-----------+------------+------------+-----------+-----------+
-@end example
-@end ifplaintext
-@end float
-
@node Memory Allocation Functions
@subsection Memory Allocation Functions and Convenience Macros
@cindex allocating memory for extensions
@@ -31706,22 +31589,24 @@ value type, as appropriate. This behavior is summarized in
The API provides a number of @dfn{memory allocation} functions for
allocating memory that can be passed to @command{gawk}, as well as a number of
convenience macros.
+This @value{SUBSECTION} presents them all as function prototypes, in
+the way that extension code would use them.
@table @code
@item void *gawk_malloc(size_t size);
-Call @command{gawk}-provided @code{api_malloc()} to allocate storage that may
+Call the correct version of @code{malloc()} to allocate storage that may
be passed to @command{gawk}.
@item void *gawk_calloc(size_t nmemb, size_t size);
-Call @command{gawk}-provided @code{api_calloc()} to allocate storage that may
+Call the correct version of @code{calloc()} to allocate storage that may
be passed to @command{gawk}.
@item void *gawk_realloc(void *ptr, size_t size);
-Call @command{gawk}-provided @code{api_realloc()} to allocate storage that may
+Call the correct version of @code{realloc()} to allocate storage that may
be passed to @command{gawk}.
@item void gawk_free(void *ptr);
-Call @command{gawk}-provided @code{api_free()} to release storage that was
+Call the correct version of @code{free()} to release storage that was
allocated with @code{gawk_malloc()}, @code{gawk_calloc()} or @code{gawk_realloc()}.
@end table
@@ -31735,8 +31620,8 @@ unrelated version of @code{malloc()}, unexpected behavior would
likely result.
Two convenience macros may be used for allocating storage
-from the API-provided function pointers @code{api_malloc()} and
-@code{api_realloc()}. If the allocation fails, they cause @command{gawk}
+from @code{gawk_malloc()} and
+@code{gawk_realloc()}. If the allocation fails, they cause @command{gawk}
to exit with a fatal error message. They should be used as if they were
procedure calls that do not return a value.
@@ -31750,7 +31635,7 @@ The arguments to this macro are as follows:
The pointer variable to point at the allocated storage.
@item type
-The type of the pointer variable, used to create a cast for the call to @code{api_malloc()}.
+The type of the pointer variable, used to create a cast for the call to @code{gawk_malloc()}.
@item size
The total number of bytes to be allocated.
@@ -31774,8 +31659,8 @@ make_malloced_string(message, strlen(message), & result);
@end example
@item #define erealloc(pointer, type, size, message) @dots{}
-This is like @code{emalloc()}, but it calls @code{api_realloc()},
-instead of @code{api_malloc()}.
+This is like @code{emalloc()}, but it calls @code{gawk_realloc()},
+instead of @code{gawk_malloc()}.
The arguments are the same as for the @code{emalloc()} macro.
@end table
@@ -31799,7 +31684,7 @@ for storage in @code{result}. It returns @code{result}.
@itemx make_malloced_string(const char *string, size_t length, awk_value_t *result)
This function creates a string value in the @code{awk_value_t} variable
pointed to by @code{result}. It expects @code{string} to be a @samp{char *}
-value pointing to data previously obtained from the api-provided functions @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()}. The idea here
+value pointing to data previously obtained from @code{gawk_malloc()}, @code{gawk_calloc()} or @code{gawk_realloc()}. The idea here
is that the data is passed directly to @command{gawk}, which assumes
responsibility for it. It returns @code{result}.
@@ -31854,17 +31739,18 @@ The name of the new function.
This is a regular C string.
Function names must obey the rules for @command{awk}
-identifiers. That is, they must begin with either a letter
+identifiers. That is, they must begin with either an English letter
or an underscore, which may be followed by any number of
letters, digits, and underscores.
Letter case in function names is significant.
@item awk_value_t *(*function)(int num_actual_args, awk_value_t *result);
-This is a pointer to the C function that provides the desired
+This is a pointer to the C function that provides the extension's
functionality.
-The function must fill in the result with either a number
+The function must fill in @code{*result} with either a number
or a string. @command{gawk} takes ownership of any string memory.
-As mentioned earlier, string memory @strong{must} come from the api-provided functions @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()}.
+As mentioned earlier, string memory @strong{must} come from one of @code{gawk_malloc()},
+@code{gawk_calloc()} or @code{gawk_realloc()}.
The @code{num_actual_args} argument tells the C function how many
actual parameters were passed from the calling @command{awk} code.
@@ -31875,7 +31761,7 @@ This is for the convenience of the calling code inside @command{gawk}.
@item size_t num_expected_args;
This is the number of arguments the function expects to receive.
Each extension function may decide what to do if the number of
-arguments isn't what it expected. Following @command{awk} functions, it
+arguments isn't what it expected. As with real @command{awk} functions, it
is likely OK to ignore extra arguments.
@end table
@@ -32129,7 +32015,7 @@ If the concept of a ``record terminator'' makes sense, then
@code{RT}, and @code{*rt_len} should be set to the length of the
data. Otherwise, @code{*rt_len} should be set to zero.
@code{gawk} makes its own copy of this data, so the
-extension must manage the storage.
+extension must manage this storage.
@end table
The return value is the length of the buffer pointed to by
@@ -32408,10 +32294,144 @@ into a (possibly translated) string using the C @code{strerror()} function.
Set @code{ERRNO} directly to the string value of @code{ERRNO}.
@command{gawk} makes a copy of the value of @code{string}.
-@item void unset_ERRNO();
+@item void unset_ERRNO(void);
Unset @code{ERRNO}.
@end table
+@node Requesting Values
+@subsection Requesting Values
+
+All of the functions that return values from @command{gawk}
+work in the same way. You pass in an @code{awk_valtype_t} value
+to indicate what kind of value you expect. If the actual value
+matches what you requested, the function returns true and fills
+in the @code{awk_value_t} result.
+Otherwise, the function returns false, and the @code{val_type}
+member indicates the type of the actual value. You may then
+print an error message, or reissue the request for the actual
+value type, as appropriate. This behavior is summarized in
+@ref{table-value-types-returned}.
+
+@float Table,table-value-types-returned
+@caption{API Value Types Returned}
+@docbook
+<informaltable>
+<tgroup cols="6">
+ <colspec colwidth="16.6*"/>
+ <colspec colwidth="16.6*"/>
+ <colspec colwidth="19.8*" colname="c3"/>
+ <colspec colwidth="15*" colname="c4"/>
+ <colspec colwidth="15*" colname="c5"/>
+ <colspec colwidth="16.6*" colname="c6"/>
+ <spanspec spanname="hspan" namest="c3" nameend="c6" align="center"/>
+ <thead>
+ <row><entry></entry><entry spanname="hspan"><para>Type of Actual Value:</para></entry></row>
+ <row>
+ <entry></entry>
+ <entry></entry>
+ <entry><para>String</para></entry>
+ <entry><para>Number</para></entry>
+ <entry><para>Array</para></entry>
+ <entry><para>Undefined</para></entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">String</emphasis></para></entry>
+ <entry><para>String</para></entry>
+ <entry><para>String</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">Number</emphasis></para></entry>
+ <entry><para>Number if can be converted, else false</para></entry>
+ <entry><para>Number</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry><para><emphasis role="bold">Type</emphasis></para></entry>
+ <entry><para><emphasis role="bold">Array</emphasis></para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>Array</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry><para><emphasis role="bold">Requested:</emphasis></para></entry>
+ <entry><para><emphasis role="bold">Scalar</emphasis></para></entry>
+ <entry><para>Scalar</para></entry>
+ <entry><para>Scalar</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">Undefined</emphasis></para></entry>
+ <entry><para>String</para></entry>
+ <entry><para>Number</para></entry>
+ <entry><para>Array</para></entry>
+ <entry><para>Undefined</para></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">Value Cookie</emphasis></para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para>
+ </entry><entry><para>false</para></entry>
+ </row>
+ </tbody>
+</tgroup>
+</informaltable>
+@end docbook
+
+@ifnotplaintext
+@ifnotdocbook
+@multitable @columnfractions .50 .50
+@headitem @tab Type of Actual Value:
+@end multitable
+@multitable @columnfractions .166 .166 .198 .15 .15 .166
+@headitem @tab @tab String @tab Number @tab Array @tab Undefined
+@item @tab @b{String} @tab String @tab String @tab false @tab false
+@item @tab @b{Number} @tab Number if can be converted, else false @tab Number @tab false @tab false
+@item @b{Type} @tab @b{Array} @tab false @tab false @tab Array @tab false
+@item @b{Requested:} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
+@item @tab @b{Undefined} @tab String @tab Number @tab Array @tab Undefined
+@item @tab @b{Value Cookie} @tab false @tab false @tab false @tab false
+@end multitable
+@end ifnotdocbook
+@end ifnotplaintext
+@ifplaintext
+@example
+ +-------------------------------------------------+
+ | Type of Actual Value: |
+ +------------+------------+-----------+-----------+
+ | String | Number | Array | Undefined |
++-----------+-----------+------------+------------+-----------+-----------+
+| | String | String | String | false | false |
+| |-----------+------------+------------+-----------+-----------+
+| | Number | Number if | Number | false | false |
+| | | can be | | | |
+| | | converted, | | | |
+| | | else false | | | |
+| |-----------+------------+------------+-----------+-----------+
+| Type | Array | false | false | Array | false |
+| Requested |-----------+------------+------------+-----------+-----------+
+| | Scalar | Scalar | Scalar | false | false |
+| |-----------+------------+------------+-----------+-----------+
+| | Undefined | String | Number | Array | Undefined |
+| |-----------+------------+------------+-----------+-----------+
+| | Value | false | false | false | false |
+| | Cookie | | | | |
++-----------+-----------+------------+------------+-----------+-----------+
+@end example
+@end ifplaintext
+@end float
+
@node Accessing Parameters
@subsection Accessing and Updating Parameters
@@ -32466,7 +32486,7 @@ about symbols is termed a @dfn{symbol table}.
Fill in the @code{awk_value_t} structure pointed to by @code{result}
with the value of the variable named by the string @code{name}, which is
a regular C string. @code{wanted} indicates the type of value expected.
-Return true if the actual type matches @code{wanted}, false otherwise
+Return true if the actual type matches @code{wanted}, false otherwise.
In the latter case, @code{result->val_type} indicates the actual type
(@pxref{table-value-types-returned}).
@@ -32485,7 +32505,7 @@ An extension can look up the value of @command{gawk}'s special variables.
However, with the exception of the @code{PROCINFO} array, an extension
cannot change any of those variables.
-@quotation NOTE
+@quotation CAUTION
It is possible for the lookup of @code{PROCINFO} to fail. This happens if
the @command{awk} program being run does not reference @code{PROCINFO};
in this case @command{gawk} doesn't bother to create the array and
@@ -32507,14 +32527,14 @@ The following functions let you work with scalar cookies.
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_valtype_t wanted,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_value_t *result);
Retrieve the current value of a scalar cookie.
-Once you have obtained a scalar_cookie using @code{sym_lookup()}, you can
+Once you have obtained a scalar cookie using @code{sym_lookup()}, you can
use this function to get its value more efficiently.
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 of type @code{AWK_STRING} or @code{AWK_NUMBER}.
-Here too, the built-in variables may not be updated.
+Here too, the predefined variables may not be updated.
@end table
It is not obvious at first glance how to work with scalar cookies or
@@ -32569,7 +32589,7 @@ my_extension_init()
/* install initial value */
sym_update("MAGIC_VAR", make_number(42.0, & value));
- /* get cookie */
+ /* get the cookie */
sym_lookup("MAGIC_VAR", AWK_SCALAR, & value);
/* save the cookie */
@@ -32618,7 +32638,8 @@ assign those values to variables using @code{sym_update()}
or @code{sym_update_scalar()}, as you like.
However, you can understand the point of cached values if you remember that
-@emph{every} string value's storage @emph{must} come from @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()}.
+@emph{every} string value's storage @emph{must} come from @code{gawk_malloc()},
+@code{gawk_calloc()} or @code{gawk_realloc()}.
If you have 20 variables, all of which have the same string value, you
must create 20 identical copies of the string.@footnote{Numeric values
are clearly less problematic, requiring only a C @code{double} to store.}
@@ -32689,7 +32710,7 @@ Using value cookies in this way saves considerable storage, since all of
You might be wondering, ``Is this sharing problematic?
What happens if @command{awk} code assigns a new value to @code{VAR1},
-are all the others be changed too?''
+are all the others changed too?''
That's a great question. The answer is that no, it's not a problem.
Internally, @command{gawk} uses @dfn{reference-counted strings}. This means
@@ -32744,7 +32765,7 @@ with the @code{<stdio.h>} library routines.
@itemx @ @ @ @ struct awk_element *next;
@itemx @ @ @ @ enum @{
@itemx @ @ @ @ @ @ @ @ AWK_ELEMENT_DEFAULT = 0,@ @ /* set by gawk */
-@itemx @ @ @ @ @ @ @ @ AWK_ELEMENT_DELETE = 1@ @ @ @ /* set by extension if should be deleted */
+@itemx @ @ @ @ @ @ @ @ AWK_ELEMENT_DELETE = 1@ @ @ @ /* set by extension */
@itemx @ @ @ @ @} flags;
@itemx @ @ @ @ awk_value_t index;
@itemx @ @ @ @ awk_value_t value;
@@ -32764,8 +32785,8 @@ an extension to create a linked list of new elements that can then be
added to an array in a loop that traverses the list.
@item enum @{ @dots{} @} flags;
-A set of flag values that convey information between @command{gawk}
-and the extension. Currently there is only one: @code{AWK_ELEMENT_DELETE}.
+A set of flag values that convey information between the extension
+and @command{gawk}. Currently there is only one: @code{AWK_ELEMENT_DELETE}.
Setting it causes @command{gawk} to delete the
element from the original array upon release of the flattened array.
@@ -32776,8 +32797,8 @@ The index and value of the element, respectively.
@end table
@item typedef struct awk_flat_array @{
-@itemx @ @ @ @ awk_const void *awk_const opaque1;@ @ @ @ /* private data for use by gawk */
-@itemx @ @ @ @ awk_const void *awk_const opaque2;@ @ @ @ /* private data for use by gawk */
+@itemx @ @ @ @ awk_const void *awk_const opaque1;@ @ @ @ /* for use by gawk */
+@itemx @ @ @ @ awk_const void *awk_const opaque2;@ @ @ @ /* for use by gawk */
@itemx @ @ @ @ awk_const size_t count;@ @ @ @ @ /* how many elements */
@itemx @ @ @ @ awk_element_t elements[1];@ @ /* will be extended */
@itemx @} awk_flat_array_t;
@@ -32796,7 +32817,7 @@ The following functions relate to individual array elements.
@table @code
@item awk_bool_t get_element_count(awk_array_t a_cookie, size_t *count);
-For the array represented by @code{a_cookie}, return in @code{*count}
+For the array represented by @code{a_cookie}, place in @code{*count}
the number of elements it contains. A subarray counts as a single element.
Return false if there is an error.
@@ -32816,7 +32837,8 @@ requires that you understand how such values are converted to strings
(@pxref{Conversion}); thus using integral values is safest.
As with @emph{all} strings passed into @code{gawk} from an extension,
-the string value of @code{index} must come from the API-provided functions @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()} and
+the string value of @code{index} must come from @code{gawk_malloc()},
+@code{gawk_calloc()} or @code{gawk_realloc()}, and
@command{gawk} releases the storage.
@item awk_bool_t set_array_element(awk_array_t a_cookie,
@@ -32843,7 +32865,7 @@ not exist in the array.
The following functions relate to arrays as a whole:
@table @code
-@item awk_array_t create_array();
+@item awk_array_t create_array(void);
Create a new array to which elements may be added.
@xref{Creating Arrays}, for a discussion of how to
create a new array and add elements to it.
@@ -32860,7 +32882,13 @@ For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t}
structure and fill it in. Set the pointer whose address is passed as @code{data}
to point to this structure.
Return true upon success, or false otherwise.
-@xref{Flattening Arrays}, for a discussion of how to
+@ifset FOR_PRINT
+See the next section
+@end ifset
+@ifclear FOR_PRINT
+@xref{Flattening Arrays},
+@end ifclear
+for a discussion of how to
flatten an array and work with it.
@item awk_bool_t release_flattened_array(awk_array_t a_cookie,
@@ -32880,6 +32908,7 @@ for C code to traverse the entire array. Test code
in @file{extension/testext.c} does this, and also serves
as a nice example showing how to use the APIs.
+We walk through that part of the code one step at a time.
First, the @command{gawk} script that drives the test extension:
@example
@@ -33018,8 +33047,7 @@ have this flag bit set:
valrep2str(& flat_array->elements[i].value));
if (strcmp(value3.str_value.str,
- flat_array->elements[i].index.str_value.str)
- == 0) @{
+ flat_array->elements[i].index.str_value.str) == 0) @{
flat_array->elements[i].flags |= AWK_ELEMENT_DELETE;
printf("dump_array_and_delete: marking element \"%s\" "
"for deletion\n",
@@ -33123,7 +33151,9 @@ of the array cookie after the call to @code{set_element()}.
The following C code is a simple test extension to create an array
with two regular elements and with a subarray. The leading @code{#include}
-directives and boilerplate variable declarations are omitted for brevity.
+directives and boilerplate variable declarations
+(@pxref{Extension API Boilerplate})
+are omitted for brevity.
The first step is to create a new array and then install it
in the symbol table:
@@ -33369,7 +33399,7 @@ This variable is true if @command{gawk} was invoked with @option{--traditional}
@end table
The value of @code{do_lint} can change if @command{awk} code
-modifies the @code{LINT} built-in variable (@pxref{Built-in Variables}).
+modifies the @code{LINT} predefined variable (@pxref{Built-in Variables}).
The others should not change during execution.
@node Extension API Boilerplate
@@ -33402,12 +33432,12 @@ static awk_bool_t (*init_func)(void) = NULL;
/* OR: */
static awk_bool_t
-init_my_module(void)
+init_my_extension(void)
@{
@dots{}
@}
-static awk_bool_t (*init_func)(void) = init_my_module;
+static awk_bool_t (*init_func)(void) = init_my_extension;
dl_load_func(func_table, some_name, "name_space_in_quotes")
@end example
@@ -33450,8 +33480,8 @@ It can then be looped over for multiple calls to
@c Use @var{OR} for docbook
@item static awk_bool_t (*init_func)(void) = NULL;
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @var{OR}
-@itemx static awk_bool_t init_my_module(void) @{ @dots{} @}
-@itemx static awk_bool_t (*init_func)(void) = init_my_module;
+@itemx static awk_bool_t init_my_extension(void) @{ @dots{} @}
+@itemx static awk_bool_t (*init_func)(void) = init_my_extension;
If you need to do some initialization work, you should define a
function that does it (creates variables, opens files, etc.)
and then define the @code{init_func} pointer to point to your
@@ -33518,8 +33548,8 @@ path with a list of directories to search for compiled extensions.
Two useful functions that are not in @command{awk} are @code{chdir()} (so
that an @command{awk} program can change its directory) and @code{stat()}
(so that an @command{awk} program can gather information about a file).
-This @value{SECTION} implements these functions for @command{gawk}
-in an extension.
+In order to illustrate the API in action, this @value{SECTION} implements
+these functions for @command{gawk} in an extension.
@menu
* Internal File Description:: What the new functions will do.
@@ -33541,8 +33571,7 @@ straightforward. It takes one argument, the new directory to change to:
newdir = "/home/arnold/funstuff"
ret = chdir(newdir)
if (ret < 0) @{
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
+ printf("could not change to %s: %s\n", newdir, ERRNO) > "/dev/stderr"
exit 1
@}
@dots{}
@@ -33730,7 +33759,7 @@ The second is a pointer to an @code{awk_value_t}, usually named
@code{result}.
@example
-/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+/* do_chdir --- provide dynamically loaded chdir() function for gawk */
static awk_value_t *
do_chdir(int nargs, awk_value_t *result)
@@ -33939,13 +33968,22 @@ for success:
@}
@}
- array_set(array, "type", make_const_string(type, strlen(type), &tmp));
+ array_set(array, "type", make_const_string(type, strlen(type), & tmp));
return 0;
@}
@end example
-Finally, here is the @code{do_stat()} function. It starts with
+The third argument to @code{stat()} was not discussed previously. This
+argument is optional. If present, it causes @code{do_stat()} to use
+the @code{stat()} system call instead of the @code{lstat()} system
+call. This is done by using a function pointer: @code{statfunc}.
+@code{statfunc} is initialized to point to @code{lstat()} (instead
+of @code{stat()}) to get the file information, in case the file is a
+symbolic link. However, if there were three arguments, @code{statfunc}
+is set point to @code{stat()}, instead.
+
+Here is the @code{do_stat()} function. It starts with
variable declarations and argument checking:
@ignore
@@ -33976,16 +34014,10 @@ do_stat(int nargs, awk_value_t *result)
@}
@end example
-The third argument to @code{stat()} was not discussed previously. This argument
-is optional. If present, it causes @code{stat()} to use the @code{stat()}
-system call instead of the @code{lstat()} system call.
-
Then comes the actual work. First, the function gets the arguments.
-Next, it gets the information for the file.
-The code use @code{lstat()} (instead of @code{stat()})
-to get the file information,
-in case the file is a symbolic link.
-If there's an error, it sets @code{ERRNO} and returns:
+Next, it gets the information for the file. If the called function
+(@code{lstat()} or @code{stat()}) returns an error, the code sets
+@code{ERRNO} and returns:
@example
/* file is first arg, array to hold results is second */
@@ -34014,7 +34046,7 @@ If there's an error, it sets @code{ERRNO} and returns:
@end example
The tedious work is done by @code{fill_stat_array()}, shown
-earlier. When done, return the result from @code{fill_stat_array()}:
+earlier. When done, the function returns the result from @code{fill_stat_array()}:
@example
ret = fill_stat_array(name, array, & sbuf);
@@ -34077,7 +34109,7 @@ of the @file{gawkapi.h} header file,
the following steps@footnote{In practice, you would probably want to
use the GNU Autotools---Automake, Autoconf, Libtool, and @command{gettext}---to
configure and build your libraries. Instructions for doing so are beyond
-the scope of this @value{DOCUMENT}. @xref{gawkextlib}, for WWW links to
+the scope of this @value{DOCUMENT}. @xref{gawkextlib}, for Internet links to
the tools.} create a GNU/Linux shared library:
@example
@@ -34105,14 +34137,14 @@ BEGIN @{
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
+ strftime("%m %d %Y %H:%M:%S", data["mtime"])
print "\nInfo for JUNK"
ret = stat("JUNK", data)
print "ret =", ret
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
- print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
+ print "JUNK modified:", strftime("%m %d %Y %H:%M:%S", data["mtime"])
@}
@end example
@@ -34126,25 +34158,26 @@ $ @kbd{AWKLIBPATH=$PWD gawk -f testff.awk}
@print{} Info for testff.awk
@print{} ret = 0
@print{} data["blksize"] = 4096
-@print{} data["mtime"] = 1350838628
+@print{} data["devbsize"] = 512
+@print{} data["mtime"] = 1412004710
@print{} data["mode"] = 33204
@print{} data["type"] = file
@print{} data["dev"] = 2053
@print{} data["gid"] = 1000
-@print{} data["ino"] = 1719496
-@print{} data["ctime"] = 1350838628
+@print{} data["ino"] = 10358899
+@print{} data["ctime"] = 1412004710
@print{} data["blocks"] = 8
@print{} data["nlink"] = 1
@print{} data["name"] = testff.awk
-@print{} data["atime"] = 1350838632
+@print{} data["atime"] = 1412004716
@print{} data["pmode"] = -rw-rw-r--
-@print{} data["size"] = 662
+@print{} data["size"] = 666
@print{} data["uid"] = 1000
-@print{} testff.awk modified: 10 21 12 18:57:08
-@print{}
+@print{} testff.awk modified: 09 29 2014 18:31:50
+@print{}
@print{} Info for JUNK
@print{} ret = -1
-@print{} JUNK modified: 01 01 70 02:00:00
+@print{} JUNK modified: 01 01 1970 02:00:00
@end example
@node Extension Samples
@@ -34169,9 +34202,9 @@ Others mainly provide example code that shows how to use the extension API.
* Extension Sample Rev2way:: Reversing data sample two-way processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to @code{gettimeofday()}
and @code{sleep()}.
+* Extension Sample API Tests:: Tests for the API.
@end menu
@node Extension Sample File Functions
@@ -34181,7 +34214,7 @@ The @code{filefuncs} extension provides three different functions, as follows:
The usage is:
@table @asis
-@item @@load "filefuncs"
+@item @code{@@load "filefuncs"}
This is how you load the extension.
@cindex @code{chdir()} extension function
@@ -34244,7 +34277,7 @@ Not all systems support all file types. @tab All
@itemx @code{result = fts(pathlist, flags, filedata)}
Walk the file trees provided in @code{pathlist} and fill in the
@code{filedata} array as described below. @code{flags} is the bitwise
-OR of several predefined constant values, also described below.
+OR of several predefined values, also described below.
Return zero if there were no errors, otherwise return @minus{}1.
@end table
@@ -34289,10 +34322,10 @@ Immediately follow a symbolic link named in @code{pathlist},
whether or not @code{FTS_LOGICAL} is set.
@item FTS_SEEDOT
-By default, the @code{fts()} routines do not return entries for @file{.} (dot)
-and @file{..} (dot-dot). This option causes entries for dot-dot to also
-be included. (The extension always includes an entry for dot,
-see below.)
+By default, the C library @code{fts()} routines do not return entries for
+@file{.} (dot) and @file{..} (dot-dot). This option causes entries for
+dot-dot to also be included. (The extension always includes an entry
+for dot, see below.)
@item FTS_XDEV
During a traversal, do not cross onto a different mounted filesystem.
@@ -34346,8 +34379,8 @@ Otherwise it returns @minus{}1.
@quotation NOTE
The @code{fts()} extension does not exactly mimic the
interface of the C library @code{fts()} routines, choosing instead to
-provide an interface that is based on associative arrays, which should
-be more comfortable to use from an @command{awk} program. This includes the
+provide an interface that is based on associative arrays, which is
+more comfortable to use from an @command{awk} program. This includes the
lack of a comparison function, since @command{gawk} already provides
powerful array sorting facilities. While an @code{fts_read()}-like
interface could have been provided, this felt less natural than simply
@@ -34355,7 +34388,8 @@ creating a multidimensional array to represent the file hierarchy and
its information.
@end quotation
-See @file{test/fts.awk} in the @command{gawk} distribution for an example.
+See @file{test/fts.awk} in the @command{gawk} distribution for an example
+use of the @code{fts()} extension function.
@node Extension Sample Fnmatch
@subsection Interface To @code{fnmatch()}
@@ -34563,7 +34597,7 @@ 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()}}
+@caption{File Types Returned By The @code{readdir} Extension}
@multitable @columnfractions .1 .9
@headitem Letter @tab File Type
@item @code{b} @tab Block device
@@ -34655,6 +34689,9 @@ The @code{rwarray} extension adds two functions,
named @code{writea()} and @code{reada()}, as follows:
@table @code
+@item @@load "rwarray"
+This is how you load the extension.
+
@cindex @code{writea()} extension function
@item ret = writea(file, array)
This function takes a string argument, which is the name of the file
@@ -34730,17 +34767,6 @@ if (contents == "" && ERRNO != "") @{
@}
@end example
-@node Extension Sample API Tests
-@subsection API Tests
-@cindex @code{testext} extension
-
-The @code{testext} extension exercises parts of the extension API that
-are not tested by the other samples. The @file{extension/testext.c}
-file contains both the C code for the extension and @command{awk}
-test code inside C comments that run the tests. The testing framework
-extracts the @command{awk} code and runs the tests. See the source file
-for more information.
-
@node Extension Sample Time
@subsection Extension Time Functions
@@ -34771,6 +34797,17 @@ Implementation details: depending on platform availability, this function
tries to use @code{nanosleep()} or @code{select()} to implement the delay.
@end table
+@node Extension Sample API Tests
+@subsection API Tests
+@cindex @code{testext} extension
+
+The @code{testext} extension exercises parts of the extension API that
+are not tested by the other samples. The @file{extension/testext.c}
+file contains both the C code for the extension and @command{awk}
+test code inside C comments that run the tests. The testing framework
+extracts the @command{awk} code and runs the tests. See the source file
+for more information.
+
@node gawkextlib
@section The @code{gawkextlib} Project
@cindex @code{gawkextlib}
@@ -34786,8 +34823,7 @@ As of this writing, there are five extensions:
@itemize @value{BULLET}
@item
-XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
-XML parsing library.
+GD graphics library extension.
@item
PDF extension.
@@ -34796,17 +34832,14 @@ PDF extension.
PostgreSQL extension.
@item
-GD graphics library extension.
-
-@item
MPFR library extension.
This provides access to a number of MPFR functions which @command{gawk}'s
native MPFR support does not.
-@end itemize
-The @code{time} extension described earlier (@pxref{Extension Sample
-Time}) was originally from this project but has been moved in to the
-main @command{gawk} distribution.
+@item
+XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
+XML parsing library.
+@end itemize
@cindex @command{git} utility
You can check out the code for the @code{gawkextlib} project
@@ -34897,6 +34930,9 @@ API function pointers are provided for the following kinds of operations:
@itemize @value{BULLET}
@item
+Allocating, reallocating, and releasing memory.
+
+@item
Registration functions. You may register
extension functions,
exit callbacks,
@@ -34920,9 +34956,6 @@ Symbol table access: retrieving a global variable, creating one,
or changing one.
@item
-Allocating, reallocating, and releasing memory.
-
-@item
Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and
can be a big performance win.
@@ -34954,7 +34987,7 @@ treated as read-only by the extension.
@item
@emph{All} memory passed from an extension to @command{gawk} must come from
the API's memory allocation functions. @command{gawk} takes responsibility for
-the memory and will release it when appropriate.
+the memory and releases it when appropriate.
@item
The API provides information about the running version of @command{gawk} so
@@ -34971,7 +35004,7 @@ The @command{gawk} distribution includes a number of small but useful
sample extensions. The @code{gawkextlib} project includes several more,
larger, extensions. If you wish to write an extension and contribute it
to the community of @command{gawk} users, the @code{gawkextlib} project
-should be the place to do so.
+is the place to do so.
@end itemize
@@ -35053,7 +35086,7 @@ which follows the POSIX specification. Many long-time @command{awk}
users learned @command{awk} programming with the original @command{awk}
implementation in Version 7 Unix. (This implementation was the basis for
@command{awk} in Berkeley Unix, through 4.3-Reno. Subsequent versions
-of Berkeley Unix, and some systems derived from 4.4BSD-Lite, used various
+of Berkeley Unix, and, for a while, some systems derived from 4.4BSD-Lite, used various
versions of @command{gawk} for their @command{awk}.) This @value{CHAPTER}
briefly describes the evolution of the @command{awk} language, with
cross-references to other parts of the @value{DOCUMENT} where you can
@@ -35126,7 +35159,7 @@ The built-in functions @code{close()} and @code{system()}
@item
The @code{ARGC}, @code{ARGV}, @code{FNR}, @code{RLENGTH}, @code{RSTART},
-and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}).
+and @code{SUBSEP} predefined variables (@pxref{Built-in Variables}).
@item
Assignable @code{$0} (@pxref{Changing Fields}).
@@ -35157,14 +35190,11 @@ of @code{FS}.
@item
Dynamic regexps as operands of the @samp{~} and @samp{!~} operators
-(@pxref{Regexp Usage}).
+(@pxref{Computed Regexps}).
@item
The escape sequences @samp{\b}, @samp{\f}, and @samp{\r}
(@pxref{Escape Sequences}).
-(Some vendors have updated their old versions of @command{awk} to
-recognize @samp{\b}, @samp{\f}, and @samp{\r}, but this is not
-something you can rely on.)
@item
Redirection of input for the @code{getline} function
@@ -35203,7 +35233,7 @@ The @option{-v} option for assigning variables before program execution begins
@c GNU, Bell Laboratories & MKS together
@item
-The @option{--} option for terminating command-line options.
+The @option{--} signal for terminating command-line options.
@item
The @samp{\a}, @samp{\v}, and @samp{\x} escape sequences
@@ -35226,7 +35256,7 @@ A cleaner specification for the @code{%c} format-control letter in the
@item
The ability to dynamically pass the field width and precision (@code{"%*.*d"})
-in the argument list of the @code{printf} function
+in the argument list of @code{printf} and @code{sprintf()}
(@pxref{Control Letters}).
@item
@@ -35261,8 +35291,8 @@ The concept of a numeric string and tighter comparison rules to go
with it (@pxref{Typing and Comparison}).
@item
-The use of built-in variables as function parameter names is forbidden
-(@pxref{Definition Syntax}.
+The use of predefined variables as function parameter names is forbidden
+(@pxref{Definition Syntax}).
@item
More complete documentation of many of the previously undocumented
@@ -35357,7 +35387,7 @@ in the current version of @command{gawk}.
@itemize @value{BULLET}
@item
-Additional built-in variables:
+Additional predefined variables:
@itemize @value{MINUS}
@item
@@ -35441,14 +35471,6 @@ The @code{BEGINFILE} and @code{ENDFILE} special patterns.
(@pxref{BEGINFILE/ENDFILE}).
@item
-The ability to delete all of an array at once with @samp{delete @var{array}}
-(@pxref{Delete}).
-
-@item
-The @code{nextfile} statement
-(@pxref{Nextfile Statement}).
-
-@item
The @code{switch} statement
(@pxref{Switch Statement}).
@end itemize
@@ -35463,7 +35485,7 @@ of a two-way pipe to a coprocess
(@pxref{Two-way I/O}).
@item
-POSIX compliance for @code{gsub()} and @code{sub()}.
+POSIX compliance for @code{gsub()} and @code{sub()} with @option{--posix}.
@item
The @code{length()} function accepts an array argument
@@ -35491,6 +35513,20 @@ Additional functions only in @command{gawk}:
@itemize @value{MINUS}
@item
+The @code{gensub()}, @code{patsplit()}, and @code{strtonum()} functions
+for more powerful text manipulation
+(@pxref{String Functions}).
+
+@item
+The @code{asort()} and @code{asorti()} functions for sorting arrays
+(@pxref{Array Sorting}).
+
+@item
+The @code{mktime()}, @code{systime()}, and @code{strftime()}
+functions for working with timestamps
+(@pxref{Time Functions}).
+
+@item
The
@code{and()},
@code{compl()},
@@ -35504,30 +35540,15 @@ functions for bit manipulation
@c In 4.1, and(), or() and xor() grew the ability to take > 2 arguments
@item
-The @code{asort()} and @code{asorti()} functions for sorting arrays
-(@pxref{Array Sorting}).
+The @code{isarray()} function to check if a variable is an array or not
+(@pxref{Type Functions}).
@item
The @code{bindtextdomain()}, @code{dcgettext()} and @code{dcngettext()}
functions for internationalization
(@pxref{Programmer i18n}).
-
-@item
-The @code{fflush()} function from BWK @command{awk}
-(@pxref{I/O Functions}).
-
-@item
-The @code{gensub()}, @code{patsplit()}, and @code{strtonum()} functions
-for more powerful text manipulation
-(@pxref{String Functions}).
-
-@item
-The @code{mktime()}, @code{systime()}, and @code{strftime()}
-functions for working with timestamps
-(@pxref{Time Functions}).
@end itemize
-
@item
Changes and/or additions in the command-line options:
@@ -35650,7 +35671,7 @@ GCC for VAX and Alpha has not been tested for a while.
@item
Support for the following obsolete systems was removed from the code
-and the documentation for @command{gawk} @value{PVERSION} 4.1:
+for @command{gawk} @value{PVERSION} 4.1:
@c nested table
@itemize @value{MINUS}
@@ -36287,33 +36308,29 @@ The dynamic extension interface was completely redone
@cindex extensions, Brian Kernighan's @command{awk}
@cindex extensions, @command{mawk}
-This @value{SECTION} summarizes the common extensions supported
+The following table summarizes the common extensions supported
by @command{gawk}, Brian Kernighan's @command{awk}, and @command{mawk},
the three most widely-used freely available versions of @command{awk}
(@pxref{Other Versions}).
-@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk}
-@headitem Feature @tab BWK Awk @tab Mawk @tab GNU Awk
-@item @samp{\x} Escape sequence @tab X @tab X @tab X
-@item @code{FS} as null string @tab X @tab X @tab X
-@item @file{/dev/stdin} special file @tab X @tab X @tab X
-@item @file{/dev/stdout} special file @tab X @tab X @tab X
-@item @file{/dev/stderr} special file @tab X @tab X @tab X
-@item @code{delete} without subscript @tab X @tab X @tab X
-@item @code{fflush()} function @tab X @tab X @tab X
-@item @code{length()} of an array @tab X @tab X @tab X
-@item @code{nextfile} statement @tab X @tab X @tab X
-@item @code{**} and @code{**=} operators @tab X @tab @tab X
-@item @code{func} keyword @tab X @tab @tab X
-@item @code{BINMODE} variable @tab @tab X @tab X
-@item @code{RS} as regexp @tab @tab X @tab X
-@item Time related functions @tab @tab X @tab X
+@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk} {Now standard}
+@headitem Feature @tab BWK Awk @tab Mawk @tab GNU Awk @tab Now standard
+@item @samp{\x} Escape sequence @tab X @tab X @tab X @tab
+@item @code{FS} as null string @tab X @tab X @tab X @tab
+@item @file{/dev/stdin} special file @tab X @tab X @tab X @tab
+@item @file{/dev/stdout} special file @tab X @tab X @tab X @tab
+@item @file{/dev/stderr} special file @tab X @tab X @tab X @tab
+@item @code{delete} without subscript @tab X @tab X @tab X @tab X
+@item @code{fflush()} function @tab X @tab X @tab X @tab X
+@item @code{length()} of an array @tab X @tab X @tab X @tab
+@item @code{nextfile} statement @tab X @tab X @tab X @tab X
+@item @code{**} and @code{**=} operators @tab X @tab @tab X @tab
+@item @code{func} keyword @tab X @tab @tab X @tab
+@item @code{BINMODE} variable @tab @tab X @tab X @tab
+@item @code{RS} as regexp @tab @tab X @tab X @tab
+@item Time related functions @tab @tab X @tab X @tab
@end multitable
-(Technically speaking, as of late 2012, @code{fflush()}, @samp{delete @var{array}},
-and @code{nextfile} are no longer extensions, since they have been added
-to POSIX.)
-
@node Ranges and Locales
@appendixsec Regexp Ranges and Locales: A Long Sad Story
@@ -36350,6 +36367,7 @@ In the @code{"C"} and @code{"POSIX"} locales, a range expression like
But outside those locales, the ordering was defined to be based on
@dfn{collation order}.
+What does that mean?
In many locales, @samp{A} and @samp{a} are both less than @samp{B}.
In other words, these locales sort characters in dictionary order,
and @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
@@ -36357,7 +36375,7 @@ instead it might be equivalent to @samp{[ABCXYabcdxyz]}, for example.
This point needs to be emphasized: Much literature teaches that you should
use @samp{[a-z]} to match a lowercase character. But on systems with
-non-ASCII locales, this also matched all of the uppercase characters
+non-ASCII locales, this also matches all of the uppercase characters
except @samp{A} or @samp{Z}! This was a continuous cause of confusion, even well
into the twenty-first century.
@@ -36547,7 +36565,7 @@ the various PC platforms.
@cindex Zoulas, Christos
Christos Zoulas
provided the @code{extension()}
-built-in function for dynamically adding new modules.
+built-in function for dynamically adding new functions.
(This was obsoleted at @command{gawk} 4.1.)
@item
@@ -36663,6 +36681,11 @@ The development of the extension API first released with
Arnold Robbins and Andrew Schorr, with notable contributions from
the rest of the development team.
+@cindex Malmberg, John E.
+@item
+John Malmberg contributed significant improvements to the
+OpenVMS port and the related documentation.
+
@item
@cindex Colombo, Antonio
Antonio Giovanni Colombo rewrote a number of examples in the early
@@ -38455,7 +38478,7 @@ make it possible to include them:
@enumerate 1
@item
Before building the new feature into @command{gawk} itself,
-consider writing it as an extension module
+consider writing it as an extension
(@pxref{Dynamic Extensions}).
If that's not possible, continue with the rest of the steps in this list.
@@ -39186,7 +39209,7 @@ Pat Rankin suggested the solution that was adopted.
@appendixsubsec Other Design Decisions
As an arbitrary design decision, extensions can read the values of
-built-in variables and arrays (such as @code{ARGV} and @code{FS}), but cannot
+predefined variables and arrays (such as @code{ARGV} and @code{FS}), but cannot
change them, with the exception of @code{PROCINFO}.
The reason for this is to prevent an extension function from affecting
@@ -39927,11 +39950,11 @@ See ``Free Documentation License.''
@item Field
When @command{awk} reads an input record, it splits the record into pieces
separated by whitespace (or by a separator regexp that you can
-change by setting the built-in variable @code{FS}). Such pieces are
+change by setting the predefined variable @code{FS}). Such pieces are
called fields. If the pieces are of fixed length, you can use the built-in
variable @code{FIELDWIDTHS} to describe their lengths.
If you wish to specify the contents of fields instead of the field
-separator, you can use the built-in variable @code{FPAT} to do so.
+separator, you can use the predefined variable @code{FPAT} to do so.
(@xref{Field Separators},
@ref{Constant Size},
and
@@ -39950,7 +39973,7 @@ See also ``Double Precision'' and ``Single Precision.''
Format strings control the appearance of output in the
@code{strftime()} and @code{sprintf()} functions, and in the
@code{printf} statement as well. Also, data conversions from numbers to strings
-are controlled by the format strings contained in the built-in variables
+are controlled by the format strings contained in the predefined variables
@code{CONVFMT} and @code{OFMT}. (@xref{Control Letters}.)
@item Free Documentation License
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index d026a3b1..eb9bb0d4 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -703,7 +703,7 @@ particular records in a file and perform operations upon them.
record.
* Nextfile Statement:: Stop processing the current file.
* Exit Statement:: Stop execution of @command{awk}.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* User-modified:: Built-in variables that you change to
control @command{awk}.
* Auto-set:: Built-in variables where @command{awk}
@@ -901,7 +901,6 @@ particular records in a file and perform operations upon them.
* Extension API Description:: A full description of the API.
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
@@ -914,6 +913,7 @@ particular records in a file and perform operations upon them.
* Two-way processors:: Registering a two-way processor.
* Printing Messages:: Functions for printing messages.
* Updating @code{ERRNO}:: Functions for updating @code{ERRNO}.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -952,9 +952,9 @@ particular records in a file and perform operations upon them.
processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to @code{gettimeofday()}
and @code{sleep()}.
+* Extension Sample API Tests:: Tests for the API.
* gawkextlib:: The @code{gawkextlib} project.
* Extension summary:: Extension summary.
* Extension Exercises:: Exercises.
@@ -1537,7 +1537,7 @@ for getting most things done in a program.
@ref{Patterns and Actions},
describes how to write patterns for matching records, actions for
-doing something when a record is matched, and the built-in variables
+doing something when a record is matched, and the predefined variables
@command{awk} and @command{gawk} use.
@ref{Arrays},
@@ -3567,8 +3567,8 @@ The @option{-v} option can only set one variable, but it can be used
more than once, setting another variable each time, like this:
@samp{awk @w{-v foo=1} @w{-v bar=2} @dots{}}.
-@cindex built-in variables, @code{-v} option@comma{} setting with
-@cindex variables, built-in, @code{-v} option@comma{} setting with
+@cindex predefined variables, @code{-v} option@comma{} setting with
+@cindex variables, predefined @code{-v} option@comma{} setting with
@quotation CAUTION
Using @option{-v} to set the values of the built-in
variables may lead to surprising results. @command{awk} will reset the
@@ -5926,7 +5926,7 @@ standard input (by default, this is the keyboard, but often it is a pipe from an
command) or from files whose names you specify on the @command{awk}
command line. If you specify input files, @command{awk} reads them
in order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
+The name of the current input file can be found in the predefined variable
@code{FILENAME}
(@pxref{Built-in Variables}).
@@ -5974,9 +5974,9 @@ used with it do not have to be named on the @command{awk} command line
@cindex @code{FNR} variable
@command{awk} divides the input for your program into records and fields.
It keeps track of the number of records that have been read so far from
-the current input file. This value is stored in a built-in variable
+the current input file. This value is stored in a predefined variable
called @code{FNR} which is reset to zero every time a new file is started.
-Another built-in variable, @code{NR}, records the total number of input
+Another predefined variable, @code{NR}, records the total number of input
records read so far from all @value{DF}s. It starts at zero, but is
never automatically reset to zero.
@@ -5994,7 +5994,7 @@ Records are separated by a character called the @dfn{record separator}.
By default, the record separator is the newline character.
This is why records are, by default, single lines.
A different character can be used for the record separator by
-assigning the character to the built-in variable @code{RS}.
+assigning the character to the predefined variable @code{RS}.
@cindex newlines, as record separators
@cindex @code{RS} variable
@@ -6323,7 +6323,7 @@ field.
@cindex @code{NF} variable
@cindex fields, number of
-@code{NF} is a built-in variable whose value is the number of fields
+@code{NF} is a predefined variable whose value is the number of fields
in the current record. @command{awk} automatically updates the value
of @code{NF} each time it reads a record. No matter how many fields
there are, the last field in a record can be represented by @code{$NF}.
@@ -6650,7 +6650,7 @@ is split into three fields: @samp{m}, @samp{@bullet{}g}, and
Note the leading spaces in the values of the second and third fields.
@cindex troubleshooting, @command{awk} uses @code{FS} not @code{IFS}
-The field separator is represented by the built-in variable @code{FS}.
+The field separator is represented by the predefined variable @code{FS}.
Shell programmers take note: @command{awk} does @emph{not} use the
name @code{IFS} that is used by the POSIX-compliant shells (such as
the Unix Bourne shell, @command{sh}, or Bash).
@@ -6895,7 +6895,7 @@ an uppercase @samp{F} instead of a lowercase @samp{f}. The latter
option (@option{-f}) specifies a file containing an @command{awk} program.
The value used for the argument to @option{-F} is processed in exactly the
-same way as assignments to the built-in variable @code{FS}.
+same way as assignments to the predefined variable @code{FS}.
Any special characters in the field separator must be escaped
appropriately. For example, to use a @samp{\} as the field separator
on the command line, you would have to type:
@@ -7786,7 +7786,7 @@ from the file
@var{file}, and put it in the variable @var{var}. As above, @var{file}
is a string-valued expression that specifies the file from which to read.
-In this version of @code{getline}, none of the built-in variables are
+In this version of @code{getline}, none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is @var{var}.@footnote{This is not quite true. @code{RT} could
be changed if @code{RS} is a regular expression.}
@@ -7948,7 +7948,7 @@ BEGIN @{
@}
@end example
-In this version of @code{getline}, none of the built-in variables are
+In this version of @code{getline}, none of the predefined variables are
changed and the record is not split into fields. However, @code{RT} is set.
@ifinfo
@@ -8010,7 +8010,7 @@ When you use @samp{@var{command} |& getline @var{var}}, the output from
the coprocess @var{command} is sent through a two-way pipe to @code{getline}
and into the variable @var{var}.
-In this version of @code{getline}, none of the built-in variables are
+In this version of @code{getline}, none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is @var{var}.
However, @code{RT} is set.
@@ -8113,9 +8113,9 @@ know that there is a string value to be assigned.
@ref{table-getline-variants}
summarizes the eight variants of @code{getline},
-listing which built-in variables are set by each one,
+listing which predefined variables are set by each one,
and whether the variant is standard or a @command{gawk} extension.
-Note: for each variant, @command{gawk} sets the @code{RT} built-in variable.
+Note: for each variant, @command{gawk} sets the @code{RT} predefined variable.
@float Table,table-getline-variants
@caption{@code{getline} Variants and What They Set}
@@ -8575,7 +8575,7 @@ of items separated by commas. In the output, the items are normally
separated by single spaces. However, this doesn't need to be the case;
a single space is simply the default. Any string of
characters may be used as the @dfn{output field separator} by setting the
-built-in variable @code{OFS}. The initial value of this variable
+predefined variable @code{OFS}. The initial value of this variable
is the string @w{@code{" "}}---that is, a single space.
The output from an entire @code{print} statement is called an
@@ -8651,7 +8651,7 @@ more fully in
@cindexawkfunc{sprintf}
@cindex @code{OFMT} variable
@cindex output, format specifier@comma{} @code{OFMT}
-The built-in variable @code{OFMT} contains the format specification
+The predefined variable @code{OFMT} contains the format specification
that @code{print} uses with @code{sprintf()} when it wants to convert a
number to a string for printing.
The default value of @code{OFMT} is @code{"%.6g"}.
@@ -9785,7 +9785,7 @@ retval = close(command) # syntax error in many Unix awks
The return value is @minus{}1 if the argument names something
that was never opened with a redirection, or if there is
a system problem closing the file or process.
-In these cases, @command{gawk} sets the built-in variable
+In these cases, @command{gawk} sets the predefined variable
@code{ERRNO} to a string describing the problem.
In @command{gawk},
@@ -10248,10 +10248,10 @@ array parameters. @xref{String Functions}.
@cindex variables, initializing
A few variables have special built-in meanings, such as @code{FS} (the
field separator), and @code{NF} (the number of fields in the current input
-record). @xref{Built-in Variables}, for a list of the built-in variables.
-These built-in variables can be used and assigned just like all other
+record). @xref{Built-in Variables}, for a list of the predefined variables.
+These predefined variables can be used and assigned just like all other
variables, but their values are also used or changed automatically by
-@command{awk}. All built-in variables' names are entirely uppercase.
+@command{awk}. All predefined variables' names are entirely uppercase.
Variables in @command{awk} can be assigned either numeric or string values.
The kind of value a variable holds can change over the life of a program.
@@ -10377,7 +10377,7 @@ Strings that can't be interpreted as valid numbers convert to zero.
@cindex @code{CONVFMT} variable
The exact manner in which numbers are converted into strings is controlled
-by the @command{awk} built-in variable @code{CONVFMT} (@pxref{Built-in Variables}).
+by the @command{awk} predefined variable @code{CONVFMT} (@pxref{Built-in Variables}).
Numbers are converted using the @code{sprintf()} function
with @code{CONVFMT} as the format
specifier
@@ -12269,7 +12269,7 @@ program, and occasionally the format for data read as input.
As you have already seen, each @command{awk} statement consists of
a pattern with an associated action. This @value{CHAPTER} describes how
you build patterns and actions, what kinds of things you can do within
-actions, and @command{awk}'s built-in variables.
+actions, and @command{awk}'s predefined variables.
The pattern-action rules and the statements available for use
within actions form the core of @command{awk} programming.
@@ -12284,7 +12284,7 @@ building something useful.
* Action Overview:: What goes into an action.
* Statements:: Describes the various control statements in
detail.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* Pattern Action Summary:: Patterns and Actions summary.
@end menu
@@ -13693,11 +13693,11 @@ results across different operating systems.
@c ENDOFRANGE accs
@node Built-in Variables
-@section Built-in Variables
+@section Predefined Variables
@c STARTOFRANGE bvar
-@cindex built-in variables
+@cindex predefined variables
@c STARTOFRANGE varb
-@cindex variables, built-in
+@cindex variables, predefined
Most @command{awk} variables are available to use for your own
purposes; they never change unless your program assigns values to
@@ -13708,8 +13708,8 @@ to tell @command{awk} how to do certain things. Others are set
automatically by @command{awk}, so that they carry information from the
internal workings of @command{awk} to your program.
-@cindex @command{gawk}, built-in variables and
-This @value{SECTION} documents all of @command{gawk}'s built-in variables,
+@cindex @command{gawk}, predefined variables and
+This @value{SECTION} documents all of @command{gawk}'s predefined variables,
most of which are also documented in the @value{CHAPTER}s describing
their areas of activity.
@@ -13724,7 +13724,7 @@ their areas of activity.
@node User-modified
@subsection Built-in Variables That Control @command{awk}
@c STARTOFRANGE bvaru
-@cindex built-in variables, user-modifiable
+@cindex predefined variables, user-modifiable
@c STARTOFRANGE nmbv
@cindex user-modifiable variables
@@ -13961,9 +13961,9 @@ The default value of @code{TEXTDOMAIN} is @code{"messages"}.
@subsection Built-in Variables That Convey Information
@c STARTOFRANGE bvconi
-@cindex built-in variables, conveying information
+@cindex predefined variables, conveying information
@c STARTOFRANGE vbconi
-@cindex variables, built-in, conveying information
+@cindex variables, predefined conveying information
The following is an alphabetical list of variables that @command{awk}
sets automatically on certain occasions in order to provide
information to your program.
@@ -14592,7 +14592,7 @@ immediately. You may pass an optional numeric value to be used
as @command{awk}'s exit status.
@item
-Some built-in variables provide control over @command{awk}, mainly for I/O.
+Some predefined variables provide control over @command{awk}, mainly for I/O.
Other variables convey information from @command{awk} to your program.
@item
@@ -15386,7 +15386,7 @@ An important aspect to remember about arrays is that @emph{array subscripts
are always strings}. When a numeric value is used as a subscript,
it is converted to a string value before being used for subscripting
(@pxref{Conversion}).
-This means that the value of the built-in variable @code{CONVFMT} can
+This means that the value of the predefined variable @code{CONVFMT} can
affect how your program accesses elements of an array. For example:
@example
@@ -16570,8 +16570,8 @@ for @code{match()}, the order is the same as for the @samp{~} operator:
@cindex @code{RSTART} variable, @code{match()} function and
@cindex @code{RLENGTH} variable, @code{match()} function and
@cindex @code{match()} function, @code{RSTART}/@code{RLENGTH} variables
-The @code{match()} function sets the built-in variable @code{RSTART} to
-the index. It also sets the built-in variable @code{RLENGTH} to the
+The @code{match()} function sets the predefined variable @code{RSTART} to
+the index. It also sets the predefined variable @code{RLENGTH} to the
length in characters of the matched substring. If no match is found,
@code{RSTART} is set to zero, and @code{RLENGTH} to @minus{}1.
@@ -18399,7 +18399,7 @@ the call.
A function cannot have two parameters with the same name, nor may it
have a parameter with the same name as the function itself.
In addition, according to the POSIX standard, function parameters
-cannot have the same name as one of the special built-in variables
+cannot have the same name as one of the special predefined variables
(@pxref{Built-in Variables}). Not all versions of @command{awk} enforce
this restriction.
@@ -19647,7 +19647,7 @@ example, @code{getopt()}'s @code{Opterr} and @code{Optind} variables
(@pxref{Getopt Function}).
The leading capital letter indicates that it is global, while the fact that
the variable name is not all capital letters indicates that the variable is
-not one of @command{awk}'s built-in variables, such as @code{FS}.
+not one of @command{awk}'s predefined variables, such as @code{FS}.
@cindex @option{--dump-variables} option, using for library functions
It is also important that @emph{all} variables in library
@@ -22532,7 +22532,7 @@ and the file transition library program
The program begins with a descriptive comment and then a @code{BEGIN} rule
that processes the command-line arguments with @code{getopt()}. The @option{-i}
(ignore case) option is particularly easy with @command{gawk}; we just use the
-@code{IGNORECASE} built-in variable
+@code{IGNORECASE} predefined variable
(@pxref{Built-in Variables}):
@cindex @code{egrep.awk} program
@@ -26434,11 +26434,13 @@ using regular pipes.
@ @ @ @ and no-one can talk to host that's close,@*
@ @ @ @ unless the host that isn't close@*
@ @ @ @ is busy, hung, or dead.}
+@author Mike O'Brien (aka Mr.@: Protocol)
@end quotation
@end ifnotdocbook
@docbook
<blockquote>
+<attribution>Mike O'Brien (aka Mr.&nbsp;Protocol)</attribution>
<literallayout class="normal"><literal>EMISTERED</literal>:
&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>A host is a host from coast to coast,</emphasis>
&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>and no-one can talk to host that's close,</emphasis>
@@ -26613,9 +26615,9 @@ in the morning to work.)
@cindex @code{BEGIN} pattern, and profiling
@cindex @code{END} pattern, and profiling
@example
- # gawk profile, created Thu Feb 27 05:16:21 2014
+ # gawk profile, created Mon Sep 29 05:16:21 2014
- # BEGIN block(s)
+ # BEGIN rule(s)
BEGIN @{
1 print "First BEGIN rule"
@@ -26642,7 +26644,7 @@ in the morning to work.)
@}
@}
- # END block(s)
+ # END rule(s)
END @{
1 print "First END rule"
@@ -26770,7 +26772,7 @@ come out as:
@end example
@noindent
-which is correct, but possibly surprising.
+which is correct, but possibly unexpected.
@cindex profiling @command{awk} programs, dynamically
@cindex @command{gawk} program, dynamic profiling
@@ -26802,7 +26804,7 @@ $ @kbd{kill -USR1 13992}
@noindent
As usual, the profiled version of the program is written to
-@file{awkprof.out}, or to a different file if one specified with
+@file{awkprof.out}, or to a different file if one was specified with
the @option{--profile} option.
Along with the regular profile, as shown earlier, the profile file
@@ -26862,6 +26864,7 @@ The @option{--non-decimal-data} option causes @command{gawk} to treat
octal- and hexadecimal-looking input data as octal and hexadecimal.
This option should be used with caution or not at all; use of @code{strtonum()}
is preferable.
+Note that this option may disappear in a future version of @command{gawk}.
@item
You can take over complete control of sorting in @samp{for (@var{indx} in @var{array})}
@@ -26881,9 +26884,9 @@ or @code{printf}. Use @code{close()} to close off the coprocess completely, or
optionally, close off one side of the two-way communications.
@item
-By using special ``@value{FN}s'' with the @samp{|&} operator, you can open a
+By using special @value{FN}s with the @samp{|&} operator, you can open a
TCP/IP (or UDP/IP) connection to remote hosts in the Internet. @command{gawk}
-supports both IPv4 an IPv6.
+supports both IPv4 and IPv6.
@item
You can generate statement count profiles of your program. This can help you
@@ -27121,7 +27124,7 @@ In June 2001 Bruno Haible wrote:
This information is accessed via the
POSIX character classes in regular expressions,
such as @code{/[[:alnum:]]/}
-(@pxref{Regexp Operators}).
+(@pxref{Bracket Expressions}).
@cindex monetary information, localization
@cindex currency symbols, localization
@@ -27204,7 +27207,7 @@ default arguments.
Return the plural form used for @var{number} of the
translation of @var{string1} and @var{string2} in text domain
@var{domain} for locale category @var{category}. @var{string1} is the
-English singular variant of a message, and @var{string2} the English plural
+English singular variant of a message, and @var{string2} is the English plural
variant of the same message.
The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
The default value for @var{category} is @code{"LC_MESSAGES"}.
@@ -27292,9 +27295,11 @@ This example would be better done with @code{dcngettext()}:
@example
if (groggy)
- message = dcngettext("%d customer disturbing me\n", "%d customers disturbing me\n", "adminprog")
+ message = dcngettext("%d customer disturbing me\n",
+ "%d customers disturbing me\n", "adminprog")
else
- message = dcngettext("enjoying %d customer\n", "enjoying %d customers\n", "adminprog")
+ message = dcngettext("enjoying %d customer\n",
+ "enjoying %d customers\n", "adminprog")
printf(message, ncustomers)
@end example
@@ -27366,7 +27371,7 @@ First, use the @option{--gen-pot} command-line option to create
the initial @file{.pot} file:
@example
-$ @kbd{gawk --gen-pot -f guide.awk > guide.pot}
+gawk --gen-pot -f guide.awk > guide.pot
@end example
@cindex @code{xgettext} utility
@@ -27430,11 +27435,11 @@ example, @samp{string} is the first argument and @samp{length(string)} is the se
@example
$ @kbd{gawk 'BEGIN @{}
-> @kbd{string = "Dont Panic"}
+> @kbd{string = "Don\47t Panic"}
> @kbd{printf "%2$d characters live in \"%1$s\"\n",}
> @kbd{string, length(string)}
> @kbd{@}'}
-@print{} 10 characters live in "Dont Panic"
+@print{} 11 characters live in "Don't Panic"
@end example
If present, positional specifiers come first in the format specification,
@@ -27646,7 +27651,8 @@ msgstr "Like, the scoop is"
@cindex GNU/Linux
The next step is to make the directory to hold the binary message object
file and then to create the @file{guide.mo} file.
-We pretend that our file is to be used in the @code{en_US.UTF-8} locale.
+We pretend that our file is to be used in the @code{en_US.UTF-8} locale,
+since we have to use a locale name known to the C @command{gettext} routines.
The directory layout shown here is standard for GNU @command{gettext} on
GNU/Linux systems. Other versions of @command{gettext} may use a different
layout:
@@ -27667,8 +27673,8 @@ $ @kbd{mkdir en_US.UTF-8 en_US.UTF-8/LC_MESSAGES}
The @command{msgfmt} utility does the conversion from human-readable
@file{.po} file to machine-readable @file{.mo} file.
By default, @command{msgfmt} creates a file named @file{messages}.
-This file must be renamed and placed in the proper directory so that
-@command{gawk} can find it:
+This file must be renamed and placed in the proper directory (using
+the @option{-o} option) so that @command{gawk} can find it:
@example
$ @kbd{msgfmt guide-mellow.po -o en_US.UTF-8/LC_MESSAGES/guide.mo}
@@ -27711,8 +27717,8 @@ complete detail in
@cite{GNU gettext tools}}.)
@end ifnotinfo
As of this writing, the latest version of GNU @command{gettext} is
-@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz,
-@value{PVERSION} 0.19.1}.
+@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.2.tar.gz,
+@value{PVERSION} 0.19.2}.
If a translation of @command{gawk}'s messages exists,
then @command{gawk} produces usage messages, warnings,
@@ -27800,7 +27806,7 @@ the discussion of debugging in @command{gawk}.
@subsection Debugging in General
(If you have used debuggers in other languages, you may want to skip
-ahead to the next section on the specific features of the @command{awk}
+ahead to the next section on the specific features of the @command{gawk}
debugger.)
Of course, a debugging program cannot remove bugs for you, since it has
@@ -27840,7 +27846,7 @@ is going wrong (or, for that matter, to better comprehend a perfectly
functional program that you or someone else wrote).
@node Debugging Terms
-@subsection Additional Debugging Concepts
+@subsection Debugging Concepts
Before diving in to the details, we need to introduce several
important concepts that apply to just about all debuggers.
@@ -27929,8 +27935,8 @@ as our example.
@cindex starting the debugger
@cindex debugger, how to start
-Starting the debugger is almost exactly like running @command{gawk},
-except you have to pass an additional option @option{--debug} or the
+Starting the debugger is almost exactly like running @command{gawk} normally,
+except you have to pass an additional option @option{--debug}, or the
corresponding short option @option{-D}. The file(s) containing the
program and any supporting code are given on the command line as arguments
to one or more @option{-f} options. (@command{gawk} is not designed
@@ -27948,6 +27954,7 @@ this syntax is slightly different from what they are used to.
With the @command{gawk} debugger, you give the arguments for running the program
in the command line to the debugger rather than as part of the @code{run}
command at the debugger prompt.)
+The @option{-1} is an option to @file{uniq.awk}.
Instead of immediately running the program on @file{inputfile}, as
@command{gawk} would ordinarily do, the debugger merely loads all
@@ -28129,7 +28136,7 @@ gawk> @kbd{p n m alast aline}
This is kind of disappointing, though. All we found out is that there
are five elements in @code{alast}; @code{m} and @code{aline} don't have
-values yet since we are at line 68 but haven't executed it yet.
+values since we are at line 68 but haven't executed it yet.
This information is useful enough (we now know that
none of the words were accidentally left out), but what if we want to see
inside the array?
@@ -28322,7 +28329,8 @@ Delete breakpoint(s) set at entry to function @var{function}.
@cindex breakpoint condition
@item @code{condition} @var{n} @code{"@var{expression}"}
Add a condition to existing breakpoint or watchpoint @var{n}. The
-condition is an @command{awk} expression that the debugger evaluates
+condition is an @command{awk} expression @emph{enclosed in double quotes}
+that the debugger evaluates
whenever the breakpoint or watchpoint is reached. If the condition is true, then
the debugger stops execution and prompts for a command. Otherwise,
the debugger continues executing the program. If the condition expression is
@@ -28510,7 +28518,7 @@ see the output shown under @code{dump} in @ref{Miscellaneous Debugger Commands}.
@item @code{until} [[@var{filename}@code{:}]@var{n} | @var{function}]
@itemx @code{u} [[@var{filename}@code{:}]@var{n} | @var{function}]
Without any argument, continue execution until a line past the current
-line in current stack frame is reached. With an argument,
+line in the current stack frame is reached. With an argument,
continue execution until the specified location is reached, or the current
stack frame returns.
@end table
@@ -28574,7 +28582,7 @@ gawk> @kbd{print $3}
@noindent
This prints the third field in the input record (if the specified field does not
exist, it prints @samp{Null field}). A variable can be an array element, with
-the subscripts being constant values. To print the contents of an array,
+the subscripts being constant string values. To print the contents of an array,
prefix the name of the array with the @samp{@@} symbol:
@example
@@ -28640,7 +28648,7 @@ watch list.
@end table
@node Execution Stack
-@subsection Dealing with the Stack
+@subsection Working with the Stack
Whenever you run a program which contains any function calls,
@command{gawk} maintains a stack of all of the function calls leading up
@@ -28651,16 +28659,22 @@ functions which called the one you are in. The commands for doing this are:
@table @asis
@cindex debugger commands, @code{bt} (@code{backtrace})
@cindex debugger commands, @code{backtrace}
+@cindex debugger commands, @code{where} (@code{backtrace})
@cindex @code{backtrace} debugger command
@cindex @code{bt} debugger command (alias for @code{backtrace})
+@cindex @code{where} debugger command
+@cindex @code{where} debugger command (alias for @code{backtrace})
@cindex call stack, display in debugger
@cindex traceback, display in debugger
@item @code{backtrace} [@var{count}]
@itemx @code{bt} [@var{count}]
+@itemx @code{where} [@var{count}]
Print a backtrace of all function calls (stack frames), or innermost @var{count}
frames if @var{count} > 0. Print the outermost @var{count} frames if
@var{count} < 0. The backtrace displays the name and arguments to each
function, the source @value{FN}, and the line number.
+The alias @code{where} for @code{backtrace} is provided for long-time
+GDB users who may be used to that command.
@cindex debugger commands, @code{down}
@cindex @code{down} debugger command
@@ -28710,7 +28724,7 @@ The value for @var{what} should be one of the following:
@table @code
@item args
@cindex show function arguments, in debugger
-Arguments of the selected frame.
+List arguments of the selected frame.
@item break
@cindex show breakpoints
@@ -28722,7 +28736,7 @@ List all items in the automatic display list.
@item frame
@cindex describe call stack frame, in debugger
-Description of the selected stack frame.
+Give a description of the selected stack frame.
@item functions
@cindex list function definitions, in debugger
@@ -28731,11 +28745,11 @@ line numbers.
@item locals
@cindex show local variables, in debugger
-Local variables of the selected frame.
+List local variables of the selected frame.
@item source
@cindex show name of current source file, in debugger
-The name of the current source file. Each time the program stops, the
+Print the name of the current source file. Each time the program stops, the
current source file is the file containing the current instruction.
When the debugger first starts, the current source file is the first file
included via the @option{-f} option. The
@@ -28852,6 +28866,7 @@ commands in a program. This can be very enlightening, as the following
partial dump of Davide Brini's obfuscated code
(@pxref{Signature Program}) demonstrates:
+@c FIXME: This will need updating if num-handler branch is ever merged in.
@smallexample
gawk> @kbd{dump}
@print{} # BEGIN
@@ -28925,7 +28940,7 @@ are as follows:
@c nested table
@table @asis
-@item @code{-}
+@item @code{-} (Minus)
Print lines before the lines last printed.
@item @code{+}
@@ -29013,7 +29028,7 @@ and
@end table
@node Limitations
-@section Limitations and Future Plans
+@section Limitations
We hope you find the @command{gawk} debugger useful and enjoyable to work with,
but as with any program, especially in its early releases, it still has
@@ -29061,8 +29076,10 @@ executing, short programs.
The @command{gawk} debugger only accepts source supplied with the @option{-f} option.
@end itemize
+@ignore
Look forward to a future release when these and other missing features may
be added, and of course feel free to try to add them yourself!
+@end ignore
@node Debugging Summary
@section Summary
@@ -29105,9 +29122,8 @@ and editing.
@cindex floating-point, numbers@comma{} arbitrary precision
This @value{CHAPTER} introduces some basic concepts relating to
-how computers do arithmetic and briefly lists the features in
-@command{gawk} for performing arbitrary precision floating point
-computations. It then proceeds to describe floating-point arithmetic,
+how computers do arithmetic and defines some important terms.
+It then proceeds to describe floating-point arithmetic,
which is what @command{awk} uses for all its computations, including a
discussion of arbitrary precision floating point arithmetic, which is
a feature available only in @command{gawk}. It continues on to present
@@ -29202,8 +29218,10 @@ Computers work with integer and floating point values of different
ranges. Integer values are usually either 32 or 64 bits in size. Single
precision floating point values occupy 32 bits, whereas double precision
floating point values occupy 64 bits. Floating point values are always
-signed. The possible ranges of values are shown in the following table.
+signed. The possible ranges of values are shown in @ref{table-numeric-ranges}.
+@float Table,table-numeric-ranges
+@caption{Value Ranges for Different Numeric Representations}
@multitable @columnfractions .34 .33 .33
@headitem Numeric representation @tab Miniumum value @tab Maximum value
@item 32-bit signed integer @tab @minus{}2,147,483,648 @tab 2,147,483,647
@@ -29213,6 +29231,7 @@ signed. The possible ranges of values are shown in the following table.
@item Single precision floating point (approximate) @tab @code{1.175494e-38} @tab @code{3.402823e+38}
@item Double precision floating point (approximate) @tab @code{2.225074e-308} @tab @code{1.797693e+308}
@end multitable
+@end float
@node Math Definitions
@section Other Stuff To Know
@@ -29240,14 +29259,12 @@ A special value representing infinity. Operations involving another
number and infinity produce infinity.
@item NaN
-``Not A Number.''@footnote{Thanks
-to Michael Brennan for this description, which I have paraphrased, and
-for the examples}.
-A special value that results from attempting a
-calculation that has no answer as a real number. In such a case,
-programs can either receive a floating-point exception, or get @code{NaN}
-back as the result. The IEEE 754 standard recommends that systems return
-@code{NaN}. Some examples:
+``Not A Number.''@footnote{Thanks to Michael Brennan for this description,
+which we have paraphrased, and for the examples.} A special value that
+results from attempting a calculation that has no answer as a real number.
+In such a case, programs can either receive a floating-point exception,
+or get @code{NaN} back as the result. The IEEE 754 standard recommends
+that systems return @code{NaN}. Some examples:
@table @code
@item sqrt(-1)
@@ -29321,9 +29338,9 @@ to allow greater precisions and larger exponent ranges.
field values for the basic IEEE 754 binary formats:
@float Table,table-ieee-formats
-@caption{Basic IEEE Format Context Values}
+@caption{Basic IEEE Format Values}
@multitable @columnfractions .20 .20 .20 .20 .20
-@headitem Name @tab Total bits @tab Precision @tab emin @tab emax
+@headitem Name @tab Total bits @tab Precision @tab Minimum exponent @tab Maximum exponent
@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
@item Double @tab 64 @tab 53 @tab @minus{}1022 @tab +1023
@item Quadruple @tab 128 @tab 113 @tab @minus{}16382 @tab +16383
@@ -29338,16 +29355,16 @@ one extra bit of significand.
@node MPFR features
@section Arbitrary Precison Arithmetic Features In @command{gawk}
-By default, @command{gawk} uses the double precision floating point values
+By default, @command{gawk} uses the double precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do, @command{gawk} uses the @uref{http://www.mpfr.org, GNU
-MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for arbitrary
+compiled to do so, @command{gawk} uses the @uref{http://www.mpfr.org
+GNU MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for arbitrary
precision arithmetic on numbers. You can see if MPFR support is available
like so:
@example
$ @kbd{gawk --version}
-@print{} GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
+@print{} GNU Awk 4.1.2, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
@print{} Copyright (C) 1989, 1991-2014 Free Software Foundation.
@dots{}
@end example
@@ -29367,11 +29384,12 @@ results. With the @option{-M} command-line option,
all floating-point arithmetic operators and numeric functions
can yield results to any desired precision level supported by MPFR.
-Two built-in variables, @code{PREC} and @code{ROUNDMODE},
+Two predefined variables, @code{PREC} and @code{ROUNDMODE},
provide control over the working precision and the rounding mode.
The precision and the rounding mode are set globally for every operation
to follow.
-@xref{Auto-set}, for more information.
+@xref{Setting precision}, and @ref{Setting the rounding mode},
+for more information.
@node FP Math Caution
@section Floating Point Arithmetic: Caveat Emptor!
@@ -29485,6 +29503,10 @@ else
# not ok
@end example
+@noindent
+(We assume that you have a simple absolute value function named
+@code{abs()} defined elsewhere in your program.)
+
@node Errors accumulate
@subsubsection Errors Accumulate
@@ -29571,7 +29593,7 @@ It is easy to forget that the finite number of bits used to store the value
is often just an approximation after proper rounding.
The test for equality succeeds if and only if @emph{all} bits in the two operands
are exactly the same. Since this is not necessarily true after floating-point
-computations with a particular precision and effective rounding rule,
+computations with a particular precision and effective rounding mode,
a straight test for equality may not work. Instead, compare the
two numbers to see if they are within the desirable delta of each other.
@@ -29638,7 +29660,7 @@ $ @kbd{gawk -f pi2.awk}
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 you can
-modify using the built-in variable @code{PREC}. You can also set the
+modify using the predefined 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.
@@ -29670,7 +29692,7 @@ Be wary of floating-point constants! When reading a floating-point
constant 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}
+internally as an MPFR number. Changing the precision using @code{PREC}
in the program text does @emph{not} change the precision of a constant.
If you need to represent a floating-point constant at a higher precision
@@ -29808,15 +29830,15 @@ the following computes
5<superscript>4<superscript>3<superscript>2</superscript></superscript></superscript>, @c
@end docbook
the result of which is beyond the
-limits of ordinary hardware double-precision floating point values:
+limits of ordinary hardware double precision floating point values:
@example
$ @kbd{gawk -M 'BEGIN @{}
> @kbd{x = 5^4^3^2}
-> @kbd{print "# of digits =", length(x)}
+> @kbd{print "number of digits =", length(x)}
> @kbd{print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20)}
> @kbd{@}'}
-@print{} # of digits = 183231
+@print{} number of digits = 183231
@print{} 62060698786608744707 ... 92256259918212890625
@end example
@@ -30039,7 +30061,7 @@ Thus @samp{+nan} and @samp{+NaN} are the same.
@itemize @value{BULLET}
@item
Most computer arithmetic is done using either integers or floating-point
-values. The default for @command{awk} is to use double-precision
+values. Standard @command{awk} uses double precision
floating-point values.
@item
@@ -30158,7 +30180,7 @@ Extensions are written in C or C++, using the @dfn{Application Programming
Interface} (API) defined for this purpose by the @command{gawk}
developers. The rest of this @value{CHAPTER} explains
the facilities that the API provides and how to use
-them, and presents a small sample extension. In addition, it documents
+them, and presents a small example extension. In addition, it documents
the sample extensions included in the @command{gawk} distribution,
and describes the @code{gawkextlib} project.
@ifclear FOR_PRINT
@@ -30174,10 +30196,14 @@ goals and design.
@node Plugin License
@section Extension Licensing
-Every dynamic extension should define the global symbol
-@code{plugin_is_GPL_compatible} to assert that it has been licensed under
-a GPL-compatible license. If this symbol does not exist, @command{gawk}
-emits a fatal error and exits when it tries to load your extension.
+Every dynamic extension must be distributed under a license that is
+compatible with the GNU GPL (@pxref{Copying}).
+
+In order for the extension to tell @command{gawk} that it is
+properly licensed, the extension must define the global symbol
+@code{plugin_is_GPL_compatible}. If this symbol does not exist,
+@command{gawk} emits a fatal error and exits when it tries to load
+your extension.
The declared type of the symbol should be @code{int}. It does not need
to be in any allocated section, though. The code merely asserts that
@@ -30192,7 +30218,7 @@ int plugin_is_GPL_compatible;
Communication between
@command{gawk} and an extension is two-way. First, when an extension
-is loaded, it is passed a pointer to a @code{struct} whose fields are
+is loaded, @command{gawk} passes it a pointer to a @code{struct} whose fields are
function pointers.
@ifnotdocbook
This is shown in @ref{figure-load-extension}.
@@ -30228,29 +30254,29 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-load-extension"/>}.
The extension can call functions inside @command{gawk} through these
function pointers, at runtime, without needing (link-time) access
to @command{gawk}'s symbols. One of these function pointers is to a
-function for ``registering'' new built-in functions.
+function for ``registering'' new functions.
@ifnotdocbook
-This is shown in @ref{figure-load-new-function}.
+This is shown in @ref{figure-register-new-function}.
@end ifnotdocbook
@ifdocbook
-This is shown in @inlineraw{docbook, <xref linkend="figure-load-new-function"/>}.
+This is shown in @inlineraw{docbook, <xref linkend="figure-register-new-function"/>}.
@end ifdocbook
@ifnotdocbook
-@float Figure,figure-load-new-function
-@caption{Loading The New Function}
+@float Figure,figure-register-new-function
+@caption{Registering A New Function}
@ifinfo
-@center @image{api-figure2, , , Loading The New Function, txt}
+@center @image{api-figure2, , , Registering A New Function, txt}
@end ifinfo
@ifnotinfo
-@center @image{api-figure2, , , Loading The New Function}
+@center @image{api-figure2, , , Registering A New Function}
@end ifnotinfo
@end float
@end ifnotdocbook
@docbook
-<figure id="figure-load-new-function" float="0">
-<title>Loading The New Function</title>
+<figure id="figure-register-new-function" float="0">
+<title>Registering A New Function</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure2.png" format="PNG"/></imageobject>
</mediaobject>
@@ -30300,8 +30326,8 @@ 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
-see this in the sample extensions @file{filefuncs.c} (@pxref{Extension
-Example}) and also the @file{testext.c} code for testing the APIs.
+see this in the sample extension @file{filefuncs.c} (@pxref{Extension
+Example}) and also in the @file{testext.c} code for testing the APIs.
Some other bits and pieces:
@@ -30335,13 +30361,13 @@ This (rather large) @value{SECTION} describes the API in detail.
@menu
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
@command{gawk}.
* Printing Messages:: Functions for printing messages.
* Updating @code{ERRNO}:: Functions for updating @code{ERRNO}.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -30360,6 +30386,9 @@ API function pointers are provided for the following kinds of operations:
@itemize @value{BULLET}
@item
+Allocating, reallocating, and releasing memory.
+
+@item
Registration functions. You may register:
@itemize @value{MINUS}
@item
@@ -30392,9 +30421,6 @@ Symbol table access: retrieving a global variable, creating one,
or changing one.
@item
-Allocating, reallocating, and releasing memory.
-
-@item
Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and
can be a big performance win.
@@ -30462,8 +30488,8 @@ does not support this keyword, you should either place
All pointers filled in by @command{gawk} point to memory
managed by @command{gawk} and should be treated by the extension as
read-only. Memory for @emph{all} strings passed into @command{gawk}
-from the extension @emph{must} come from calling the API-provided function
-pointers @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()},
+from the extension @emph{must} come from calling one of
+@code{gawk_malloc()}, @code{gawk_calloc()} or @code{gawk_realloc()},
and is managed by @command{gawk} from then on.
@item
@@ -30483,7 +30509,7 @@ and also how characters are likely to be input and output from files.
@item
When retrieving a value (such as a parameter or that of a global variable
or array element), the extension requests a specific type (number, string,
-scalars, value cookie, array, or ``undefined''). When the request is
+scalar, value cookie, array, or ``undefined''). When the request is
``undefined,'' the returned value will have the real underlying type.
However, if the request and actual type don't match, the access function
@@ -30546,8 +30572,8 @@ A simple boolean type.
This represents a mutable string. @command{gawk}
owns the memory pointed to if it supplied
the value. Otherwise, it takes ownership of the memory pointed to.
-@strong{Such memory must come from calling the API-provided function
-pointers @code{api_malloc()}, @code{api_calloc()}, or @code{api_realloc()}!}
+@strong{Such memory must come from calling one of the
+@code{gawk_malloc()}, @code{gawk_calloc()}, or @code{gawk_realloc()} functions!}
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -30642,7 +30668,7 @@ the cookie for getting the variable's value or for changing the variable's
value.
This is the @code{awk_scalar_t} type and @code{scalar_cookie} macro.
Given a scalar cookie, @command{gawk} can directly retrieve or
-modify the value, as required, without having to first find it.
+modify the value, as required, without having to find it first.
The @code{awk_value_cookie_t} type and @code{value_cookie} macro are similar.
If you know that you wish to
@@ -30652,149 +30678,6 @@ and then pass in that value cookie whenever you wish to set the value of a
variable. This saves both storage space within the running @command{gawk}
process as well as the time needed to create the value.
-@node Requesting Values
-@subsection Requesting Values
-
-All of the functions that return values from @command{gawk}
-work in the same way. You pass in an @code{awk_valtype_t} value
-to indicate what kind of value you expect. If the actual value
-matches what you requested, the function returns true and fills
-in the @code{awk_value_t} result.
-Otherwise, the function returns false, and the @code{val_type}
-member indicates the type of the actual value. You may then
-print an error message, or reissue the request for the actual
-value type, as appropriate. This behavior is summarized in
-@ref{table-value-types-returned}.
-
-@c FIXME: Try to do this with spans...
-
-@float Table,table-value-types-returned
-@caption{API Value Types Returned}
-@docbook
-<informaltable>
-<tgroup cols="2">
- <colspec colwidth="50*"/><colspec colwidth="50*"/>
- <thead>
- <row><entry></entry><entry><para>Type of Actual Value:</para></entry></row>
- </thead>
- <tbody>
- <row><entry></entry><entry></entry></row>
- </tbody>
-</tgroup>
-<tgroup cols="6">
- <colspec colwidth="16.6*"/>
- <colspec colwidth="16.6*"/>
- <colspec colwidth="19.8*"/>
- <colspec colwidth="15*"/>
- <colspec colwidth="15*"/>
- <colspec colwidth="16.6*"/>
- <thead>
- <row>
- <entry></entry>
- <entry></entry>
- <entry><para>String</para></entry>
- <entry><para>Number</para></entry>
- <entry><para>Array</para></entry>
- <entry><para>Undefined</para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">String</emphasis></para></entry>
- <entry><para>String</para></entry>
- <entry><para>String</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">Number</emphasis></para></entry>
- <entry><para>Number if can be converted, else false</para></entry>
- <entry><para>Number</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry><para><emphasis role="bold">Type</emphasis></para></entry>
- <entry><para><emphasis role="bold">Array</emphasis></para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- <entry><para>Array</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry><para><emphasis role="bold">Requested:</emphasis></para></entry>
- <entry><para><emphasis role="bold">Scalar</emphasis></para></entry>
- <entry><para>Scalar</para></entry>
- <entry><para>Scalar</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- </row>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">Undefined</emphasis></para></entry>
- <entry><para>String</para></entry>
- <entry><para>Number</para></entry>
- <entry><para>Array</para></entry>
- <entry><para>Undefined</para></entry>
- </row>
- <row>
- <entry></entry>
- <entry><para><emphasis role="bold">Value Cookie</emphasis></para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para></entry>
- <entry><para>false</para>
- </entry><entry><para>false</para></entry>
- </row>
- </tbody>
-</tgroup>
-</informaltable>
-@end docbook
-
-@ifnotplaintext
-@ifnotdocbook
-@multitable @columnfractions .50 .50
-@headitem @tab Type of Actual Value:
-@end multitable
-@multitable @columnfractions .166 .166 .198 .15 .15 .166
-@headitem @tab @tab String @tab Number @tab Array @tab Undefined
-@item @tab @b{String} @tab String @tab String @tab false @tab false
-@item @tab @b{Number} @tab Number if can be converted, else false @tab Number @tab false @tab false
-@item @b{Type} @tab @b{Array} @tab false @tab false @tab Array @tab false
-@item @b{Requested:} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
-@item @tab @b{Undefined} @tab String @tab Number @tab Array @tab Undefined
-@item @tab @b{Value Cookie} @tab false @tab false @tab false @tab false
-@end multitable
-@end ifnotdocbook
-@end ifnotplaintext
-@ifplaintext
-@example
- +-------------------------------------------------+
- | Type of Actual Value: |
- +------------+------------+-----------+-----------+
- | String | Number | Array | Undefined |
-+-----------+-----------+------------+------------+-----------+-----------+
-| | String | String | String | false | false |
-| |-----------+------------+------------+-----------+-----------+
-| | Number | Number if | Number | false | false |
-| | | can be | | | |
-| | | converted, | | | |
-| | | else false | | | |
-| |-----------+------------+------------+-----------+-----------+
-| Type | Array | false | false | Array | false |
-| Requested |-----------+------------+------------+-----------+-----------+
-| | Scalar | Scalar | Scalar | false | false |
-| |-----------+------------+------------+-----------+-----------+
-| | Undefined | String | Number | Array | Undefined |
-| |-----------+------------+------------+-----------+-----------+
-| | Value | false | false | false | false |
-| | Cookie | | | | |
-+-----------+-----------+------------+------------+-----------+-----------+
-@end example
-@end ifplaintext
-@end float
-
@node Memory Allocation Functions
@subsection Memory Allocation Functions and Convenience Macros
@cindex allocating memory for extensions
@@ -30803,22 +30686,24 @@ value type, as appropriate. This behavior is summarized in
The API provides a number of @dfn{memory allocation} functions for
allocating memory that can be passed to @command{gawk}, as well as a number of
convenience macros.
+This @value{SUBSECTION} presents them all as function prototypes, in
+the way that extension code would use them.
@table @code
@item void *gawk_malloc(size_t size);
-Call @command{gawk}-provided @code{api_malloc()} to allocate storage that may
+Call the correct version of @code{malloc()} to allocate storage that may
be passed to @command{gawk}.
@item void *gawk_calloc(size_t nmemb, size_t size);
-Call @command{gawk}-provided @code{api_calloc()} to allocate storage that may
+Call the correct version of @code{calloc()} to allocate storage that may
be passed to @command{gawk}.
@item void *gawk_realloc(void *ptr, size_t size);
-Call @command{gawk}-provided @code{api_realloc()} to allocate storage that may
+Call the correct version of @code{realloc()} to allocate storage that may
be passed to @command{gawk}.
@item void gawk_free(void *ptr);
-Call @command{gawk}-provided @code{api_free()} to release storage that was
+Call the correct version of @code{free()} to release storage that was
allocated with @code{gawk_malloc()}, @code{gawk_calloc()} or @code{gawk_realloc()}.
@end table
@@ -30832,8 +30717,8 @@ unrelated version of @code{malloc()}, unexpected behavior would
likely result.
Two convenience macros may be used for allocating storage
-from the API-provided function pointers @code{api_malloc()} and
-@code{api_realloc()}. If the allocation fails, they cause @command{gawk}
+from @code{gawk_malloc()} and
+@code{gawk_realloc()}. If the allocation fails, they cause @command{gawk}
to exit with a fatal error message. They should be used as if they were
procedure calls that do not return a value.
@@ -30847,7 +30732,7 @@ The arguments to this macro are as follows:
The pointer variable to point at the allocated storage.
@item type
-The type of the pointer variable, used to create a cast for the call to @code{api_malloc()}.
+The type of the pointer variable, used to create a cast for the call to @code{gawk_malloc()}.
@item size
The total number of bytes to be allocated.
@@ -30871,8 +30756,8 @@ make_malloced_string(message, strlen(message), & result);
@end example
@item #define erealloc(pointer, type, size, message) @dots{}
-This is like @code{emalloc()}, but it calls @code{api_realloc()},
-instead of @code{api_malloc()}.
+This is like @code{emalloc()}, but it calls @code{gawk_realloc()},
+instead of @code{gawk_malloc()}.
The arguments are the same as for the @code{emalloc()} macro.
@end table
@@ -30896,7 +30781,7 @@ for storage in @code{result}. It returns @code{result}.
@itemx make_malloced_string(const char *string, size_t length, awk_value_t *result)
This function creates a string value in the @code{awk_value_t} variable
pointed to by @code{result}. It expects @code{string} to be a @samp{char *}
-value pointing to data previously obtained from the api-provided functions @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()}. The idea here
+value pointing to data previously obtained from @code{gawk_malloc()}, @code{gawk_calloc()} or @code{gawk_realloc()}. The idea here
is that the data is passed directly to @command{gawk}, which assumes
responsibility for it. It returns @code{result}.
@@ -30951,17 +30836,18 @@ The name of the new function.
This is a regular C string.
Function names must obey the rules for @command{awk}
-identifiers. That is, they must begin with either a letter
+identifiers. That is, they must begin with either an English letter
or an underscore, which may be followed by any number of
letters, digits, and underscores.
Letter case in function names is significant.
@item awk_value_t *(*function)(int num_actual_args, awk_value_t *result);
-This is a pointer to the C function that provides the desired
+This is a pointer to the C function that provides the extension's
functionality.
-The function must fill in the result with either a number
+The function must fill in @code{*result} with either a number
or a string. @command{gawk} takes ownership of any string memory.
-As mentioned earlier, string memory @strong{must} come from the api-provided functions @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()}.
+As mentioned earlier, string memory @strong{must} come from one of @code{gawk_malloc()},
+@code{gawk_calloc()} or @code{gawk_realloc()}.
The @code{num_actual_args} argument tells the C function how many
actual parameters were passed from the calling @command{awk} code.
@@ -30972,7 +30858,7 @@ This is for the convenience of the calling code inside @command{gawk}.
@item size_t num_expected_args;
This is the number of arguments the function expects to receive.
Each extension function may decide what to do if the number of
-arguments isn't what it expected. Following @command{awk} functions, it
+arguments isn't what it expected. As with real @command{awk} functions, it
is likely OK to ignore extra arguments.
@end table
@@ -31226,7 +31112,7 @@ If the concept of a ``record terminator'' makes sense, then
@code{RT}, and @code{*rt_len} should be set to the length of the
data. Otherwise, @code{*rt_len} should be set to zero.
@code{gawk} makes its own copy of this data, so the
-extension must manage the storage.
+extension must manage this storage.
@end table
The return value is the length of the buffer pointed to by
@@ -31505,10 +31391,144 @@ into a (possibly translated) string using the C @code{strerror()} function.
Set @code{ERRNO} directly to the string value of @code{ERRNO}.
@command{gawk} makes a copy of the value of @code{string}.
-@item void unset_ERRNO();
+@item void unset_ERRNO(void);
Unset @code{ERRNO}.
@end table
+@node Requesting Values
+@subsection Requesting Values
+
+All of the functions that return values from @command{gawk}
+work in the same way. You pass in an @code{awk_valtype_t} value
+to indicate what kind of value you expect. If the actual value
+matches what you requested, the function returns true and fills
+in the @code{awk_value_t} result.
+Otherwise, the function returns false, and the @code{val_type}
+member indicates the type of the actual value. You may then
+print an error message, or reissue the request for the actual
+value type, as appropriate. This behavior is summarized in
+@ref{table-value-types-returned}.
+
+@float Table,table-value-types-returned
+@caption{API Value Types Returned}
+@docbook
+<informaltable>
+<tgroup cols="6">
+ <colspec colwidth="16.6*"/>
+ <colspec colwidth="16.6*"/>
+ <colspec colwidth="19.8*" colname="c3"/>
+ <colspec colwidth="15*" colname="c4"/>
+ <colspec colwidth="15*" colname="c5"/>
+ <colspec colwidth="16.6*" colname="c6"/>
+ <spanspec spanname="hspan" namest="c3" nameend="c6" align="center"/>
+ <thead>
+ <row><entry></entry><entry spanname="hspan"><para>Type of Actual Value:</para></entry></row>
+ <row>
+ <entry></entry>
+ <entry></entry>
+ <entry><para>String</para></entry>
+ <entry><para>Number</para></entry>
+ <entry><para>Array</para></entry>
+ <entry><para>Undefined</para></entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">String</emphasis></para></entry>
+ <entry><para>String</para></entry>
+ <entry><para>String</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">Number</emphasis></para></entry>
+ <entry><para>Number if can be converted, else false</para></entry>
+ <entry><para>Number</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry><para><emphasis role="bold">Type</emphasis></para></entry>
+ <entry><para><emphasis role="bold">Array</emphasis></para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>Array</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry><para><emphasis role="bold">Requested:</emphasis></para></entry>
+ <entry><para><emphasis role="bold">Scalar</emphasis></para></entry>
+ <entry><para>Scalar</para></entry>
+ <entry><para>Scalar</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">Undefined</emphasis></para></entry>
+ <entry><para>String</para></entry>
+ <entry><para>Number</para></entry>
+ <entry><para>Array</para></entry>
+ <entry><para>Undefined</para></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><para><emphasis role="bold">Value Cookie</emphasis></para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para></entry>
+ <entry><para>false</para>
+ </entry><entry><para>false</para></entry>
+ </row>
+ </tbody>
+</tgroup>
+</informaltable>
+@end docbook
+
+@ifnotplaintext
+@ifnotdocbook
+@multitable @columnfractions .50 .50
+@headitem @tab Type of Actual Value:
+@end multitable
+@multitable @columnfractions .166 .166 .198 .15 .15 .166
+@headitem @tab @tab String @tab Number @tab Array @tab Undefined
+@item @tab @b{String} @tab String @tab String @tab false @tab false
+@item @tab @b{Number} @tab Number if can be converted, else false @tab Number @tab false @tab false
+@item @b{Type} @tab @b{Array} @tab false @tab false @tab Array @tab false
+@item @b{Requested:} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
+@item @tab @b{Undefined} @tab String @tab Number @tab Array @tab Undefined
+@item @tab @b{Value Cookie} @tab false @tab false @tab false @tab false
+@end multitable
+@end ifnotdocbook
+@end ifnotplaintext
+@ifplaintext
+@example
+ +-------------------------------------------------+
+ | Type of Actual Value: |
+ +------------+------------+-----------+-----------+
+ | String | Number | Array | Undefined |
++-----------+-----------+------------+------------+-----------+-----------+
+| | String | String | String | false | false |
+| |-----------+------------+------------+-----------+-----------+
+| | Number | Number if | Number | false | false |
+| | | can be | | | |
+| | | converted, | | | |
+| | | else false | | | |
+| |-----------+------------+------------+-----------+-----------+
+| Type | Array | false | false | Array | false |
+| Requested |-----------+------------+------------+-----------+-----------+
+| | Scalar | Scalar | Scalar | false | false |
+| |-----------+------------+------------+-----------+-----------+
+| | Undefined | String | Number | Array | Undefined |
+| |-----------+------------+------------+-----------+-----------+
+| | Value | false | false | false | false |
+| | Cookie | | | | |
++-----------+-----------+------------+------------+-----------+-----------+
+@end example
+@end ifplaintext
+@end float
+
@node Accessing Parameters
@subsection Accessing and Updating Parameters
@@ -31563,7 +31583,7 @@ about symbols is termed a @dfn{symbol table}.
Fill in the @code{awk_value_t} structure pointed to by @code{result}
with the value of the variable named by the string @code{name}, which is
a regular C string. @code{wanted} indicates the type of value expected.
-Return true if the actual type matches @code{wanted}, false otherwise
+Return true if the actual type matches @code{wanted}, false otherwise.
In the latter case, @code{result->val_type} indicates the actual type
(@pxref{table-value-types-returned}).
@@ -31582,7 +31602,7 @@ An extension can look up the value of @command{gawk}'s special variables.
However, with the exception of the @code{PROCINFO} array, an extension
cannot change any of those variables.
-@quotation NOTE
+@quotation CAUTION
It is possible for the lookup of @code{PROCINFO} to fail. This happens if
the @command{awk} program being run does not reference @code{PROCINFO};
in this case @command{gawk} doesn't bother to create the array and
@@ -31604,14 +31624,14 @@ The following functions let you work with scalar cookies.
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_valtype_t wanted,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_value_t *result);
Retrieve the current value of a scalar cookie.
-Once you have obtained a scalar_cookie using @code{sym_lookup()}, you can
+Once you have obtained a scalar cookie using @code{sym_lookup()}, you can
use this function to get its value more efficiently.
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 of type @code{AWK_STRING} or @code{AWK_NUMBER}.
-Here too, the built-in variables may not be updated.
+Here too, the predefined variables may not be updated.
@end table
It is not obvious at first glance how to work with scalar cookies or
@@ -31666,7 +31686,7 @@ my_extension_init()
/* install initial value */
sym_update("MAGIC_VAR", make_number(42.0, & value));
- /* get cookie */
+ /* get the cookie */
sym_lookup("MAGIC_VAR", AWK_SCALAR, & value);
/* save the cookie */
@@ -31715,7 +31735,8 @@ assign those values to variables using @code{sym_update()}
or @code{sym_update_scalar()}, as you like.
However, you can understand the point of cached values if you remember that
-@emph{every} string value's storage @emph{must} come from @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()}.
+@emph{every} string value's storage @emph{must} come from @code{gawk_malloc()},
+@code{gawk_calloc()} or @code{gawk_realloc()}.
If you have 20 variables, all of which have the same string value, you
must create 20 identical copies of the string.@footnote{Numeric values
are clearly less problematic, requiring only a C @code{double} to store.}
@@ -31786,7 +31807,7 @@ Using value cookies in this way saves considerable storage, since all of
You might be wondering, ``Is this sharing problematic?
What happens if @command{awk} code assigns a new value to @code{VAR1},
-are all the others be changed too?''
+are all the others changed too?''
That's a great question. The answer is that no, it's not a problem.
Internally, @command{gawk} uses @dfn{reference-counted strings}. This means
@@ -31841,7 +31862,7 @@ with the @code{<stdio.h>} library routines.
@itemx @ @ @ @ struct awk_element *next;
@itemx @ @ @ @ enum @{
@itemx @ @ @ @ @ @ @ @ AWK_ELEMENT_DEFAULT = 0,@ @ /* set by gawk */
-@itemx @ @ @ @ @ @ @ @ AWK_ELEMENT_DELETE = 1@ @ @ @ /* set by extension if should be deleted */
+@itemx @ @ @ @ @ @ @ @ AWK_ELEMENT_DELETE = 1@ @ @ @ /* set by extension */
@itemx @ @ @ @ @} flags;
@itemx @ @ @ @ awk_value_t index;
@itemx @ @ @ @ awk_value_t value;
@@ -31861,8 +31882,8 @@ an extension to create a linked list of new elements that can then be
added to an array in a loop that traverses the list.
@item enum @{ @dots{} @} flags;
-A set of flag values that convey information between @command{gawk}
-and the extension. Currently there is only one: @code{AWK_ELEMENT_DELETE}.
+A set of flag values that convey information between the extension
+and @command{gawk}. Currently there is only one: @code{AWK_ELEMENT_DELETE}.
Setting it causes @command{gawk} to delete the
element from the original array upon release of the flattened array.
@@ -31873,8 +31894,8 @@ The index and value of the element, respectively.
@end table
@item typedef struct awk_flat_array @{
-@itemx @ @ @ @ awk_const void *awk_const opaque1;@ @ @ @ /* private data for use by gawk */
-@itemx @ @ @ @ awk_const void *awk_const opaque2;@ @ @ @ /* private data for use by gawk */
+@itemx @ @ @ @ awk_const void *awk_const opaque1;@ @ @ @ /* for use by gawk */
+@itemx @ @ @ @ awk_const void *awk_const opaque2;@ @ @ @ /* for use by gawk */
@itemx @ @ @ @ awk_const size_t count;@ @ @ @ @ /* how many elements */
@itemx @ @ @ @ awk_element_t elements[1];@ @ /* will be extended */
@itemx @} awk_flat_array_t;
@@ -31893,7 +31914,7 @@ The following functions relate to individual array elements.
@table @code
@item awk_bool_t get_element_count(awk_array_t a_cookie, size_t *count);
-For the array represented by @code{a_cookie}, return in @code{*count}
+For the array represented by @code{a_cookie}, place in @code{*count}
the number of elements it contains. A subarray counts as a single element.
Return false if there is an error.
@@ -31913,7 +31934,8 @@ requires that you understand how such values are converted to strings
(@pxref{Conversion}); thus using integral values is safest.
As with @emph{all} strings passed into @code{gawk} from an extension,
-the string value of @code{index} must come from the API-provided functions @code{api_malloc()}, @code{api_calloc()} or @code{api_realloc()} and
+the string value of @code{index} must come from @code{gawk_malloc()},
+@code{gawk_calloc()} or @code{gawk_realloc()}, and
@command{gawk} releases the storage.
@item awk_bool_t set_array_element(awk_array_t a_cookie,
@@ -31940,7 +31962,7 @@ not exist in the array.
The following functions relate to arrays as a whole:
@table @code
-@item awk_array_t create_array();
+@item awk_array_t create_array(void);
Create a new array to which elements may be added.
@xref{Creating Arrays}, for a discussion of how to
create a new array and add elements to it.
@@ -31957,7 +31979,13 @@ For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t}
structure and fill it in. Set the pointer whose address is passed as @code{data}
to point to this structure.
Return true upon success, or false otherwise.
-@xref{Flattening Arrays}, for a discussion of how to
+@ifset FOR_PRINT
+See the next section
+@end ifset
+@ifclear FOR_PRINT
+@xref{Flattening Arrays},
+@end ifclear
+for a discussion of how to
flatten an array and work with it.
@item awk_bool_t release_flattened_array(awk_array_t a_cookie,
@@ -31977,6 +32005,7 @@ for C code to traverse the entire array. Test code
in @file{extension/testext.c} does this, and also serves
as a nice example showing how to use the APIs.
+We walk through that part of the code one step at a time.
First, the @command{gawk} script that drives the test extension:
@example
@@ -32115,8 +32144,7 @@ have this flag bit set:
valrep2str(& flat_array->elements[i].value));
if (strcmp(value3.str_value.str,
- flat_array->elements[i].index.str_value.str)
- == 0) @{
+ flat_array->elements[i].index.str_value.str) == 0) @{
flat_array->elements[i].flags |= AWK_ELEMENT_DELETE;
printf("dump_array_and_delete: marking element \"%s\" "
"for deletion\n",
@@ -32220,7 +32248,9 @@ of the array cookie after the call to @code{set_element()}.
The following C code is a simple test extension to create an array
with two regular elements and with a subarray. The leading @code{#include}
-directives and boilerplate variable declarations are omitted for brevity.
+directives and boilerplate variable declarations
+(@pxref{Extension API Boilerplate})
+are omitted for brevity.
The first step is to create a new array and then install it
in the symbol table:
@@ -32466,7 +32496,7 @@ This variable is true if @command{gawk} was invoked with @option{--traditional}
@end table
The value of @code{do_lint} can change if @command{awk} code
-modifies the @code{LINT} built-in variable (@pxref{Built-in Variables}).
+modifies the @code{LINT} predefined variable (@pxref{Built-in Variables}).
The others should not change during execution.
@node Extension API Boilerplate
@@ -32499,12 +32529,12 @@ static awk_bool_t (*init_func)(void) = NULL;
/* OR: */
static awk_bool_t
-init_my_module(void)
+init_my_extension(void)
@{
@dots{}
@}
-static awk_bool_t (*init_func)(void) = init_my_module;
+static awk_bool_t (*init_func)(void) = init_my_extension;
dl_load_func(func_table, some_name, "name_space_in_quotes")
@end example
@@ -32547,8 +32577,8 @@ It can then be looped over for multiple calls to
@c Use @var{OR} for docbook
@item static awk_bool_t (*init_func)(void) = NULL;
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @var{OR}
-@itemx static awk_bool_t init_my_module(void) @{ @dots{} @}
-@itemx static awk_bool_t (*init_func)(void) = init_my_module;
+@itemx static awk_bool_t init_my_extension(void) @{ @dots{} @}
+@itemx static awk_bool_t (*init_func)(void) = init_my_extension;
If you need to do some initialization work, you should define a
function that does it (creates variables, opens files, etc.)
and then define the @code{init_func} pointer to point to your
@@ -32615,8 +32645,8 @@ path with a list of directories to search for compiled extensions.
Two useful functions that are not in @command{awk} are @code{chdir()} (so
that an @command{awk} program can change its directory) and @code{stat()}
(so that an @command{awk} program can gather information about a file).
-This @value{SECTION} implements these functions for @command{gawk}
-in an extension.
+In order to illustrate the API in action, this @value{SECTION} implements
+these functions for @command{gawk} in an extension.
@menu
* Internal File Description:: What the new functions will do.
@@ -32638,8 +32668,7 @@ straightforward. It takes one argument, the new directory to change to:
newdir = "/home/arnold/funstuff"
ret = chdir(newdir)
if (ret < 0) @{
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
+ printf("could not change to %s: %s\n", newdir, ERRNO) > "/dev/stderr"
exit 1
@}
@dots{}
@@ -32827,7 +32856,7 @@ The second is a pointer to an @code{awk_value_t}, usually named
@code{result}.
@example
-/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+/* do_chdir --- provide dynamically loaded chdir() function for gawk */
static awk_value_t *
do_chdir(int nargs, awk_value_t *result)
@@ -33036,13 +33065,22 @@ for success:
@}
@}
- array_set(array, "type", make_const_string(type, strlen(type), &tmp));
+ array_set(array, "type", make_const_string(type, strlen(type), & tmp));
return 0;
@}
@end example
-Finally, here is the @code{do_stat()} function. It starts with
+The third argument to @code{stat()} was not discussed previously. This
+argument is optional. If present, it causes @code{do_stat()} to use
+the @code{stat()} system call instead of the @code{lstat()} system
+call. This is done by using a function pointer: @code{statfunc}.
+@code{statfunc} is initialized to point to @code{lstat()} (instead
+of @code{stat()}) to get the file information, in case the file is a
+symbolic link. However, if there were three arguments, @code{statfunc}
+is set point to @code{stat()}, instead.
+
+Here is the @code{do_stat()} function. It starts with
variable declarations and argument checking:
@ignore
@@ -33073,16 +33111,10 @@ do_stat(int nargs, awk_value_t *result)
@}
@end example
-The third argument to @code{stat()} was not discussed previously. This argument
-is optional. If present, it causes @code{stat()} to use the @code{stat()}
-system call instead of the @code{lstat()} system call.
-
Then comes the actual work. First, the function gets the arguments.
-Next, it gets the information for the file.
-The code use @code{lstat()} (instead of @code{stat()})
-to get the file information,
-in case the file is a symbolic link.
-If there's an error, it sets @code{ERRNO} and returns:
+Next, it gets the information for the file. If the called function
+(@code{lstat()} or @code{stat()}) returns an error, the code sets
+@code{ERRNO} and returns:
@example
/* file is first arg, array to hold results is second */
@@ -33111,7 +33143,7 @@ If there's an error, it sets @code{ERRNO} and returns:
@end example
The tedious work is done by @code{fill_stat_array()}, shown
-earlier. When done, return the result from @code{fill_stat_array()}:
+earlier. When done, the function returns the result from @code{fill_stat_array()}:
@example
ret = fill_stat_array(name, array, & sbuf);
@@ -33174,7 +33206,7 @@ of the @file{gawkapi.h} header file,
the following steps@footnote{In practice, you would probably want to
use the GNU Autotools---Automake, Autoconf, Libtool, and @command{gettext}---to
configure and build your libraries. Instructions for doing so are beyond
-the scope of this @value{DOCUMENT}. @xref{gawkextlib}, for WWW links to
+the scope of this @value{DOCUMENT}. @xref{gawkextlib}, for Internet links to
the tools.} create a GNU/Linux shared library:
@example
@@ -33202,14 +33234,14 @@ BEGIN @{
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
+ strftime("%m %d %Y %H:%M:%S", data["mtime"])
print "\nInfo for JUNK"
ret = stat("JUNK", data)
print "ret =", ret
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
- print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
+ print "JUNK modified:", strftime("%m %d %Y %H:%M:%S", data["mtime"])
@}
@end example
@@ -33223,25 +33255,26 @@ $ @kbd{AWKLIBPATH=$PWD gawk -f testff.awk}
@print{} Info for testff.awk
@print{} ret = 0
@print{} data["blksize"] = 4096
-@print{} data["mtime"] = 1350838628
+@print{} data["devbsize"] = 512
+@print{} data["mtime"] = 1412004710
@print{} data["mode"] = 33204
@print{} data["type"] = file
@print{} data["dev"] = 2053
@print{} data["gid"] = 1000
-@print{} data["ino"] = 1719496
-@print{} data["ctime"] = 1350838628
+@print{} data["ino"] = 10358899
+@print{} data["ctime"] = 1412004710
@print{} data["blocks"] = 8
@print{} data["nlink"] = 1
@print{} data["name"] = testff.awk
-@print{} data["atime"] = 1350838632
+@print{} data["atime"] = 1412004716
@print{} data["pmode"] = -rw-rw-r--
-@print{} data["size"] = 662
+@print{} data["size"] = 666
@print{} data["uid"] = 1000
-@print{} testff.awk modified: 10 21 12 18:57:08
-@print{}
+@print{} testff.awk modified: 09 29 2014 18:31:50
+@print{}
@print{} Info for JUNK
@print{} ret = -1
-@print{} JUNK modified: 01 01 70 02:00:00
+@print{} JUNK modified: 01 01 1970 02:00:00
@end example
@node Extension Samples
@@ -33266,9 +33299,9 @@ Others mainly provide example code that shows how to use the extension API.
* Extension Sample Rev2way:: Reversing data sample two-way processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to @code{gettimeofday()}
and @code{sleep()}.
+* Extension Sample API Tests:: Tests for the API.
@end menu
@node Extension Sample File Functions
@@ -33278,7 +33311,7 @@ The @code{filefuncs} extension provides three different functions, as follows:
The usage is:
@table @asis
-@item @@load "filefuncs"
+@item @code{@@load "filefuncs"}
This is how you load the extension.
@cindex @code{chdir()} extension function
@@ -33341,7 +33374,7 @@ Not all systems support all file types. @tab All
@itemx @code{result = fts(pathlist, flags, filedata)}
Walk the file trees provided in @code{pathlist} and fill in the
@code{filedata} array as described below. @code{flags} is the bitwise
-OR of several predefined constant values, also described below.
+OR of several predefined values, also described below.
Return zero if there were no errors, otherwise return @minus{}1.
@end table
@@ -33386,10 +33419,10 @@ Immediately follow a symbolic link named in @code{pathlist},
whether or not @code{FTS_LOGICAL} is set.
@item FTS_SEEDOT
-By default, the @code{fts()} routines do not return entries for @file{.} (dot)
-and @file{..} (dot-dot). This option causes entries for dot-dot to also
-be included. (The extension always includes an entry for dot,
-see below.)
+By default, the C library @code{fts()} routines do not return entries for
+@file{.} (dot) and @file{..} (dot-dot). This option causes entries for
+dot-dot to also be included. (The extension always includes an entry
+for dot, see below.)
@item FTS_XDEV
During a traversal, do not cross onto a different mounted filesystem.
@@ -33443,8 +33476,8 @@ Otherwise it returns @minus{}1.
@quotation NOTE
The @code{fts()} extension does not exactly mimic the
interface of the C library @code{fts()} routines, choosing instead to
-provide an interface that is based on associative arrays, which should
-be more comfortable to use from an @command{awk} program. This includes the
+provide an interface that is based on associative arrays, which is
+more comfortable to use from an @command{awk} program. This includes the
lack of a comparison function, since @command{gawk} already provides
powerful array sorting facilities. While an @code{fts_read()}-like
interface could have been provided, this felt less natural than simply
@@ -33452,7 +33485,8 @@ creating a multidimensional array to represent the file hierarchy and
its information.
@end quotation
-See @file{test/fts.awk} in the @command{gawk} distribution for an example.
+See @file{test/fts.awk} in the @command{gawk} distribution for an example
+use of the @code{fts()} extension function.
@node Extension Sample Fnmatch
@subsection Interface To @code{fnmatch()}
@@ -33660,7 +33694,7 @@ 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()}}
+@caption{File Types Returned By The @code{readdir} Extension}
@multitable @columnfractions .1 .9
@headitem Letter @tab File Type
@item @code{b} @tab Block device
@@ -33752,6 +33786,9 @@ The @code{rwarray} extension adds two functions,
named @code{writea()} and @code{reada()}, as follows:
@table @code
+@item @@load "rwarray"
+This is how you load the extension.
+
@cindex @code{writea()} extension function
@item ret = writea(file, array)
This function takes a string argument, which is the name of the file
@@ -33827,17 +33864,6 @@ if (contents == "" && ERRNO != "") @{
@}
@end example
-@node Extension Sample API Tests
-@subsection API Tests
-@cindex @code{testext} extension
-
-The @code{testext} extension exercises parts of the extension API that
-are not tested by the other samples. The @file{extension/testext.c}
-file contains both the C code for the extension and @command{awk}
-test code inside C comments that run the tests. The testing framework
-extracts the @command{awk} code and runs the tests. See the source file
-for more information.
-
@node Extension Sample Time
@subsection Extension Time Functions
@@ -33868,6 +33894,17 @@ Implementation details: depending on platform availability, this function
tries to use @code{nanosleep()} or @code{select()} to implement the delay.
@end table
+@node Extension Sample API Tests
+@subsection API Tests
+@cindex @code{testext} extension
+
+The @code{testext} extension exercises parts of the extension API that
+are not tested by the other samples. The @file{extension/testext.c}
+file contains both the C code for the extension and @command{awk}
+test code inside C comments that run the tests. The testing framework
+extracts the @command{awk} code and runs the tests. See the source file
+for more information.
+
@node gawkextlib
@section The @code{gawkextlib} Project
@cindex @code{gawkextlib}
@@ -33883,8 +33920,7 @@ As of this writing, there are five extensions:
@itemize @value{BULLET}
@item
-XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
-XML parsing library.
+GD graphics library extension.
@item
PDF extension.
@@ -33893,17 +33929,14 @@ PDF extension.
PostgreSQL extension.
@item
-GD graphics library extension.
-
-@item
MPFR library extension.
This provides access to a number of MPFR functions which @command{gawk}'s
native MPFR support does not.
-@end itemize
-The @code{time} extension described earlier (@pxref{Extension Sample
-Time}) was originally from this project but has been moved in to the
-main @command{gawk} distribution.
+@item
+XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
+XML parsing library.
+@end itemize
@cindex @command{git} utility
You can check out the code for the @code{gawkextlib} project
@@ -33994,6 +34027,9 @@ API function pointers are provided for the following kinds of operations:
@itemize @value{BULLET}
@item
+Allocating, reallocating, and releasing memory.
+
+@item
Registration functions. You may register
extension functions,
exit callbacks,
@@ -34017,9 +34053,6 @@ Symbol table access: retrieving a global variable, creating one,
or changing one.
@item
-Allocating, reallocating, and releasing memory.
-
-@item
Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and
can be a big performance win.
@@ -34051,7 +34084,7 @@ treated as read-only by the extension.
@item
@emph{All} memory passed from an extension to @command{gawk} must come from
the API's memory allocation functions. @command{gawk} takes responsibility for
-the memory and will release it when appropriate.
+the memory and releases it when appropriate.
@item
The API provides information about the running version of @command{gawk} so
@@ -34068,7 +34101,7 @@ The @command{gawk} distribution includes a number of small but useful
sample extensions. The @code{gawkextlib} project includes several more,
larger, extensions. If you wish to write an extension and contribute it
to the community of @command{gawk} users, the @code{gawkextlib} project
-should be the place to do so.
+is the place to do so.
@end itemize
@@ -34150,7 +34183,7 @@ which follows the POSIX specification. Many long-time @command{awk}
users learned @command{awk} programming with the original @command{awk}
implementation in Version 7 Unix. (This implementation was the basis for
@command{awk} in Berkeley Unix, through 4.3-Reno. Subsequent versions
-of Berkeley Unix, and some systems derived from 4.4BSD-Lite, used various
+of Berkeley Unix, and, for a while, some systems derived from 4.4BSD-Lite, used various
versions of @command{gawk} for their @command{awk}.) This @value{CHAPTER}
briefly describes the evolution of the @command{awk} language, with
cross-references to other parts of the @value{DOCUMENT} where you can
@@ -34223,7 +34256,7 @@ The built-in functions @code{close()} and @code{system()}
@item
The @code{ARGC}, @code{ARGV}, @code{FNR}, @code{RLENGTH}, @code{RSTART},
-and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}).
+and @code{SUBSEP} predefined variables (@pxref{Built-in Variables}).
@item
Assignable @code{$0} (@pxref{Changing Fields}).
@@ -34254,14 +34287,11 @@ of @code{FS}.
@item
Dynamic regexps as operands of the @samp{~} and @samp{!~} operators
-(@pxref{Regexp Usage}).
+(@pxref{Computed Regexps}).
@item
The escape sequences @samp{\b}, @samp{\f}, and @samp{\r}
(@pxref{Escape Sequences}).
-(Some vendors have updated their old versions of @command{awk} to
-recognize @samp{\b}, @samp{\f}, and @samp{\r}, but this is not
-something you can rely on.)
@item
Redirection of input for the @code{getline} function
@@ -34300,7 +34330,7 @@ The @option{-v} option for assigning variables before program execution begins
@c GNU, Bell Laboratories & MKS together
@item
-The @option{--} option for terminating command-line options.
+The @option{--} signal for terminating command-line options.
@item
The @samp{\a}, @samp{\v}, and @samp{\x} escape sequences
@@ -34323,7 +34353,7 @@ A cleaner specification for the @code{%c} format-control letter in the
@item
The ability to dynamically pass the field width and precision (@code{"%*.*d"})
-in the argument list of the @code{printf} function
+in the argument list of @code{printf} and @code{sprintf()}
(@pxref{Control Letters}).
@item
@@ -34358,8 +34388,8 @@ The concept of a numeric string and tighter comparison rules to go
with it (@pxref{Typing and Comparison}).
@item
-The use of built-in variables as function parameter names is forbidden
-(@pxref{Definition Syntax}.
+The use of predefined variables as function parameter names is forbidden
+(@pxref{Definition Syntax}).
@item
More complete documentation of many of the previously undocumented
@@ -34454,7 +34484,7 @@ in the current version of @command{gawk}.
@itemize @value{BULLET}
@item
-Additional built-in variables:
+Additional predefined variables:
@itemize @value{MINUS}
@item
@@ -34538,14 +34568,6 @@ The @code{BEGINFILE} and @code{ENDFILE} special patterns.
(@pxref{BEGINFILE/ENDFILE}).
@item
-The ability to delete all of an array at once with @samp{delete @var{array}}
-(@pxref{Delete}).
-
-@item
-The @code{nextfile} statement
-(@pxref{Nextfile Statement}).
-
-@item
The @code{switch} statement
(@pxref{Switch Statement}).
@end itemize
@@ -34560,7 +34582,7 @@ of a two-way pipe to a coprocess
(@pxref{Two-way I/O}).
@item
-POSIX compliance for @code{gsub()} and @code{sub()}.
+POSIX compliance for @code{gsub()} and @code{sub()} with @option{--posix}.
@item
The @code{length()} function accepts an array argument
@@ -34588,6 +34610,20 @@ Additional functions only in @command{gawk}:
@itemize @value{MINUS}
@item
+The @code{gensub()}, @code{patsplit()}, and @code{strtonum()} functions
+for more powerful text manipulation
+(@pxref{String Functions}).
+
+@item
+The @code{asort()} and @code{asorti()} functions for sorting arrays
+(@pxref{Array Sorting}).
+
+@item
+The @code{mktime()}, @code{systime()}, and @code{strftime()}
+functions for working with timestamps
+(@pxref{Time Functions}).
+
+@item
The
@code{and()},
@code{compl()},
@@ -34601,30 +34637,15 @@ functions for bit manipulation
@c In 4.1, and(), or() and xor() grew the ability to take > 2 arguments
@item
-The @code{asort()} and @code{asorti()} functions for sorting arrays
-(@pxref{Array Sorting}).
+The @code{isarray()} function to check if a variable is an array or not
+(@pxref{Type Functions}).
@item
The @code{bindtextdomain()}, @code{dcgettext()} and @code{dcngettext()}
functions for internationalization
(@pxref{Programmer i18n}).
-
-@item
-The @code{fflush()} function from BWK @command{awk}
-(@pxref{I/O Functions}).
-
-@item
-The @code{gensub()}, @code{patsplit()}, and @code{strtonum()} functions
-for more powerful text manipulation
-(@pxref{String Functions}).
-
-@item
-The @code{mktime()}, @code{systime()}, and @code{strftime()}
-functions for working with timestamps
-(@pxref{Time Functions}).
@end itemize
-
@item
Changes and/or additions in the command-line options:
@@ -34747,7 +34768,7 @@ GCC for VAX and Alpha has not been tested for a while.
@item
Support for the following obsolete systems was removed from the code
-and the documentation for @command{gawk} @value{PVERSION} 4.1:
+for @command{gawk} @value{PVERSION} 4.1:
@c nested table
@itemize @value{MINUS}
@@ -35384,33 +35405,29 @@ The dynamic extension interface was completely redone
@cindex extensions, Brian Kernighan's @command{awk}
@cindex extensions, @command{mawk}
-This @value{SECTION} summarizes the common extensions supported
+The following table summarizes the common extensions supported
by @command{gawk}, Brian Kernighan's @command{awk}, and @command{mawk},
the three most widely-used freely available versions of @command{awk}
(@pxref{Other Versions}).
-@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk}
-@headitem Feature @tab BWK Awk @tab Mawk @tab GNU Awk
-@item @samp{\x} Escape sequence @tab X @tab X @tab X
-@item @code{FS} as null string @tab X @tab X @tab X
-@item @file{/dev/stdin} special file @tab X @tab X @tab X
-@item @file{/dev/stdout} special file @tab X @tab X @tab X
-@item @file{/dev/stderr} special file @tab X @tab X @tab X
-@item @code{delete} without subscript @tab X @tab X @tab X
-@item @code{fflush()} function @tab X @tab X @tab X
-@item @code{length()} of an array @tab X @tab X @tab X
-@item @code{nextfile} statement @tab X @tab X @tab X
-@item @code{**} and @code{**=} operators @tab X @tab @tab X
-@item @code{func} keyword @tab X @tab @tab X
-@item @code{BINMODE} variable @tab @tab X @tab X
-@item @code{RS} as regexp @tab @tab X @tab X
-@item Time related functions @tab @tab X @tab X
+@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk} {Now standard}
+@headitem Feature @tab BWK Awk @tab Mawk @tab GNU Awk @tab Now standard
+@item @samp{\x} Escape sequence @tab X @tab X @tab X @tab
+@item @code{FS} as null string @tab X @tab X @tab X @tab
+@item @file{/dev/stdin} special file @tab X @tab X @tab X @tab
+@item @file{/dev/stdout} special file @tab X @tab X @tab X @tab
+@item @file{/dev/stderr} special file @tab X @tab X @tab X @tab
+@item @code{delete} without subscript @tab X @tab X @tab X @tab X
+@item @code{fflush()} function @tab X @tab X @tab X @tab X
+@item @code{length()} of an array @tab X @tab X @tab X @tab
+@item @code{nextfile} statement @tab X @tab X @tab X @tab X
+@item @code{**} and @code{**=} operators @tab X @tab @tab X @tab
+@item @code{func} keyword @tab X @tab @tab X @tab
+@item @code{BINMODE} variable @tab @tab X @tab X @tab
+@item @code{RS} as regexp @tab @tab X @tab X @tab
+@item Time related functions @tab @tab X @tab X @tab
@end multitable
-(Technically speaking, as of late 2012, @code{fflush()}, @samp{delete @var{array}},
-and @code{nextfile} are no longer extensions, since they have been added
-to POSIX.)
-
@node Ranges and Locales
@appendixsec Regexp Ranges and Locales: A Long Sad Story
@@ -35447,6 +35464,7 @@ In the @code{"C"} and @code{"POSIX"} locales, a range expression like
But outside those locales, the ordering was defined to be based on
@dfn{collation order}.
+What does that mean?
In many locales, @samp{A} and @samp{a} are both less than @samp{B}.
In other words, these locales sort characters in dictionary order,
and @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
@@ -35454,7 +35472,7 @@ instead it might be equivalent to @samp{[ABCXYabcdxyz]}, for example.
This point needs to be emphasized: Much literature teaches that you should
use @samp{[a-z]} to match a lowercase character. But on systems with
-non-ASCII locales, this also matched all of the uppercase characters
+non-ASCII locales, this also matches all of the uppercase characters
except @samp{A} or @samp{Z}! This was a continuous cause of confusion, even well
into the twenty-first century.
@@ -35644,7 +35662,7 @@ the various PC platforms.
@cindex Zoulas, Christos
Christos Zoulas
provided the @code{extension()}
-built-in function for dynamically adding new modules.
+built-in function for dynamically adding new functions.
(This was obsoleted at @command{gawk} 4.1.)
@item
@@ -35760,6 +35778,11 @@ The development of the extension API first released with
Arnold Robbins and Andrew Schorr, with notable contributions from
the rest of the development team.
+@cindex Malmberg, John E.
+@item
+John Malmberg contributed significant improvements to the
+OpenVMS port and the related documentation.
+
@item
@cindex Colombo, Antonio
Antonio Giovanni Colombo rewrote a number of examples in the early
@@ -37552,7 +37575,7 @@ make it possible to include them:
@enumerate 1
@item
Before building the new feature into @command{gawk} itself,
-consider writing it as an extension module
+consider writing it as an extension
(@pxref{Dynamic Extensions}).
If that's not possible, continue with the rest of the steps in this list.
@@ -38283,7 +38306,7 @@ Pat Rankin suggested the solution that was adopted.
@appendixsubsec Other Design Decisions
As an arbitrary design decision, extensions can read the values of
-built-in variables and arrays (such as @code{ARGV} and @code{FS}), but cannot
+predefined variables and arrays (such as @code{ARGV} and @code{FS}), but cannot
change them, with the exception of @code{PROCINFO}.
The reason for this is to prevent an extension function from affecting
@@ -39024,11 +39047,11 @@ See ``Free Documentation License.''
@item Field
When @command{awk} reads an input record, it splits the record into pieces
separated by whitespace (or by a separator regexp that you can
-change by setting the built-in variable @code{FS}). Such pieces are
+change by setting the predefined variable @code{FS}). Such pieces are
called fields. If the pieces are of fixed length, you can use the built-in
variable @code{FIELDWIDTHS} to describe their lengths.
If you wish to specify the contents of fields instead of the field
-separator, you can use the built-in variable @code{FPAT} to do so.
+separator, you can use the predefined variable @code{FPAT} to do so.
(@xref{Field Separators},
@ref{Constant Size},
and
@@ -39047,7 +39070,7 @@ See also ``Double Precision'' and ``Single Precision.''
Format strings control the appearance of output in the
@code{strftime()} and @code{sprintf()} functions, and in the
@code{printf} statement as well. Also, data conversions from numbers to strings
-are controlled by the format strings contained in the built-in variables
+are controlled by the format strings contained in the predefined variables
@code{CONVFMT} and @code{OFMT}. (@xref{Control Letters}.)
@item Free Documentation License
diff --git a/extension/ChangeLog b/extension/ChangeLog
index cae97deb..d165d5ef 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * filefuncs.c: Minor edits to sync with documentation.
+ * testext.c: Add test to get PROCINFO, expected to fail.
+
2014-08-12 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (RM): Define for makes that don't have it,
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index d5249a4e..a20e9ff7 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -145,7 +145,7 @@ static const char *ext_version = "filefuncs extension: version 1.0";
int plugin_is_GPL_compatible;
-/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+/* do_chdir --- provide dynamically loaded chdir() function for gawk */
static awk_value_t *
do_chdir(int nargs, awk_value_t *result)
@@ -448,7 +448,7 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf)
}
}
- array_set(array, "type", make_const_string(type, strlen(type), &tmp));
+ array_set(array, "type", make_const_string(type, strlen(type), & tmp));
return 0;
}
diff --git a/extension/testext.c b/extension/testext.c
index 2dda339f..7462265b 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -302,6 +302,12 @@ var_test(int nargs, awk_value_t *result)
goto out;
}
+ /* look up PROCINFO - should fail */
+ if (sym_lookup("PROCINFO", AWK_ARRAY, & value))
+ printf("var_test: sym_lookup of PROCINFO failed - got a value!\n");
+ else
+ printf("var_test: sym_lookup of PROCINFO passed - did not get a value\n");
+
/* look up a reserved variable - should pass */
if (sym_lookup("ARGC", AWK_NUMBER, & value))
printf("var_test: sym_lookup of ARGC passed - got a value!\n");
diff --git a/gawkapi.h b/gawkapi.h
index 090cf797..d8215450 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -865,17 +865,17 @@ static awk_bool_t (*init_func)(void) = NULL;
/* OR: */
static awk_bool_t
-init_my_module(void)
+init_my_extension(void)
{
...
}
-static awk_bool_t (*init_func)(void) = init_my_module;
+static awk_bool_t (*init_func)(void) = init_my_extension;
dl_load_func(func_table, some_name, "name_space_in_quotes")
#endif
-#define dl_load_func(func_table, module, name_space) \
+#define dl_load_func(func_table, extension, name_space) \
int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \
{ \
size_t i, j; \
@@ -886,7 +886,7 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \
\
if (api->major_version != GAWK_API_MAJOR_VERSION \
|| api->minor_version < GAWK_API_MINOR_VERSION) { \
- fprintf(stderr, #module ": version mismatch with gawk!\n"); \
+ fprintf(stderr, #extension ": version mismatch with gawk!\n"); \
fprintf(stderr, "\tmy version (%d, %d), gawk version (%d, %d)\n", \
GAWK_API_MAJOR_VERSION, GAWK_API_MINOR_VERSION, \
api->major_version, api->minor_version); \
@@ -898,7 +898,7 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \
if (func_table[i].name == NULL) \
break; \
if (! add_ext_func(name_space, & func_table[i])) { \
- warning(ext_id, #module ": could not add %s\n", \
+ warning(ext_id, #extension ": could not add %s\n", \
func_table[i].name); \
errors++; \
} \
@@ -906,7 +906,7 @@ int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id) \
\
if (init_func != NULL) { \
if (! init_func()) { \
- warning(ext_id, #module ": initialization function failed\n"); \
+ warning(ext_id, #extension ": initialization function failed\n"); \
errors++; \
} \
} \
diff --git a/test/ChangeLog b/test/ChangeLog
index 5a641b84..33ba57af 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2014-09-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * testext.ok: Adjusted after minor code change.
+
2014-09-27 Arnold D. Robbins <arnold@skeeve.com>
* profile2.ok, profile3.ok, profile4.ok, profile5.ok:
diff --git a/test/testext.ok b/test/testext.ok
index 5612e92c..9b36bf72 100644
--- a/test/testext.ok
+++ b/test/testext.ok
@@ -15,6 +15,7 @@ try_modify_environ: set_array_element of ENVIRON failed
try_modify_environ: marking element "testext" for deletion
try_del_environ() could not delete element - pass
try_del_environ() could not add an element - pass
+var_test: sym_lookup of PROCINFO passed - did not get a value
var_test: sym_lookup of ARGC passed - got a value!
var_test: sym_update of ARGC failed - correctly
var_test: sym_update("testvar") succeeded