summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-09-27 22:22:15 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-09-27 22:22:15 +0300
commit6f66d82e5794022ec2873d1f3ccba8e1267ca9a3 (patch)
tree9a62f3b51dd28ae5f3c45c76c4270ab415411b9e
parenteeb0b5d5b0791c580e49e7a6ca4f844f2a0edabb (diff)
downloadgawk-6f66d82e5794022ec2873d1f3ccba8e1267ca9a3.tar.gz
Lots more documentation fixes.
-rw-r--r--awklib/eg/lib/groupawk.in3
-rw-r--r--awklib/eg/lib/noassign.awk2
-rw-r--r--awklib/eg/lib/readable.awk2
-rw-r--r--awklib/eg/prog/cut.awk8
-rw-r--r--awklib/eg/prog/egrep.awk7
-rw-r--r--awklib/eg/prog/extract.awk11
-rw-r--r--awklib/eg/prog/id.awk22
-rw-r--r--awklib/eg/prog/split.awk5
-rw-r--r--awklib/eg/prog/uniq.awk5
-rw-r--r--doc/ChangeLog6
-rw-r--r--doc/gawk.info1394
-rw-r--r--doc/gawk.texi258
-rw-r--r--doc/gawktexi.in258
13 files changed, 964 insertions, 1017 deletions
diff --git a/awklib/eg/lib/groupawk.in b/awklib/eg/lib/groupawk.in
index 9382bce8..54a27f3d 100644
--- a/awklib/eg/lib/groupawk.in
+++ b/awklib/eg/lib/groupawk.in
@@ -38,8 +38,7 @@ function _gr_init( oldfs, oldrs, olddol0, grcat,
n = split($4, a, "[ \t]*,[ \t]*")
for (i = 1; i <= n; i++)
if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
+ _gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1
else
_gr_groupsbyuser[a[i]] = $1
diff --git a/awklib/eg/lib/noassign.awk b/awklib/eg/lib/noassign.awk
index 1f750edf..99227b37 100644
--- a/awklib/eg/lib/noassign.awk
+++ b/awklib/eg/lib/noassign.awk
@@ -7,7 +7,7 @@
function disable_assigns(argc, argv, i)
{
for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/)
+ if (argv[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/)
argv[i] = ("./" argv[i])
}
diff --git a/awklib/eg/lib/readable.awk b/awklib/eg/lib/readable.awk
index 6942dcca..37970a82 100644
--- a/awklib/eg/lib/readable.awk
+++ b/awklib/eg/lib/readable.awk
@@ -6,7 +6,7 @@
BEGIN {
for (i = 1; i < ARGC; i++) {
- if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \
+ if (ARGV[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/ \
|| ARGV[i] == "-" || ARGV[i] == "/dev/stdin")
continue # assignment or standard input
else if ((getline junk < ARGV[i]) < 0) # unreadable
diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk
index 56e35e71..080279bc 100644
--- a/awklib/eg/prog/cut.awk
+++ b/awklib/eg/prog/cut.awk
@@ -12,12 +12,10 @@
#
# Requires getopt() and join() library functions
-function usage( e1, e2)
+function usage()
{
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
+ print("usage: cut [-f list] [-d c] [-s] [files...]") > "/dev/stderr"
+ print("usage: cut [-c list] [files...]") > "/dev/stderr"
exit 1
}
BEGIN {
diff --git a/awklib/eg/prog/egrep.awk b/awklib/eg/prog/egrep.awk
index 094bdea5..a4165a90 100644
--- a/awklib/eg/prog/egrep.awk
+++ b/awklib/eg/prog/egrep.awk
@@ -91,10 +91,9 @@ function endfile(file)
END {
exit (total == 0)
}
-function usage( e)
+function usage()
{
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
+ print("Usage: egrep [-csvil] [-e pat] [files ...]") > "/dev/stderr"
+ print("\n\tegrep [-csvil] pat [files ...]") > "/dev/stderr"
exit 1
}
diff --git a/awklib/eg/prog/extract.awk b/awklib/eg/prog/extract.awk
index 12e30b54..24f40ce5 100644
--- a/awklib/eg/prog/extract.awk
+++ b/awklib/eg/prog/extract.awk
@@ -1,5 +1,4 @@
-# extract.awk --- extract files and run programs
-# from texinfo files
+# extract.awk --- extract files and run programs from texinfo files
#
# Arnold Robbins, arnold@skeeve.com, Public Domain
# May 1993
@@ -7,8 +6,7 @@
BEGIN { IGNORECASE = 1 }
-/^@c(omment)?[ \t]+system/ \
-{
+/^@c(omment)?[ \t]+system/ {
if (NF < 3) {
e = ("extract: " FILENAME ":" FNR)
e = (e ": badly formed `system' line")
@@ -24,8 +22,7 @@ BEGIN { IGNORECASE = 1 }
print e > "/dev/stderr"
}
}
-/^@c(omment)?[ \t]+file/ \
-{
+/^@c(omment)?[ \t]+file/ {
if (NF != 3) {
e = ("extract: " FILENAME ":" FNR ": badly formed `file' line")
print e > "/dev/stderr"
@@ -66,7 +63,7 @@ BEGIN { IGNORECASE = 1 }
function unexpected_eof()
{
printf("extract: %s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
+ FILENAME, FNR) > "/dev/stderr"
exit 1
}
diff --git a/awklib/eg/prog/id.awk b/awklib/eg/prog/id.awk
index 992fa57c..b6061f9b 100644
--- a/awklib/eg/prog/id.awk
+++ b/awklib/eg/prog/id.awk
@@ -6,6 +6,7 @@
# May 1993
# Revised February 1996
# Revised May 2014
+# Revised September 2014
# output is:
# uid=12(foo) euid=34(bar) gid=3(baz) \
@@ -19,26 +20,22 @@ BEGIN {
printf("uid=%d", uid)
pw = getpwuid(uid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (euid != uid) {
printf(" euid=%d", euid)
pw = getpwuid(euid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
}
printf(" gid=%d", gid)
pw = getgrgid(gid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (egid != gid) {
printf(" egid=%d", egid)
pw = getgrgid(egid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
}
for (i = 1; ("group" i) in PROCINFO; i++) {
@@ -47,8 +44,7 @@ BEGIN {
group = PROCINFO["group" i]
printf("%d", group)
pw = getgrgid(group)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (("group" (i+1)) in PROCINFO)
printf(",")
}
@@ -58,6 +54,8 @@ BEGIN {
function pr_first_field(str, a)
{
- split(str, a, ":")
- printf("(%s)", a[1])
+ if (str != "") {
+ split(str, a, ":")
+ printf("(%s)", a[1])
+ }
}
diff --git a/awklib/eg/prog/split.awk b/awklib/eg/prog/split.awk
index bcc73ae6..6a7198f6 100644
--- a/awklib/eg/prog/split.awk
+++ b/awklib/eg/prog/split.awk
@@ -50,9 +50,8 @@ BEGIN {
}
print > out
}
-function usage( e)
+function usage()
{
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
+ print("usage: split [-num] [file] [outname]") > "/dev/stderr"
exit 1
}
diff --git a/awklib/eg/prog/uniq.awk b/awklib/eg/prog/uniq.awk
index 2a2cf63e..7dd16099 100644
--- a/awklib/eg/prog/uniq.awk
+++ b/awklib/eg/prog/uniq.awk
@@ -5,10 +5,9 @@
# Arnold Robbins, arnold@skeeve.com, Public Domain
# May 1993
-function usage( e)
+function usage()
{
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
+ print("Usage: uniq [-udc [-n]] [+n] [ in [ out ]]") > "/dev/stderr"
exit 1
}
diff --git a/doc/ChangeLog b/doc/ChangeLog
index cacaf940..314192c0 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,6 +1,10 @@
+2014-09-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Lots more fixes after reading through the MS.
+
2014-09-23 Arnold D. Robbins <arnold@skeeve.com>
- * gawktex.in: Rework the documentation of special files in
+ * gawktexi.in: Rework the documentation of special files in
Chapter 5; some reordering as well as rewriting.
2014-09-22 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/doc/gawk.info b/doc/gawk.info
index 547bee90..bd3966bd 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -2570,6 +2570,8 @@ The following list describes options mandated by the POSIX standard:
CAUTION: This option can severely break old programs. Use
with care.
+ This option may disappear in a future version of `gawk'.
+
`-N'
`--use-lc-numeric'
Force the use of the locale's decimal point character when parsing
@@ -15135,15 +15137,12 @@ over with it from the top. For lack of a better name, we'll call it
nextfile
}
- This code relies on the `ARGIND' variable (*note Auto-set::), which
-is specific to `gawk'. If you are not using `gawk', you can use ideas
-presented in *note Filetrans Function::, to either update `ARGIND' on
-your own or modify this code as appropriate.
-
- The `rewind()' function also relies on the `nextfile' keyword (*note
-Nextfile Statement::). Because of this, you should not call it from an
-`ENDFILE' rule. (This isn't necessary anyway, since as soon as an
-`ENDFILE' rule finishes `gawk' goes to the next file!)
+ The `rewind()' function relies on the `ARGIND' variable (*note
+Auto-set::), which is specific to `gawk'. It also relies on the
+`nextfile' keyword (*note Nextfile Statement::). Because of this, you
+should not call it from an `ENDFILE' rule. (This isn't necessary
+anyway, since as soon as an `ENDFILE' rule finishes `gawk' goes to the
+next file!)

File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management
@@ -15160,7 +15159,7 @@ following program to your `awk' program:
BEGIN {
for (i = 1; i < ARGC; i++) {
- if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \
+ if (ARGV[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/ \
|| ARGV[i] == "-" || ARGV[i] == "/dev/stdin")
continue # assignment or standard input
else if ((getline junk < ARGV[i]) < 0) # unreadable
@@ -15174,6 +15173,10 @@ following program to your `awk' program:
element from `ARGV' with `delete' skips the file (since it's no longer
in the list). See also *note ARGC and ARGV::.
+ The regular expression check purposely does not use character classes
+such as `[:alpha:]' and `[:alnum:]' (*note Bracket Expressions::) since
+`awk' variable names only allow the English letters.
+
---------- Footnotes ----------
(1) The `BEGINFILE' special pattern (*note BEGINFILE/ENDFILE::)
@@ -15252,7 +15255,7 @@ programming with a library file does the trick:
function disable_assigns(argc, argv, i)
{
for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/)
+ if (argv[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/)
argv[i] = ("./" argv[i])
}
@@ -15552,10 +15555,14 @@ result of two sample runs of the test program:
In both runs, the first `--' terminates the arguments to `awk', so
that it does not try to interpret the `-a', etc., as its own options.
- NOTE: After `getopt()' is through, it is the responsibility of the
- user level code to clear out all the elements of `ARGV' from 1 to
- `Optind', so that `awk' does not try to process the command-line
- options as file names.
+ NOTE: After `getopt()' is through, user level code must clear out
+ all the elements of `ARGV' from 1 to `Optind', so that `awk' does
+ not try to process the command-line options as file names.
+
+ Using `#!' with the `-E' option may help avoid conflicts between
+your program's options and `gawk''s options, since `-E' causes `gawk'
+to abandon processing of further options (*note Executable Scripts::,
+and *note Options::).
Several of the sample programs presented in *note Sample Programs::,
use `getopt()' to process their arguments.
@@ -15714,8 +15721,8 @@ corresponding to the C functions of the same names:
routine, we have chosen to put it in `/usr/local/libexec/awk'; however,
you might want it to be in a different directory on your system.
- The function `_pw_init()' keeps three copies of the user information
-in three associative arrays. The arrays are indexed by username
+ The function `_pw_init()' fills three copies of the user information
+into three associative arrays. The arrays are indexed by username
(`_pw_byname'), by user ID number (`_pw_byuid'), and by order of
occurrence (`_pw_bycount'). The variable `_pw_inited' is used for
efficiency, since `_pw_init()' needs to be called only once.
@@ -15725,13 +15732,10 @@ efficiency, since `_pw_init()' needs to be called only once.
in the variable `using_fw' whether field splitting with `FIELDWIDTHS'
is in effect or not. Doing so is necessary, since these functions
could be called from anywhere within a user's program, and the user may
-have his or her own way of splitting records and fields.
-
- The `using_fw' variable checks `PROCINFO["FS"]', which is
-`"FIELDWIDTHS"' if field splitting is being done with `FIELDWIDTHS'.
-This makes it possible to restore the correct field-splitting mechanism
-later. The test can only be true for `gawk'. It is false if using
-`FS' or `FPAT', or on some other `awk' implementation.
+have his or her own way of splitting records and fields. This makes it
+possible to restore the correct field-splitting mechanism later. The
+test can only be true for `gawk'. It is false if using `FS' or `FPAT',
+or on some other `awk' implementation.
The code that checks for using `FPAT', using `using_fpat' and
`PROCINFO["FS"]', is similar.
@@ -15927,8 +15931,7 @@ the same names:
n = split($4, a, "[ \t]*,[ \t]*")
for (i = 1; i <= n; i++)
if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
+ _gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1
else
_gr_groupsbyuser[a[i]] = $1
@@ -16104,8 +16107,8 @@ File: gawk.info, Node: Library Functions Summary, Next: Library Exercises, Pr
============
* Reading programs is an excellent way to learn Good Programming.
- The functions provided in this major node and the next are intended
- to serve that purpose.
+ The functions and programs provided in this major node and the next
+ are intended to serve that purpose.
* When writing general-purpose library functions, put some thought
into how to name any global variables so that they won't conflict
@@ -16296,18 +16299,13 @@ supplied:
#
# Requires getopt() and join() library functions
- function usage( e1, e2)
+ function usage()
{
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
+ print("usage: cut [-f list] [-d c] [-s] [files...]") > "/dev/stderr"
+ print("usage: cut [-c list] [files...]") > "/dev/stderr"
exit 1
}
-The variables `e1' and `e2' are used so that the function fits nicely
-on the screen.
-
Next comes a `BEGIN' rule that parses the command-line options. It
sets `FS' to a single TAB character, because that is `cut''s default
field separator. The rule then sets the output field separator to be the
@@ -16709,17 +16707,13 @@ there are no matches, the exit status is one; otherwise it is zero:
The `usage()' function prints a usage message in case of invalid
options, and then exits:
- function usage( e)
+ function usage()
{
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
+ print("Usage: egrep [-csvil] [-e pat] [files ...]") > "/dev/stderr"
+ print("\n\tegrep [-csvil] pat [files ...]") > "/dev/stderr"
exit 1
}
- The variable `e' is used so that the function fits nicely on the
-printed page.
-
---------- Footnotes ----------
(1) It also introduces a subtle bug; if a match happens, we output
@@ -16770,26 +16764,22 @@ and the group numbers:
printf("uid=%d", uid)
pw = getpwuid(uid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (euid != uid) {
printf(" euid=%d", euid)
pw = getpwuid(euid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
}
printf(" gid=%d", gid)
pw = getgrgid(gid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (egid != gid) {
printf(" egid=%d", egid)
pw = getgrgid(egid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
}
for (i = 1; ("group" i) in PROCINFO; i++) {
@@ -16798,8 +16788,7 @@ and the group numbers:
group = PROCINFO["group" i]
printf("%d", group)
pw = getgrgid(group)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (("group" (i+1)) in PROCINFO)
printf(",")
}
@@ -16809,8 +16798,10 @@ and the group numbers:
function pr_first_field(str, a)
{
- split(str, a, ":")
- printf("(%s)", a[1])
+ if (str != "") {
+ split(str, a, ":")
+ printf("(%s)", a[1])
+ }
}
The test in the `for' loop is worth noting. Any supplementary
@@ -16828,8 +16819,9 @@ then the condition is false the first time it's tested, and the loop
body never executes.
The `pr_first_field()' function simply isolates out some code that
-is used repeatedly, making the whole program slightly shorter and
-cleaner.
+is used repeatedly, making the whole program shorter and cleaner. In
+particular, moving the check for the empty string into this function
+saves several lines of code.

File: gawk.info, Node: Split Program, Next: Tee Program, Prev: Id Program, Up: Clones
@@ -16920,15 +16912,12 @@ moves to the next letter in the alphabet and `s2' starts over again at
The `usage()' function simply prints an error message and exits:
- function usage( e)
+ function usage()
{
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
+ print("usage: split [-num] [file] [outname]") > "/dev/stderr"
exit 1
}
-The variable `e' is used so that the function fits nicely on the screen.
-
This program is a bit sloppy; it relies on `awk' to automatically
close the last file instead of doing it in an `END' rule. It also
assumes that letters are contiguous in the character set, which isn't
@@ -17041,10 +17030,10 @@ usage is as follows:
The options for `uniq' are:
`-d'
- Print only repeated lines.
+ Print only repeated (duplicated) lines.
`-u'
- Print only nonrepeated lines.
+ Print only nonrepeated (unique) lines.
`-c'
Count lines. This option overrides `-d' and `-u'. Both repeated
@@ -17094,10 +17083,9 @@ standard output, `/dev/stdout':
#
# Requires getopt() and join() library functions
- function usage( e)
+ function usage()
{
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
+ print("Usage: uniq [-udc [-n]] [+n] [ in [ out ]]") > "/dev/stderr"
exit 1
}
@@ -17151,16 +17139,18 @@ standard output, `/dev/stdout':
The following function, `are_equal()', compares the current line,
`$0', to the previous line, `last'. It handles skipping fields and
characters. If no field count and no character count are specified,
-`are_equal()' simply returns one or zero depending upon the result of a
-simple string comparison of `last' and `$0'. Otherwise, things get more
-complicated. If fields have to be skipped, each line is broken into an
-array using `split()' (*note String Functions::); the desired fields
-are then joined back into a line using `join()'. The joined lines are
-stored in `clast' and `cline'. If no fields are skipped, `clast' and
-`cline' are set to `last' and `$0', respectively. Finally, if
-characters are skipped, `substr()' is used to strip off the leading
-`charcount' characters in `clast' and `cline'. The two strings are
-then compared and `are_equal()' returns the result:
+`are_equal()' returns one or zero depending upon the result of a simple
+string comparison of `last' and `$0'.
+
+ Otherwise, things get more complicated. If fields have to be
+skipped, each line is broken into an array using `split()' (*note
+String Functions::); the desired fields are then joined back into a line
+using `join()'. The joined lines are stored in `clast' and `cline'.
+If no fields are skipped, `clast' and `cline' are set to `last' and
+`$0', respectively. Finally, if characters are skipped, `substr()' is
+used to strip off the leading `charcount' characters in `clast' and
+`cline'. The two strings are then compared and `are_equal()' returns
+the result:
function are_equal( n, m, clast, cline, alast, aline)
{
@@ -17256,8 +17246,8 @@ one or more input files. Its usage is as follows:
If no files are specified on the command line, `wc' reads its
standard input. If there are multiple files, it also prints total
-counts for all the files. The options and their meanings are shown in
-the following list:
+counts for all the files. The options and their meanings are as
+follows:
`-l'
Count only lines.
@@ -17748,12 +17738,12 @@ splits records at blank lines (*note Records::). It sets `MAXLINES' to
Most of the work is done in the `printpage()' function. The label
lines are stored sequentially in the `line' array. But they have to
print horizontally; `line[1]' next to `line[6]', `line[2]' next to
-`line[7]', and so on. Two loops are used to accomplish this. The
-outer loop, controlled by `i', steps through every 10 lines of data;
-this is each row of labels. The inner loop, controlled by `j', goes
-through the lines within the row. As `j' goes from 0 to 4, `i+j' is
-the `j'-th line in the row, and `i+j+5' is the entry next to it. The
-output ends up looking something like this:
+`line[7]', and so on. Two loops accomplish this. The outer loop,
+controlled by `i', steps through every 10 lines of data; this is each
+row of labels. The inner loop, controlled by `j', goes through the
+lines within the row. As `j' goes from 0 to 4, `i+j' is the `j'-th
+line in the row, and `i+j+5' is the entry next to it. The output ends
+up looking something like this:
line 1 line 6
line 2 line 7
@@ -17844,7 +17834,7 @@ a useful format.
At first glance, a program like this would seem to do the job:
- # Print list of word frequencies
+ # wordfreq-first-try.awk --- print list of word frequencies
{
for (i = 1; i <= NF; i++)
@@ -17998,9 +17988,9 @@ Texinfo input file into separate files.
This Info file is written in Texinfo
(http://www.gnu.org/software/texinfo/), the GNU project's document
formatting language. A single Texinfo source file can be used to
-produce both printed and online documentation. The Texinfo language is
-described fully, starting with *note (Texinfo)Top::
-texinfo,Texinfo--The GNU Documentation Format.
+produce both printed documentation, with TeX, and online documentation.
+(The Texinfo language is described fully, starting with *note
+(Texinfo)Top:: texinfo,Texinfo--The GNU Documentation Format.)
For our purposes, it is enough to know three things about Texinfo
input files:
@@ -18062,13 +18052,11 @@ upper- and lowercase letters in the directives won't matter.
given (`NF' is at least three) and also checking that the command exits
with a zero exit status, signifying OK:
- # extract.awk --- extract files and run programs
- # from texinfo files
+ # extract.awk --- extract files and run programs from texinfo files
BEGIN { IGNORECASE = 1 }
- /^@c(omment)?[ \t]+system/ \
- {
+ /^@c(omment)?[ \t]+system/ {
if (NF < 3) {
e = ("extract: " FILENAME ":" FNR)
e = (e ": badly formed `system' line")
@@ -18116,8 +18104,7 @@ with the value of `SUBSEP' (*note Multidimensional::), to rejoin the
pieces back into a single line. That line is then printed to the
output file:
- /^@c(omment)?[ \t]+file/ \
- {
+ /^@c(omment)?[ \t]+file/ {
if (NF != 3) {
e = ("extract: " FILENAME ":" FNR ": badly formed `file' line")
print e > "/dev/stderr"
@@ -18171,7 +18158,7 @@ closing the open file:
function unexpected_eof()
{
printf("extract: %s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
+ FILENAME, FNR) > "/dev/stderr"
exit 1
}
@@ -18380,8 +18367,8 @@ arguments are supplied, then the first nonoption argument should be the
`awk' program. If there are no command-line arguments left, `igawk'
prints an error message and exits. Otherwise, the first argument is
appended to `program'. In any case, after the arguments have been
-processed, `program' contains the complete text of the original `awk'
-program.
+processed, the shell variable `program' contains the complete text of
+the original `awk' program.
The program is as follows:
@@ -18627,7 +18614,7 @@ and it is frequently easier to do certain kinds of string and argument
manipulation using the shell than it is in `awk'.
Finally, `igawk' shows that it is not always necessary to add new
-features to a program; they can often be layered on top.
+features to a program; they can often be layered on top.(3)
---------- Footnotes ----------
@@ -18638,6 +18625,9 @@ programming book if you wish to understand things in more depth.
(2) On some very old versions of `awk', the test `getline junk < t'
can loop forever if the file exists but is empty.
+ (3) `gawk' does `@include' processing itself in order to support the
+use of `awk' programs as Web CGI scripts.
+

File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs
@@ -18649,12 +18639,11 @@ word list (such as `/usr/share/dict/words' on many GNU/Linux systems).
One word is an anagram of another if both words contain the same letters
(for example, "babbling" and "blabbing").
- An elegant algorithm is presented in Column 2, Problem C of Jon
-Bentley's `Programming Pearls', second edition. The idea is to give
-words that are anagrams a common signature, sort all the words together
-by their signature, and then print them. Dr. Bentley observes that
-taking the letters in each word and sorting them produces that common
-signature.
+ Column 2, Problem C of Jon Bentley's `Programming Pearls', second
+edition, presents an elegant algorithm. The idea is to give words that
+are anagrams a common signature, sort all the words together by their
+signature, and then print them. Dr. Bentley observes that taking the
+letters in each word and sorting them produces that common signature.
The following program uses arrays of arrays to bring together words
with the same signature and array sorting to print the words in sorted
@@ -18763,9 +18752,9 @@ File: gawk.info, Node: Programs Summary, Next: Programs Exercises, Prev: Misc
11.4 Summary
============
- * The functions provided in this major node and the previous one
- continue on the theme that reading programs is an excellent way to
- learn Good Programming.
+ * The programs provided in this major node continue on the theme
+ that reading programs is an excellent way to learn Good
+ Programming.
* Using `#!' to make `awk' programs directly runnable makes them
easier to use. Otherwise, invoke the program using `awk -f ...'.
@@ -18942,11 +18931,10 @@ File: gawk.info, Node: Nondecimal Data, Next: Array Sorting, Up: Advanced Fea
===================================
If you run `gawk' with the `--non-decimal-data' option, you can have
-nondecimal constants in your input data:
+nondecimal values in your input data:
$ echo 0123 123 0x123 |
- > gawk --non-decimal-data '{ printf "%d, %d, %d\n",
- > $1, $2, $3 }'
+ > gawk --non-decimal-data '{ printf "%d, %d, %d\n", $1, $2, $3 }'
-| 83, 123, 291
For this feature to work, write your program so that `gawk' treats
@@ -18977,6 +18965,8 @@ request it.
programs easier to write and easier to read, and leads to less
surprising results.
+ This option may disappear in a future version of `gawk'.
+

File: gawk.info, Node: Array Sorting, Next: Two-way I/O, Prev: Nondecimal Data, Up: Advanced Features
@@ -19015,7 +19005,7 @@ pre-defined values to `PROCINFO["sorted_in"]' in order to control the
order in which `gawk' traverses an array during a `for' loop.
In addition, the value of `PROCINFO["sorted_in"]' can be a function
-name. This lets you traverse an array based on any custom criterion.
+name.(1) This lets you traverse an array based on any custom criterion.
The array elements are ordered according to the return value of this
function. The comparison function should be defined with at least four
arguments:
@@ -19130,7 +19120,7 @@ of the previous functions:
according to login name. The following program sorts records by a
specific field position and can be used for this purpose:
- # sort.awk --- simple program to sort by field position
+ # passwd-sort.awk --- simple program to sort by field position
# field position is specified by the global variable POS
function cmp_field(i1, v1, i2, v2)
@@ -19182,13 +19172,14 @@ seemingly ordered data:
elements compare equal. This is usually not a problem, but letting the
tied elements come out in arbitrary order can be an issue, especially
when comparing item values. The partial ordering of the equal elements
-may change during the next loop traversal, if other elements are added
-or removed from the array. One way to resolve ties when comparing
-elements with otherwise equal values is to include the indices in the
-comparison rules. Note that doing this may make the loop traversal
-less efficient, so consider it only if necessary. The following
-comparison functions force a deterministic order, and are based on the
-fact that the (string) indices of two elements are never equal:
+may change the next time the array is traversed, if other elements are
+added or removed from the array. One way to resolve ties when
+comparing elements with otherwise equal values is to include the
+indices in the comparison rules. Note that doing this may make the
+loop traversal less efficient, so consider it only if necessary. The
+following comparison functions force a deterministic order, and are
+based on the fact that the (string) indices of two elements are never
+equal:
function cmp_numeric(i1, v1, i2, v2)
{
@@ -19227,6 +19218,11 @@ array has been reported to add 15% to 20% overhead to the execution
time of `awk' programs. For this reason, sorted array traversal is not
the default.
+ ---------- Footnotes ----------
+
+ (1) This is why the predefined sorting orders start with an `@'
+character, which cannot be part of an identifier.
+

File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traversal, Up: Array Sorting
@@ -19439,7 +19435,7 @@ using regular pipes.
(1) Michael Brennan suggests the use of `rand()' to generate unique
file names. This is a valid point; nevertheless, temporary files remain
-more difficult than two-way pipes.
+more difficult to use than two-way pipes.
(2) This is very different from the same operator in the C shell and
in Bash.
@@ -19454,7 +19450,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.
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
@@ -19478,8 +19474,8 @@ NET-TYPE
PROTOCOL
The protocol to use over IP. This must be either `tcp', or `udp',
- for a TCP or UDP IP connection, respectively. The use of TCP is
- recommended for most applications.
+ for a TCP or UDP IP connection, respectively. TCP should be used
+ for most applications.
LOCAL-PORT
The local TCP or UDP port number to use. Use a port number of `0'
@@ -19505,10 +19501,10 @@ REMOTE-PORT
Consider the following very simple example:
BEGIN {
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
+ Service = "/inet/tcp/0/localhost/daytime"
+ Service |& getline
+ print $0
+ close(Service)
}
This program reads the current date and time from the local system's
@@ -31138,20 +31134,20 @@ Index
* --include option: Options. (line 159)
* --lint option <1>: Options. (line 185)
* --lint option: Command Line. (line 20)
-* --lint-old option: Options. (line 295)
+* --lint-old option: Options. (line 297)
* --load option: Options. (line 173)
* --non-decimal-data option <1>: Nondecimal Data. (line 6)
* --non-decimal-data option: Options. (line 211)
* --non-decimal-data option, strtonum() function and: Nondecimal Data.
- (line 36)
-* --optimize option: Options. (line 237)
-* --posix option: Options. (line 254)
-* --posix option, --traditional option and: Options. (line 273)
-* --pretty-print option: Options. (line 224)
+ (line 35)
+* --optimize option: Options. (line 239)
+* --posix option: Options. (line 256)
+* --posix option, --traditional option and: Options. (line 275)
+* --pretty-print option: Options. (line 226)
* --profile option <1>: Profiling. (line 12)
-* --profile option: Options. (line 242)
-* --re-interval option: Options. (line 279)
-* --sandbox option: Options. (line 286)
+* --profile option: Options. (line 244)
+* --re-interval option: Options. (line 281)
+* --sandbox option: Options. (line 288)
* --sandbox option, disabling system() function: I/O Functions.
(line 96)
* --sandbox option, input redirection with getline: Getline. (line 19)
@@ -31159,9 +31155,9 @@ Index
(line 6)
* --source option: Options. (line 117)
* --traditional option: Options. (line 81)
-* --traditional option, --posix option and: Options. (line 273)
-* --use-lc-numeric option: Options. (line 219)
-* --version option: Options. (line 300)
+* --traditional option, --posix option and: Options. (line 275)
+* --use-lc-numeric option: Options. (line 221)
+* --version option: Options. (line 302)
* --with-whiny-user-strftime configuration option: Additional Configuration Options.
(line 35)
* -b option: Options. (line 68)
@@ -31169,32 +31165,32 @@ Index
* -c option: Options. (line 81)
* -D option: Options. (line 108)
* -d option: Options. (line 93)
-* -e option: Options. (line 336)
+* -e option: Options. (line 338)
* -E option: Options. (line 125)
* -e option: Options. (line 117)
* -f option: Options. (line 25)
* -F option: Options. (line 21)
* -f option: Long. (line 12)
-* -F option, -Ft sets FS to TAB: Options. (line 308)
+* -F option, -Ft sets FS to TAB: Options. (line 310)
* -F option, command-line: Command Line Field Separator.
(line 6)
-* -f option, multiple uses: Options. (line 313)
+* -f option, multiple uses: Options. (line 315)
* -g option: Options. (line 147)
* -h option: Options. (line 154)
* -i option: Options. (line 159)
-* -L option: Options. (line 295)
+* -L option: Options. (line 297)
* -l option: Options. (line 173)
* -M option: Options. (line 205)
-* -N option: Options. (line 219)
+* -N option: Options. (line 221)
* -n option: Options. (line 211)
-* -O option: Options. (line 237)
-* -o option: Options. (line 224)
-* -P option: Options. (line 254)
-* -p option: Options. (line 242)
-* -r option: Options. (line 279)
-* -S option: Options. (line 286)
+* -O option: Options. (line 239)
+* -o option: Options. (line 226)
+* -P option: Options. (line 256)
+* -p option: Options. (line 244)
+* -r option: Options. (line 281)
+* -S option: Options. (line 288)
* -v option: Assignment Options. (line 12)
-* -V option: Options. (line 300)
+* -V option: Options. (line 302)
* -v option: Options. (line 32)
* -W option: Options. (line 46)
* . (period), regexp operator: Regexp Operators. (line 44)
@@ -31354,7 +31350,7 @@ Index
* ampersand (&), && operator: Boolean Ops. (line 59)
* ampersand (&), gsub()/gensub()/sub() functions and: Gory Details.
(line 6)
-* anagram.awk program: Anagram Program. (line 22)
+* anagram.awk program: Anagram Program. (line 21)
* anagrams, finding: Anagram Program. (line 6)
* and: Bitwise Functions. (line 40)
* AND bitwise operation: Bitwise Functions. (line 6)
@@ -31467,7 +31463,7 @@ Index
* awf (amazingly workable formatter) program: Glossary. (line 24)
* awk debugging, enabling: Options. (line 108)
* awk language, POSIX version: Assignment Ops. (line 137)
-* awk profiling, enabling: Options. (line 242)
+* awk profiling, enabling: Options. (line 244)
* awk programs <1>: Two Rules. (line 6)
* awk programs <2>: Executable Scripts. (line 6)
* awk programs: Getting Started. (line 12)
@@ -31594,7 +31590,7 @@ Index
* BEGIN pattern, operators and: Using BEGIN/END. (line 17)
* BEGIN pattern, print statement and: I/O And BEGIN/END. (line 16)
* BEGIN pattern, pwcat program: Passwd Functions. (line 143)
-* BEGIN pattern, running awk programs and: Cut Program. (line 68)
+* BEGIN pattern, running awk programs and: Cut Program. (line 63)
* BEGIN pattern, TEXTDOMAIN variable and: Programmer i18n. (line 60)
* BEGINFILE pattern: BEGINFILE/ENDFILE. (line 6)
* BEGINFILE pattern, Boolean patterns and: Expression Patterns.
@@ -31871,7 +31867,7 @@ Index
* cosine: Numeric Functions. (line 15)
* counting: Wc Program. (line 6)
* csh utility: Statements/Lines. (line 44)
-* csh utility, POSIXLY_CORRECT environment variable: Options. (line 354)
+* csh utility, POSIXLY_CORRECT environment variable: Options. (line 356)
* csh utility, |& operator, comparison with: Two-way I/O. (line 25)
* ctime() user-defined function: Function Example. (line 74)
* currency symbols, localization: Explaining gettext. (line 104)
@@ -32055,7 +32051,7 @@ Index
* debugger, read commands from a file: Debugger Info. (line 96)
* debugging awk programs: Debugger. (line 6)
* debugging gawk, bug reports: Bugs. (line 9)
-* decimal point character, locale specific: Options. (line 270)
+* decimal point character, locale specific: Options. (line 272)
* decrement operators: Increment Ops. (line 35)
* default keyword: Switch Statement. (line 6)
* Deifik, Scott <1>: Bugs. (line 71)
@@ -32219,10 +32215,10 @@ Index
* ENDFILE pattern: BEGINFILE/ENDFILE. (line 6)
* ENDFILE pattern, Boolean patterns and: Expression Patterns. (line 70)
* endfile() user-defined function: Filetrans Function. (line 61)
-* endgrent() function (C library): Group Functions. (line 212)
-* endgrent() user-defined function: Group Functions. (line 215)
-* endpwent() function (C library): Passwd Functions. (line 210)
-* endpwent() user-defined function: Passwd Functions. (line 213)
+* endgrent() function (C library): Group Functions. (line 211)
+* endgrent() user-defined function: Group Functions. (line 214)
+* endpwent() function (C library): Passwd Functions. (line 207)
+* endpwent() user-defined function: Passwd Functions. (line 210)
* English, Steve: Advanced Features. (line 6)
* ENVIRON array: Auto-set. (line 60)
* environment variables used by gawk: Environment Variables.
@@ -32356,7 +32352,7 @@ Index
(line 6)
* field separators, regular expressions as: Field Separators. (line 51)
* field separators, See Also OFS: Changing Fields. (line 64)
-* field separators, spaces as: Cut Program. (line 108)
+* field separators, spaces as: Cut Program. (line 103)
* fields <1>: Basic High Level. (line 73)
* fields <2>: Fields. (line 6)
* fields: Reading Files. (line 14)
@@ -32484,9 +32480,9 @@ Index
* FS variable, --field-separator option and: Options. (line 21)
* FS variable, as null string: Single Character Fields.
(line 20)
-* FS variable, as TAB character: Options. (line 266)
+* FS variable, as TAB character: Options. (line 268)
* FS variable, changing value of: Field Separators. (line 35)
-* FS variable, running awk programs and: Cut Program. (line 68)
+* FS variable, running awk programs and: Cut Program. (line 63)
* FS variable, setting from command line: Command Line Field Separator.
(line 6)
* FS, containing ^: Regexp Field Splitting.
@@ -32572,7 +32568,7 @@ Index
(line 140)
* gawk, ERRNO variable in: Getline. (line 19)
* gawk, escape sequences: Escape Sequences. (line 130)
-* gawk, extensions, disabling: Options. (line 254)
+* gawk, extensions, disabling: Options. (line 256)
* gawk, features, adding: Adding Code. (line 6)
* gawk, features, advanced: Advanced Features. (line 6)
* gawk, field separators and: User-modified. (line 71)
@@ -32633,7 +32629,7 @@ Index
* gawk, TEXTDOMAIN variable in: User-modified. (line 151)
* gawk, timestamps: Time Functions. (line 6)
* gawk, uses for: Preface. (line 34)
-* gawk, versions of, information about, printing: Options. (line 300)
+* gawk, versions of, information about, printing: Options. (line 302)
* gawk, VMS version of: VMS Installation. (line 6)
* gawk, word-boundary operator: GNU Regexp Operators.
(line 63)
@@ -32649,12 +32645,12 @@ Index
* getaddrinfo() function (C library): TCP/IP Networking. (line 38)
* getgrent() function (C library): Group Functions. (line 6)
* getgrent() user-defined function: Group Functions. (line 6)
-* getgrgid() function (C library): Group Functions. (line 183)
-* getgrgid() user-defined function: Group Functions. (line 186)
-* getgrnam() function (C library): Group Functions. (line 172)
-* getgrnam() user-defined function: Group Functions. (line 177)
-* getgruser() function (C library): Group Functions. (line 192)
-* getgruser() function, user-defined: Group Functions. (line 195)
+* getgrgid() function (C library): Group Functions. (line 182)
+* getgrgid() user-defined function: Group Functions. (line 185)
+* getgrnam() function (C library): Group Functions. (line 171)
+* getgrnam() user-defined function: Group Functions. (line 176)
+* getgruser() function (C library): Group Functions. (line 191)
+* getgruser() function, user-defined: Group Functions. (line 194)
* getline command: Reading Files. (line 20)
* getline command, _gr_init() user-defined function: Group Functions.
(line 83)
@@ -32678,10 +32674,10 @@ Index
* getopt() user-defined function: Getopt Function. (line 108)
* getpwent() function (C library): Passwd Functions. (line 16)
* getpwent() user-defined function: Passwd Functions. (line 16)
-* getpwnam() function (C library): Passwd Functions. (line 177)
-* getpwnam() user-defined function: Passwd Functions. (line 182)
-* getpwuid() function (C library): Passwd Functions. (line 188)
-* getpwuid() user-defined function: Passwd Functions. (line 192)
+* getpwnam() function (C library): Passwd Functions. (line 174)
+* getpwnam() user-defined function: Passwd Functions. (line 179)
+* getpwuid() function (C library): Passwd Functions. (line 185)
+* getpwuid() user-defined function: Passwd Functions. (line 189)
* gettext library: Explaining gettext. (line 6)
* gettext library, locale categories: Explaining gettext. (line 81)
* gettext() function (C library): Explaining gettext. (line 63)
@@ -32945,7 +32941,7 @@ Index
* lint checking, empty programs: Command Line. (line 16)
* lint checking, issuing warnings: Options. (line 185)
* lint checking, POSIXLY_CORRECT environment variable: Options.
- (line 339)
+ (line 341)
* lint checking, undefined functions: Pass By Value/Reference.
(line 88)
* LINT variable: User-modified. (line 88)
@@ -32961,7 +32957,7 @@ Index
* loading, extensions: Options. (line 173)
* local variables, in a function: Variable Scope. (line 6)
* locale categories: Explaining gettext. (line 81)
-* locale decimal point character: Options. (line 270)
+* locale decimal point character: Options. (line 272)
* locale, definition of: Locales. (line 6)
* localization: I18N and L10N. (line 6)
* localization, See internationalization, localization: I18N and L10N.
@@ -33042,7 +33038,7 @@ Index
* networks, programming: TCP/IP Networking. (line 6)
* networks, support for: Special Network. (line 6)
* newlines <1>: Boolean Ops. (line 69)
-* newlines <2>: Options. (line 260)
+* newlines <2>: Options. (line 262)
* newlines: Statements/Lines. (line 6)
* newlines, as field separators: Default Field Splitting.
(line 6)
@@ -33263,7 +33259,7 @@ Index
* portability, NF variable, decrementing: Changing Fields. (line 115)
* portability, operators: Increment Ops. (line 60)
* portability, operators, not in POSIX awk: Precedence. (line 98)
-* portability, POSIXLY_CORRECT environment variable: Options. (line 359)
+* portability, POSIXLY_CORRECT environment variable: Options. (line 361)
* portability, substr() function: String Functions. (line 511)
* portable object files <1>: Translator i18n. (line 6)
* portable object files: Explaining gettext. (line 37)
@@ -33312,11 +33308,11 @@ Index
* POSIX awk, regular expressions and: Regexp Operators. (line 161)
* POSIX awk, timestamps and: Time Functions. (line 6)
* POSIX awk, | I/O operator and: Getline/Pipe. (line 55)
-* POSIX mode: Options. (line 254)
+* POSIX mode: Options. (line 256)
* POSIX, awk and: Preface. (line 21)
* POSIX, gawk extensions not included in: POSIX/GNU. (line 6)
* POSIX, programs, implementing in awk: Clones. (line 6)
-* POSIXLY_CORRECT environment variable: Options. (line 339)
+* POSIXLY_CORRECT environment variable: Options. (line 341)
* PREC variable: User-modified. (line 123)
* precedence <1>: Precedence. (line 6)
* precedence: Increment Ops. (line 60)
@@ -33370,7 +33366,7 @@ Index
* PROCINFO array, and group membership: Group Functions. (line 6)
* PROCINFO array, and user and group ID numbers: Id Program. (line 15)
* PROCINFO array, testing the field splitting: Passwd Functions.
- (line 161)
+ (line 154)
* PROCINFO array, uses: Auto-set. (line 241)
* PROCINFO, values of sorted_in: Controlling Scanning.
(line 26)
@@ -33379,7 +33375,7 @@ Index
* program identifiers: Auto-set. (line 147)
* program, definition of: Getting Started. (line 21)
* programming conventions, --non-decimal-data option: Nondecimal Data.
- (line 36)
+ (line 35)
* programming conventions, ARGC/ARGV variables: Auto-set. (line 35)
* programming conventions, exit statement: Exit Statement. (line 38)
* programming conventions, function parameters: Return Statement.
@@ -33495,7 +33491,7 @@ Index
(line 59)
* regular expressions, gawk, command-line options: GNU Regexp Operators.
(line 70)
-* regular expressions, interval expressions and: Options. (line 279)
+* regular expressions, interval expressions and: Options. (line 281)
* regular expressions, leftmost longest match: Leftmost Longest.
(line 6)
* regular expressions, operators <1>: Regexp Operators. (line 6)
@@ -33576,7 +33572,7 @@ Index
(line 68)
* sample debugging session: Sample Debugging Session.
(line 6)
-* sandbox mode: Options. (line 286)
+* sandbox mode: Options. (line 288)
* save debugger options: Debugger Info. (line 84)
* scalar or array: Type Functions. (line 11)
* scalar values: Basic Data Typing. (line 13)
@@ -33809,7 +33805,7 @@ Index
* strings, numeric: Variable Typing. (line 6)
* strtonum: String Functions. (line 389)
* strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data.
- (line 36)
+ (line 35)
* sub <1>: String Functions. (line 407)
* sub: Using Constant Regexps.
(line 43)
@@ -34046,7 +34042,7 @@ Index
* whitespace, as field separators: Default Field Splitting.
(line 6)
* whitespace, functions, calling: Calling Built-in. (line 10)
-* whitespace, newlines as: Options. (line 260)
+* whitespace, newlines as: Options. (line 262)
* Williams, Kent: Contributors. (line 34)
* Woehlke, Matthew: Contributors. (line 79)
* Woods, John: Contributors. (line 27)
@@ -34138,515 +34134,517 @@ Node: Intro Summary110420
Node: Invoking Gawk111303
Node: Command Line112818
Node: Options113609
-Ref: Options-Footnote-1129436
-Node: Other Arguments129461
-Node: Naming Standard Input132422
-Node: Environment Variables133515
-Node: AWKPATH Variable134073
-Ref: AWKPATH Variable-Footnote-1136925
-Ref: AWKPATH Variable-Footnote-2136970
-Node: AWKLIBPATH Variable137230
-Node: Other Environment Variables137989
-Node: Exit Status141691
-Node: Include Files142366
-Node: Loading Shared Libraries145944
-Node: Obsolete147371
-Node: Undocumented148068
-Node: Invoking Summary148335
-Node: Regexp150001
-Node: Regexp Usage151460
-Node: Escape Sequences153493
-Node: Regexp Operators159510
-Ref: Regexp Operators-Footnote-1166945
-Ref: Regexp Operators-Footnote-2167092
-Node: Bracket Expressions167190
-Ref: table-char-classes169207
-Node: Leftmost Longest172147
-Node: Computed Regexps173449
-Node: GNU Regexp Operators176846
-Node: Case-sensitivity180552
-Ref: Case-sensitivity-Footnote-1183442
-Ref: Case-sensitivity-Footnote-2183677
-Node: Regexp Summary183785
-Node: Reading Files185254
-Node: Records187346
-Node: awk split records188074
-Node: gawk split records192986
-Ref: gawk split records-Footnote-1197525
-Node: Fields197562
-Ref: Fields-Footnote-1200358
-Node: Nonconstant Fields200444
-Ref: Nonconstant Fields-Footnote-1202674
-Node: Changing Fields202876
-Node: Field Separators208808
-Node: Default Field Splitting211510
-Node: Regexp Field Splitting212627
-Node: Single Character Fields215977
-Node: Command Line Field Separator217036
-Node: Full Line Fields220246
-Ref: Full Line Fields-Footnote-1220754
-Node: Field Splitting Summary220800
-Ref: Field Splitting Summary-Footnote-1223931
-Node: Constant Size224032
-Node: Splitting By Content228638
-Ref: Splitting By Content-Footnote-1232711
-Node: Multiple Line232751
-Ref: Multiple Line-Footnote-1238640
-Node: Getline238819
-Node: Plain Getline241030
-Node: Getline/Variable243670
-Node: Getline/File244817
-Node: Getline/Variable/File246201
-Ref: Getline/Variable/File-Footnote-1247800
-Node: Getline/Pipe247887
-Node: Getline/Variable/Pipe250570
-Node: Getline/Coprocess251699
-Node: Getline/Variable/Coprocess252951
-Node: Getline Notes253688
-Node: Getline Summary256480
-Ref: table-getline-variants256888
-Node: Read Timeout257717
-Ref: Read Timeout-Footnote-1261531
-Node: Command-line directories261589
-Node: Input Summary262493
-Node: Input Exercises265745
-Node: Printing266473
-Node: Print268250
-Node: Print Examples269707
-Node: Output Separators272486
-Node: OFMT274502
-Node: Printf275854
-Node: Basic Printf276639
-Node: Control Letters278210
-Node: Format Modifiers282194
-Node: Printf Examples288201
-Node: Redirection290683
-Node: Special FD297414
-Ref: Special FD-Footnote-1300571
-Node: Special Files300645
-Node: Other Inherited Files301261
-Node: Special Network302261
-Node: Special Caveats303122
-Node: Close Files And Pipes304073
-Ref: Close Files And Pipes-Footnote-1311250
-Ref: Close Files And Pipes-Footnote-2311398
-Node: Output Summary311548
-Node: Output Exercises312544
-Node: Expressions313224
-Node: Values314409
-Node: Constants315085
-Node: Scalar Constants315765
-Ref: Scalar Constants-Footnote-1316624
-Node: Nondecimal-numbers316874
-Node: Regexp Constants319874
-Node: Using Constant Regexps320399
-Node: Variables323537
-Node: Using Variables324192
-Node: Assignment Options326096
-Node: Conversion327971
-Node: Strings And Numbers328495
-Ref: Strings And Numbers-Footnote-1331557
-Node: Locale influences conversions331666
-Ref: table-locale-affects334381
-Node: All Operators334969
-Node: Arithmetic Ops335599
-Node: Concatenation338104
-Ref: Concatenation-Footnote-1340923
-Node: Assignment Ops341029
-Ref: table-assign-ops346012
-Node: Increment Ops347290
-Node: Truth Values and Conditions350728
-Node: Truth Values351811
-Node: Typing and Comparison352860
-Node: Variable Typing353653
-Node: Comparison Operators357305
-Ref: table-relational-ops357715
-Node: POSIX String Comparison361230
-Ref: POSIX String Comparison-Footnote-1362302
-Node: Boolean Ops362440
-Ref: Boolean Ops-Footnote-1366919
-Node: Conditional Exp367010
-Node: Function Calls368737
-Node: Precedence372617
-Node: Locales376285
-Node: Expressions Summary377916
-Node: Patterns and Actions380490
-Node: Pattern Overview381606
-Node: Regexp Patterns383285
-Node: Expression Patterns383828
-Node: Ranges387608
-Node: BEGIN/END390714
-Node: Using BEGIN/END391476
-Ref: Using BEGIN/END-Footnote-1394213
-Node: I/O And BEGIN/END394319
-Node: BEGINFILE/ENDFILE396633
-Node: Empty399534
-Node: Using Shell Variables399851
-Node: Action Overview402127
-Node: Statements404454
-Node: If Statement406302
-Node: While Statement407800
-Node: Do Statement409828
-Node: For Statement410970
-Node: Switch Statement414125
-Node: Break Statement416513
-Node: Continue Statement418554
-Node: Next Statement420379
-Node: Nextfile Statement422759
-Node: Exit Statement425389
-Node: Built-in Variables427792
-Node: User-modified428919
-Ref: User-modified-Footnote-1436599
-Node: Auto-set436661
-Ref: Auto-set-Footnote-1449518
-Ref: Auto-set-Footnote-2449723
-Node: ARGC and ARGV449779
-Node: Pattern Action Summary453983
-Node: Arrays456402
-Node: Array Basics457731
-Node: Array Intro458575
-Ref: figure-array-elements460548
-Ref: Array Intro-Footnote-1463072
-Node: Reference to Elements463200
-Node: Assigning Elements465650
-Node: Array Example466141
-Node: Scanning an Array467899
-Node: Controlling Scanning470915
-Ref: Controlling Scanning-Footnote-1476104
-Node: Numeric Array Subscripts476420
-Node: Uninitialized Subscripts478603
-Node: Delete480220
-Ref: Delete-Footnote-1482964
-Node: Multidimensional483021
-Node: Multiscanning486116
-Node: Arrays of Arrays487705
-Node: Arrays Summary492466
-Node: Functions494571
-Node: Built-in495444
-Node: Calling Built-in496522
-Node: Numeric Functions498510
-Ref: Numeric Functions-Footnote-1502532
-Ref: Numeric Functions-Footnote-2502889
-Ref: Numeric Functions-Footnote-3502937
-Node: String Functions503206
-Ref: String Functions-Footnote-1526666
-Ref: String Functions-Footnote-2526795
-Ref: String Functions-Footnote-3527043
-Node: Gory Details527130
-Ref: table-sub-escapes528911
-Ref: table-sub-proposed530431
-Ref: table-posix-sub531795
-Ref: table-gensub-escapes533335
-Ref: Gory Details-Footnote-1534167
-Node: I/O Functions534318
-Ref: I/O Functions-Footnote-1541419
-Node: Time Functions541566
-Ref: Time Functions-Footnote-1552035
-Ref: Time Functions-Footnote-2552103
-Ref: Time Functions-Footnote-3552261
-Ref: Time Functions-Footnote-4552372
-Ref: Time Functions-Footnote-5552484
-Ref: Time Functions-Footnote-6552711
-Node: Bitwise Functions552977
-Ref: table-bitwise-ops553539
-Ref: Bitwise Functions-Footnote-1557847
-Node: Type Functions558016
-Node: I18N Functions559165
-Node: User-defined560810
-Node: Definition Syntax561614
-Ref: Definition Syntax-Footnote-1567018
-Node: Function Example567087
-Ref: Function Example-Footnote-1570004
-Node: Function Caveats570026
-Node: Calling A Function570544
-Node: Variable Scope571499
-Node: Pass By Value/Reference574487
-Node: Return Statement577997
-Node: Dynamic Typing580981
-Node: Indirect Calls581910
-Ref: Indirect Calls-Footnote-1591631
-Node: Functions Summary591759
-Node: Library Functions594458
-Ref: Library Functions-Footnote-1598076
-Ref: Library Functions-Footnote-2598219
-Node: Library Names598390
-Ref: Library Names-Footnote-1601848
-Ref: Library Names-Footnote-2602068
-Node: General Functions602154
-Node: Strtonum Function603182
-Node: Assert Function606202
-Node: Round Function609526
-Node: Cliff Random Function611067
-Node: Ordinal Functions612083
-Ref: Ordinal Functions-Footnote-1615148
-Ref: Ordinal Functions-Footnote-2615400
-Node: Join Function615611
-Ref: Join Function-Footnote-1617382
-Node: Getlocaltime Function617582
-Node: Readfile Function621323
-Node: Data File Management623271
-Node: Filetrans Function623903
-Node: Rewind Function627962
-Node: File Checking629520
-Ref: File Checking-Footnote-1630652
-Node: Empty Files630853
-Node: Ignoring Assigns632832
-Node: Getopt Function634386
-Ref: Getopt Function-Footnote-1645650
-Node: Passwd Functions645853
-Ref: Passwd Functions-Footnote-1654832
-Node: Group Functions654920
-Ref: Group Functions-Footnote-1662851
-Node: Walking Arrays663064
-Node: Library Functions Summary664667
-Node: Library Exercises666055
-Node: Sample Programs667335
-Node: Running Examples668105
-Node: Clones668833
-Node: Cut Program670057
-Node: Egrep Program679915
-Ref: Egrep Program-Footnote-1687502
-Node: Id Program687612
-Node: Split Program691266
-Ref: Split Program-Footnote-1694804
-Node: Tee Program694932
-Node: Uniq Program697719
-Node: Wc Program705142
-Ref: Wc Program-Footnote-1709407
-Node: Miscellaneous Programs709499
-Node: Dupword Program710712
-Node: Alarm Program712743
-Node: Translate Program717547
-Ref: Translate Program-Footnote-1722120
-Ref: Translate Program-Footnote-2722390
-Node: Labels Program722529
-Ref: Labels Program-Footnote-1725890
-Node: Word Sorting725974
-Node: History Sorting730017
-Node: Extract Program731853
-Node: Simple Sed739389
-Node: Igawk Program742451
-Ref: Igawk Program-Footnote-1756755
-Ref: Igawk Program-Footnote-2756956
-Node: Anagram Program757078
-Node: Signature Program760146
-Node: Programs Summary761393
-Node: Programs Exercises762608
-Ref: Programs Exercises-Footnote-1766739
-Node: Advanced Features766830
-Node: Nondecimal Data768778
-Node: Array Sorting770355
-Node: Controlling Array Traversal771052
-Node: Array Sorting Functions779332
-Ref: Array Sorting Functions-Footnote-1783224
-Node: Two-way I/O783418
-Ref: Two-way I/O-Footnote-1788362
-Ref: Two-way I/O-Footnote-2788541
-Node: TCP/IP Networking788623
-Node: Profiling791465
-Node: Advanced Features Summary799007
-Node: Internationalization800868
-Node: I18N and L10N802348
-Node: Explaining gettext803034
-Ref: Explaining gettext-Footnote-1808060
-Ref: Explaining gettext-Footnote-2808244
-Node: Programmer i18n808409
-Ref: Programmer i18n-Footnote-1813203
-Node: Translator i18n813252
-Node: String Extraction814046
-Ref: String Extraction-Footnote-1815179
-Node: Printf Ordering815265
-Ref: Printf Ordering-Footnote-1818047
-Node: I18N Portability818111
-Ref: I18N Portability-Footnote-1820560
-Node: I18N Example820623
-Ref: I18N Example-Footnote-1823329
-Node: Gawk I18N823401
-Node: I18N Summary824039
-Node: Debugger825378
-Node: Debugging826400
-Node: Debugging Concepts826841
-Node: Debugging Terms828697
-Node: Awk Debugging831294
-Node: Sample Debugging Session832186
-Node: Debugger Invocation832706
-Node: Finding The Bug834042
-Node: List of Debugger Commands840521
-Node: Breakpoint Control841853
-Node: Debugger Execution Control845517
-Node: Viewing And Changing Data848877
-Node: Execution Stack852235
-Node: Debugger Info853748
-Node: Miscellaneous Debugger Commands857742
-Node: Readline Support862926
-Node: Limitations863818
-Node: Debugging Summary866091
-Node: Arbitrary Precision Arithmetic867259
-Node: Computer Arithmetic868746
-Ref: Computer Arithmetic-Footnote-1873133
-Node: Math Definitions873190
-Ref: table-ieee-formats876479
-Ref: Math Definitions-Footnote-1877019
-Node: MPFR features877122
-Node: FP Math Caution878739
-Ref: FP Math Caution-Footnote-1879789
-Node: Inexactness of computations880158
-Node: Inexact representation881106
-Node: Comparing FP Values882461
-Node: Errors accumulate883425
-Node: Getting Accuracy884858
-Node: Try To Round887517
-Node: Setting precision888416
-Ref: table-predefined-precision-strings889098
-Node: Setting the rounding mode890891
-Ref: table-gawk-rounding-modes891255
-Ref: Setting the rounding mode-Footnote-1894709
-Node: Arbitrary Precision Integers894888
-Ref: Arbitrary Precision Integers-Footnote-1897869
-Node: POSIX Floating Point Problems898018
-Ref: POSIX Floating Point Problems-Footnote-1901894
-Node: Floating point summary901932
-Node: Dynamic Extensions904136
-Node: Extension Intro905688
-Node: Plugin License906953
-Node: Extension Mechanism Outline907638
-Ref: figure-load-extension908062
-Ref: figure-load-new-function909547
-Ref: figure-call-new-function910549
-Node: Extension API Description912533
-Node: Extension API Functions Introduction913983
-Node: General Data Types918850
-Ref: General Data Types-Footnote-1924543
-Node: Requesting Values924842
-Ref: table-value-types-returned925579
-Node: Memory Allocation Functions926537
-Ref: Memory Allocation Functions-Footnote-1929284
-Node: Constructor Functions929380
-Node: Registration Functions931138
-Node: Extension Functions931823
-Node: Exit Callback Functions934125
-Node: Extension Version String935373
-Node: Input Parsers936023
-Node: Output Wrappers945837
-Node: Two-way processors950353
-Node: Printing Messages952557
-Ref: Printing Messages-Footnote-1953634
-Node: Updating `ERRNO'953786
-Node: Accessing Parameters954525
-Node: Symbol Table Access955755
-Node: Symbol table by name956269
-Node: Symbol table by cookie958245
-Ref: Symbol table by cookie-Footnote-1962378
-Node: Cached values962441
-Ref: Cached values-Footnote-1965945
-Node: Array Manipulation966036
-Ref: Array Manipulation-Footnote-1967134
-Node: Array Data Types967173
-Ref: Array Data Types-Footnote-1969876
-Node: Array Functions969968
-Node: Flattening Arrays973842
-Node: Creating Arrays980694
-Node: Extension API Variables985425
-Node: Extension Versioning986061
-Node: Extension API Informational Variables987962
-Node: Extension API Boilerplate989048
-Node: Finding Extensions992852
-Node: Extension Example993412
-Node: Internal File Description994142
-Node: Internal File Ops998233
-Ref: Internal File Ops-Footnote-11009665
-Node: Using Internal File Ops1009805
-Ref: Using Internal File Ops-Footnote-11012152
-Node: Extension Samples1012420
-Node: Extension Sample File Functions1013944
-Node: Extension Sample Fnmatch1021512
-Node: Extension Sample Fork1022994
-Node: Extension Sample Inplace1024207
-Node: Extension Sample Ord1025882
-Node: Extension Sample Readdir1026718
-Ref: table-readdir-file-types1027574
-Node: Extension Sample Revout1028373
-Node: Extension Sample Rev2way1028964
-Node: Extension Sample Read write array1029705
-Node: Extension Sample Readfile1031584
-Node: Extension Sample API Tests1032684
-Node: Extension Sample Time1033209
-Node: gawkextlib1034524
-Node: Extension summary1037337
-Node: Extension Exercises1041030
-Node: Language History1041752
-Node: V7/SVR3.11043395
-Node: SVR41045715
-Node: POSIX1047157
-Node: BTL1048543
-Node: POSIX/GNU1049277
-Node: Feature History1054993
-Node: Common Extensions1068084
-Node: Ranges and Locales1069396
-Ref: Ranges and Locales-Footnote-11074013
-Ref: Ranges and Locales-Footnote-21074040
-Ref: Ranges and Locales-Footnote-31074274
-Node: Contributors1074495
-Node: History summary1079920
-Node: Installation1081289
-Node: Gawk Distribution1082240
-Node: Getting1082724
-Node: Extracting1083548
-Node: Distribution contents1085190
-Node: Unix Installation1090907
-Node: Quick Installation1091524
-Node: Additional Configuration Options1093966
-Node: Configuration Philosophy1095704
-Node: Non-Unix Installation1098055
-Node: PC Installation1098513
-Node: PC Binary Installation1099824
-Node: PC Compiling1101672
-Ref: PC Compiling-Footnote-11104671
-Node: PC Testing1104776
-Node: PC Using1105952
-Node: Cygwin1110104
-Node: MSYS1110913
-Node: VMS Installation1111411
-Node: VMS Compilation1112207
-Ref: VMS Compilation-Footnote-11113429
-Node: VMS Dynamic Extensions1113487
-Node: VMS Installation Details1114860
-Node: VMS Running1117112
-Node: VMS GNV1119946
-Node: VMS Old Gawk1120669
-Node: Bugs1121139
-Node: Other Versions1125143
-Node: Installation summary1131367
-Node: Notes1132423
-Node: Compatibility Mode1133288
-Node: Additions1134070
-Node: Accessing The Source1134995
-Node: Adding Code1136431
-Node: New Ports1142609
-Node: Derived Files1147090
-Ref: Derived Files-Footnote-11152565
-Ref: Derived Files-Footnote-21152599
-Ref: Derived Files-Footnote-31153195
-Node: Future Extensions1153309
-Node: Implementation Limitations1153915
-Node: Extension Design1155163
-Node: Old Extension Problems1156317
-Ref: Old Extension Problems-Footnote-11157834
-Node: Extension New Mechanism Goals1157891
-Ref: Extension New Mechanism Goals-Footnote-11161251
-Node: Extension Other Design Decisions1161440
-Node: Extension Future Growth1163546
-Node: Old Extension Mechanism1164382
-Node: Notes summary1166144
-Node: Basic Concepts1167330
-Node: Basic High Level1168011
-Ref: figure-general-flow1168283
-Ref: figure-process-flow1168882
-Ref: Basic High Level-Footnote-11172111
-Node: Basic Data Typing1172296
-Node: Glossary1175624
-Node: Copying1200776
-Node: GNU Free Documentation License1238332
-Node: Index1263468
+Ref: Options-Footnote-1129504
+Node: Other Arguments129529
+Node: Naming Standard Input132490
+Node: Environment Variables133583
+Node: AWKPATH Variable134141
+Ref: AWKPATH Variable-Footnote-1136993
+Ref: AWKPATH Variable-Footnote-2137038
+Node: AWKLIBPATH Variable137298
+Node: Other Environment Variables138057
+Node: Exit Status141759
+Node: Include Files142434
+Node: Loading Shared Libraries146012
+Node: Obsolete147439
+Node: Undocumented148136
+Node: Invoking Summary148403
+Node: Regexp150069
+Node: Regexp Usage151528
+Node: Escape Sequences153561
+Node: Regexp Operators159578
+Ref: Regexp Operators-Footnote-1167013
+Ref: Regexp Operators-Footnote-2167160
+Node: Bracket Expressions167258
+Ref: table-char-classes169275
+Node: Leftmost Longest172215
+Node: Computed Regexps173517
+Node: GNU Regexp Operators176914
+Node: Case-sensitivity180620
+Ref: Case-sensitivity-Footnote-1183510
+Ref: Case-sensitivity-Footnote-2183745
+Node: Regexp Summary183853
+Node: Reading Files185322
+Node: Records187414
+Node: awk split records188142
+Node: gawk split records193054
+Ref: gawk split records-Footnote-1197593
+Node: Fields197630
+Ref: Fields-Footnote-1200426
+Node: Nonconstant Fields200512
+Ref: Nonconstant Fields-Footnote-1202742
+Node: Changing Fields202944
+Node: Field Separators208876
+Node: Default Field Splitting211578
+Node: Regexp Field Splitting212695
+Node: Single Character Fields216045
+Node: Command Line Field Separator217104
+Node: Full Line Fields220314
+Ref: Full Line Fields-Footnote-1220822
+Node: Field Splitting Summary220868
+Ref: Field Splitting Summary-Footnote-1223999
+Node: Constant Size224100
+Node: Splitting By Content228706
+Ref: Splitting By Content-Footnote-1232779
+Node: Multiple Line232819
+Ref: Multiple Line-Footnote-1238708
+Node: Getline238887
+Node: Plain Getline241098
+Node: Getline/Variable243738
+Node: Getline/File244885
+Node: Getline/Variable/File246269
+Ref: Getline/Variable/File-Footnote-1247868
+Node: Getline/Pipe247955
+Node: Getline/Variable/Pipe250638
+Node: Getline/Coprocess251767
+Node: Getline/Variable/Coprocess253019
+Node: Getline Notes253756
+Node: Getline Summary256548
+Ref: table-getline-variants256956
+Node: Read Timeout257785
+Ref: Read Timeout-Footnote-1261599
+Node: Command-line directories261657
+Node: Input Summary262561
+Node: Input Exercises265813
+Node: Printing266541
+Node: Print268318
+Node: Print Examples269775
+Node: Output Separators272554
+Node: OFMT274570
+Node: Printf275922
+Node: Basic Printf276707
+Node: Control Letters278278
+Node: Format Modifiers282262
+Node: Printf Examples288269
+Node: Redirection290751
+Node: Special FD297482
+Ref: Special FD-Footnote-1300639
+Node: Special Files300713
+Node: Other Inherited Files301329
+Node: Special Network302329
+Node: Special Caveats303190
+Node: Close Files And Pipes304141
+Ref: Close Files And Pipes-Footnote-1311318
+Ref: Close Files And Pipes-Footnote-2311466
+Node: Output Summary311616
+Node: Output Exercises312612
+Node: Expressions313292
+Node: Values314477
+Node: Constants315153
+Node: Scalar Constants315833
+Ref: Scalar Constants-Footnote-1316692
+Node: Nondecimal-numbers316942
+Node: Regexp Constants319942
+Node: Using Constant Regexps320467
+Node: Variables323605
+Node: Using Variables324260
+Node: Assignment Options326164
+Node: Conversion328039
+Node: Strings And Numbers328563
+Ref: Strings And Numbers-Footnote-1331625
+Node: Locale influences conversions331734
+Ref: table-locale-affects334449
+Node: All Operators335037
+Node: Arithmetic Ops335667
+Node: Concatenation338172
+Ref: Concatenation-Footnote-1340991
+Node: Assignment Ops341097
+Ref: table-assign-ops346080
+Node: Increment Ops347358
+Node: Truth Values and Conditions350796
+Node: Truth Values351879
+Node: Typing and Comparison352928
+Node: Variable Typing353721
+Node: Comparison Operators357373
+Ref: table-relational-ops357783
+Node: POSIX String Comparison361298
+Ref: POSIX String Comparison-Footnote-1362370
+Node: Boolean Ops362508
+Ref: Boolean Ops-Footnote-1366987
+Node: Conditional Exp367078
+Node: Function Calls368805
+Node: Precedence372685
+Node: Locales376353
+Node: Expressions Summary377984
+Node: Patterns and Actions380558
+Node: Pattern Overview381674
+Node: Regexp Patterns383353
+Node: Expression Patterns383896
+Node: Ranges387676
+Node: BEGIN/END390782
+Node: Using BEGIN/END391544
+Ref: Using BEGIN/END-Footnote-1394281
+Node: I/O And BEGIN/END394387
+Node: BEGINFILE/ENDFILE396701
+Node: Empty399602
+Node: Using Shell Variables399919
+Node: Action Overview402195
+Node: Statements404522
+Node: If Statement406370
+Node: While Statement407868
+Node: Do Statement409896
+Node: For Statement411038
+Node: Switch Statement414193
+Node: Break Statement416581
+Node: Continue Statement418622
+Node: Next Statement420447
+Node: Nextfile Statement422827
+Node: Exit Statement425457
+Node: Built-in Variables427860
+Node: User-modified428987
+Ref: User-modified-Footnote-1436667
+Node: Auto-set436729
+Ref: Auto-set-Footnote-1449586
+Ref: Auto-set-Footnote-2449791
+Node: ARGC and ARGV449847
+Node: Pattern Action Summary454051
+Node: Arrays456470
+Node: Array Basics457799
+Node: Array Intro458643
+Ref: figure-array-elements460616
+Ref: Array Intro-Footnote-1463140
+Node: Reference to Elements463268
+Node: Assigning Elements465718
+Node: Array Example466209
+Node: Scanning an Array467967
+Node: Controlling Scanning470983
+Ref: Controlling Scanning-Footnote-1476172
+Node: Numeric Array Subscripts476488
+Node: Uninitialized Subscripts478671
+Node: Delete480288
+Ref: Delete-Footnote-1483032
+Node: Multidimensional483089
+Node: Multiscanning486184
+Node: Arrays of Arrays487773
+Node: Arrays Summary492534
+Node: Functions494639
+Node: Built-in495512
+Node: Calling Built-in496590
+Node: Numeric Functions498578
+Ref: Numeric Functions-Footnote-1502600
+Ref: Numeric Functions-Footnote-2502957
+Ref: Numeric Functions-Footnote-3503005
+Node: String Functions503274
+Ref: String Functions-Footnote-1526734
+Ref: String Functions-Footnote-2526863
+Ref: String Functions-Footnote-3527111
+Node: Gory Details527198
+Ref: table-sub-escapes528979
+Ref: table-sub-proposed530499
+Ref: table-posix-sub531863
+Ref: table-gensub-escapes533403
+Ref: Gory Details-Footnote-1534235
+Node: I/O Functions534386
+Ref: I/O Functions-Footnote-1541487
+Node: Time Functions541634
+Ref: Time Functions-Footnote-1552103
+Ref: Time Functions-Footnote-2552171
+Ref: Time Functions-Footnote-3552329
+Ref: Time Functions-Footnote-4552440
+Ref: Time Functions-Footnote-5552552
+Ref: Time Functions-Footnote-6552779
+Node: Bitwise Functions553045
+Ref: table-bitwise-ops553607
+Ref: Bitwise Functions-Footnote-1557915
+Node: Type Functions558084
+Node: I18N Functions559233
+Node: User-defined560878
+Node: Definition Syntax561682
+Ref: Definition Syntax-Footnote-1567086
+Node: Function Example567155
+Ref: Function Example-Footnote-1570072
+Node: Function Caveats570094
+Node: Calling A Function570612
+Node: Variable Scope571567
+Node: Pass By Value/Reference574555
+Node: Return Statement578065
+Node: Dynamic Typing581049
+Node: Indirect Calls581978
+Ref: Indirect Calls-Footnote-1591699
+Node: Functions Summary591827
+Node: Library Functions594526
+Ref: Library Functions-Footnote-1598144
+Ref: Library Functions-Footnote-2598287
+Node: Library Names598458
+Ref: Library Names-Footnote-1601916
+Ref: Library Names-Footnote-2602136
+Node: General Functions602222
+Node: Strtonum Function603250
+Node: Assert Function606270
+Node: Round Function609594
+Node: Cliff Random Function611135
+Node: Ordinal Functions612151
+Ref: Ordinal Functions-Footnote-1615216
+Ref: Ordinal Functions-Footnote-2615468
+Node: Join Function615679
+Ref: Join Function-Footnote-1617450
+Node: Getlocaltime Function617650
+Node: Readfile Function621391
+Node: Data File Management623339
+Node: Filetrans Function623971
+Node: Rewind Function628030
+Node: File Checking629415
+Ref: File Checking-Footnote-1630743
+Node: Empty Files630944
+Node: Ignoring Assigns632923
+Node: Getopt Function634474
+Ref: Getopt Function-Footnote-1645934
+Node: Passwd Functions646137
+Ref: Passwd Functions-Footnote-1654988
+Node: Group Functions655076
+Ref: Group Functions-Footnote-1662979
+Node: Walking Arrays663192
+Node: Library Functions Summary664795
+Node: Library Exercises666196
+Node: Sample Programs667476
+Node: Running Examples668246
+Node: Clones668974
+Node: Cut Program670198
+Node: Egrep Program679928
+Ref: Egrep Program-Footnote-1687430
+Node: Id Program687540
+Node: Split Program691184
+Ref: Split Program-Footnote-1694630
+Node: Tee Program694758
+Node: Uniq Program697545
+Node: Wc Program704966
+Ref: Wc Program-Footnote-1709214
+Node: Miscellaneous Programs709306
+Node: Dupword Program710519
+Node: Alarm Program712550
+Node: Translate Program717354
+Ref: Translate Program-Footnote-1721927
+Ref: Translate Program-Footnote-2722197
+Node: Labels Program722336
+Ref: Labels Program-Footnote-1725685
+Node: Word Sorting725769
+Node: History Sorting729839
+Node: Extract Program731675
+Node: Simple Sed739207
+Node: Igawk Program742269
+Ref: Igawk Program-Footnote-1756595
+Ref: Igawk Program-Footnote-2756796
+Ref: Igawk Program-Footnote-3756918
+Node: Anagram Program757033
+Node: Signature Program760095
+Node: Programs Summary761342
+Node: Programs Exercises762535
+Ref: Programs Exercises-Footnote-1766666
+Node: Advanced Features766757
+Node: Nondecimal Data768705
+Node: Array Sorting770295
+Node: Controlling Array Traversal770992
+Ref: Controlling Array Traversal-Footnote-1779323
+Node: Array Sorting Functions779441
+Ref: Array Sorting Functions-Footnote-1783333
+Node: Two-way I/O783527
+Ref: Two-way I/O-Footnote-1788471
+Ref: Two-way I/O-Footnote-2788657
+Node: TCP/IP Networking788739
+Node: Profiling791580
+Node: Advanced Features Summary799122
+Node: Internationalization800983
+Node: I18N and L10N802463
+Node: Explaining gettext803149
+Ref: Explaining gettext-Footnote-1808175
+Ref: Explaining gettext-Footnote-2808359
+Node: Programmer i18n808524
+Ref: Programmer i18n-Footnote-1813318
+Node: Translator i18n813367
+Node: String Extraction814161
+Ref: String Extraction-Footnote-1815294
+Node: Printf Ordering815380
+Ref: Printf Ordering-Footnote-1818162
+Node: I18N Portability818226
+Ref: I18N Portability-Footnote-1820675
+Node: I18N Example820738
+Ref: I18N Example-Footnote-1823444
+Node: Gawk I18N823516
+Node: I18N Summary824154
+Node: Debugger825493
+Node: Debugging826515
+Node: Debugging Concepts826956
+Node: Debugging Terms828812
+Node: Awk Debugging831409
+Node: Sample Debugging Session832301
+Node: Debugger Invocation832821
+Node: Finding The Bug834157
+Node: List of Debugger Commands840636
+Node: Breakpoint Control841968
+Node: Debugger Execution Control845632
+Node: Viewing And Changing Data848992
+Node: Execution Stack852350
+Node: Debugger Info853863
+Node: Miscellaneous Debugger Commands857857
+Node: Readline Support863041
+Node: Limitations863933
+Node: Debugging Summary866206
+Node: Arbitrary Precision Arithmetic867374
+Node: Computer Arithmetic868861
+Ref: Computer Arithmetic-Footnote-1873248
+Node: Math Definitions873305
+Ref: table-ieee-formats876594
+Ref: Math Definitions-Footnote-1877134
+Node: MPFR features877237
+Node: FP Math Caution878854
+Ref: FP Math Caution-Footnote-1879904
+Node: Inexactness of computations880273
+Node: Inexact representation881221
+Node: Comparing FP Values882576
+Node: Errors accumulate883540
+Node: Getting Accuracy884973
+Node: Try To Round887632
+Node: Setting precision888531
+Ref: table-predefined-precision-strings889213
+Node: Setting the rounding mode891006
+Ref: table-gawk-rounding-modes891370
+Ref: Setting the rounding mode-Footnote-1894824
+Node: Arbitrary Precision Integers895003
+Ref: Arbitrary Precision Integers-Footnote-1897984
+Node: POSIX Floating Point Problems898133
+Ref: POSIX Floating Point Problems-Footnote-1902009
+Node: Floating point summary902047
+Node: Dynamic Extensions904251
+Node: Extension Intro905803
+Node: Plugin License907068
+Node: Extension Mechanism Outline907753
+Ref: figure-load-extension908177
+Ref: figure-load-new-function909662
+Ref: figure-call-new-function910664
+Node: Extension API Description912648
+Node: Extension API Functions Introduction914098
+Node: General Data Types918965
+Ref: General Data Types-Footnote-1924658
+Node: Requesting Values924957
+Ref: table-value-types-returned925694
+Node: Memory Allocation Functions926652
+Ref: Memory Allocation Functions-Footnote-1929399
+Node: Constructor Functions929495
+Node: Registration Functions931253
+Node: Extension Functions931938
+Node: Exit Callback Functions934240
+Node: Extension Version String935488
+Node: Input Parsers936138
+Node: Output Wrappers945952
+Node: Two-way processors950468
+Node: Printing Messages952672
+Ref: Printing Messages-Footnote-1953749
+Node: Updating `ERRNO'953901
+Node: Accessing Parameters954640
+Node: Symbol Table Access955870
+Node: Symbol table by name956384
+Node: Symbol table by cookie958360
+Ref: Symbol table by cookie-Footnote-1962493
+Node: Cached values962556
+Ref: Cached values-Footnote-1966060
+Node: Array Manipulation966151
+Ref: Array Manipulation-Footnote-1967249
+Node: Array Data Types967288
+Ref: Array Data Types-Footnote-1969991
+Node: Array Functions970083
+Node: Flattening Arrays973957
+Node: Creating Arrays980809
+Node: Extension API Variables985540
+Node: Extension Versioning986176
+Node: Extension API Informational Variables988077
+Node: Extension API Boilerplate989163
+Node: Finding Extensions992967
+Node: Extension Example993527
+Node: Internal File Description994257
+Node: Internal File Ops998348
+Ref: Internal File Ops-Footnote-11009780
+Node: Using Internal File Ops1009920
+Ref: Using Internal File Ops-Footnote-11012267
+Node: Extension Samples1012535
+Node: Extension Sample File Functions1014059
+Node: Extension Sample Fnmatch1021627
+Node: Extension Sample Fork1023109
+Node: Extension Sample Inplace1024322
+Node: Extension Sample Ord1025997
+Node: Extension Sample Readdir1026833
+Ref: table-readdir-file-types1027689
+Node: Extension Sample Revout1028488
+Node: Extension Sample Rev2way1029079
+Node: Extension Sample Read write array1029820
+Node: Extension Sample Readfile1031699
+Node: Extension Sample API Tests1032799
+Node: Extension Sample Time1033324
+Node: gawkextlib1034639
+Node: Extension summary1037452
+Node: Extension Exercises1041145
+Node: Language History1041867
+Node: V7/SVR3.11043510
+Node: SVR41045830
+Node: POSIX1047272
+Node: BTL1048658
+Node: POSIX/GNU1049392
+Node: Feature History1055108
+Node: Common Extensions1068199
+Node: Ranges and Locales1069511
+Ref: Ranges and Locales-Footnote-11074128
+Ref: Ranges and Locales-Footnote-21074155
+Ref: Ranges and Locales-Footnote-31074389
+Node: Contributors1074610
+Node: History summary1080035
+Node: Installation1081404
+Node: Gawk Distribution1082355
+Node: Getting1082839
+Node: Extracting1083663
+Node: Distribution contents1085305
+Node: Unix Installation1091022
+Node: Quick Installation1091639
+Node: Additional Configuration Options1094081
+Node: Configuration Philosophy1095819
+Node: Non-Unix Installation1098170
+Node: PC Installation1098628
+Node: PC Binary Installation1099939
+Node: PC Compiling1101787
+Ref: PC Compiling-Footnote-11104786
+Node: PC Testing1104891
+Node: PC Using1106067
+Node: Cygwin1110219
+Node: MSYS1111028
+Node: VMS Installation1111526
+Node: VMS Compilation1112322
+Ref: VMS Compilation-Footnote-11113544
+Node: VMS Dynamic Extensions1113602
+Node: VMS Installation Details1114975
+Node: VMS Running1117227
+Node: VMS GNV1120061
+Node: VMS Old Gawk1120784
+Node: Bugs1121254
+Node: Other Versions1125258
+Node: Installation summary1131482
+Node: Notes1132538
+Node: Compatibility Mode1133403
+Node: Additions1134185
+Node: Accessing The Source1135110
+Node: Adding Code1136546
+Node: New Ports1142724
+Node: Derived Files1147205
+Ref: Derived Files-Footnote-11152680
+Ref: Derived Files-Footnote-21152714
+Ref: Derived Files-Footnote-31153310
+Node: Future Extensions1153424
+Node: Implementation Limitations1154030
+Node: Extension Design1155278
+Node: Old Extension Problems1156432
+Ref: Old Extension Problems-Footnote-11157949
+Node: Extension New Mechanism Goals1158006
+Ref: Extension New Mechanism Goals-Footnote-11161366
+Node: Extension Other Design Decisions1161555
+Node: Extension Future Growth1163661
+Node: Old Extension Mechanism1164497
+Node: Notes summary1166259
+Node: Basic Concepts1167445
+Node: Basic High Level1168126
+Ref: figure-general-flow1168398
+Ref: figure-process-flow1168997
+Ref: Basic High Level-Footnote-11172226
+Node: Basic Data Typing1172411
+Node: Glossary1175739
+Node: Copying1200891
+Node: GNU Free Documentation License1238447
+Node: Index1263583

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index bec627a4..dae2bc3e 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -3914,6 +3914,8 @@ values in input data
@quotation CAUTION
This option can severely break old programs.
Use with care.
+
+This option may disappear in a future version of @command{gawk}.
@end quotation
@item @option{-N}
@@ -21483,24 +21485,12 @@ function rewind( i)
@c endfile
@end example
-This code relies on the @code{ARGIND} variable
-(@pxref{Auto-set}),
-which is specific to @command{gawk}.
-If you are not using
-@command{gawk}, you can use ideas presented in
-@ifnotinfo
-the previous @value{SECTION}
-@end ifnotinfo
-@ifinfo
-@ref{Filetrans Function},
-@end ifinfo
-to either update @code{ARGIND} on your own
-or modify this code as appropriate.
-
-The @code{rewind()} function also relies on the @code{nextfile} keyword
-(@pxref{Nextfile Statement}). Because of this, you should not call it
-from an @code{ENDFILE} rule. (This isn't necessary anyway, since as soon
-as an @code{ENDFILE} rule finishes @command{gawk} goes to the next file!)
+The @code{rewind()} function relies on the @code{ARGIND} variable
+(@pxref{Auto-set}), which is specific to @command{gawk}. It also
+relies on the @code{nextfile} keyword (@pxref{Nextfile Statement}).
+Because of this, you should not call it from an @code{ENDFILE} rule.
+(This isn't necessary anyway, since as soon as an @code{ENDFILE} rule
+finishes @command{gawk} goes to the next file!)
@node File Checking
@subsection Checking for Readable @value{DDF}s
@@ -21533,7 +21523,7 @@ the following program to your @command{awk} program:
BEGIN @{
for (i = 1; i < ARGC; i++) @{
- if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \
+ if (ARGV[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/ \
|| ARGV[i] == "-" || ARGV[i] == "/dev/stdin")
continue # assignment or standard input
else if ((getline junk < ARGV[i]) < 0) # unreadable
@@ -21551,6 +21541,11 @@ Removing the element from @code{ARGV} with @code{delete}
skips the file (since it's no longer in the list).
See also @ref{ARGC and ARGV}.
+The regular expression check purposely does not use character classes
+such as @samp{[:alpha:]} and @samp{[:alnum:]}
+(@pxref{Bracket Expressions})
+since @command{awk} variable names only allow the English letters.
+
@node Empty Files
@subsection Checking for Zero-length Files
@@ -21647,7 +21642,7 @@ a library file does the trick:
function disable_assigns(argc, argv, i)
@{
for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/)
+ if (argv[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/)
argv[i] = ("./" argv[i])
@}
@@ -22019,12 +22014,18 @@ In both runs, the first @option{--} terminates the arguments to
etc., as its own options.
@quotation NOTE
-After @code{getopt()} is through, it is the responsibility of the
-user level code to clear out all the elements of @code{ARGV} from 1
+After @code{getopt()} is through,
+user level code must clear out all the elements of @code{ARGV} from 1
to @code{Optind}, so that @command{awk} does not try to process the
command-line options as @value{FN}s.
@end quotation
+Using @samp{#!} with the @option{-E} option may help avoid
+conflicts between your program's options and @command{gawk}'s options,
+since @option{-E} causes @command{gawk} to abandon processing of
+further options
+(@pxref{Executable Scripts}, and @pxref{Options}).
+
Several of the sample programs presented in
@ref{Sample Programs},
use @code{getopt()} to process their arguments.
@@ -22269,13 +22270,14 @@ The @code{BEGIN} rule sets a private variable to the directory where
routine, we have chosen to put it in @file{/usr/local/libexec/awk};
however, you might want it to be in a different directory on your system.
-The function @code{_pw_init()} keeps three copies of the user information
-in three associative arrays. The arrays are indexed by username
+The function @code{_pw_init()} fills three copies of the user information
+into three associative arrays. The arrays are indexed by username
(@code{_pw_byname}), by user ID number (@code{_pw_byuid}), and by order of
occurrence (@code{_pw_bycount}).
The variable @code{_pw_inited} is used for efficiency, since @code{_pw_init()}
needs to be called only once.
+@cindex @code{PROCINFO} array, testing the field splitting
@cindex @code{getline} command, @code{_pw_init()} function
Because this function uses @code{getline} to read information from
@command{pwcat}, it first saves the values of @code{FS}, @code{RS}, and @code{$0}.
@@ -22283,13 +22285,8 @@ It notes in the variable @code{using_fw} whether field splitting
with @code{FIELDWIDTHS} is in effect or not.
Doing so is necessary, since these functions could be called
from anywhere within a user's program, and the user may have his
-or her
-own way of splitting records and fields.
-
-@cindex @code{PROCINFO} array, testing the field splitting
-The @code{using_fw} variable checks @code{PROCINFO["FS"]}, which
-is @code{"FIELDWIDTHS"} if field splitting is being done with
-@code{FIELDWIDTHS}. This makes it possible to restore the correct
+or her own way of splitting records and fields.
+This makes it possible to restore the correct
field-splitting mechanism later. The test can only be true for
@command{gawk}. It is false if using @code{FS} or @code{FPAT},
or on some other @command{awk} implementation.
@@ -22603,8 +22600,7 @@ function _gr_init( oldfs, oldrs, olddol0, grcat,
n = split($4, a, "[ \t]*,[ \t]*")
for (i = 1; i <= n; i++)
if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
+ _gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1
else
_gr_groupsbyuser[a[i]] = $1
@@ -22831,8 +22827,8 @@ $ @kbd{gawk -f walk_array.awk}
@itemize @value{BULLET}
@item
Reading programs is an excellent way to learn Good Programming.
-The functions provided in this @value{CHAPTER} and the next are intended
-to serve that purpose.
+The functions and programs provided in this @value{CHAPTER} and the next
+are intended to serve that purpose.
@item
When writing general-purpose library functions, put some thought into how
@@ -23119,22 +23115,16 @@ supplied:
# Requires getopt() and join() library functions
@group
-function usage( e1, e2)
+function usage()
@{
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
+ print("usage: cut [-f list] [-d c] [-s] [files...]") > "/dev/stderr"
+ print("usage: cut [-c list] [files...]") > "/dev/stderr"
exit 1
@}
@end group
@c endfile
@end example
-@noindent
-The variables @code{e1} and @code{e2} are used so that the function
-fits nicely on the @value{PAGE}.
-
@cindex @code{BEGIN} pattern, running @command{awk} programs and
@cindex @code{FS} variable, running @command{awk} programs and
Next comes a @code{BEGIN} rule that parses the command-line options.
@@ -23635,19 +23625,15 @@ and then exits:
@example
@c file eg/prog/egrep.awk
-function usage( e)
+function usage()
@{
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
+ print("Usage: egrep [-csvil] [-e pat] [files ...]") > "/dev/stderr"
+ print("\n\tegrep [-csvil] pat [files ...]") > "/dev/stderr"
exit 1
@}
@c endfile
@end example
-The variable @code{e} is used so that the function fits nicely
-on the printed page.
-
@c ENDOFRANGE regexps
@c ENDOFRANGE sfregexp
@c ENDOFRANGE fsregexp
@@ -23705,6 +23691,7 @@ numbers:
# May 1993
# Revised February 1996
# Revised May 2014
+# Revised September 2014
@c endfile
@end ignore
@@ -23723,26 +23710,22 @@ BEGIN @{
printf("uid=%d", uid)
pw = getpwuid(uid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (euid != uid) @{
printf(" euid=%d", euid)
pw = getpwuid(euid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
@}
printf(" gid=%d", gid)
pw = getgrgid(gid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (egid != gid) @{
printf(" egid=%d", egid)
pw = getgrgid(egid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
@}
for (i = 1; ("group" i) in PROCINFO; i++) @{
@@ -23751,8 +23734,7 @@ BEGIN @{
group = PROCINFO["group" i]
printf("%d", group)
pw = getgrgid(group)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (("group" (i+1)) in PROCINFO)
printf(",")
@}
@@ -23762,8 +23744,10 @@ BEGIN @{
function pr_first_field(str, a)
@{
- split(str, a, ":")
- printf("(%s)", a[1])
+ if (str != "") @{
+ split(str, a, ":")
+ printf("(%s)", a[1])
+ @}
@}
@c endfile
@end example
@@ -23786,7 +23770,8 @@ tested, and the loop body never executes.
The @code{pr_first_field()} function simply isolates out some
code that is used repeatedly, making the whole program
-slightly shorter and cleaner.
+shorter and cleaner. In particular, moving the check for
+the empty string into this function saves several lines of code.
@c ENDOFRANGE id
@@ -23913,19 +23898,14 @@ The @code{usage()} function simply prints an error message and exits:
@example
@c file eg/prog/split.awk
-function usage( e)
+function usage()
@{
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
+ print("usage: split [-num] [file] [outname]") > "/dev/stderr"
exit 1
@}
@c endfile
@end example
-@noindent
-The variable @code{e} is used so that the function
-fits nicely on the @value{PAGE}.
-
This program is a bit sloppy; it relies on @command{awk} to automatically close the last file
instead of doing it in an @code{END} rule.
It also assumes that letters are contiguous in the character set,
@@ -24084,10 +24064,10 @@ The options for @command{uniq} are:
@table @code
@item -d
-Print only repeated lines.
+Print only repeated (duplicated) lines.
@item -u
-Print only nonrepeated lines.
+Print only nonrepeated (unique) lines.
@item -c
Count lines. This option overrides @option{-d} and @option{-u}. Both repeated
@@ -24156,10 +24136,9 @@ standard output, @file{/dev/stdout}:
@end ignore
@c file eg/prog/uniq.awk
-function usage( e)
+function usage()
@{
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
+ print("Usage: uniq [-udc [-n]] [+n] [ in [ out ]]") > "/dev/stderr"
exit 1
@}
@@ -24213,22 +24192,20 @@ BEGIN @{
@end example
The following function, @code{are_equal()}, compares the current line,
-@code{$0}, to the
-previous line, @code{last}. It handles skipping fields and characters.
-If no field count and no character count are specified, @code{are_equal()}
-simply returns one or zero depending upon the result of a simple string
-comparison of @code{last} and @code{$0}. Otherwise, things get more
-complicated.
-If fields have to be skipped, each line is broken into an array using
-@code{split()}
-(@pxref{String Functions});
-the desired fields are then joined back into a line using @code{join()}.
-The joined lines are stored in @code{clast} and @code{cline}.
-If no fields are skipped, @code{clast} and @code{cline} are set to
-@code{last} and @code{$0}, respectively.
-Finally, if characters are skipped, @code{substr()} is used to strip off the
-leading @code{charcount} characters in @code{clast} and @code{cline}. The
-two strings are then compared and @code{are_equal()} returns the result:
+@code{$0}, to the previous line, @code{last}. It handles skipping fields
+and characters. If no field count and no character count are specified,
+@code{are_equal()} returns one or zero depending upon the result of a
+simple string comparison of @code{last} and @code{$0}.
+
+Otherwise, things get more complicated. If fields have to be skipped,
+each line is broken into an array using @code{split()} (@pxref{String
+Functions}); the desired fields are then joined back into a line
+using @code{join()}. The joined lines are stored in @code{clast} and
+@code{cline}. If no fields are skipped, @code{clast} and @code{cline}
+are set to @code{last} and @code{$0}, respectively. Finally, if
+characters are skipped, @code{substr()} is used to strip off the leading
+@code{charcount} characters in @code{clast} and @code{cline}. The two
+strings are then compared and @code{are_equal()} returns the result:
@example
@c file eg/prog/uniq.awk
@@ -24319,6 +24296,13 @@ END @{
@c endfile
@end example
+@c FIXME: Include this?
+@ignore
+This program does not follow our recommended convention of naming
+global variables with a leading capital letter. Doing that would
+make the program a little easier to follow.
+@end ignore
+
@ifset FOR_PRINT
The logic for choosing which lines to print represents a @dfn{state
machine}, which is ``a device that can be in one of a set number of stable
@@ -24364,7 +24348,7 @@ one or more input files. Its usage is as follows:
If no files are specified on the command line, @command{wc} reads its standard
input. If there are multiple files, it also prints total counts for all
-the files. The options and their meanings are shown in the following list:
+the files. The options and their meanings are as follows:
@table @code
@item -l
@@ -25016,7 +25000,7 @@ of lines on the page
Most of the work is done in the @code{printpage()} function.
The label lines are stored sequentially in the @code{line} array. But they
have to print horizontally; @code{line[1]} next to @code{line[6]},
-@code{line[2]} next to @code{line[7]}, and so on. Two loops are used to
+@code{line[2]} next to @code{line[7]}, and so on. Two loops
accomplish this. The outer loop, controlled by @code{i}, steps through
every 10 lines of data; this is each row of labels. The inner loop,
controlled by @code{j}, goes through the lines within the row.
@@ -25130,7 +25114,7 @@ in a useful format.
At first glance, a program like this would seem to do the job:
@example
-# Print list of word frequencies
+# wordfreq-first-try.awk --- print list of word frequencies
@{
for (i = 1; i <= NF; i++)
@@ -25347,16 +25331,16 @@ Texinfo input file into separate files.
This @value{DOCUMENT} is written in @uref{http://www.gnu.org/software/texinfo/, Texinfo},
the GNU project's document formatting language.
A single Texinfo source file can be used to produce both
-printed and online documentation.
+printed documentation, with @TeX{}, and online documentation.
@ifnotinfo
-Texinfo is fully documented in the book
+(Texinfo is fully documented in the book
@cite{Texinfo---The GNU Documentation Format},
available from the Free Software Foundation,
-and also available @uref{http://www.gnu.org/software/texinfo/manual/texinfo/, online}.
+and also available @uref{http://www.gnu.org/software/texinfo/manual/texinfo/, online}.)
@end ifnotinfo
@ifinfo
-The Texinfo language is described fully, starting with
-@inforef{Top, , Texinfo, texinfo,Texinfo---The GNU Documentation Format}.
+(The Texinfo language is described fully, starting with
+@inforef{Top, , Texinfo, texinfo,Texinfo---The GNU Documentation Format}.)
@end ifinfo
For our purposes, it is enough to know three things about Texinfo input
@@ -25434,8 +25418,7 @@ exits with a zero exit status, signifying OK:
@cindex @code{extract.awk} program
@example
@c file eg/prog/extract.awk
-# extract.awk --- extract files and run programs
-# from texinfo files
+# extract.awk --- extract files and run programs from texinfo files
@c endfile
@ignore
@c file eg/prog/extract.awk
@@ -25449,8 +25432,7 @@ exits with a zero exit status, signifying OK:
BEGIN @{ IGNORECASE = 1 @}
-/^@@c(omment)?[ \t]+system/ \
-@{
+/^@@c(omment)?[ \t]+system/ @{
if (NF < 3) @{
e = ("extract: " FILENAME ":" FNR)
e = (e ": badly formed `system' line")
@@ -25507,8 +25489,7 @@ line. That line is then printed to the output file:
@example
@c file eg/prog/extract.awk
-/^@@c(omment)?[ \t]+file/ \
-@{
+/^@@c(omment)?[ \t]+file/ @{
if (NF != 3) @{
e = ("extract: " FILENAME ":" FNR ": badly formed `file' line")
print e > "/dev/stderr"
@@ -25568,7 +25549,7 @@ The @code{END} rule handles the final cleanup, closing the open file:
function unexpected_eof()
@{
printf("extract: %s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
+ FILENAME, FNR) > "/dev/stderr"
exit 1
@}
@end group
@@ -25828,6 +25809,7 @@ should be the @command{awk} program. If there are no command-line
arguments left, @command{igawk} prints an error message and exits.
Otherwise, the first argument is appended to @code{program}.
In any case, after the arguments have been processed,
+the shell variable
@code{program} contains the complete text of the original @command{awk}
program.
@@ -26151,12 +26133,10 @@ in C or C++, and it is frequently easier to do certain kinds of string
and argument manipulation using the shell than it is in @command{awk}.
Finally, @command{igawk} shows that it is not always necessary to add new
-features to a program; they can often be layered on top.
-@ignore
-With @command{igawk},
-there is no real reason to build @code{@@include} processing into
-@command{gawk} itself.
-@end ignore
+features to a program; they can often be layered on top.@footnote{@command{gawk}
+does @code{@@include} processing itself in order to support the use
+of @command{awk} programs as Web CGI scripts.}
+
@c ENDOFRANGE libfex
@c ENDOFRANGE flibex
@c ENDOFRANGE awkpex
@@ -26174,12 +26154,11 @@ One word is an anagram of another if both words contain
the same letters
(for example, ``babbling'' and ``blabbing'').
-An elegant algorithm is presented in Column 2, Problem C of
-Jon Bentley's @cite{Programming Pearls}, second edition.
-The idea is to give words that are anagrams a common signature,
-sort all the words together by their signature, and then print them.
-Dr.@: Bentley observes that taking the letters in each word and
-sorting them produces that common signature.
+Column 2, Problem C of Jon Bentley's @cite{Programming Pearls}, second
+edition, presents an elegant algorithm. The idea is to give words that
+are anagrams a common signature, sort all the words together by their
+signature, and then print them. Dr.@: Bentley observes that taking the
+letters in each word and sorting them produces that common signature.
The following program uses arrays of arrays to bring together
words with the same signature and array sorting to print the words
@@ -26413,7 +26392,7 @@ BEGIN {
@itemize @value{BULLET}
@item
-The functions provided in this @value{CHAPTER} and the previous one
+The programs provided in this @value{CHAPTER}
continue on the theme that reading programs is an excellent way to learn
Good Programming.
@@ -26690,13 +26669,11 @@ discusses the ability to dynamically add new built-in functions to
@cindex constants, nondecimal
If you run @command{gawk} with the @option{--non-decimal-data} option,
-you can have nondecimal constants in your input data:
+you can have nondecimal values in your input data:
-@c line break here for small book format
@example
$ @kbd{echo 0123 123 0x123 |}
-> @kbd{gawk --non-decimal-data '@{ printf "%d, %d, %d\n",}
-> @kbd{$1, $2, $3 @}'}
+> @kbd{gawk --non-decimal-data '@{ printf "%d, %d, %d\n", $1, $2, $3 @}'}
@print{} 83, 123, 291
@end example
@@ -26737,6 +26714,8 @@ Instead, use the @code{strtonum()} function to convert your data
(@pxref{String Functions}).
This makes your programs easier to write and easier to read, and
leads to less surprising results.
+
+This option may disappear in a future version of @command{gawk}.
@end quotation
@node Array Sorting
@@ -26771,7 +26750,9 @@ pre-defined values to @code{PROCINFO["sorted_in"]} in order to
control the order in which @command{gawk} traverses an array
during a @code{for} loop.
-In addition, the value of @code{PROCINFO["sorted_in"]} can be a function name.
+In addition, the value of @code{PROCINFO["sorted_in"]} can be a
+function name.@footnote{This is why the predefined sorting orders
+start with an @samp{@@} character, which cannot be part of an identifier.}
This lets you traverse an array based on any custom criterion.
The array elements are ordered according to the return value of this
function. The comparison function should be defined with at least
@@ -26903,7 +26884,7 @@ according to login name. The following program sorts records
by a specific field position and can be used for this purpose:
@example
-# sort.awk --- simple program to sort by field position
+# passwd-sort.awk --- simple program to sort by field position
# field position is specified by the global variable POS
function cmp_field(i1, v1, i2, v2)
@@ -26962,7 +26943,7 @@ As mentioned above, the order of the indices is arbitrary if two
elements compare equal. This is usually not a problem, but letting
the tied elements come out in arbitrary order can be an issue, especially
when comparing item values. The partial ordering of the equal elements
-may change during the next loop traversal, if other elements are added or
+may change the next time the array is traversed, if other elements are added or
removed from the array. One way to resolve ties when comparing elements
with otherwise equal values is to include the indices in the comparison
rules. Note that doing this may make the loop traversal less efficient,
@@ -27196,7 +27177,7 @@ for example, @file{/tmp} will not do, as another user might happen
to be using a temporary file with the same name.@footnote{Michael
Brennan suggests the use of @command{rand()} to generate unique
@value{FN}s. This is a valid point; nevertheless, temporary files
-remain more difficult than two-way pipes.} @c 8/2014
+remain more difficult to use than two-way pipes.} @c 8/2014
@cindex coprocesses
@cindex input/output, two-way
@@ -27339,7 +27320,7 @@ using regular pipes.
@ @ @ @ @i{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.}
@end quotation
@end ifnotdocbook
@@ -27349,7 +27330,7 @@ using regular pipes.
&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>
&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>unless the host that isn't close</emphasis>
-&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>is busy hung or dead.</emphasis></literallayout>
+&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>is busy, hung, or dead.</emphasis></literallayout>
</blockquote>
@end docbook
@@ -27380,7 +27361,7 @@ the system default, most likely IPv4.
@item protocol
The protocol to use over IP. This must be either @samp{tcp}, or
@samp{udp}, for a TCP or UDP IP connection,
-respectively. The use of TCP is recommended for most applications.
+respectively. TCP should be used for most applications.
@item local-port
@cindex @code{getaddrinfo()} function (C library)
@@ -27413,10 +27394,10 @@ Consider the following very simple example:
@example
BEGIN @{
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
+ Service = "/inet/tcp/0/localhost/daytime"
+ Service |& getline
+ print $0
+ close(Service)
@}
@end example
@@ -38050,10 +38031,8 @@ Date: Wed, 4 Sep 1996 08:11:48 -0700 (PDT)
@docbook
<blockquote><attribution>Michael Brennan</attribution>
-<literallayout>
-<emphasis>It's kind of fun to put comments like this in your awk code.</emphasis>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<literal>// Do C++ comments work? answer: yes! of course</literal>
-</literallayout>
+<literallayout><emphasis>It's kind of fun to put comments like this in your awk code.</emphasis>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<literal>// Do C++ comments work? answer: yes! of course</literal></literallayout>
</blockquote>
@end docbook
@@ -41694,4 +41673,3 @@ But to use it you have to say
which sorta sucks.
TODO:
------
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 1acd1a99..bfe058b1 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -3825,6 +3825,8 @@ values in input data
@quotation CAUTION
This option can severely break old programs.
Use with care.
+
+This option may disappear in a future version of @command{gawk}.
@end quotation
@item @option{-N}
@@ -20580,24 +20582,12 @@ function rewind( i)
@c endfile
@end example
-This code relies on the @code{ARGIND} variable
-(@pxref{Auto-set}),
-which is specific to @command{gawk}.
-If you are not using
-@command{gawk}, you can use ideas presented in
-@ifnotinfo
-the previous @value{SECTION}
-@end ifnotinfo
-@ifinfo
-@ref{Filetrans Function},
-@end ifinfo
-to either update @code{ARGIND} on your own
-or modify this code as appropriate.
-
-The @code{rewind()} function also relies on the @code{nextfile} keyword
-(@pxref{Nextfile Statement}). Because of this, you should not call it
-from an @code{ENDFILE} rule. (This isn't necessary anyway, since as soon
-as an @code{ENDFILE} rule finishes @command{gawk} goes to the next file!)
+The @code{rewind()} function relies on the @code{ARGIND} variable
+(@pxref{Auto-set}), which is specific to @command{gawk}. It also
+relies on the @code{nextfile} keyword (@pxref{Nextfile Statement}).
+Because of this, you should not call it from an @code{ENDFILE} rule.
+(This isn't necessary anyway, since as soon as an @code{ENDFILE} rule
+finishes @command{gawk} goes to the next file!)
@node File Checking
@subsection Checking for Readable @value{DDF}s
@@ -20630,7 +20620,7 @@ the following program to your @command{awk} program:
BEGIN @{
for (i = 1; i < ARGC; i++) @{
- if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \
+ if (ARGV[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/ \
|| ARGV[i] == "-" || ARGV[i] == "/dev/stdin")
continue # assignment or standard input
else if ((getline junk < ARGV[i]) < 0) # unreadable
@@ -20648,6 +20638,11 @@ Removing the element from @code{ARGV} with @code{delete}
skips the file (since it's no longer in the list).
See also @ref{ARGC and ARGV}.
+The regular expression check purposely does not use character classes
+such as @samp{[:alpha:]} and @samp{[:alnum:]}
+(@pxref{Bracket Expressions})
+since @command{awk} variable names only allow the English letters.
+
@node Empty Files
@subsection Checking for Zero-length Files
@@ -20744,7 +20739,7 @@ a library file does the trick:
function disable_assigns(argc, argv, i)
@{
for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/)
+ if (argv[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/)
argv[i] = ("./" argv[i])
@}
@@ -21116,12 +21111,18 @@ In both runs, the first @option{--} terminates the arguments to
etc., as its own options.
@quotation NOTE
-After @code{getopt()} is through, it is the responsibility of the
-user level code to clear out all the elements of @code{ARGV} from 1
+After @code{getopt()} is through,
+user level code must clear out all the elements of @code{ARGV} from 1
to @code{Optind}, so that @command{awk} does not try to process the
command-line options as @value{FN}s.
@end quotation
+Using @samp{#!} with the @option{-E} option may help avoid
+conflicts between your program's options and @command{gawk}'s options,
+since @option{-E} causes @command{gawk} to abandon processing of
+further options
+(@pxref{Executable Scripts}, and @pxref{Options}).
+
Several of the sample programs presented in
@ref{Sample Programs},
use @code{getopt()} to process their arguments.
@@ -21366,13 +21367,14 @@ The @code{BEGIN} rule sets a private variable to the directory where
routine, we have chosen to put it in @file{/usr/local/libexec/awk};
however, you might want it to be in a different directory on your system.
-The function @code{_pw_init()} keeps three copies of the user information
-in three associative arrays. The arrays are indexed by username
+The function @code{_pw_init()} fills three copies of the user information
+into three associative arrays. The arrays are indexed by username
(@code{_pw_byname}), by user ID number (@code{_pw_byuid}), and by order of
occurrence (@code{_pw_bycount}).
The variable @code{_pw_inited} is used for efficiency, since @code{_pw_init()}
needs to be called only once.
+@cindex @code{PROCINFO} array, testing the field splitting
@cindex @code{getline} command, @code{_pw_init()} function
Because this function uses @code{getline} to read information from
@command{pwcat}, it first saves the values of @code{FS}, @code{RS}, and @code{$0}.
@@ -21380,13 +21382,8 @@ It notes in the variable @code{using_fw} whether field splitting
with @code{FIELDWIDTHS} is in effect or not.
Doing so is necessary, since these functions could be called
from anywhere within a user's program, and the user may have his
-or her
-own way of splitting records and fields.
-
-@cindex @code{PROCINFO} array, testing the field splitting
-The @code{using_fw} variable checks @code{PROCINFO["FS"]}, which
-is @code{"FIELDWIDTHS"} if field splitting is being done with
-@code{FIELDWIDTHS}. This makes it possible to restore the correct
+or her own way of splitting records and fields.
+This makes it possible to restore the correct
field-splitting mechanism later. The test can only be true for
@command{gawk}. It is false if using @code{FS} or @code{FPAT},
or on some other @command{awk} implementation.
@@ -21700,8 +21697,7 @@ function _gr_init( oldfs, oldrs, olddol0, grcat,
n = split($4, a, "[ \t]*,[ \t]*")
for (i = 1; i <= n; i++)
if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
+ _gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1
else
_gr_groupsbyuser[a[i]] = $1
@@ -21928,8 +21924,8 @@ $ @kbd{gawk -f walk_array.awk}
@itemize @value{BULLET}
@item
Reading programs is an excellent way to learn Good Programming.
-The functions provided in this @value{CHAPTER} and the next are intended
-to serve that purpose.
+The functions and programs provided in this @value{CHAPTER} and the next
+are intended to serve that purpose.
@item
When writing general-purpose library functions, put some thought into how
@@ -22216,22 +22212,16 @@ supplied:
# Requires getopt() and join() library functions
@group
-function usage( e1, e2)
+function usage()
@{
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
+ print("usage: cut [-f list] [-d c] [-s] [files...]") > "/dev/stderr"
+ print("usage: cut [-c list] [files...]") > "/dev/stderr"
exit 1
@}
@end group
@c endfile
@end example
-@noindent
-The variables @code{e1} and @code{e2} are used so that the function
-fits nicely on the @value{PAGE}.
-
@cindex @code{BEGIN} pattern, running @command{awk} programs and
@cindex @code{FS} variable, running @command{awk} programs and
Next comes a @code{BEGIN} rule that parses the command-line options.
@@ -22732,19 +22722,15 @@ and then exits:
@example
@c file eg/prog/egrep.awk
-function usage( e)
+function usage()
@{
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
+ print("Usage: egrep [-csvil] [-e pat] [files ...]") > "/dev/stderr"
+ print("\n\tegrep [-csvil] pat [files ...]") > "/dev/stderr"
exit 1
@}
@c endfile
@end example
-The variable @code{e} is used so that the function fits nicely
-on the printed page.
-
@c ENDOFRANGE regexps
@c ENDOFRANGE sfregexp
@c ENDOFRANGE fsregexp
@@ -22802,6 +22788,7 @@ numbers:
# May 1993
# Revised February 1996
# Revised May 2014
+# Revised September 2014
@c endfile
@end ignore
@@ -22820,26 +22807,22 @@ BEGIN @{
printf("uid=%d", uid)
pw = getpwuid(uid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (euid != uid) @{
printf(" euid=%d", euid)
pw = getpwuid(euid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
@}
printf(" gid=%d", gid)
pw = getgrgid(gid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (egid != gid) @{
printf(" egid=%d", egid)
pw = getgrgid(egid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
@}
for (i = 1; ("group" i) in PROCINFO; i++) @{
@@ -22848,8 +22831,7 @@ BEGIN @{
group = PROCINFO["group" i]
printf("%d", group)
pw = getgrgid(group)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (("group" (i+1)) in PROCINFO)
printf(",")
@}
@@ -22859,8 +22841,10 @@ BEGIN @{
function pr_first_field(str, a)
@{
- split(str, a, ":")
- printf("(%s)", a[1])
+ if (str != "") @{
+ split(str, a, ":")
+ printf("(%s)", a[1])
+ @}
@}
@c endfile
@end example
@@ -22883,7 +22867,8 @@ tested, and the loop body never executes.
The @code{pr_first_field()} function simply isolates out some
code that is used repeatedly, making the whole program
-slightly shorter and cleaner.
+shorter and cleaner. In particular, moving the check for
+the empty string into this function saves several lines of code.
@c ENDOFRANGE id
@@ -23010,19 +22995,14 @@ The @code{usage()} function simply prints an error message and exits:
@example
@c file eg/prog/split.awk
-function usage( e)
+function usage()
@{
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
+ print("usage: split [-num] [file] [outname]") > "/dev/stderr"
exit 1
@}
@c endfile
@end example
-@noindent
-The variable @code{e} is used so that the function
-fits nicely on the @value{PAGE}.
-
This program is a bit sloppy; it relies on @command{awk} to automatically close the last file
instead of doing it in an @code{END} rule.
It also assumes that letters are contiguous in the character set,
@@ -23181,10 +23161,10 @@ The options for @command{uniq} are:
@table @code
@item -d
-Print only repeated lines.
+Print only repeated (duplicated) lines.
@item -u
-Print only nonrepeated lines.
+Print only nonrepeated (unique) lines.
@item -c
Count lines. This option overrides @option{-d} and @option{-u}. Both repeated
@@ -23253,10 +23233,9 @@ standard output, @file{/dev/stdout}:
@end ignore
@c file eg/prog/uniq.awk
-function usage( e)
+function usage()
@{
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
+ print("Usage: uniq [-udc [-n]] [+n] [ in [ out ]]") > "/dev/stderr"
exit 1
@}
@@ -23310,22 +23289,20 @@ BEGIN @{
@end example
The following function, @code{are_equal()}, compares the current line,
-@code{$0}, to the
-previous line, @code{last}. It handles skipping fields and characters.
-If no field count and no character count are specified, @code{are_equal()}
-simply returns one or zero depending upon the result of a simple string
-comparison of @code{last} and @code{$0}. Otherwise, things get more
-complicated.
-If fields have to be skipped, each line is broken into an array using
-@code{split()}
-(@pxref{String Functions});
-the desired fields are then joined back into a line using @code{join()}.
-The joined lines are stored in @code{clast} and @code{cline}.
-If no fields are skipped, @code{clast} and @code{cline} are set to
-@code{last} and @code{$0}, respectively.
-Finally, if characters are skipped, @code{substr()} is used to strip off the
-leading @code{charcount} characters in @code{clast} and @code{cline}. The
-two strings are then compared and @code{are_equal()} returns the result:
+@code{$0}, to the previous line, @code{last}. It handles skipping fields
+and characters. If no field count and no character count are specified,
+@code{are_equal()} returns one or zero depending upon the result of a
+simple string comparison of @code{last} and @code{$0}.
+
+Otherwise, things get more complicated. If fields have to be skipped,
+each line is broken into an array using @code{split()} (@pxref{String
+Functions}); the desired fields are then joined back into a line
+using @code{join()}. The joined lines are stored in @code{clast} and
+@code{cline}. If no fields are skipped, @code{clast} and @code{cline}
+are set to @code{last} and @code{$0}, respectively. Finally, if
+characters are skipped, @code{substr()} is used to strip off the leading
+@code{charcount} characters in @code{clast} and @code{cline}. The two
+strings are then compared and @code{are_equal()} returns the result:
@example
@c file eg/prog/uniq.awk
@@ -23416,6 +23393,13 @@ END @{
@c endfile
@end example
+@c FIXME: Include this?
+@ignore
+This program does not follow our recommended convention of naming
+global variables with a leading capital letter. Doing that would
+make the program a little easier to follow.
+@end ignore
+
@ifset FOR_PRINT
The logic for choosing which lines to print represents a @dfn{state
machine}, which is ``a device that can be in one of a set number of stable
@@ -23461,7 +23445,7 @@ one or more input files. Its usage is as follows:
If no files are specified on the command line, @command{wc} reads its standard
input. If there are multiple files, it also prints total counts for all
-the files. The options and their meanings are shown in the following list:
+the files. The options and their meanings are as follows:
@table @code
@item -l
@@ -24113,7 +24097,7 @@ of lines on the page
Most of the work is done in the @code{printpage()} function.
The label lines are stored sequentially in the @code{line} array. But they
have to print horizontally; @code{line[1]} next to @code{line[6]},
-@code{line[2]} next to @code{line[7]}, and so on. Two loops are used to
+@code{line[2]} next to @code{line[7]}, and so on. Two loops
accomplish this. The outer loop, controlled by @code{i}, steps through
every 10 lines of data; this is each row of labels. The inner loop,
controlled by @code{j}, goes through the lines within the row.
@@ -24227,7 +24211,7 @@ in a useful format.
At first glance, a program like this would seem to do the job:
@example
-# Print list of word frequencies
+# wordfreq-first-try.awk --- print list of word frequencies
@{
for (i = 1; i <= NF; i++)
@@ -24444,16 +24428,16 @@ Texinfo input file into separate files.
This @value{DOCUMENT} is written in @uref{http://www.gnu.org/software/texinfo/, Texinfo},
the GNU project's document formatting language.
A single Texinfo source file can be used to produce both
-printed and online documentation.
+printed documentation, with @TeX{}, and online documentation.
@ifnotinfo
-Texinfo is fully documented in the book
+(Texinfo is fully documented in the book
@cite{Texinfo---The GNU Documentation Format},
available from the Free Software Foundation,
-and also available @uref{http://www.gnu.org/software/texinfo/manual/texinfo/, online}.
+and also available @uref{http://www.gnu.org/software/texinfo/manual/texinfo/, online}.)
@end ifnotinfo
@ifinfo
-The Texinfo language is described fully, starting with
-@inforef{Top, , Texinfo, texinfo,Texinfo---The GNU Documentation Format}.
+(The Texinfo language is described fully, starting with
+@inforef{Top, , Texinfo, texinfo,Texinfo---The GNU Documentation Format}.)
@end ifinfo
For our purposes, it is enough to know three things about Texinfo input
@@ -24531,8 +24515,7 @@ exits with a zero exit status, signifying OK:
@cindex @code{extract.awk} program
@example
@c file eg/prog/extract.awk
-# extract.awk --- extract files and run programs
-# from texinfo files
+# extract.awk --- extract files and run programs from texinfo files
@c endfile
@ignore
@c file eg/prog/extract.awk
@@ -24546,8 +24529,7 @@ exits with a zero exit status, signifying OK:
BEGIN @{ IGNORECASE = 1 @}
-/^@@c(omment)?[ \t]+system/ \
-@{
+/^@@c(omment)?[ \t]+system/ @{
if (NF < 3) @{
e = ("extract: " FILENAME ":" FNR)
e = (e ": badly formed `system' line")
@@ -24604,8 +24586,7 @@ line. That line is then printed to the output file:
@example
@c file eg/prog/extract.awk
-/^@@c(omment)?[ \t]+file/ \
-@{
+/^@@c(omment)?[ \t]+file/ @{
if (NF != 3) @{
e = ("extract: " FILENAME ":" FNR ": badly formed `file' line")
print e > "/dev/stderr"
@@ -24665,7 +24646,7 @@ The @code{END} rule handles the final cleanup, closing the open file:
function unexpected_eof()
@{
printf("extract: %s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
+ FILENAME, FNR) > "/dev/stderr"
exit 1
@}
@end group
@@ -24925,6 +24906,7 @@ should be the @command{awk} program. If there are no command-line
arguments left, @command{igawk} prints an error message and exits.
Otherwise, the first argument is appended to @code{program}.
In any case, after the arguments have been processed,
+the shell variable
@code{program} contains the complete text of the original @command{awk}
program.
@@ -25248,12 +25230,10 @@ in C or C++, and it is frequently easier to do certain kinds of string
and argument manipulation using the shell than it is in @command{awk}.
Finally, @command{igawk} shows that it is not always necessary to add new
-features to a program; they can often be layered on top.
-@ignore
-With @command{igawk},
-there is no real reason to build @code{@@include} processing into
-@command{gawk} itself.
-@end ignore
+features to a program; they can often be layered on top.@footnote{@command{gawk}
+does @code{@@include} processing itself in order to support the use
+of @command{awk} programs as Web CGI scripts.}
+
@c ENDOFRANGE libfex
@c ENDOFRANGE flibex
@c ENDOFRANGE awkpex
@@ -25271,12 +25251,11 @@ One word is an anagram of another if both words contain
the same letters
(for example, ``babbling'' and ``blabbing'').
-An elegant algorithm is presented in Column 2, Problem C of
-Jon Bentley's @cite{Programming Pearls}, second edition.
-The idea is to give words that are anagrams a common signature,
-sort all the words together by their signature, and then print them.
-Dr.@: Bentley observes that taking the letters in each word and
-sorting them produces that common signature.
+Column 2, Problem C of Jon Bentley's @cite{Programming Pearls}, second
+edition, presents an elegant algorithm. The idea is to give words that
+are anagrams a common signature, sort all the words together by their
+signature, and then print them. Dr.@: Bentley observes that taking the
+letters in each word and sorting them produces that common signature.
The following program uses arrays of arrays to bring together
words with the same signature and array sorting to print the words
@@ -25510,7 +25489,7 @@ BEGIN {
@itemize @value{BULLET}
@item
-The functions provided in this @value{CHAPTER} and the previous one
+The programs provided in this @value{CHAPTER}
continue on the theme that reading programs is an excellent way to learn
Good Programming.
@@ -25787,13 +25766,11 @@ discusses the ability to dynamically add new built-in functions to
@cindex constants, nondecimal
If you run @command{gawk} with the @option{--non-decimal-data} option,
-you can have nondecimal constants in your input data:
+you can have nondecimal values in your input data:
-@c line break here for small book format
@example
$ @kbd{echo 0123 123 0x123 |}
-> @kbd{gawk --non-decimal-data '@{ printf "%d, %d, %d\n",}
-> @kbd{$1, $2, $3 @}'}
+> @kbd{gawk --non-decimal-data '@{ printf "%d, %d, %d\n", $1, $2, $3 @}'}
@print{} 83, 123, 291
@end example
@@ -25834,6 +25811,8 @@ Instead, use the @code{strtonum()} function to convert your data
(@pxref{String Functions}).
This makes your programs easier to write and easier to read, and
leads to less surprising results.
+
+This option may disappear in a future version of @command{gawk}.
@end quotation
@node Array Sorting
@@ -25868,7 +25847,9 @@ pre-defined values to @code{PROCINFO["sorted_in"]} in order to
control the order in which @command{gawk} traverses an array
during a @code{for} loop.
-In addition, the value of @code{PROCINFO["sorted_in"]} can be a function name.
+In addition, the value of @code{PROCINFO["sorted_in"]} can be a
+function name.@footnote{This is why the predefined sorting orders
+start with an @samp{@@} character, which cannot be part of an identifier.}
This lets you traverse an array based on any custom criterion.
The array elements are ordered according to the return value of this
function. The comparison function should be defined with at least
@@ -26000,7 +25981,7 @@ according to login name. The following program sorts records
by a specific field position and can be used for this purpose:
@example
-# sort.awk --- simple program to sort by field position
+# passwd-sort.awk --- simple program to sort by field position
# field position is specified by the global variable POS
function cmp_field(i1, v1, i2, v2)
@@ -26059,7 +26040,7 @@ As mentioned above, the order of the indices is arbitrary if two
elements compare equal. This is usually not a problem, but letting
the tied elements come out in arbitrary order can be an issue, especially
when comparing item values. The partial ordering of the equal elements
-may change during the next loop traversal, if other elements are added or
+may change the next time the array is traversed, if other elements are added or
removed from the array. One way to resolve ties when comparing elements
with otherwise equal values is to include the indices in the comparison
rules. Note that doing this may make the loop traversal less efficient,
@@ -26293,7 +26274,7 @@ for example, @file{/tmp} will not do, as another user might happen
to be using a temporary file with the same name.@footnote{Michael
Brennan suggests the use of @command{rand()} to generate unique
@value{FN}s. This is a valid point; nevertheless, temporary files
-remain more difficult than two-way pipes.} @c 8/2014
+remain more difficult to use than two-way pipes.} @c 8/2014
@cindex coprocesses
@cindex input/output, two-way
@@ -26436,7 +26417,7 @@ using regular pipes.
@ @ @ @ @i{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.}
@end quotation
@end ifnotdocbook
@@ -26446,7 +26427,7 @@ using regular pipes.
&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>
&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>unless the host that isn't close</emphasis>
-&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>is busy hung or dead.</emphasis></literallayout>
+&nbsp;&nbsp;&nbsp;&nbsp;<emphasis>is busy, hung, or dead.</emphasis></literallayout>
</blockquote>
@end docbook
@@ -26477,7 +26458,7 @@ the system default, most likely IPv4.
@item protocol
The protocol to use over IP. This must be either @samp{tcp}, or
@samp{udp}, for a TCP or UDP IP connection,
-respectively. The use of TCP is recommended for most applications.
+respectively. TCP should be used for most applications.
@item local-port
@cindex @code{getaddrinfo()} function (C library)
@@ -26510,10 +26491,10 @@ Consider the following very simple example:
@example
BEGIN @{
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
+ Service = "/inet/tcp/0/localhost/daytime"
+ Service |& getline
+ print $0
+ close(Service)
@}
@end example
@@ -37147,10 +37128,8 @@ Date: Wed, 4 Sep 1996 08:11:48 -0700 (PDT)
@docbook
<blockquote><attribution>Michael Brennan</attribution>
-<literallayout>
-<emphasis>It's kind of fun to put comments like this in your awk code.</emphasis>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<literal>// Do C++ comments work? answer: yes! of course</literal>
-</literallayout>
+<literallayout><emphasis>It's kind of fun to put comments like this in your awk code.</emphasis>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<literal>// Do C++ comments work? answer: yes! of course</literal></literallayout>
</blockquote>
@end docbook
@@ -40791,4 +40770,3 @@ But to use it you have to say
which sorta sucks.
TODO:
------