summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-11-17 16:54:41 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-11-17 16:54:41 +0200
commit41da6a35e2cca4ec3c6b7c61e204e51484ecd7eb (patch)
tree39104b9569f71242e40d5c990bd63f56116c3d65
parent31c6051694d3152e50eb037e20c4734c7321eac6 (diff)
parent46fb38d70fe250f318fb95a6083beaceaaf5155d (diff)
downloadgawk-41da6a35e2cca4ec3c6b7c61e204e51484ecd7eb.tar.gz
Merge branch 'gawk-4.1-stable' into memory-work
-rw-r--r--NOTES26
-rw-r--r--awklib/eg/lib/ftrans.awk2
-rw-r--r--awklib/eg/lib/strtonum.awk2
-rw-r--r--awklib/eg/prog/indirectcall.awk2
-rw-r--r--awklib/eg/prog/split.awk2
-rw-r--r--doc/ChangeLog4
-rw-r--r--doc/gawk.info4127
-rw-r--r--doc/gawk.texi2610
-rw-r--r--doc/gawktexi.in2545
9 files changed, 4804 insertions, 4516 deletions
diff --git a/NOTES b/NOTES
new file mode 100644
index 00000000..f7dee5ca
--- /dev/null
+++ b/NOTES
@@ -0,0 +1,26 @@
+Page 18. OK to move the sidebar although having it at the opening
+is sort of like the opening quotes I have in other places; it's meant
+to be humorous.
+
+Page 10 - references to 'Chapter 10' and 'Chapter 11' have been left
+alone since they are links and I can't do it that way in texinfo anyway.
+
+Appendices vs. Appendixes: I have left it as the former; the latter
+looks totally wrong to me.
+
+Numbers: I use the style where values from zero to nine are spelled
+out and from 10 up they're written with digits. (I forget what the
+Chicago Manual of Style calls this.) So I've rejected those changes.
+
+C heads - I have not lowercased them; this would be incorrect
+for the Texinfo, so I've marked them as Rejected but with a reply
+in the PDF to please do this during production.
+
+Literal layout blocks not being indented - I used literal layout to get
+the brackets, which indicate optional stuff, in Roman. I think that if you
+simply fix the style sheets to indent those blocks, we should be in better
+shape.
+
+ADD STUFF ON danfuzz repo.
+
+At page 482.
diff --git a/awklib/eg/lib/ftrans.awk b/awklib/eg/lib/ftrans.awk
index 2fec27ef..6461efff 100644
--- a/awklib/eg/lib/ftrans.awk
+++ b/awklib/eg/lib/ftrans.awk
@@ -1,4 +1,4 @@
-# ftrans.awk --- handle data file transitions
+# ftrans.awk --- handle datafile transitions
#
# user supplies beginfile() and endfile() functions
#
diff --git a/awklib/eg/lib/strtonum.awk b/awklib/eg/lib/strtonum.awk
index cd56a449..783496e4 100644
--- a/awklib/eg/lib/strtonum.awk
+++ b/awklib/eg/lib/strtonum.awk
@@ -52,7 +52,7 @@ function mystrtonum(str, ret, n, i, k, c)
# a[6] = "1.e3"
# a[7] = "1.32"
# a[8] = "1.32E2"
-#
+#
# for (i = 1; i in a; i++)
# print a[i], strtonum(a[i]), mystrtonum(a[i])
# }
diff --git a/awklib/eg/prog/indirectcall.awk b/awklib/eg/prog/indirectcall.awk
index 3ecb2887..165b022a 100644
--- a/awklib/eg/prog/indirectcall.awk
+++ b/awklib/eg/prog/indirectcall.awk
@@ -27,7 +27,7 @@ function do_sort(first, last, compare, data, i, retval)
retval = data[1]
for (i = 2; i in data; i++)
retval = retval " " data[i]
-
+
return retval
}
# sort --- sort the data in ascending order and return it as a string
diff --git a/awklib/eg/prog/split.awk b/awklib/eg/prog/split.awk
index 6a7198f6..b878fa50 100644
--- a/awklib/eg/prog/split.awk
+++ b/awklib/eg/prog/split.awk
@@ -22,7 +22,7 @@ BEGIN {
}
# test argv in case reading from stdin instead of file
if (i in ARGV)
- i++ # skip data file name
+ i++ # skip datafile name
if (i in ARGV) {
outfile = ARGV[i]
ARGV[i] = ""
diff --git a/doc/ChangeLog b/doc/ChangeLog
index ae3a25cd..7288fb77 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Copyedits applied.
+
2014-11-02 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Comment out that I need an owner for awk.info.
diff --git a/doc/gawk.info b/doc/gawk.info
index 32d86905..a318498b 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -690,24 +690,24 @@ circumstances--and our favorite programming language, AWK. The
circumstances started a couple of years earlier. I was working at a new
job and noticed an unplugged Unix computer sitting in the corner. No
one knew how to use it, and neither did I. However, a couple of days
-later it was running, and I was `root' and the one-and-only user. That
-day, I began the transition from statistician to Unix programmer.
+later, it was running, and I was `root' and the one-and-only user.
+That day, I began the transition from statistician to Unix programmer.
On one of many trips to the library or bookstore in search of books
-on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and
-Weinberger, `The AWK Programming Language', Addison-Wesley, 1988.
-AWK's simple programming paradigm--find a pattern in the input and then
-perform an action--often reduced complex or tedious data manipulations
-to a few lines of code. I was excited to try my hand at programming in
-AWK.
+on Unix, I found the gray AWK book, a.k.a. Alfred V. Aho, Brian W.
+Kernighan, and Peter J. Weinberger's `The AWK Programming Language'
+(Addison-Wesley, 1988). `awk''s simple programming paradigm--find a
+pattern in the input and then perform an action--often reduced complex
+or tedious data manipulations to a few lines of code. I was excited to
+try my hand at programming in AWK.
Alas, the `awk' on my computer was a limited version of the
-language described in the AWK book. I discovered that my computer had
-"old `awk'" and the AWK book described "new `awk'." I learned that
-this was typical; the old version refused to step aside or relinquish
-its name. If a system had a new `awk', it was invariably called
-`nawk', and few systems had it. The best way to get a new `awk' was to
-`ftp' the source code for `gawk' from `prep.ai.mit.edu'. `gawk' was a
+language described in the gray book. I discovered that my computer had
+"old `awk'" and the book described "new `awk'." I learned that this
+was typical; the old version refused to step aside or relinquish its
+name. If a system had a new `awk', it was invariably called `nawk',
+and few systems had it. The best way to get a new `awk' was to `ftp'
+the source code for `gawk' from `prep.ai.mit.edu'. `gawk' was a
version of new `awk' written by David Trueman and Arnold, and available
under the GNU General Public License.
@@ -718,14 +718,15 @@ almost any system; my wife uses `gawk' on her VMS box.)
My Unix system started out unplugged from the wall; it certainly was
not plugged into a network. So, oblivious to the existence of `gawk'
and the Unix community in general, and desiring a new `awk', I wrote my
-own, called `mawk'. Before I was finished I knew about `gawk', but it
+own, called `mawk'. Before I was finished, I knew about `gawk', but it
was too late to stop, so I eventually posted to a `comp.sources'
newsgroup.
A few days after my posting, I got a friendly email from Arnold
introducing himself. He suggested we share design and algorithms and
attached a draft of the POSIX standard so that I could update `mawk' to
-support language extensions added after publication of the AWK book.
+support language extensions added after publication of `The AWK
+Programming Language'.
Frankly, if our roles had been reversed, I would not have been so
open and we probably would have never met. I'm glad we did meet. He
@@ -739,9 +740,9 @@ a definitive reference to the AWK language as defined by the 1987 Bell
Laboratories release and codified in the 1992 POSIX Utilities standard.
On the other hand, the novice AWK programmer can study a wealth of
-practical programs that emphasize the power of AWK's basic idioms: data
-driven control-flow, pattern matching with regular expressions, and
-associative arrays. Those looking for something new can try out
+practical programs that emphasize the power of AWK's basic idioms:
+data-driven control flow, pattern matching with regular expressions,
+and associative arrays. Those looking for something new can try out
`gawk''s interface to network protocols via special `/inet' files.
The programs in this book make clear that an AWK program is
@@ -764,7 +765,7 @@ want to learn how, then read this book.
Michael Brennan
Author of `mawk'
- March, 2001
+ March 2001

File: gawk.info, Node: Foreword4, Next: Preface, Prev: Foreword3, Up: Top
@@ -798,7 +799,7 @@ help you learn the ins and outs.
Michael Brennan
Author of `mawk'
- October, 2014
+ October 2014

File: gawk.info, Node: Preface, Next: Getting Started, Prev: Foreword4, Up: Top
@@ -814,12 +815,12 @@ rest of the file alone. Such jobs are often easy with `awk'. The
makes it easy to handle simple data-reformatting jobs.
The GNU implementation of `awk' is called `gawk'; if you invoke it
-with the proper options or environment variables it is fully compatible
-with the POSIX(1) specification of the `awk' language and with the Unix
-version of `awk' maintained by Brian Kernighan. This means that all
-properly written `awk' programs should work with `gawk'. So most of
-the time, we don't distinguish between `gawk' and other `awk'
-implementations.
+with the proper options or environment variables, it is fully
+compatible with the POSIX(1) specification of the `awk' language and
+with the Unix version of `awk' maintained by Brian Kernighan. This
+means that all properly written `awk' programs should work with `gawk'.
+So most of the time, we don't distinguish between `gawk' and other
+`awk' implementations.
Using `awk' you can:
@@ -892,7 +893,7 @@ File: gawk.info, Node: History, Next: Names, Up: Preface
History of `awk' and `gawk'
===========================
- Recipe For A Programming Language
+ Recipe for a Programming Language
1 part `egrep' 1 part `snobol'
2 parts `ed' 3 parts C
@@ -904,7 +905,7 @@ release.
Document very well and release.
The name `awk' comes from the initials of its designers: Alfred V.
-Aho, Peter J. Weinberger and Brian W. Kernighan. The original version
+Aho, Peter J. Weinberger, and Brian W. Kernighan. The original version
of `awk' was written in 1977 at AT&T Bell Laboratories. In 1985, a new
version made the programming language more powerful, introducing
user-defined functions, multiple input streams, and computed regular
@@ -924,7 +925,7 @@ Circa 1994, I became the primary maintainer. Current development
focuses on bug fixes, performance improvements, standards compliance
and, occasionally, new features.
- In May of 1997, Ju"rgen Kahrs felt the need for network access from
+ In May 1997, Ju"rgen Kahrs felt the need for network access from
`awk', and with a little help from me, set about adding features to do
this for `gawk'. At that time, he also wrote the bulk of `TCP/IP
Internetworking with `gawk'' (a separate document, available as part of
@@ -946,7 +947,7 @@ A Rose by Any Other Name
The `awk' language has evolved over the years. Full details are
provided in *note Language History::. The language described in this
-Info file is often referred to as "new `awk'". By analogy, the
+Info file is often referred to as "new `awk'." By analogy, the
original version of `awk' is referred to as "old `awk'."
Today, on most systems, when you run the `awk' utility, you get some
@@ -1001,110 +1002,120 @@ heading "sidebar."
the more advanced sections show only the part of the `awk' program that
illustrates the concept being described.
- While this Info file is aimed principally at people who have not been
-exposed to `awk', there is a lot of information here that even the `awk'
-expert should find useful. In particular, the description of POSIX
-`awk' and the example programs in *note Library Functions::, and in
-*note Sample Programs::, should be of interest.
+ Although this Info file is aimed principally at people who have not
+been exposed to `awk', there is a lot of information here that even the
+`awk' expert should find useful. In particular, the description of
+POSIX `awk' and the example programs in *note Library Functions::, and
+in *note Sample Programs::, should be of interest.
This Info file is split into several parts, as follows:
- Part I describes the `awk' language and `gawk' program in detail.
-It starts with the basics, and continues through all of the features of
-`awk'. It contains the following chapters:
+ * Part I describes the `awk' language and `gawk' program in detail.
+ It starts with the basics, and continues through all of the
+ features of `awk'. It contains the following chapters:
- *note Getting Started::, provides the essentials you need to know to
-begin using `awk'.
+ - *note Getting Started::, provides the essentials you need to
+ know to begin using `awk'.
- *note Invoking Gawk::, describes how to run `gawk', the meaning of
-its command-line options, and how it finds `awk' program source files.
+ - *note Invoking Gawk::, describes how to run `gawk', the
+ meaning of its command-line options, and how it finds `awk'
+ program source files.
- *note Regexp::, introduces regular expressions in general, and in
-particular the flavors supported by POSIX `awk' and `gawk'.
+ - *note Regexp::, introduces regular expressions in general,
+ and in particular the flavors supported by POSIX `awk' and
+ `gawk'.
- *note Reading Files::, describes how `awk' reads your data. It
-introduces the concepts of records and fields, as well as the `getline'
-command. I/O redirection is first described here. Network I/O is also
-briefly introduced here.
+ - *note Reading Files::, describes how `awk' reads your data.
+ It introduces the concepts of records and fields, as well as
+ the `getline' command. I/O redirection is first described
+ here. Network I/O is also briefly introduced here.
- *note Printing::, describes how `awk' programs can produce output
-with `print' and `printf'.
+ - *note Printing::, describes how `awk' programs can produce
+ output with `print' and `printf'.
- *note Expressions::, describes expressions, which are the basic
-building blocks for getting most things done in a program.
+ - *note Expressions::, describes expressions, which are the
+ basic building blocks for getting most things done in a
+ program.
- *note Patterns and Actions::, describes how to write patterns for
-matching records, actions for doing something when a record is matched,
-and the predefined variables `awk' and `gawk' use.
+ - *note Patterns and Actions::, describes how to write patterns
+ for matching records, actions for doing something when a
+ record is matched, and the predefined variables `awk' and
+ `gawk' use.
- *note Arrays::, covers `awk''s one-and-only data structure:
-associative arrays. Deleting array elements and whole arrays is also
-described, as well as sorting arrays in `gawk'. It also describes how
-`gawk' provides arrays of arrays.
+ - *note Arrays::, covers `awk''s one-and-only data structure:
+ associative arrays. Deleting array elements and whole arrays
+ is also described, as well as sorting arrays in `gawk'. It
+ also describes how `gawk' provides arrays of arrays.
- *note Functions::, describes the built-in functions `awk' and `gawk'
-provide, as well as how to define your own functions. It also
-discusses how `gawk' lets you call functions indirectly.
+ - *note Functions::, describes the built-in functions `awk' and
+ `gawk' provide, as well as how to define your own functions.
+ It also discusses how `gawk' lets you call functions
+ indirectly.
- Part II shows how to use `awk' and `gawk' for problem solving.
-There is lots of code here for you to read and learn from. It contains
-the following chapters:
+ * Part II shows how to use `awk' and `gawk' for problem solving.
+ There is lots of code here for you to read and learn from. It
+ contains the following chapters:
- *note Library Functions::, which provides a number of functions
-meant to be used from main `awk' programs.
+ - *note Library Functions::, which provides a number of
+ functions meant to be used from main `awk' programs.
- *note Sample Programs::, which provides many sample `awk' programs.
+ - *note Sample Programs::, which provides many sample `awk'
+ programs.
- Reading these two chapters allows you to see `awk' solving real
-problems.
+ Reading these two chapters allows you to see `awk' solving real
+ problems.
- Part III focuses on features specific to `gawk'. It contains the
-following chapters:
+ * Part III focuses on features specific to `gawk'. It contains the
+ following chapters:
- *note Advanced Features::, describes a number of advanced features.
-Of particular note are the abilities to control the order of array
-traversal, have two-way communications with another process, perform
-TCP/IP networking, and profile your `awk' programs.
+ - *note Advanced Features::, describes a number of advanced
+ features. Of particular note are the abilities to control
+ the order of array traversal, have two-way communications
+ with another process, perform TCP/IP networking, and profile
+ your `awk' programs.
- *note Internationalization::, describes special features for
-translating program messages into different languages at runtime.
+ - *note Internationalization::, describes special features for
+ translating program messages into different languages at
+ runtime.
- *note Debugger::, describes the `gawk' debugger.
+ - *note Debugger::, describes the `gawk' debugger.
- *note Arbitrary Precision Arithmetic::, describes advanced
-arithmetic facilities.
+ - *note Arbitrary Precision Arithmetic::, describes advanced
+ arithmetic facilities.
- *note Dynamic Extensions::, describes how to add new variables and
-functions to `gawk' by writing extensions in C or C++.
+ - *note Dynamic Extensions::, describes how to add new
+ variables and functions to `gawk' by writing extensions in C
+ or C++.
- Part IV provides the appendices, the Glossary, and two licenses that
-cover the `gawk' source code and this Info file, respectively. It
-contains the following appendices:
+ * Part IV provides the appendices, the Glossary, and two licenses
+ that cover the `gawk' source code and this Info file, respectively.
+ It contains the following appendices:
- *note Language History::, describes how the `awk' language has
-evolved since its first release to present. It also describes how
-`gawk' has acquired features over time.
+ - *note Language History::, describes how the `awk' language
+ has evolved since its first release to present. It also
+ describes how `gawk' has acquired features over time.
- *note Installation::, describes how to get `gawk', how to compile it
-on POSIX-compatible systems, and how to compile and use it on different
-non-POSIX systems. It also describes how to report bugs in `gawk' and
-where to get other freely available `awk' implementations.
+ - *note Installation::, describes how to get `gawk', how to
+ compile it on POSIX-compatible systems, and how to compile
+ and use it on different non-POSIX systems. It also describes
+ how to report bugs in `gawk' and where to get other freely
+ available `awk' implementations.
- *note Notes::, describes how to disable `gawk''s extensions, as well
-as how to contribute new code to `gawk', and some possible future
-directions for `gawk' development.
+ - *note Notes::, describes how to disable `gawk''s extensions,
+ as well as how to contribute new code to `gawk', and some
+ possible future directions for `gawk' development.
- *note Basic Concepts::, provides some very cursory background
-material for those who are completely unfamiliar with computer
-programming.
+ - *note Basic Concepts::, provides some very cursory background
+ material for those who are completely unfamiliar with
+ computer programming.
- The *note Glossary::, defines most, if not all, the significant
-terms used throughout the Info file. If you find terms that you aren't
-familiar with, try looking them up here.
+ The *note Glossary::, defines most, if not all of, the
+ significant terms used throughout the Info file. If you find
+ terms that you aren't familiar with, try looking them up here.
- *note Copying::, and *note GNU Free Documentation License::, present
-the licenses that cover the `gawk' source code and this Info file,
-respectively.
+ - *note Copying::, and *note GNU Free Documentation License::,
+ present the licenses that cover the `gawk' source code and
+ this Info file, respectively.
---------- Footnotes ----------
@@ -1149,7 +1160,7 @@ Versions::, for information on his and other versions.)
Dark Corners
------------
- Dark corners are basically fractal -- no matter how much you
+ Dark corners are basically fractal--no matter how much you
illuminate, there's always a smaller but darker one. -- Brian
Kernighan
@@ -1185,7 +1196,7 @@ always available to the end user. A copy of the GPL is included for
your reference (*note Copying::). The GPL applies to the C language
source code for `gawk'. To find out more about the FSF and the GNU
Project online, see the GNU Project's home page (http://www.gnu.org).
-This Info file may also be read from their web site
+This Info file may also be read from GNU's website
(http://www.gnu.org/software/gawk/manual/).
A shell, an editor (Emacs), highly portable optimizing C, C++, and
@@ -1202,9 +1213,9 @@ from the Internet.
The Info file itself has gone through multiple previous editions.
Paul Rubin wrote the very first draft of `The GAWK Manual'; it was
-around 40 pages in size. Diane Close and Richard Stallman improved it,
-yielding a version that was around 90 pages long and barely described
-the original, "old" version of `awk'.
+around 40 pages long. Diane Close and Richard Stallman improved it,
+yielding a version that was around 90 pages and barely described the
+original, "old" version of `awk'.
I started working with that version in the fall of 1988. As work on
it progressed, the FSF published several preliminary versions (numbered
@@ -1251,12 +1262,12 @@ contributed code: the archive did not grow and the domain went unused
for several years.
Late in 2008, a volunteer took on the task of setting up an
-`awk'-related web site--`http://awk.info'--and did a very nice job.
+`awk'-related website--`http://awk.info'--and did a very nice job.
If you have written an interesting `awk' program, or have written a
`gawk' extension that you would like to share with the rest of the
world, please see `http://awk.info/?contribute' for how to contribute
-it to the web site.
+it to the website.

File: gawk.info, Node: Acknowledgments, Prev: How To Contribute, Up: Preface
@@ -1336,7 +1347,7 @@ of people. *Note Contributors::, for the full list.
Karl Berry who continues to work to keep the Texinfo markup language
sane.
- Robert P.J. Day, Michael Brennan and Brian Kernighan kindly acted as
+ Robert P.J. Day, Michael Brennan, and Brian Kernighan kindly acted as
reviewers for the 2015 edition of this Info file. Their feedback helped
improve the final work.
@@ -1347,8 +1358,8 @@ have done nearly as good a job on either `gawk' or its documentation
without his help.
Brian is in a class by himself as a programmer and technical author.
-I have to thank him (yet again) for his ongoing friendship and the role
-model he has been for me for close to 30 years! Having him as a
+I have to thank him (yet again) for his ongoing friendship and for
+being a role model to me for close to 30 years! Having him as a
reviewer is an exciting privilege. It has also been extremely
humbling...
@@ -1369,22 +1380,22 @@ File: gawk.info, Node: Getting Started, Next: Invoking Gawk, Prev: Preface,
The basic function of `awk' is to search files for lines (or other
units of text) that contain certain patterns. When a line matches one
of the patterns, `awk' performs specified actions on that line. `awk'
-keeps processing input lines in this way until it reaches the end of
-the input files.
+continues to process input lines in this way until it reaches the end
+of the input files.
Programs in `awk' are different from programs in most other
-languages, because `awk' programs are "data-driven"; that is, you
-describe the data you want to work with and then what to do when you
-find it. Most other languages are "procedural"; you have to describe,
-in great detail, every step the program is to take. When working with
+languages, because `awk' programs are "data driven" (i.e., you describe
+the data you want to work with and then what to do when you find it).
+Most other languages are "procedural"; you have to describe, in great
+detail, every step the program should take. When working with
procedural languages, it is usually much harder to clearly describe the
data your program will process. For this reason, `awk' programs are
often refreshingly easy to read and write.
When you run `awk', you specify an `awk' "program" that tells `awk'
-what to do. The program consists of a series of "rules". (It may also
+what to do. The program consists of a series of "rules" (it may also
contain "function definitions", an advanced feature that we will ignore
-for now. *Note User-defined::.) Each rule specifies one pattern to
+for now; *note User-defined::). Each rule specifies one pattern to
search for and one action to perform upon finding the pattern.
Syntactically, a rule consists of a pattern followed by an action.
@@ -1473,7 +1484,8 @@ programs from shell scripts, because it avoids the need for a separate
file for the `awk' program. A self-contained shell script is more
reliable because there are no other files to misplace.
- *note Very Simple::, presents several short, self-contained programs.
+ Later in this chapter, *note Very Simple::, presents several short,
+self-contained programs.

File: gawk.info, Node: Read Terminal, Next: Long, Prev: One-shot, Up: Running gawk
@@ -1515,7 +1527,7 @@ ugly shell quoting tricks.
This next simple `awk' program emulates the `cat' utility; it copies
whatever you type on the keyboard to its standard output (why this
-works is explained shortly).
+works is explained shortly):
$ awk '{ print }'
Now is the time for all good men
@@ -1607,7 +1619,7 @@ the instructions in your program. (This is different from a "compiled"
language such as C, where your program is first compiled into machine
code that is executed directly by your system's processor.) The `awk'
utility is thus termed an "interpreter". Many modern languages are
-interperted.
+interpreted.
The line beginning with `#!' lists the full file name of an
interpreter to run and a single optional initial command-line argument
@@ -1635,8 +1647,8 @@ the name of your script (`advice'). (d.c.) Don't rely on the value of
---------- Footnotes ----------
- (1) The `#!' mechanism works on GNU/Linux systems, BSD-based systems
-and commercial Unix systems.
+ (1) The `#!' mechanism works on GNU/Linux systems, BSD-based
+systems, and commercial Unix systems.

File: gawk.info, Node: Comments, Next: Quoting, Prev: Executable Scripts, Up: Running gawk
@@ -1650,13 +1662,13 @@ Comments can explain what the program does and how it works. Nearly all
programming languages have provisions for comments, as programs are
typically hard to understand without them.
- In the `awk' language, a comment starts with the sharp sign
+ In the `awk' language, a comment starts with the number sign
character (`#') and continues to the end of the line. The `#' does not
have to be the first character on the line. The `awk' language ignores
-the rest of a line following a sharp sign. For example, we could have
+the rest of a line following a number sign. For example, we could have
put the following into `advice':
- # This program prints a nice friendly message. It helps
+ # This program prints a nice, friendly message. It helps
# keep novice users from being afraid of the computer.
BEGIN { print "Don't Panic!" }
@@ -1665,15 +1677,15 @@ programs, but this usually isn't very useful; the purpose of a comment
is to help you or another person understand the program when reading it
at a later time.
- CAUTION: As mentioned in *note One-shot::, you can enclose small
- to medium programs in single quotes, in order to keep your shell
- scripts self-contained. When doing so, _don't_ put an apostrophe
- (i.e., a single quote) into a comment (or anywhere else in your
- program). The shell interprets the quote as the closing quote for
- the entire program. As a result, usually the shell prints a
- message about mismatched quotes, and if `awk' actually runs, it
- will probably print strange messages about syntax errors. For
- example, look at the following:
+ CAUTION: As mentioned in *note One-shot::, you can enclose short
+ to medium-sized programs in single quotes, in order to keep your
+ shell scripts self-contained. When doing so, _don't_ put an
+ apostrophe (i.e., a single quote) into a comment (or anywhere else
+ in your program). The shell interprets the quote as the closing
+ quote for the entire program. As a result, usually the shell
+ prints a message about mismatched quotes, and if `awk' actually
+ runs, it will probably print strange messages about syntax errors.
+ For example, look at the following:
$ awk 'BEGIN { print "hello" } # let's be cute'
>
@@ -1689,8 +1701,8 @@ at a later time.
error--> source line number 1
Putting a backslash before the single quote in `let's' wouldn't
- help, since backslashes are not special inside single quotes. The
- next node describes the shell's quoting rules.
+ help, because backslashes are not special inside single quotes.
+ The next node describes the shell's quoting rules.

File: gawk.info, Node: Quoting, Prev: Comments, Up: Running gawk
@@ -1702,7 +1714,7 @@ File: gawk.info, Node: Quoting, Prev: Comments, Up: Running gawk
* DOS Quoting:: Quoting in Windows Batch Files.
- For short to medium length `awk' programs, it is most convenient to
+ For short to medium-length `awk' programs, it is most convenient to
enter the program on the `awk' command line. This is best done by
enclosing the entire program in single quotes. This is true whether
you are entering the program interactively at the shell prompt, or
@@ -1722,15 +1734,15 @@ string.
The null string is character data that has no value. In other
words, it is empty. It is written in `awk' programs like this: `""'.
In the shell, it can be written using single or double quotes: `""' or
-`'''. While the null string has no characters in it, it does exist.
-Consider this command:
+`'''. Although the null string has no characters in it, it does exist.
+For example, consider this command:
$ echo ""
Here, the `echo' utility receives a single argument, even though that
argument has no characters in it. In the rest of this Info file, we use
the terms "null string" and "empty string" interchangeably. Now, on to
-the quoting rules.
+the quoting rules:
* Quoted items can be concatenated with nonquoted items as well as
with other quoted items. The shell turns everything into one
@@ -1751,7 +1763,7 @@ the quoting rules.
on the quoted text. Different shells may do additional kinds of
processing on double-quoted text.
- Since certain characters within double-quoted text are processed
+ Because certain characters within double-quoted text are processed
by the shell, they must be "escaped" within the text. Of note are
the characters `$', ``', `\', and `"', all of which must be
preceded by a backslash within double-quoted text if they are to
@@ -1790,7 +1802,7 @@ shell quoting tricks, like this:
-| Here is a single quote <'>
This program consists of three concatenated quoted strings. The first
-and the third are single-quoted, the second is double-quoted.
+and the third are single quoted, the second is double quoted.
This can be "simplified" to:
@@ -1865,7 +1877,7 @@ about monthly shipments. In both files, each line is considered to be
one "record".
In `mail-list', each record contains the name of a person, his/her
-phone number, his/her email-address, and a code for their relationship
+phone number, his/her email address, and a code for his/her relationship
with the author of the list. The columns are aligned using spaces. An
`A' in the last column means that the person is an acquaintance. An
`F' in the last column means that the person is a friend. An `R' means
@@ -1961,13 +1973,13 @@ that does nothing (i.e., no lines are printed).
collection of useful, short programs to get you started. Some of these
programs contain constructs that haven't been covered yet. (The
description of the program will give you a good idea of what is going
-on, but please read the rest of the Info file to become an `awk'
-expert!) Most of the examples use a data file named `data'. This is
-just a placeholder; if you use these programs yourself, substitute your
-own file names for `data'. For future reference, note that there is
-often more than one way to do things in `awk'. At some point, you may
-want to look back at these examples and see if you can come up with
-different ways to do the same things shown here:
+on, but you'll need to read the rest of the Info file to become an
+`awk' expert!) Most of the examples use a data file named `data'.
+This is just a placeholder; if you use these programs yourself,
+substitute your own file names for `data'. For future reference, note
+that there is often more than one way to do things in `awk'. At some
+point, you may want to look back at these examples and see if you can
+come up with different ways to do the same things shown here:
* Print every line that is longer than 80 characters:
@@ -1989,7 +2001,7 @@ different ways to do the same things shown here:
expand data | awk '{ if (x < length($0)) x = length($0) }
END { print "maximum line length is " x }'
- This example differs slightly from the previous one: The input is
+ This example differs slightly from the previous one: the input is
processed by the `expand' utility to change TABs into spaces, so
the widths compared are actually the right-margin columns, as
opposed to the number of input characters on each line.
@@ -2183,10 +2195,10 @@ or a string.
the C shell._ It works for `awk' programs in files and for
one-shot programs, _provided_ you are using a POSIX-compliant
shell, such as the Unix Bourne shell or Bash. But the C shell
- behaves differently! There, you must use two backslashes in a
- row, followed by a newline. Note also that when using the C
- shell, _every_ newline in your `awk' program must be escaped with
- a backslash. To illustrate:
+ behaves differently! There you must use two backslashes in a row,
+ followed by a newline. Note also that when using the C shell,
+ _every_ newline in your `awk' program must be escaped with a
+ backslash. To illustrate:
% awk 'BEGIN { \
? print \\
@@ -2291,8 +2303,8 @@ edit-compile-test-debug cycle of software development.
Complex programs have been written in `awk', including a complete
retargetable assembler for eight-bit microprocessors (*note Glossary::,
for more information), and a microcode assembler for a special-purpose
-Prolog computer. While the original `awk''s capabilities were strained
-by tasks of such complexity, modern versions are more capable.
+Prolog computer. The original `awk''s capabilities were strained by
+tasks of such complexity, but modern versions are more capable.
If you find yourself writing `awk' scripts of more than, say, a few
hundred lines, you might consider using a different programming
@@ -2340,10 +2352,10 @@ File: gawk.info, Node: Invoking Gawk, Next: Regexp, Prev: Getting Started, U
This major node covers how to run `awk', both POSIX-standard and
`gawk'-specific command-line options, and what `awk' and `gawk' do with
-non-option arguments. It then proceeds to cover how `gawk' searches
-for source files, reading standard input along with other files,
-`gawk''s environment variables, `gawk''s exit status, using include
-files, and obsolete and undocumented options and/or features.
+nonoption arguments. It then proceeds to cover how `gawk' searches for
+source files, reading standard input along with other files, `gawk''s
+environment variables, `gawk''s exit status, using include files, and
+obsolete and undocumented options and/or features.
Many of the options and features described here are discussed in
more detail later in the Info file; feel free to skip over things in
@@ -2377,8 +2389,8 @@ enclosed in [...] in these templates are optional:
`awk' [OPTIONS] `-f' PROGFILE [`--'] FILE ...
`awk' [OPTIONS] [`--'] `'PROGRAM'' FILE ...
- Besides traditional one-letter POSIX-style options, `gawk' also
-supports GNU long options.
+ In addition to traditional one-letter POSIX-style options, `gawk'
+also supports GNU long options.
It is possible to invoke `awk' with an empty program:
@@ -2414,7 +2426,7 @@ The following list describes options mandated by the POSIX standard:
`-f SOURCE-FILE'
`--file SOURCE-FILE'
Read `awk' program source from SOURCE-FILE instead of in the first
- non-option argument. This option may be given multiple times; the
+ nonoption argument. This option may be given multiple times; the
`awk' program consists of the concatenation of the contents of
each specified SOURCE-FILE.
@@ -2593,7 +2605,7 @@ The following list describes options mandated by the POSIX standard:
`-M'
`--bignum'
- Force arbitrary precision arithmetic on numbers. This option has
+ Force arbitrary-precision arithmetic on numbers. This option has
no effect if `gawk' is not compiled to use the GNU MPFR and MP
libraries (*note Arbitrary Precision Arithmetic::).
@@ -2603,9 +2615,8 @@ The following list describes options mandated by the POSIX standard:
input data (*note Nondecimal Data::).
CAUTION: This option can severely break old programs. Use
- with care.
-
- This option may disappear in a future version of `gawk'.
+ with care. Also note that this option may disappear in a
+ future version of `gawk'.
`-N'
`--use-lc-numeric'
@@ -2628,7 +2639,8 @@ The following list describes options mandated by the POSIX standard:
`-O'
`--optimize'
Enable some optimizations on the internal representation of the
- program. At the moment this includes just simple constant folding.
+ program. At the moment, this includes just simple constant
+ folding.
`-p'[FILE]
`--profile'[`='FILE]
@@ -2671,8 +2683,8 @@ The following list describes options mandated by the POSIX standard:
`--re-interval'
Allow interval expressions (*note Regexp Operators::) in regexps.
This is now `gawk''s default behavior. Nevertheless, this option
- remains both for backward compatibility, and for use in
- combination with `--traditional'.
+ remains (both for backward compatibility and for use in
+ combination with `--traditional').
`-S'
`--sandbox'
@@ -2708,7 +2720,7 @@ it is, `awk' reads its program source from all of the named files, as
if they had been concatenated together into one big file. This is
useful for creating libraries of `awk' functions. These functions can
be written once and then retrieved from a standard place, instead of
-having to be included into each individual program. The `-i' option is
+having to be included in each individual program. The `-i' option is
similar in this regard. (As mentioned in *note Definition Syntax::,
function names must be unique.)
@@ -2716,7 +2728,7 @@ function names must be unique.)
the program is entered at the keyboard, by specifying `-f /dev/tty'.
After typing your program, type `Ctrl-d' (the end-of-file character) to
terminate it. (You may also use `-f -' to read program source from the
-standard input but then you will not be able to also use the standard
+standard input, but then you will not be able to also use the standard
input as a source of data.)
Because it is clumsy using the standard `awk' mechanisms to mix
@@ -2727,7 +2739,7 @@ source code (*note AWKPATH Variable::). As with `-f', the `-e' and `-i'
options may also be used multiple times on the command line.
If no `-f' or `-e' option is specified, then `gawk' uses the first
-non-option command-line argument as the text of the program source code.
+nonoption command-line argument as the text of the program source code.
If the environment variable `POSIXLY_CORRECT' exists, then `gawk'
behaves in strict POSIX mode, exactly as if you had supplied `--posix'.
@@ -2776,8 +2788,8 @@ not a file name:
program in the `ARGV' array (*note Built-in Variables::). Command-line
options and the program text (if present) are omitted from `ARGV'. All
other arguments, including variable assignments, are included. As
-each element of `ARGV' is processed, `gawk' sets the variable `ARGIND'
-to the index in `ARGV' of the current element.
+each element of `ARGV' is processed, `gawk' sets `ARGIND' to the index
+in `ARGV' of the current element.
Changing `ARGC' and `ARGV' in your `awk' program lets you control
how `awk' processes the input files; this is described in more detail
@@ -2921,11 +2933,11 @@ this means that you will rarely need to change the value of `AWKPATH'.
`ENVIRON["AWKPATH"]'. This provides access to the actual search path
value from within an `awk' program.
- While you can change `ENVIRON["AWKPATH"]' within your `awk' program,
-this has no effect on the running program's behavior. This makes
-sense: the `AWKPATH' environment variable is used to find the program
-source files. Once your program is running, all the files have been
-found, and `gawk' no longer needs to use `AWKPATH'.
+ Although you can change `ENVIRON["AWKPATH"]' within your `awk'
+program, this has no effect on the running program's behavior. This
+makes sense: the `AWKPATH' environment variable is used to find the
+program source files. Once your program is running, all the files have
+been found, and `gawk' no longer needs to use `AWKPATH'.
---------- Footnotes ----------
@@ -2968,7 +2980,7 @@ File: gawk.info, Node: Other Environment Variables, Prev: AWKLIBPATH Variable,
A number of other environment variables affect `gawk''s behavior, but
they are more specialized. Those in the following list are meant to be
-used by regular users.
+used by regular users:
`GAWK_MSEC_SLEEP'
Specifies the interval between connection retries, in
@@ -2985,7 +2997,7 @@ used by regular users.
Networking::.
`POSIXLY_CORRECT'
- Causes `gawk' to switch to POSIX compatibility mode, disabling all
+ Causes `gawk' to switch to POSIX-compatibility mode, disabling all
traditional and GNU extensions. *Note Options::.
The environment variables in the following list are meant for use by
@@ -3016,8 +3028,8 @@ change. The variables are:
If this variable exists, `gawk' includes the file name and line
number within the `gawk' source code from which warning and/or
fatal messages are generated. Its purpose is to help isolate the
- source of a message, since there are multiple places which produce
- the same warning or error message.
+ source of a message, as there are multiple places which produce the
+ same warning or error message.
`GAWK_NO_DFA'
If this variable exists, `gawk' does not use the DFA regexp matcher
@@ -3028,8 +3040,8 @@ change. The variables are:
don't coordinate with each other.)
`GAWK_NO_PP_RUN'
- If this variable exists, then when invoked with the
- `--pretty-print' option, `gawk' skips running the program.
+ When `gawk' is invoked with the `--pretty-print' option, it will
+ not run the program if this environment variable exists.
CAUTION: This variable will not survive into the next major
release.
@@ -3065,13 +3077,13 @@ with the value of the C constant `EXIT_SUCCESS'. This is usually zero.
If an error occurs, `gawk' exits with the value of the C constant
`EXIT_FAILURE'. This is usually one.
- If `gawk' exits because of a fatal error, the exit status is 2. On
-non-POSIX systems, this value may be mapped to `EXIT_FAILURE'.
+ If `gawk' exits because of a fatal error, the exit status is two.
+On non-POSIX systems, this value may be mapped to `EXIT_FAILURE'.

File: gawk.info, Node: Include Files, Next: Loading Shared Libraries, Prev: Exit Status, Up: Invoking Gawk
-2.7 Including Other Files Into Your Program
+2.7 Including Other Files into Your Program
===========================================
This minor node describes a feature that is specific to `gawk'.
@@ -3106,9 +3118,9 @@ and here is `test2':
-| This is script test1.
-| This is script test2.
- `gawk' runs the `test2' script which includes `test1' using the
-`@include' keyword. So, to include external `awk' source files you just
-use `@include' followed by the name of the file to be included,
+ `gawk' runs the `test2' script, which includes `test1' using the
+`@include' keyword. So, to include external `awk' source files, you
+just use `@include' followed by the name of the file to be included,
enclosed in double quotes.
NOTE: Keep in mind that this is a language construct and the file
@@ -3134,22 +3146,22 @@ Running `gawk' with the `test3' script produces the following results:
@include "../io_funcs"
-or:
+and:
@include "/usr/awklib/network"
-are valid. The `AWKPATH' environment variable can be of great value
-when using `@include'. The same rules for the use of the `AWKPATH'
-variable in command-line file searches (*note AWKPATH Variable::) apply
-to `@include' also.
+are both valid. The `AWKPATH' environment variable can be of great
+value when using `@include'. The same rules for the use of the
+`AWKPATH' variable in command-line file searches (*note AWKPATH
+Variable::) apply to `@include' also.
This is very helpful in constructing `gawk' function libraries. If
-you have a large script with useful, general purpose `awk' functions,
+you have a large script with useful, general-purpose `awk' functions,
you can break it down into library files and put those files in a
special directory. You can then include those "libraries," using
either the full pathnames of the files, or by setting the `AWKPATH'
environment variable accordingly and then using `@include' with just
-the file part of the full pathname. Of course you can have more than
+the file part of the full pathname. Of course, you can have more than
one directory to keep library files; the more complex the working
environment is, the more directories you may need to organize the files
to be included.
@@ -3168,7 +3180,7 @@ and this also applies to files named with `@include'.

File: gawk.info, Node: Loading Shared Libraries, Next: Obsolete, Prev: Include Files, Up: Invoking Gawk
-2.8 Loading Dynamic Extensions Into Your Program
+2.8 Loading Dynamic Extensions into Your Program
================================================
This minor node describes a feature that is specific to `gawk'.
@@ -3183,7 +3195,7 @@ The `AWKLIBPATH' variable is used to search for the extension. Using
If the extension is not initially found in `AWKLIBPATH', another
search is conducted after appending the platform's default shared
library suffix to the file name. For example, on GNU/Linux systems,
-the suffix `.so' is used.
+the suffix `.so' is used:
$ gawk '@load "ordchr"; BEGIN {print chr(65)}'
-| A
@@ -3240,12 +3252,12 @@ File: gawk.info, Node: Invoking Summary, Prev: Undocumented, Up: Invoking Gaw
`-F' and `-v'. `gawk' supplies these and many others, as well as
corresponding GNU-style long options.
- * Non-option command-line arguments are usually treated as file
- names, unless they have the form `VAR=VALUE', in which case they
- are taken as variable assignments to be performed at that point in
+ * Nonoption command-line arguments are usually treated as file names,
+ unless they have the form `VAR=VALUE', in which case they are
+ taken as variable assignments to be performed at that point in
processing the input.
- * All non-option command-line arguments, excluding the program text,
+ * All nonoption command-line arguments, excluding the program text,
are placed in the `ARGV' array. Adjusting `ARGC' and `ARGV'
affects how `awk' processes input.
@@ -3284,7 +3296,7 @@ strings. Because regular expressions are such a fundamental part of
that matches every input record whose text belongs to that set. The
simplest regular expression is a sequence of letters, numbers, or both.
Such a regexp matches any string that contains that sequence. Thus,
-the regexp `foo' matches any string containing `foo'. Therefore, the
+the regexp `foo' matches any string containing `foo'. Thus, the
pattern `/foo/' matches any input record containing the three adjacent
characters `foo' _anywhere_ in the record. Other kinds of regexps let
you specify more complicated classes of strings.
@@ -3325,13 +3337,13 @@ expressions allow you to specify the string to match against; it need
not be the entire current input record. The two operators `~' and `!~'
perform regular expression comparisons. Expressions using these
operators can be used as patterns, or in `if', `while', `for', and `do'
-statements. (*Note Statements::.) For example:
+statements. (*Note Statements::.) For example, the following is true
+if the expression EXP (taken as a string) matches REGEXP:
EXP ~ /REGEXP/
-is true if the expression EXP (taken as a string) matches REGEXP. The
-following example matches, or selects, all input records with the
-uppercase letter `J' somewhere in the first field:
+This example matches, or selects, all input records with the uppercase
+letter `J' somewhere in the first field:
$ awk '$1 ~ /J/' inventory-shipped
-| Jan 13 25 15 115
@@ -3385,9 +3397,9 @@ string or regexp. Thus, the string whose contents are the two
characters `"' and `\' must be written `"\"\\"'.
Other escape sequences represent unprintable characters such as TAB
-or newline. While there is nothing to stop you from entering most
+or newline. There is nothing to stop you from entering most
unprintable characters directly in a string constant or regexp constant,
-they may look ugly.
+but they may look ugly.
The following list presents all the escape sequences used in `awk'
and what they represent. Unless noted otherwise, all these escape
@@ -3431,7 +3443,7 @@ sequences apply to both string constants and regexp constants:
more than two hexadecimal digits produces undefined results. (The
`\x' escape sequence is not allowed in POSIX `awk'.)
- CAUTION: The next major relase of `gawk' will change, such
+ CAUTION: The next major release of `gawk' will change, such
that a maximum of two hexadecimal digits following the `\x'
will be used.
@@ -3439,7 +3451,7 @@ sequences apply to both string constants and regexp constants:
A literal slash (necessary for regexp constants only). This
sequence is used when you want to write a regexp constant that
contains a slash (such as `/.*:\/home\/[[:alnum:]]+:.*/'; the
- `[[:alnum:]]' notation is discussed shortly, in *note Bracket
+ `[[:alnum:]]' notation is discussed in *note Bracket
Expressions::). Because the regexp is delimited by slashes, you
need to escape any slash that is part of the pattern, in order to
tell `awk' to keep processing the rest of the regexp.
@@ -3465,19 +3477,6 @@ characters `a+b'.
For complete portability, do not use a backslash before any
character not shown in the previous list and that is not an operator.
- To summarize:
-
- * The escape sequences in the list above are always processed first,
- for both string constants and regexp constants. This happens very
- early, as soon as `awk' reads your program.
-
- * `gawk' processes both regexp constants and dynamic regexps (*note
- Computed Regexps::), for the special operators listed in *note GNU
- Regexp Operators::.
-
- * A backslash before any other character means to treat that
- character literally.
-
Backslash Before Regular Characters
If you place a backslash in a string constant before something that
@@ -3496,6 +3495,19 @@ Leave the backslash alone
Some other `awk' implementations do this. In such
implementations, typing `"a\qc"' is the same as typing `"a\\qc"'.
+ To summarize:
+
+ * The escape sequences in the preceding list are always processed
+ first, for both string constants and regexp constants. This
+ happens very early, as soon as `awk' reads your program.
+
+ * `gawk' processes both regexp constants and dynamic regexps (*note
+ Computed Regexps::), for the special operators listed in *note GNU
+ Regexp Operators::.
+
+ * A backslash before any other character means to treat that
+ character literally.
+
Escape Sequences for Metacharacters
Suppose you use an octal or hexadecimal escape to represent a regexp
@@ -3528,15 +3540,15 @@ in processing regexps.
sequences and that are not listed in the following stand for themselves:
`\'
- This is used to suppress the special meaning of a character when
- matching. For example, `\$' matches the character `$'.
+ This suppresses the special meaning of a character when matching.
+ For example, `\$' matches the character `$'.
`^'
- This matches the beginning of a string. For example, `^@chapter'
- matches `@chapter' at the beginning of a string and can be used to
- identify chapter beginnings in Texinfo source files. The `^' is
- known as an "anchor", because it anchors the pattern to match only
- at the beginning of the string.
+ This matches the beginning of a string. `^@chapter' matches
+ `@chapter' at the beginning of a string, for example, and can be
+ used to identify chapter beginnings in Texinfo source files. The
+ `^' is known as an "anchor", because it anchors the pattern to
+ match only at the beginning of the string.
It is important to realize that `^' does not match the beginning of
a line (the point right after a `\n' newline character) embedded
@@ -3609,7 +3621,7 @@ sequences and that are not listed in the following stand for themselves:
First, the `*' applies only to the single preceding regular
expression component (e.g., in `ph*', it applies just to the `h').
To cause `*' to apply to a larger sub-expression, use parentheses:
- `(ph)*' matches `ph', `phph', `phphph' and so on.
+ `(ph)*' matches `ph', `phph', `phphph', and so on.
Second, `*' finds as many repetitions as possible. If the text to
be matched is `phhhhhhhhhhhhhhooey', `ph*' matches all of the `h's.
@@ -3693,7 +3705,7 @@ File: gawk.info, Node: Bracket Expressions, Next: Leftmost Longest, Prev: Reg
3.4 Using Bracket Expressions
=============================
-As mentioned earlier, a bracket expression matches any character amongst
+As mentioned earlier, a bracket expression matches any character among
those listed between the opening and closing square brackets.
Within a bracket expression, a "range expression" consists of two
@@ -3733,24 +3745,24 @@ character classes defined by the POSIX standard.
Class Meaning
--------------------------------------------------------------------------
-`[:alnum:]' Alphanumeric characters.
-`[:alpha:]' Alphabetic characters.
-`[:blank:]' Space and TAB characters.
-`[:cntrl:]' Control characters.
-`[:digit:]' Numeric characters.
-`[:graph:]' Characters that are both printable and visible. (A space is
- printable but not visible, whereas an `a' is both.)
-`[:lower:]' Lowercase alphabetic characters.
+`[:alnum:]' Alphanumeric characters
+`[:alpha:]' Alphabetic characters
+`[:blank:]' Space and TAB characters
+`[:cntrl:]' Control characters
+`[:digit:]' Numeric characters
+`[:graph:]' Characters that are both printable and visible (a space is
+ printable but not visible, whereas an `a' is both)
+`[:lower:]' Lowercase alphabetic characters
`[:print:]' Printable characters (characters that are not control
- characters).
+ characters)
`[:punct:]' Punctuation characters (characters that are not letters,
- digits, control characters, or space characters).
+ digits control characters, or space characters)
`[:space:]' Space characters (such as space, TAB, and formfeed, to name
- a few).
-`[:upper:]' Uppercase alphabetic characters.
-`[:xdigit:]'Characters that are hexadecimal digits.
+ a few)
+`[:upper:]' Uppercase alphabetic characters
+`[:xdigit:]'Characters that are hexadecimal digits
-Table 3.1: POSIX Character Classes
+Table 3.1: POSIX character classes
For example, before the POSIX standard, you had to write
`/[A-Za-z0-9]/' to match alphanumeric characters. If your character
@@ -3758,7 +3770,7 @@ set had other alphabetic characters in it, this would not match them.
With the POSIX character classes, you can write `/[[:alnum:]]/' to
match the alphabetic and numeric characters in your character set.
- Some utilities that match regular expressions provide a non-standard
+ Some utilities that match regular expressions provide a nonstandard
`[:ascii:]' character class; `awk' does not. However, you can simulate
such a construct using `[\x00-\x7F]'. This matches all values
numerically between zero and 127, which is the defined range of the
@@ -3951,9 +3963,9 @@ letters, digits, or underscores (`_'):
not match `dirty rat'. `\B' is essentially the opposite of `\y'.
There are two other operators that work on buffers. In Emacs, a
-"buffer" is, naturally, an Emacs buffer. For other programs, `gawk''s
-regexp library routines consider the entire string to match as the
-buffer. The operators are:
+"buffer" is, naturally, an Emacs buffer. Other GNU programs, including
+`gawk', consider the entire string to match as the buffer. The
+operators are:
`\`'
Matches the empty string at the beginning of a buffer (string).
@@ -3981,15 +3993,14 @@ No options
Operators::.
`--posix'
- Only POSIX regexps are supported; the GNU operators are not special
- (e.g., `\w' matches a literal `w'). Interval expressions are
- allowed.
+ Match only POSIX regexps; the GNU operators are not special (e.g.,
+ `\w' matches a literal `w'). Interval expressions are allowed.
`--traditional'
- Traditional Unix `awk' regexps are matched. The GNU operators are
- not special, and interval expressions are not available. The
- POSIX character classes (`[[:alnum:]]', etc.) are supported, as
- BWK `awk' supports them. Characters described by octal and
+ Match traditional Unix `awk' regexps. The GNU operators are not
+ special, and interval expressions are not available. Because BWK
+ `awk' supports them, the POSIX character classes (`[[:alnum:]]',
+ etc.) are available. Characters described by octal and
hexadecimal escape sequences are treated literally, even if they
represent regexp metacharacters.
@@ -4029,10 +4040,9 @@ works in any POSIX-compliant `awk'.
`IGNORECASE' is not zero, _all_ regexp and string operations ignore
case.
- Changing the value of `IGNORECASE' dynamically controls the
-case-sensitivity of the program as it runs. Case is significant by
-default because `IGNORECASE' (like most variables) is initialized to
-zero:
+ Changing the value of `IGNORECASE' dynamically controls the case
+sensitivity of the program as it runs. Case is significant by default
+because `IGNORECASE' (like most variables) is initialized to zero:
x = "aB"
if (x ~ /ab/) ... # this test will fail
@@ -4040,17 +4050,17 @@ zero:
IGNORECASE = 1
if (x ~ /ab/) ... # now it will succeed
- In general, you cannot use `IGNORECASE' to make certain rules
-case-insensitive and other rules case-sensitive, because there is no
+ In general, you cannot use `IGNORECASE' to make certain rules case
+insensitive and other rules case sensitive, as there is no
straightforward way to set `IGNORECASE' just for the pattern of a
particular rule.(1) To do this, use either bracket expressions or
`tolower()'. However, one thing you can do with `IGNORECASE' only is
-dynamically turn case-sensitivity on or off for all the rules at once.
+dynamically turn case sensitivity on or off for all the rules at once.
`IGNORECASE' can be set on the command line or in a `BEGIN' rule
(*note Other Arguments::; also *note Using BEGIN/END::). Setting
-`IGNORECASE' from the command line is a way to make a program
-case-insensitive without having to edit it.
+`IGNORECASE' from the command line is a way to make a program case
+insensitive without having to edit it.
In multibyte locales, the equivalences between upper- and lowercase
characters are tested based on the wide-character values of the
@@ -4087,11 +4097,11 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp
conditional expressions, or as part of matching expressions using
the `~' and `!~' operators.
- * Escape sequences let you represent non-printable characters and
+ * Escape sequences let you represent nonprintable characters and
also let you represent regexp metacharacters as literal characters
to be matched.
- * Regexp operators provide grouping, alternation and repetition.
+ * Regexp operators provide grouping, alternation, and repetition.
* Bracket expressions give you a shorthand for specifying sets of
characters that can match at a particular point in a regexp.
@@ -4103,8 +4113,8 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp
extent of the match, such as for text substitution and when the
record separator is a regexp.
- * Matching expressions may use dynamic regexps, that is, string
- values treated as regular expressions.
+ * Matching expressions may use dynamic regexps (i.e., string values
+ treated as regular expressions).
* `gawk''s `IGNORECASE' variable lets you control the case
sensitivity of regexp matching. In other `awk' versions, use
@@ -4163,7 +4173,7 @@ File: gawk.info, Node: Records, Next: Fields, Up: Reading Files
`awk' divides the input for your program into records and fields. It
keeps track of the number of records that have been read so far from
the current input file. This value is stored in a predefined variable
-called `FNR' which is reset to zero every time a new file is started.
+called `FNR', which is reset to zero every time a new file is started.
Another predefined variable, `NR', records the total number of input
records read so far from all data files. It starts at zero, but is
never automatically reset to zero.
@@ -4176,7 +4186,7 @@ never automatically reset to zero.

File: gawk.info, Node: awk split records, Next: gawk split records, Up: Records
-4.1.1 Record Splitting With Standard `awk'
+4.1.1 Record Splitting with Standard `awk'
------------------------------------------
Records are separated by a character called the "record separator". By
@@ -4188,7 +4198,7 @@ predefined variable `RS'.
Like any other variable, the value of `RS' can be changed in the
`awk' program with the assignment operator, `=' (*note Assignment
Ops::). The new record-separator character should be enclosed in
-quotation marks, which indicate a string constant. Often the right
+quotation marks, which indicate a string constant. Often, the right
time to do this is at the beginning of execution, before any input is
processed, so that the very first record is read with the proper
separator. To do this, use the special `BEGIN' pattern (*note
@@ -4198,7 +4208,7 @@ BEGIN/END::). For example:
{ print $0 }' mail-list
changes the value of `RS' to `u', before reading any input. This is a
-string whose first character is the letter "u;" as a result, records
+string whose first character is the letter "u"; as a result, records
are separated by the letter "u." Then the input file is read, and the
second rule in the `awk' program (the action with no pattern) prints
each record. Because each `print' statement adds a newline at the end
@@ -4304,7 +4314,7 @@ variable `RT' to the text in the input that matched `RS'.

File: gawk.info, Node: gawk split records, Prev: awk split records, Up: Records
-4.1.2 Record Splitting With `gawk'
+4.1.2 Record Splitting with `gawk'
----------------------------------
When using `gawk', the value of `RS' is not limited to a one-character
@@ -4344,7 +4354,7 @@ leading and trailing whitespace. The final value of `RT' is a newline.
`RT'.
If you set `RS' to a regular expression that allows optional
-trailing text, such as `RS = "abc(XYZ)?"' it is possible, due to
+trailing text, such as `RS = "abc(XYZ)?"', it is possible, due to
implementation constraints, that `gawk' may match the leading part of
the regular expression, but not the trailing part, particularly if the
input text that could match the trailing part is fairly long. `gawk'
@@ -4412,8 +4422,8 @@ When `awk' reads an input record, the record is automatically "parsed"
or separated by the `awk' utility into chunks called "fields". By
default, fields are separated by "whitespace", like words in a line.
Whitespace in `awk' means any string of one or more spaces, TABs, or
-newlines;(1) other characters, such as formfeed, vertical tab, etc.,
-that are considered whitespace by other languages, are _not_ considered
+newlines;(1) other characters that are considered whitespace by other
+languages (such as formfeed, vertical tab, etc.) are _not_ considered
whitespace by `awk'.
The purpose of fields is to make it more convenient for you to refer
@@ -4424,9 +4434,9 @@ simple `awk' programs so powerful.
You use a dollar-sign (`$') to refer to a field in an `awk' program,
followed by the number of the field you want. Thus, `$1' refers to the
first field, `$2' to the second, and so on. (Unlike the Unix shells,
-the field numbers are not limited to single digits. `$127' is the one
-hundred twenty-seventh field in the record.) For example, suppose the
-following is a line of input:
+the field numbers are not limited to single digits. `$127' is the
+127th field in the record.) For example, suppose the following is a
+line of input:
This seems like a pretty nice example.
@@ -4485,11 +4495,11 @@ example:
awk '{ print $NR }'
Recall that `NR' is the number of records read so far: one in the first
-record, two in the second, etc. So this example prints the first field
-of the first record, the second field of the second record, and so on.
-For the twentieth record, field number 20 is printed; most likely, the
-record has fewer than 20 fields, so this prints a blank line. Here is
-another example of using expressions as field numbers:
+record, two in the second, and so on. So this example prints the first
+field of the first record, the second field of the second record, and so
+on. For the twentieth record, field number 20 is printed; most likely,
+the record has fewer than 20 fields, so this prints a blank line. Here
+is another example of using expressions as field numbers:
awk '{ print $(2*2) }' mail-list
@@ -4519,7 +4529,7 @@ field number.
---------- Footnotes ----------
(1) A "binary operator", such as `*' for multiplication, is one that
-takes two operands. The distinction is required, since `awk' also has
+takes two operands. The distinction is required, because `awk' also has
unary (one-operand) and ternary (three-operand) operators.

@@ -4565,8 +4575,8 @@ subtracted from the second field of each line:
-| Mar 5 24 34 228
...
- It is also possible to also assign contents to fields that are out
-of range. For example:
+ It is also possible to assign contents to fields that are out of
+range. For example:
$ awk '{ $6 = ($5 + $4 + $3 + $2)
> print $6 }' inventory-shipped
@@ -4667,7 +4677,7 @@ separate the fields.
record simply by setting `FS' and `OFS', and then expecting a plain
`print' or `print $0' to print the modified record.
- But this does not work, since nothing was done to change the record
+ But this does not work, because nothing was done to change the record
itself. Instead, you must force the record to be rebuilt, typically
with a statement such as `$1 = $1', as described earlier.
@@ -4707,7 +4717,7 @@ is used by the POSIX-compliant shells (such as the Unix Bourne shell,
`sh', or Bash).
The value of `FS' can be changed in the `awk' program with the
-assignment operator, `=' (*note Assignment Ops::). Often the right
+assignment operator, `=' (*note Assignment Ops::). Often, the right
time to do this is at the beginning of execution before any input has
been processed, so that the very first record is read with the proper
separator. To do this, use the special `BEGIN' pattern (*note
@@ -4819,7 +4829,7 @@ was ignored when finding `$1', it is not part of the new `$0'.
Finally, the last `print' statement prints the new `$0'.
There is an additional subtlety to be aware of when using regular
-expressions for field splitting. It is not well-specified in the POSIX
+expressions for field splitting. It is not well specified in the POSIX
standard, or anywhere else, what `^' means when splitting fields. Does
the `^' match only at the beginning of the entire record? Or is each
field separator a new string? It turns out that different `awk'
@@ -4944,21 +4954,50 @@ the entries for users whose full name is not indicated:

File: gawk.info, Node: Full Line Fields, Next: Field Splitting Summary, Prev: Command Line Field Separator, Up: Field Separators
-4.5.5 Making The Full Line Be A Single Field
+4.5.5 Making the Full Line Be a Single Field
--------------------------------------------
Occasionally, it's useful to treat the whole input line as a single
field. This can be done easily and portably simply by setting `FS' to
-`"\n"' (a newline).(1)
+`"\n"' (a newline):(1)
awk -F'\n' 'PROGRAM' FILES ...
When you do this, `$1' is the same as `$0'.
+ Changing `FS' Does Not Affect the Fields
+
+ According to the POSIX standard, `awk' is supposed to behave as if
+each record is split into fields at the time it is read. In
+particular, this means that if you change the value of `FS' after a
+record is read, the value of the fields (i.e., how they were split)
+should reflect the old value of `FS', not the new one.
+
+ However, many older implementations of `awk' do not work this way.
+Instead, they defer splitting the fields until a field is actually
+referenced. The fields are split using the _current_ value of `FS'!
+(d.c.) This behavior can be difficult to diagnose. The following
+example illustrates the difference between the two methods. (The
+`sed'(2) command prints just the first line of `/etc/passwd'.)
+
+ sed 1q /etc/passwd | awk '{ FS = ":" ; print $1 }'
+
+which usually prints:
+
+ root
+
+on an incorrect implementation of `awk', while `gawk' prints the full
+first line of the file, something like:
+
+ root:nSijPlPhZZwgE:0:0:Root:/:
+
---------- Footnotes ----------
(1) Thanks to Andrew Schorr for this tip.
+ (2) The `sed' utility is a "stream editor." Its behavior is also
+defined by the POSIX standard.
+

File: gawk.info, Node: Field Splitting Summary, Prev: Full Line Fields, Up: Field Separators
@@ -4997,32 +5036,6 @@ value of `FS' (`==' means "is equal to"):
(This is a common extension; it is not specified by the POSIX
standard.)
- Changing `FS' Does Not Affect the Fields
-
- According to the POSIX standard, `awk' is supposed to behave as if
-each record is split into fields at the time it is read. In
-particular, this means that if you change the value of `FS' after a
-record is read, the value of the fields (i.e., how they were split)
-should reflect the old value of `FS', not the new one.
-
- However, many older implementations of `awk' do not work this way.
-Instead, they defer splitting the fields until a field is actually
-referenced. The fields are split using the _current_ value of `FS'!
-(d.c.) This behavior can be difficult to diagnose. The following
-example illustrates the difference between the two methods. (The
-`sed'(1) command prints just the first line of `/etc/passwd'.)
-
- sed 1q /etc/passwd | awk '{ FS = ":" ; print $1 }'
-
-which usually prints:
-
- root
-
-on an incorrect implementation of `awk', while `gawk' prints the full
-first line of the file, something like:
-
- root:nSijPlPhZZwgE:0:0:Root:/:
-
`FS' and `IGNORECASE'
The `IGNORECASE' variable (*note User-modified::) affects field
@@ -5037,23 +5050,17 @@ Thus, in the following code:
The output is `aCa'. If you really want to split fields on an
alphabetic character while ignoring case, use a regexp that will do it
-for you. E.g., `FS = "[c]"'. In this case, `IGNORECASE' will take
+for you (e.g., `FS = "[c]"'). In this case, `IGNORECASE' will take
effect.
- ---------- Footnotes ----------
-
- (1) The `sed' utility is a "stream editor." Its behavior is also
-defined by the POSIX standard.
-

File: gawk.info, Node: Constant Size, Next: Splitting By Content, Prev: Field Separators, Up: Reading Files
4.6 Reading Fixed-Width Data
============================
- NOTE: This minor node discusses an advanced feature of `gawk'. If
- you are a novice `awk' user, you might want to skip it on the
- first reading.
+This minor node discusses an advanced feature of `gawk'. If you are a
+novice `awk' user, you might want to skip it on the first reading.
`gawk' provides a facility for dealing with fixed-width fields with
no distinctive field separator. For example, data of this nature
@@ -5089,13 +5096,10 @@ use of `FIELDWIDTHS':
brent ttyp0 26Jun91 4:46 26:46 4:41 bash
dave ttyq4 26Jun9115days 46 46 wnewmail
- The following program takes the above input, converts the idle time
-to number of seconds, and prints out the first two fields and the
+ The following program takes this input, converts the idle time to
+number of seconds, and prints out the first two fields and the
calculated idle time:
- NOTE: This program uses a number of `awk' features that haven't
- been introduced yet.
-
BEGIN { FIELDWIDTHS = "9 6 10 6 7 7 35" }
NR > 2 {
idle = $4
@@ -5112,6 +5116,9 @@ calculated idle time:
print $1, $2, idle
}
+ NOTE: The preceding program uses a number of `awk' features that
+ haven't been introduced yet.
+
Running the program on the data produces the following results:
hzuo ttyV0 0
@@ -5155,12 +5162,11 @@ of such a function).

File: gawk.info, Node: Splitting By Content, Next: Multiple Line, Prev: Constant Size, Up: Reading Files
-4.7 Defining Fields By Content
+4.7 Defining Fields by Content
==============================
- NOTE: This minor node discusses an advanced feature of `gawk'. If
- you are a novice `awk' user, you might want to skip it on the
- first reading.
+This minor node discusses an advanced feature of `gawk'. If you are a
+novice `awk' user, you might want to skip it on the first reading.
Normally, when using `FS', `gawk' defines the fields as the parts of
the record that occur in between each field separator. In other words,
@@ -5168,13 +5174,13 @@ the record that occur in between each field separator. In other words,
However, there are times when you really want to define the fields by
what they are, and not by what they are not.
- The most notorious such case is so-called "comma separated value"
+ The most notorious such case is so-called "comma-separated values"
(CSV) data. Many spreadsheet programs, for example, can export their
data into text files, where each record is terminated with a newline,
and fields are separated by commas. If only commas separated the data,
there wouldn't be an issue. The problem comes when one of the fields
-contains an _embedded_ comma. While there is no formal standard
-specification for CSV data(1), in such cases, most programs embed the
+contains an _embedded_ comma. Although there is no formal standard
+specification for CSV data,(1) in such cases, most programs embed the
field in double quotes. So we might have data like this:
Robbins,Arnold,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA
@@ -5183,7 +5189,7 @@ field in double quotes. So we might have data like this:
value of `FPAT' should be a string that provides a regular expression.
This regular expression describes the contents of each field.
- In the case of CSV data as presented above, each field is either
+ In the case of CSV data as presented here, each field is either
"anything that is not a comma," or "a double quote, anything that is
not a double quote, and a closing double quote." If written as a
regular expression constant (*note Regexp::), we would have
@@ -5237,8 +5243,8 @@ being used.
NOTE: Some programs export CSV data that contains embedded
newlines between the double quotes. `gawk' provides no way to
- deal with this. Since there is no formal specification for CSV
- data, there isn't much more to be done; the `FPAT' mechanism
+ deal with this. Because no formal specification for CSV data
+ exists, there isn't much more to be done; the `FPAT' mechanism
provides an elegant solution for the majority of cases, and the
`gawk' developers are satisfied with that.
@@ -5364,7 +5370,7 @@ A simple program to process this file is as follows:
-|
...
- *Note Labels Program::, for a more realistic program that deals with
+ *Note Labels Program::, for a more realistic program dealing with
address lists. The following list summarizes how records are split,
based on the value of `RS'. (`==' means "is equal to.")
@@ -5429,7 +5435,7 @@ describing the error that occurred.
represents a shell command.
NOTE: When `--sandbox' is specified (*note Options::), reading
- lines from files, pipes and coprocesses is disabled.
+ lines from files, pipes, and coprocesses is disabled.
* Menu:
@@ -5546,7 +5552,7 @@ and produces these results:
free
The `getline' command used in this way sets only the variables `NR',
-`FNR' and `RT' (and of course, VAR). The record is not split into
+`FNR', and `RT' (and of course, VAR). The record is not split into
fields, so the values of the fields (including `$0') and the value of
`NF' do not change.
@@ -5590,8 +5596,8 @@ File: gawk.info, Node: Getline/Variable/File, Next: Getline/Pipe, Prev: Getli
-------------------------------------------------
Use `getline VAR < FILE' to read input from the file FILE, and put it
-in the variable VAR. As above, FILE is a string-valued expression that
-specifies the file from which to read.
+in the variable VAR. As earlier, FILE is a string-valued expression
+that specifies the file from which to read.
In this version of `getline', none of the predefined variables are
changed and the record is not split into fields. The only variable
@@ -5857,19 +5863,19 @@ COMMAND `|& getline' Sets `$0', `NF', and `RT' `gawk'
COMMAND `|& getline' Sets VAR and `RT' `gawk'
VAR
-Table 4.1: `getline' Variants and What They Set
+Table 4.1: `getline' variants and what they set

File: gawk.info, Node: Read Timeout, Next: Command-line directories, Prev: Getline, Up: Reading Files
-4.10 Reading Input With A Timeout
+4.10 Reading Input with a Timeout
=================================
This minor node describes a feature that is specific to `gawk'.
You may specify a timeout in milliseconds for reading input from the
keyboard, a pipe, or two-way communication, including TCP/IP sockets.
-This can be done on a per input, command or connection basis, by
+This can be done on a per input, command, or connection basis, by
setting a special element in the `PROCINFO' array (*note Auto-set::):
PROCINFO["input_name", "READ_TIMEOUT"] = TIMEOUT IN MILLISECONDS
@@ -5928,13 +5934,13 @@ input to arrive:
exactly after the tenth record has been printed. It is possible
that `gawk' will read and buffer more than one record's worth of
data the first time. Because of this, changing the value of
- timeout like in the above example is not very useful.
+ timeout like in the preceding example is not very useful.
- If the `PROCINFO' element is not present and the environment
-variable `GAWK_READ_TIMEOUT' exists, `gawk' uses its value to
-initialize the timeout value. The exclusive use of the environment
-variable to specify timeout has the disadvantage of not being able to
-control it on a per command or connection basis.
+ If the `PROCINFO' element is not present and the `GAWK_READ_TIMEOUT'
+environment variable exists, `gawk' uses its value to initialize the
+timeout value. The exclusive use of the environment variable to
+specify timeout has the disadvantage of not being able to control it on
+a per command or connection basis.
`gawk' considers a timeout event to be an error even though the
attempt to read from the underlying device may succeed in a later
@@ -5956,7 +5962,7 @@ writing.

File: gawk.info, Node: Command-line directories, Next: Input Summary, Prev: Read Timeout, Up: Reading Files
-4.11 Directories On The Command Line
+4.11 Directories on the Command Line
====================================
According to the POSIX standard, files named on the `awk' command line
@@ -5967,7 +5973,7 @@ of `awk' treat a directory on the command line as a fatal error.
line, but otherwise ignores it. This makes it easier to use shell
wildcards with your `awk' program:
- $ gawk -f whizprog.awk * Directories could kill this progam
+ $ gawk -f whizprog.awk * Directories could kill this program
If either of the `--posix' or `--traditional' options is given, then
`gawk' reverts to treating a directory on the command line as a fatal
@@ -6001,8 +6007,8 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li
* `gawk' sets `RT' to the text matched by `RS'.
* After splitting the input into records, `awk' further splits the
- record into individual fields, named `$1', `$2' and so on. `$0' is
- the whole record, and `NF' indicates how many fields there are.
+ record into individual fields, named `$1', `$2', and so on. `$0'
+ is the whole record, and `NF' indicates how many fields there are.
The default way to split fields is between whitespace characters.
* Fields may be referenced using a variable, as in `$NF'. Fields
@@ -6013,7 +6019,7 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li
does the same thing. Decrementing `NF' throws away fields and
rebuilds the record.
- * Field splitting is more complicated than record splitting.
+ * Field splitting is more complicated than record splitting:
Field separator value Fields are split ... `awk' /
`gawk'
@@ -6230,14 +6236,15 @@ separated by commas. In the output, the items are normally separated
by single spaces. However, this doesn't need to be the case; a single
space is simply the default. Any string of characters may be used as
the "output field separator" by setting the predefined variable `OFS'.
-The initial value of this variable is the string `" "'--that is, a
-single space.
+The initial value of this variable is the string `" "' (i.e., a single
+space).
The output from an entire `print' statement is called an "output
record". Each `print' statement outputs one output record, and then
outputs a string called the "output record separator" (or `ORS'). The
-initial value of `ORS' is the string `"\n"'; i.e., a newline character.
-Thus, each `print' statement normally makes a separate line.
+initial value of `ORS' is the string `"\n"' (i.e., a newline
+character). Thus, each `print' statement normally makes a separate
+line.
In order to change how output fields and records are separated,
assign new values to the variables `OFS' and `ORS'. The usual place to
@@ -6336,10 +6343,10 @@ A simple `printf' statement looks like this:
printf FORMAT, ITEM1, ITEM2, ...
-As print `print', the entire list of arguments may optionally be
-enclosed in parentheses. Here too, the parentheses are necessary if any
-of the item expressions use the `>' relational operator; otherwise, it
-can be confused with an output redirection (*note Redirection::).
+As for `print', the entire list of arguments may optionally be enclosed
+in parentheses. Here too, the parentheses are necessary if any of the
+item expressions use the `>' relational operator; otherwise, it can be
+confused with an output redirection (*note Redirection::).
The difference between `printf' and `print' is the FORMAT argument.
This is an expression whose value is taken as a string; it specifies
@@ -6422,7 +6429,7 @@ width. Here is a list of the format-control letters:
of which follow the decimal point. (The `4.3' represents two
modifiers, discussed in the next node.)
- On systems supporting IEEE 754 floating point format, values
+ On systems supporting IEEE 754 floating-point format, values
representing negative infinity are formatted as `-inf' or
`-infinity', and positive infinity as `inf' and `infinity'. The
special "not a number" value formats as `-nan' or `nan' (*note
@@ -6448,7 +6455,7 @@ width. Here is a list of the format-control letters:
`%u'
Print an unsigned decimal integer. (This format is of marginal
- use, because all numbers in `awk' are floating-point; it is
+ use, because all numbers in `awk' are floating point; it is
provided primarily for compatibility with C.)
`%x', `%X'
@@ -6519,7 +6526,7 @@ which they may appear:
space modifier.
`#'
- Use an "alternate form" for certain control letters. For `%o',
+ Use an "alternative form" for certain control letters. For `%o',
supply a leading zero. For `%x' and `%X', supply a leading `0x'
or `0X' for a nonzero result. For `%e', `%E', `%f', and `%F', the
result always contains a decimal point. For `%g' and `%G',
@@ -6533,7 +6540,7 @@ which they may appear:
`''
A single quote or apostrophe character is a POSIX extension to ISO
- C. It indicates that the integer part of a floating point value,
+ C. It indicates that the integer part of a floating-point value,
or the entire part of an integer decimal value, should have a
thousands-separator character in it. This only works in locales
that support such characters. For example:
@@ -6598,10 +6605,10 @@ which they may appear:
prints `foob'.
- The C library `printf''s dynamic WIDTH and PREC capability (for
-example, `"%*.*s"') is supported. Instead of supplying explicit WIDTH
-and/or PREC values in the format string, they are passed in the
-argument list. For example:
+ The C library `printf''s dynamic WIDTH and PREC capability (e.g.,
+`"%*.*s"') is supported. Instead of supplying explicit WIDTH and/or
+PREC values in the format string, they are passed in the argument list.
+For example:
w = 5
p = 3
@@ -6679,8 +6686,9 @@ beginning of the `awk' program:
print "---- ------" }
{ printf "%-10s %s\n", $1, $2 }' mail-list
- The above example mixes `print' and `printf' statements in the same
-program. Using just `printf' statements can produce the same results:
+ The preceding example mixes `print' and `printf' statements in the
+same program. Using just `printf' statements can produce the same
+results:
awk 'BEGIN { printf "%-10s %s\n", "Name", "Number"
printf "%-10s %s\n", "----", "------" }
@@ -6821,7 +6829,7 @@ a file, and then to use `>>' for subsequent output:
This is indeed how redirections must be used from the shell. But in
`awk', it isn't necessary. In this kind of case, a program should use
-`>' for all the `print' statements, since the output file is only
+`>' for all the `print' statements, because the output file is only
opened once. (It happens that if you mix `>' and `>>' that output is
produced in the expected order. However, mixing the operators for the
same file is definitely poor style, and is confusing to readers of your
@@ -6893,7 +6901,7 @@ that happens, writing to the screen is not correct. In fact, if `awk'
is run from a background job, it may not have a terminal at all. Then
opening `/dev/tty' fails.
- `gawk', BWK `awk' and `mawk' provide special file names for
+ `gawk', BWK `awk', and `mawk' provide special file names for
accessing the three standard streams. If the file name matches one of
these special names when `gawk' (or one of the others) redirects input
or output, then it directly uses the descriptor that the file name
@@ -6918,10 +6926,10 @@ becomes:
redirection, the value must be a string. It is a common error to omit
the quotes, which leads to confusing results.
- `gawk' does not treat these file names as special when in POSIX
-compatibility mode. However, since BWK `awk' supports them, `gawk' does
-support them even when invoked with the `--traditional' option (*note
-Options::).
+ `gawk' does not treat these file names as special when in
+POSIX-compatibility mode. However, because BWK `awk' supports them,
+`gawk' does support them even when invoked with the `--traditional'
+option (*note Options::).
---------- Footnotes ----------
@@ -6933,7 +6941,7 @@ File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Spec
5.8 Special File Names in `gawk'
================================
-Besides access to standard input, stanard output, and standard error,
+Besides access to standard input, standard output, and standard error,
`gawk' provides access to any open file descriptor. Additionally,
there are special file names reserved for TCP/IP networking.
@@ -6980,7 +6988,7 @@ form:
`/NET-TYPE/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT'
- The NET-TYPE is one of `inet', `inet4' or `inet6'. The PROTOCOL is
+ The NET-TYPE is one of `inet', `inet4', or `inet6'. The PROTOCOL is
one of `tcp' or `udp', and the other fields represent the other
essential pieces of information for making a networking connection.
These file names are used with the `|&' operator for communicating with
@@ -7122,9 +7130,10 @@ terminated;(1) more importantly, the file descriptor for the pipe is
not closed and released until `close()' is called or `awk' exits.
`close()' silently does nothing if given an argument that does not
-represent a file, pipe or coprocess that was opened with a redirection.
-In such a case, it returns a negative value, indicating an error. In
-addition, `gawk' sets `ERRNO' to a string indicating the error.
+represent a file, pipe, or coprocess that was opened with a
+redirection. In such a case, it returns a negative value, indicating
+an error. In addition, `gawk' sets `ERRNO' to a string indicating the
+error.
Note also that `close(FILENAME)' has no "magic" effects on the
implicit loop that reads through the files named on the command line.
@@ -7145,8 +7154,8 @@ describes it in more detail and gives an example.
Using `close()''s Return Value
In many older versions of Unix `awk', the `close()' function is
-actually a statement. It is a syntax error to try and use the return
-value from `close()': (d.c.)
+actually a statement. (d.c.) It is a syntax error to try and use the
+return value from `close()':
command = "..."
command | getline info
@@ -7199,9 +7208,9 @@ File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Fi
pipes, and coprocesses.
* `gawk' provides special file names for access to standard input,
- output and error, and for network communications.
+ output, and error, and for network communications.
- * Use `close()' to close open file, pipe and coprocess redirections.
+ * Use `close()' to close open file, pipe, and coprocess redirections.
For coprocesses, it is possible to close only one direction of the
communications.
@@ -7261,8 +7270,8 @@ operators.

File: gawk.info, Node: Values, Next: All Operators, Up: Expressions
-6.1 Constants, Variables and Conversions
-========================================
+6.1 Constants, Variables, and Conversions
+=========================================
Expressions are built up from values and the operations performed upon
them. This minor node describes the elementary objects which provide
@@ -7288,7 +7297,7 @@ regular expression.
Each is used in the appropriate context when you need a data value
that isn't going to change. Numeric constants can have different
-forms, but are stored identically internally.
+forms, but are internally stored in an identical manner.
* Menu:
@@ -7312,7 +7321,7 @@ the same value:
1050e-1
A string constant consists of a sequence of characters enclosed in
-double-quotation marks. For example:
+double quotation marks. For example:
"parrot"
@@ -7325,7 +7334,7 @@ codes.
---------- Footnotes ----------
(1) The internal representation of all numbers, including integers,
-uses double precision floating-point numbers. On most modern systems,
+uses double-precision floating-point numbers. On most modern systems,
these are in IEEE 754 standard format. *Note Arbitrary Precision
Arithmetic::, for much more information.
@@ -7335,17 +7344,17 @@ File: gawk.info, Node: Nondecimal-numbers, Next: Regexp Constants, Prev: Scal
6.1.1.2 Octal and Hexadecimal Numbers
.....................................
-In `awk', all numbers are in decimal; i.e., base 10. Many other
+In `awk', all numbers are in decimal (i.e., base 10). Many other
programming languages allow you to specify numbers in other bases, often
octal (base 8) and hexadecimal (base 16). In octal, the numbers go 0,
-1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc. Just as `11', in decimal, is 1
-times 10 plus 1, so `11', in octal, is 1 times 8, plus 1. This equals 9
-in decimal. In hexadecimal, there are 16 digits. Since the everyday
-decimal number system only has ten digits (`0'-`9'), the letters `a'
-through `f' are used to represent the rest. (Case in the letters is
-usually irrelevant; hexadecimal `a' and `A' have the same value.)
-Thus, `11', in hexadecimal, is 1 times 16 plus 1, which equals 17 in
-decimal.
+1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on. Just as `11', in decimal,
+is 1 times 10 plus 1, so `11', in octal, is 1 times 8, plus 1. This
+equals 9 in decimal. In hexadecimal, there are 16 digits. Because the
+everyday decimal number system only has ten digits (`0'-`9'), the
+letters `a' through `f' are used to represent the rest. (Case in the
+letters is usually irrelevant; hexadecimal `a' and `A' have the same
+value.) Thus, `11', in hexadecimal, is 1 times 16 plus 1, which equals
+17 in decimal.
Just by looking at plain `11', you can't tell what base it's in.
So, in C, C++, and other languages derived from C, there is a special
@@ -7383,7 +7392,7 @@ manipulation functions; see *note Bitwise Functions::, for more
information.
Unlike some early C implementations, `8' and `9' are not valid in
-octal constants; e.g., `gawk' treats `018' as decimal 18:
+octal constants. For example, `gawk' treats `018' as decimal 18:
$ gawk 'BEGIN { print "021 is", 021 ; print 018 }'
-| 021 is 17
@@ -7426,8 +7435,8 @@ When used on the righthand side of the `~' or `!~' operators, a regexp
constant merely stands for the regexp that is to be matched. However,
regexp constants (such as `/foo/') may be used like simple expressions.
When a regexp constant appears by itself, it has the same meaning as if
-it appeared in a pattern, i.e., `($0 ~ /foo/)' (d.c.) *Note Expression
-Patterns::. This means that the following two code segments:
+it appeared in a pattern (i.e., `($0 ~ /foo/)'). (d.c.) *Note
+Expression Patterns::. This means that the following two code segments:
if ($0 ~ /barfly/ || $0 ~ /camelot/)
print "found"
@@ -7491,8 +7500,8 @@ the user-defined function `mysub()', which in turn passes it on to
either `sub()' or `gsub()'. However, what really happens is that the
`pat' parameter is either one or zero, depending upon whether or not
`$0' matches `/hi/'. `gawk' issues a warning when it sees a regexp
-constant used as a parameter to a user-defined function, since passing
-a truth value in this way is probably not what was intended.
+constant used as a parameter to a user-defined function, because
+passing a truth value in this way is probably not what was intended.

File: gawk.info, Node: Variables, Next: Conversion, Prev: Using Constant Regexps, Up: Values
@@ -7532,7 +7541,7 @@ variable's current value. Variables are given new values with
"assignment operators", "increment operators", and "decrement
operators". *Note Assignment Ops::. In addition, the `sub()' and
`gsub()' functions can change a variable's value, and the `match()',
-`split()' and `patsplit()' functions can change the contents of their
+`split()', and `patsplit()' functions can change the contents of their
array parameters. *Note String Functions::.
A few variables have special built-in meanings, such as `FS' (the
@@ -7604,7 +7613,7 @@ File: gawk.info, Node: Conversion, Prev: Variables, Up: Values
6.1.4 Conversion of Strings and Numbers
---------------------------------------
-Number to string and string to number conversion are generally
+Number-to-string and string-to-number conversion are generally
straightforward. There can be subtleties to be aware of; this minor
node discusses this important facet of `awk'.
@@ -7617,7 +7626,7 @@ node discusses this important facet of `awk'.

File: gawk.info, Node: Strings And Numbers, Next: Locale influences conversions, Up: Conversion
-6.1.4.1 How `awk' Converts Between Strings And Numbers
+6.1.4.1 How `awk' Converts Between Strings and Numbers
......................................................
Strings are converted to numbers and numbers are converted to strings,
@@ -7640,7 +7649,7 @@ string, concatenate that number with the empty string, `""'. To force
a string to be converted to a number, add zero to that string. A
string is converted to a number by interpreting any numeric prefix of
the string as numerals: `"2.5"' converts to 2.5, `"1e3"' converts to
-1000, and `"25fix"' has a numeric value of 25. Strings that can't be
+1,000, and `"25fix"' has a numeric value of 25. Strings that can't be
interpreted as valid numbers convert to zero.
The exact manner in which numbers are converted into strings is
@@ -7669,7 +7678,7 @@ value of `CONVFMT' may be. Given the following code fragment:
`b' has the value `"12"', not `"12.00"'. (d.c.)
- Pre-POSIX `awk' Used `OFMT' For String Conversion
+ Pre-POSIX `awk' Used `OFMT' for String Conversion
Prior to the POSIX standard, `awk' used the value of `OFMT' for
converting numbers to strings. `OFMT' specifies the output format to
@@ -7706,7 +7715,7 @@ separator, if they have one.
decimal point when reading the `awk' program source code, and for
command-line variable assignments (*note Other Arguments::). However,
when interpreting input data, for `print' and `printf' output, and for
-number to string conversion, the local decimal point character is used.
+number-to-string conversion, the local decimal point character is used.
(d.c.) In all cases, numbers in source code and in input data cannot
have a thousands separator. Here are some examples indicating the
difference in behavior, on a GNU/Linux system:
@@ -7728,7 +7737,7 @@ full number including the fractional part, 4.321.
Some earlier versions of `gawk' fully complied with this aspect of
the standard. However, many users in non-English locales complained
-about this behavior, since their data used a period as the decimal
+about this behavior, because their data used a period as the decimal
point, so the default behavior was restored to use a period as the
decimal point character. You can use the `--use-lc-numeric' option
(*note Options::) to force `gawk' to use the locale's decimal point
@@ -7747,9 +7756,9 @@ Feature Default `--posix' or `--use-lc-numeric'
Input Use period Use locale
`strtonum()'Use period Use locale
-Table 6.1: Locale Decimal Point versus A Period
+Table 6.1: Locale decimal point versus a period
- Finally, modern day formal standards and IEEE standard floating point
+ Finally, modern day formal standards and IEEE standard floating-point
representation can have an unusual but important effect on the way
`gawk' converts some special string values to numbers. The details are
presented in *note POSIX Floating Point Problems::.
@@ -7757,7 +7766,7 @@ presented in *note POSIX Floating Point Problems::.

File: gawk.info, Node: All Operators, Next: Truth Values and Conditions, Prev: Values, Up: Expressions
-6.2 Operators: Doing Something With Values
+6.2 Operators: Doing Something with Values
==========================================
This minor node introduces the "operators" which make use of the values
@@ -7819,9 +7828,9 @@ order from the highest precedence to the lowest:
Division; because all numbers in `awk' are floating-point
numbers, the result is _not_ rounded to an integer--`3 / 4' has
the value 0.75. (It is a common mistake, especially for C
- programmers, to forget that _all_ numbers in `awk' are
- floating-point, and that division of integer-looking constants
- produces a real number, not an integer.)
+ programmers, to forget that _all_ numbers in `awk' are floating
+ point, and that division of integer-looking constants produces a
+ real number, not an integer.)
`X % Y'
Remainder; further discussion is provided in the text, just after
@@ -7883,7 +7892,7 @@ runs together. For example:
...
Because string concatenation does not have an explicit operator, it
-is often necessary to insure that it happens at the right time by using
+is often necessary to ensure that it happens at the right time by using
parentheses to enclose the items to concatenate. For example, you
might expect that the following code fragment concatenates `file' and
`name':
@@ -8058,7 +8067,7 @@ righthand expression. For example:
The indices of `bar' are practically guaranteed to be different, because
`rand()' returns different values each time it is called. (Arrays and
the `rand()' function haven't been covered yet. *Note Arrays::, and
-see *note Numeric Functions::, for more information). This example
+*note Numeric Functions::, for more information). This example
illustrates an important fact about assignment operators: the lefthand
expression is only evaluated _once_.
@@ -8076,16 +8085,16 @@ converted to a number.
Operator Effect
--------------------------------------------------------------------------
-LVALUE `+=' INCREMENT Add INCREMENT to the value of LVALUE.
-LVALUE `-=' DECREMENT Subtract DECREMENT from the value of LVALUE.
-LVALUE `*=' Multiply the value of LVALUE by COEFFICIENT.
+LVALUE `+=' INCREMENT Add INCREMENT to the value of LVALUE
+LVALUE `-=' DECREMENT Subtract DECREMENT from the value of LVALUE
+LVALUE `*=' Multiply the value of LVALUE by COEFFICIENT
COEFFICIENT
-LVALUE `/=' DIVISOR Divide the value of LVALUE by DIVISOR.
-LVALUE `%=' MODULUS Set LVALUE to its remainder by MODULUS.
+LVALUE `/=' DIVISOR Divide the value of LVALUE by DIVISOR
+LVALUE `%=' MODULUS Set LVALUE to its remainder by MODULUS
LVALUE `^=' POWER
-LVALUE `**=' POWER Raise LVALUE to the power POWER. (c.e.)
+LVALUE `**=' POWER Raise LVALUE to the power POWER (c.e.)
-Table 6.2: Arithmetic Assignment Operators
+Table 6.2: Arithmetic assignment operators
NOTE: Only the `^=' operator is specified by POSIX. For maximum
portability, do not use the `**=' operator.
@@ -8134,7 +8143,7 @@ effect of incrementing it.
The post-increment `foo++' is nearly the same as writing `(foo += 1)
- 1'. It is not perfectly equivalent because all numbers in `awk' are
-floating-point--in floating-point, `foo + 1 - 1' does not necessarily
+floating point--in floating point, `foo + 1 - 1' does not necessarily
equal `foo'. But the difference is minute as long as you stick to
numbers that are fairly small (less than 10e12).
@@ -8198,8 +8207,8 @@ File: gawk.info, Node: Truth Values and Conditions, Next: Function Calls, Pre
6.3 Truth Values and Conditions
===============================
-In certain contexts, expression values also serve as "truth values;"
-i.e., they determine what should happen next as the program runs. This
+In certain contexts, expression values also serve as "truth values";
+(i.e., they determine what should happen next as the program runs). This
minor node describes how `awk' defines "true" and "false" and how
values are compared.
@@ -8250,8 +8259,8 @@ File: gawk.info, Node: Typing and Comparison, Next: Boolean Ops, Prev: Truth
6.3.2 Variable Typing and Comparison Expressions
------------------------------------------------
- The Guide is definitive. Reality is frequently inaccurate. -- The
- Hitchhiker's Guide to the Galaxy
+ The Guide is definitive. Reality is frequently inaccurate. --
+ Douglas Adams, `The Hitchhiker's Guide to the Galaxy'
Unlike other programming languages, `awk' variables do not have a
fixed type. Instead, they can be either a number or a string, depending
@@ -8267,7 +8276,7 @@ are typed, and how `awk' compares variables.

File: gawk.info, Node: Variable Typing, Next: Comparison Operators, Up: Typing and Comparison
-6.3.2.1 String Type Versus Numeric Type
+6.3.2.1 String Type versus Numeric Type
.......................................
The POSIX standard introduced the concept of a "numeric string", which
@@ -8284,7 +8293,7 @@ determine how they are compared. Variable typing follows these rules:
* Fields, `getline' input, `FILENAME', `ARGV' elements, `ENVIRON'
elements, and the elements of an array created by `match()',
- `split()' and `patsplit()' that are numeric strings have the
+ `split()', and `patsplit()' that are numeric strings have the
STRNUM attribute. Otherwise, they have the STRING attribute.
Uninitialized variables also have the STRNUM attribute.
@@ -8365,19 +8374,19 @@ them.
Expression Result
--------------------------------------------------------------------------
-X `<' Y True if X is less than Y.
-X `<=' Y True if X is less than or equal to Y.
-X `>' Y True if X is greater than Y.
-X `>=' Y True if X is greater than or equal to Y.
-X `==' Y True if X is equal to Y.
-X `!=' Y True if X is not equal to Y.
-X `~' Y True if the string X matches the regexp denoted by Y.
+X `<' Y True if X is less than Y
+X `<=' Y True if X is less than or equal to Y
+X `>' Y True if X is greater than Y
+X `>=' Y True if X is greater than or equal to Y
+X `==' Y True if X is equal to Y
+X `!=' Y True if X is not equal to Y
+X `~' Y True if the string X matches the regexp denoted by Y
X `!~' Y True if the string X does not match the regexp
- denoted by Y.
+ denoted by Y
SUBSCRIPT `in' True if the array ARRAY has an element with the
-ARRAY subscript SUBSCRIPT.
+ARRAY subscript SUBSCRIPT
-Table 6.3: Relational Operators
+Table 6.3: Relational operators
Comparison expressions have the value one if true and zero if false.
When comparing operands of mixed types, numeric operands are converted
@@ -8407,24 +8416,24 @@ comparisons `awk' performs, as well as what the result of each
comparison is:
`1.5 <= 2.0'
- numeric comparison (true)
+ Numeric comparison (true)
`"abc" >= "xyz"'
- string comparison (false)
+ String comparison (false)
`1.5 != " +2"'
- string comparison (true)
+ String comparison (true)
`"1e2" < "3"'
- string comparison (true)
+ String comparison (true)
`a = 2; b = "2"'
`a == b'
- string comparison (true)
+ String comparison (true)
`a = 2; b = " +2"'
`a == b'
- string comparison (false)
+ String comparison (false)
In this example:
@@ -8456,8 +8465,8 @@ case, the value of the expression as a string is used as a dynamic
regexp (*note Regexp Usage::; also *note Computed Regexps::).
A constant regular expression in slashes by itself is also an
-expression. The regexp `/REGEXP/' is an abbreviation for the following
-comparison expression:
+expression. `/REGEXP/' is an abbreviation for the following comparison
+expression:
$0 ~ /REGEXP/
@@ -8468,7 +8477,7 @@ Constant Regexps::, where this is discussed in more detail.

File: gawk.info, Node: POSIX String Comparison, Prev: Comparison Operators, Up: Typing and Comparison
-6.3.2.3 String Comparison With POSIX Rules
+6.3.2.3 String Comparison with POSIX Rules
..........................................
The POSIX standard says that string comparison is performed based on
@@ -8655,7 +8664,7 @@ these. *Note Built-in::, for a list of built-in functions and their
descriptions. In addition, you can define functions for use in your
program. *Note User-defined::, for instructions on how to do this.
Finally, `gawk' lets you write functions in C or C++ that may be called
-from your program: see *note Dynamic Extensions::.
+from your program (*note Dynamic Extensions::).
The way to use a function is with a "function call" expression,
which consists of the function name followed immediately by a list of
@@ -8670,7 +8679,7 @@ examples show function calls with and without arguments:
rand() no arguments
CAUTION: Do not put any space between the function name and the
- open-parenthesis! A user-defined function name looks just like
+ opening parenthesis! A user-defined function name looks just like
the name of a variable--a space would make the expression look
like concatenation of a variable with an expression inside
parentheses. With built-in functions, space before the
@@ -8795,7 +8804,7 @@ precedence:
`+ -'
Addition, subtraction.
-String Concatenation
+String concatenation
There is no special symbol for concatenation. The operands are
simply written side by side (*note Concatenation::).
@@ -8810,9 +8819,9 @@ String Concatenation
redirection does not produce an expression that could be the
operand of another operator. As a result, it does not make sense
to use a redirection operator near another operator of lower
- precedence without parentheses. Such combinations (for example,
- `print foo > a ? b : c'), result in syntax errors. The correct
- way to write this statement is `print foo > (a ? b : c)'.
+ precedence without parentheses. Such combinations (e.g., `print
+ foo > a ? b : c'), result in syntax errors. The correct way to
+ write this statement is `print foo > (a ? b : c)'.
`~ !~'
Matching, nonmatching.
@@ -8838,7 +8847,7 @@ String Concatenation

File: gawk.info, Node: Locales, Next: Expressions Summary, Prev: Precedence, Up: Expressions
-6.6 Where You Are Makes A Difference
+6.6 Where You Are Makes a Difference
====================================
Modern systems support the notion of "locales": a way to tell the
@@ -8858,7 +8867,7 @@ terminator.
Locales can affect how dates and times are formatted (*note Time
Functions::). For example, a common way to abbreviate the date
-September 4, 2015 in the United States is "9/4/15." In many countries
+September 4, 2015, in the United States is "9/4/15." In many countries
in Europe, however, it is abbreviated "4.9.15." Thus, the `%x'
specification in a `"US"' locale might produce `9/4/15', while in a
`"EUROPE"' locale, it might produce `4.9.15'.
@@ -8878,12 +8887,12 @@ File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions
===========
* Expressions are the basic elements of computation in programs.
- They are built from constants, variables, function calls and
+ They are built from constants, variables, function calls, and
combinations of the various kinds of values with operators.
* `awk' supplies three kinds of constants: numeric, string, and
regexp. `gawk' lets you specify numeric constants in octal and
- hexadecimal (bases 8 and 16) in addition to decimal (base 10). In
+ hexadecimal (bases 8 and 16) as well as decimal (base 10). In
certain contexts, a standalone regexp constant such as `/foo/' has
the same meaning as `$0 ~ /foo/'.
@@ -8918,8 +8927,7 @@ File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions
* Function calls return a value which may be used as part of a larger
expression. Expressions used to pass parameter values are fully
evaluated before the function is called. `awk' provides built-in
- and user-defined functions; this is described later on in this
- Info file.
+ and user-defined functions; this is described in *note Functions::.
* Operator precedence specifies the order in which operations are
performed, unless explicitly overridden by parentheses. `awk''s
@@ -9088,7 +9096,7 @@ _not_ contain the string `li':
constant regular expressions, comparisons, or any other `awk'
expressions. Range patterns are not expressions, so they cannot appear
inside Boolean patterns. Likewise, the special patterns `BEGIN', `END',
-`BEGINFILE' and `ENDFILE', which never match any input record, are not
+`BEGINFILE', and `ENDFILE', which never match any input record, are not
expressions and cannot appear inside Boolean patterns.
The precedence of the different operators which can appear in
@@ -9174,8 +9182,7 @@ All the patterns described so far are for matching input records. The
and cleanup actions for `awk' programs. `BEGIN' and `END' rules must
have actions; there is no default action for these rules because there
is no current record when they run. `BEGIN' and `END' rules are often
-referred to as "`BEGIN' and `END' blocks" by long-time `awk'
-programmers.
+referred to as "`BEGIN' and `END' blocks" by longtime `awk' programmers.
* Menu:
@@ -9202,7 +9209,7 @@ input is read. For example:
This program finds the number of records in the input file
`mail-list' that contain the string `li'. The `BEGIN' rule prints a
title for the report. There is no need to use the `BEGIN' rule to
-initialize the counter `n' to zero, since `awk' does this automatically
+initialize the counter `n' to zero, as `awk' does this automatically
(*note Variables::). The second rule increments the variable `n' every
time a record containing the pattern `li' is read. The `END' rule
prints the value of `n' at the end of the run.
@@ -9270,20 +9277,20 @@ many older versions of Unix `awk' do not.
The third point follows from the first two. The meaning of `print'
inside a `BEGIN' or `END' rule is the same as always: `print $0'. If
-`$0' is the null string, then this prints an empty record. Many long
-time `awk' programmers use an unadorned `print' in `BEGIN' and `END'
-rules, to mean `print ""', relying on `$0' being null. Although one
-might generally get away with this in `BEGIN' rules, it is a very bad
-idea in `END' rules, at least in `gawk'. It is also poor style, since
-if an empty line is needed in the output, the program should print one
-explicitly.
+`$0' is the null string, then this prints an empty record. Many
+longtime `awk' programmers use an unadorned `print' in `BEGIN' and
+`END' rules, to mean `print ""', relying on `$0' being null. Although
+one might generally get away with this in `BEGIN' rules, it is a very
+bad idea in `END' rules, at least in `gawk'. It is also poor style,
+because if an empty line is needed in the output, the program should
+print one explicitly.
Finally, the `next' and `nextfile' statements are not allowed in a
`BEGIN' rule, because the implicit
read-a-record-and-match-against-the-rules loop has not started yet.
-Similarly, those statements are not valid in an `END' rule, since all
-the input has been read. (*Note Next Statement::, and see *note
-Nextfile Statement::.)
+Similarly, those statements are not valid in an `END' rule, because all
+the input has been read. (*Note Next Statement::, and *note Nextfile
+Statement::,.)

File: gawk.info, Node: BEGINFILE/ENDFILE, Next: Empty, Prev: BEGIN/END, Up: Pattern Overview
@@ -9382,9 +9389,9 @@ following program:
END { print nmatches, "found" }' /path/to/data
The `awk' program consists of two pieces of quoted text that are
-concatenated together to form the program. The first part is
-double-quoted, which allows substitution of the `pattern' shell
-variable inside the quotes. The second part is single-quoted.
+concatenated together to form the program. The first part is double
+quoted, which allows substitution of the `pattern' shell variable
+inside the quotes. The second part is single quoted.
Variable substitution via quoting works, but can be potentially
messy. It requires a good understanding of the shell's quoting rules
@@ -9406,10 +9413,10 @@ Now, the `awk' program is just one single-quoted string. The
assignment `-v pat="$pattern"' still requires double quotes, in case
there is whitespace in the value of `$pattern'. The `awk' variable
`pat' could be named `pattern' too, but that would be more confusing.
-Using a variable also provides more flexibility, since the variable can
-be used anywhere inside the program--for printing, as an array
-subscript, or for any other use--without requiring the quoting tricks
-at every point in the program.
+Using a variable also provides more flexibility, as the variable can be
+used anywhere inside the program--for printing, as an array subscript,
+or for any other use--without requiring the quoting tricks at every
+point in the program.

File: gawk.info, Node: Action Overview, Next: Statements, Prev: Using Shell Variables, Up: Patterns and Actions
@@ -9461,7 +9468,7 @@ Compound statements
Input statements
Use the `getline' command (*note Getline::). Also supplied in
- `awk' are the `next' statement (*note Next Statement::), and the
+ `awk' are the `next' statement (*note Next Statement::) and the
`nextfile' statement (*note Nextfile Statement::).
Output statements
@@ -9529,7 +9536,7 @@ following:
else
print "x is odd"
- In this example, if the expression `x % 2 == 0' is true (that is, if
+ In this example, if the expression `x % 2 == 0' is true (i.e., if
the value of `x' is evenly divisible by two), then the first `print'
statement is executed; otherwise, the second `print' statement is
executed. If the `else' keyword appears on the same line as THEN-BODY
@@ -9588,7 +9595,7 @@ increments the value of `i' and the loop repeats. The loop terminates
when `i' reaches four.
A newline is not required between the condition and the body;
-however using one makes the program clearer unless the body is a
+however, using one makes the program clearer unless the body is a
compound statement or else is very simple. The newline after the
open-brace that begins the compound statement is not required either,
but the program is harder to read without it.
@@ -9626,8 +9633,8 @@ false to begin with. The following is an example of a `do' statement:
}
This program prints each input record 10 times. However, it isn't a
-very realistic example, since in this case an ordinary `while' would do
-just as well. This situation reflects actual experience; only
+very realistic example, because in this case an ordinary `while' would
+do just as well. This situation reflects actual experience; only
occasionally is there a real use for a `do' statement.

@@ -9706,7 +9713,7 @@ natural to think of. Counting the number of iterations is very common
in loops. It can be easier to think of this counting as part of
looping rather than as something to do inside the loop.
- There is an alternate version of the `for' loop, for iterating over
+ There is an alternative version of the `for' loop, for iterating over
all the indices of an array:
for (i in array)
@@ -9773,12 +9780,12 @@ the end of the `switch' statement itself. For example:
}
}
- Note that if none of the statements specified above halt execution
-of a matched `case' statement, execution falls through to the next
-`case' until execution halts. In the above example, the `case' for
-`"?"' falls through to the `default' case, which is to call a function
-named `usage()'. (The `getopt()' function being called here is
-described in *note Getopt Function::.)
+ Note that if none of the statements specified here halt execution of
+a matched `case' statement, execution falls through to the next `case'
+until execution halts. In this example, the `case' for `"?"' falls
+through to the `default' case, which is to call a function named
+`usage()'. (The `getopt()' function being called here is described in
+*note Getopt Function::.)

File: gawk.info, Node: Break Statement, Next: Continue Statement, Prev: Switch Statement, Up: Statements
@@ -9879,7 +9886,7 @@ the previous example with the following `while' loop:
print ""
}
-This program loops forever once `x' reaches 5, since the increment
+This program loops forever once `x' reaches 5, because the increment
(`x++') is never reached.
The `continue' statement has no special meaning with respect to the
@@ -9925,7 +9932,7 @@ beginning, in the following manner:
Because of the `next' statement, the program's subsequent rules won't
see the bad record. The error message is redirected to the standard
-error output stream, as error messages should be. For more detail see
+error output stream, as error messages should be. For more detail, see
*note Special Files::.
If the `next' statement causes the end of the input to be reached,
@@ -9978,14 +9985,14 @@ over a file that would otherwise cause `gawk' to exit with a fatal
error. In this case, `ENDFILE' rules are not executed. *Note
BEGINFILE/ENDFILE::.
- While one might think that `close(FILENAME)' would accomplish the
+ Although it might seem that `close(FILENAME)' would accomplish the
same as `nextfile', this isn't true. `close()' is reserved for closing
files, pipes, and coprocesses that are opened with redirections. It is
not related to the main processing that `awk' does with the files
listed in `ARGV'.
NOTE: For many years, `nextfile' was a common extension. In
- September, 2012, it was accepted for inclusion into the POSIX
+ September 2012, it was accepted for inclusion into the POSIX
standard. See the Austin Group website
(http://austingroupbugs.net/view.php?id=607).
@@ -10082,7 +10089,7 @@ of activity.

File: gawk.info, Node: User-modified, Next: Auto-set, Up: Built-in Variables
-7.5.1 Built-in Variables That Control `awk'
+7.5.1 Built-In Variables That Control `awk'
-------------------------------------------
The following is an alphabetical list of variables that you can change
@@ -10203,11 +10210,11 @@ description of each variable.)
character. (*Note Output Separators::.)
`PREC #'
- The working precision of arbitrary precision floating-point
+ The working precision of arbitrary-precision floating-point
numbers, 53 bits by default (*note Setting precision::).
`ROUNDMODE #'
- The rounding mode to use for arbitrary precision arithmetic on
+ The rounding mode to use for arbitrary-precision arithmetic on
numbers, by default `"N"' (`roundTiesToEven' in the IEEE 754
standard; *note Setting the rounding mode::).
@@ -10234,7 +10241,7 @@ description of each variable.)
Used for internationalization of programs at the `awk' level. It
sets the default text domain for specially marked string constants
in the source text, as well as for the `dcgettext()',
- `dcngettext()' and `bindtextdomain()' functions (*note
+ `dcngettext()', and `bindtextdomain()' functions (*note
Internationalization::). The default value of `TEXTDOMAIN' is
`"messages"'.
@@ -10245,7 +10252,7 @@ description of each variable.)

File: gawk.info, Node: Auto-set, Next: ARGC and ARGV, Prev: User-modified, Up: Built-in Variables
-7.5.2 Built-in Variables That Convey Information
+7.5.2 Built-In Variables That Convey Information
------------------------------------------------
The following is an alphabetical list of variables that `awk' sets
@@ -10255,7 +10262,7 @@ your program.
The variables that are specific to `gawk' are marked with a pound
sign (`#'). These variables are `gawk' extensions. In other `awk'
implementations or if `gawk' is in compatibility mode (*note
-Options::), they are not special.
+Options::), they are not special:
`ARGC', `ARGV'
The command-line arguments available to `awk' programs are stored
@@ -10337,9 +10344,10 @@ Options::), they are not special.
on the command line, `awk' reads from the standard input and
`FILENAME' is set to `"-"'. `FILENAME' changes each time a new
file is read (*note Reading Files::). Inside a `BEGIN' rule, the
- value of `FILENAME' is `""', since there are no input files being
- processed yet.(1) (d.c.) Note, though, that using `getline' (*note
- Getline::) inside a `BEGIN' rule can give `FILENAME' a value.
+ value of `FILENAME' is `""', because there are no input files
+ being processed yet.(1) (d.c.) Note, though, that using `getline'
+ (*note Getline::) inside a `BEGIN' rule can give `FILENAME' a
+ value.
`FNR'
The current record number in the current file. `awk' increments
@@ -10359,7 +10367,7 @@ Options::), they are not special.
`FUNCTAB #'
An array whose indices and corresponding values are the names of
- all the built-in, user-defined and extension functions in the
+ all the built-in, user-defined, and extension functions in the
program.
NOTE: Attempting to use the `delete' statement with the
@@ -10435,8 +10443,8 @@ Options::), they are not special.
`PROCINFO["sorted_in"]'
If this element exists in `PROCINFO', its value controls the
order in which array indices will be processed by `for (INDX
- in ARRAY)' loops. Since this is an advanced feature, we
- defer the full description until later; see *note Scanning an
+ in ARRAY)' loops. This is an advanced feature, so we defer
+ the full description until later; see *note Scanning an
Array::.
`PROCINFO["strftime"]'
@@ -10452,7 +10460,7 @@ Options::), they are not special.
The following additional elements in the array are available to
provide information about the MPFR and GMP libraries if your
- version of `gawk' supports arbitrary precision arithmetic (*note
+ version of `gawk' supports arbitrary-precision arithmetic (*note
Arbitrary Precision Arithmetic::):
`PROCINFO["mpfr_version"]'
@@ -10644,7 +10652,7 @@ string. Another option is to use the `delete' statement to remove
elements from `ARGV' (*note Delete::).
All of these actions are typically done in the `BEGIN' rule, before
-actual processing of the input begins. *Note Split Program::, and see
+actual processing of the input begins. *Note Split Program::, and
*note Tee Program::, for examples of each way of removing elements from
`ARGV'.
@@ -10655,7 +10663,7 @@ manner:
awk -f myprog.awk -- -v -q file1 file2 ...
The following fragment processes `ARGV' in order to examine, and
-then remove, the above command-line options:
+then remove, the previously mentioned command-line options:
BEGIN {
for (i = 1; i < ARGC; i++) {
@@ -10687,10 +10695,10 @@ are passed on to the `awk' program. (*Note Getopt Function::, for an
`awk' library function that parses command-line options.)
When designing your program, you should choose options that don't
-conflict with `gawk''s, since it will process any options that it
+conflict with `gawk''s, because it will process any options that it
accepts before passing the rest of the command line on to your program.
-Using `#!' with the `-E' option may help (*note Executable Scripts::,
-and *note Options::).
+Using `#!' with the `-E' option may help (*Note Executable Scripts::,
+and *note Options::,).

File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up: Patterns and Actions
@@ -10842,14 +10850,14 @@ example, conceptually, if the element values are 8, `"foo"', `""', and
| 8 | "foo" | "" | 30 | @r{Value}
+---------+---------+--------+---------+
0 1 2 3 @r{Index}
-Figure 8.1: A Contiguous Array
+Figure 8.1: A contiguous array
Only the values are stored; the indices are implicit from the order of
the values. Here, 8 is the value at index zero, because 8 appears in the
position with zero elements before it.
Arrays in `awk' are different--they are "associative". This means
-that each array is a collection of pairs: an index and its corresponding
+that each array is a collection of pairs--an index and its corresponding
array element value:
Index 3 Value 30
@@ -10889,7 +10897,7 @@ numeric form--thus illustrating that a single array can have both
numbers and strings as indices. (In fact, array subscripts are always
strings. There are some subtleties to how numbers work when used as
array subscripts; this is discussed in more detail in *note Numeric
-Array Subscripts::.) Here, the number `1' isn't double-quoted, since
+Array Subscripts::.) Here, the number `1' isn't double quoted, because
`awk' automatically converts it to a string.
The value of `IGNORECASE' has no effect upon array subscripting.
@@ -10952,8 +10960,8 @@ index, use the following expression:
This expression tests whether the particular index INDX exists, without
the side effect of creating that element if it is not present. The
expression has the value one (true) if `ARRAY[INDX]' exists and zero
-(false) if it does not exist. (We use INDX here, since `index' is the
-name of a built-in function.) For example, this statement tests
+(false) if it does not exist. (We use INDX here, because `index' is
+the name of a built-in function.) For example, this statement tests
whether the array `frequencies' contains the index `2':
if (2 in frequencies)
@@ -11129,7 +11137,7 @@ all `awk' versions do so. Consider this program, named `loopcheck.awk':

File: gawk.info, Node: Controlling Scanning, Prev: Scanning an Array, Up: Array Basics
-8.1.6 Using Predefined Array Scanning Orders With `gawk'
+8.1.6 Using Predefined Array Scanning Orders with `gawk'
--------------------------------------------------------
This node describes a feature that is specific to `gawk'.
@@ -11150,7 +11158,7 @@ internal implementation of arrays and will vary from one version of
* Set `PROCINFO["sorted_in"]' to the name of a user-defined function
to use for comparison of array elements. This advanced feature is
- described later, in *note Array Sorting::.
+ described later in *note Array Sorting::.
The following special values for `PROCINFO["sorted_in"]' are
available:
@@ -11239,7 +11247,7 @@ subarrays are treated as being equal to each other. Their order
relative to each other is determined by their index strings.
Here are some additional things to bear in mind about sorted array
-traversal.
+traversal:
* The value of `PROCINFO["sorted_in"]' is global. That is, it affects
all array traversal `for' loops. If you need to change it within
@@ -11255,12 +11263,12 @@ traversal.
if (save_sorted)
PROCINFO["sorted_in"] = save_sorted
- * As mentioned, the default array traversal order is represented by
- `"@unsorted"'. You can also get the default behavior by assigning
- the null string to `PROCINFO["sorted_in"]' or by just deleting the
- `"sorted_in"' element from the `PROCINFO' array with the `delete'
- statement. (The `delete' statement hasn't been described yet;
- *note Delete::.)
+ * As already mentioned, the default array traversal order is
+ represented by `"@unsorted"'. You can also get the default
+ behavior by assigning the null string to `PROCINFO["sorted_in"]'
+ or by just deleting the `"sorted_in"' element from the `PROCINFO'
+ array with the `delete' statement. (The `delete' statement hasn't
+ been described yet; *note Delete::.)
In addition, `gawk' provides built-in functions for sorting arrays;
see *note Array Sorting Functions::.
@@ -11301,8 +11309,8 @@ string value `"12.153"' (using the default conversion value of
assigned the value one. The program then changes the value of
`CONVFMT'. The test `(xyz in data)' generates a new string value from
`xyz'--this time `"12.15"'--because the value of `CONVFMT' only allows
-two significant digits. This test fails, since `"12.15"' is different
-from `"12.153"'.
+two significant digits. This test fails, because `"12.15"' is
+different from `"12.153"'.
According to the rules for conversions (*note Conversion::), integer
values always convert to strings as integers, no matter what the value
@@ -11321,7 +11329,7 @@ the same element!
As with many things in `awk', the majority of the time things work
as you would expect them to. But it is useful to have a precise
-knowledge of the actual rules since they can sometimes have a subtle
+knowledge of the actual rules, as they can sometimes have a subtle
effect on your programs.

@@ -11424,7 +11432,7 @@ at a time.
and `mawk', as well as by a number of other implementations.
NOTE: For many years, using `delete' without a subscript was a
- common extension. In September, 2012, it was accepted for
+ common extension. In September 2012, it was accepted for
inclusion into the POSIX standard. See the Austin Group website
(http://austingroupbugs.net/view.php?id=544).
@@ -11461,7 +11469,7 @@ File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Delete
* Multiscanning:: Scanning multidimensional arrays.
- A multidimensional array is an array in which an element is
+ A "multidimensional array" is an array in which an element is
identified by a sequence of indices instead of a single index. For
example, a two-dimensional array requires two indices. The usual way
(in many languages, including `awk') to refer to an element of a
@@ -11496,7 +11504,7 @@ stored as `foo["a@b@c"]'.
To test whether a particular index sequence exists in a
multidimensional array, use the same operator (`in') that is used for
-single dimensional arrays. Write the whole sequence of indices in
+single-dimensional arrays. Write the whole sequence of indices in
parentheses, separated by commas, as the left operand:
if ((SUBSCRIPT1, SUBSCRIPT2, ...) in ARRAY)
@@ -11597,8 +11605,8 @@ two-element subarray at index `1' of the main array `a':
can contain another subarray as a value, which in turn can hold other
arrays as well. In this way, you can create arrays of three or more
dimensions. The indices can be any `awk' expression, including scalars
-separated by commas (that is, a regular `awk' simulated
-multidimensional subscript). So the following is valid in `gawk':
+separated by commas (i.e., a regular `awk' simulated multidimensional
+subscript). So the following is valid in `gawk':
a[1][3][1, "name"] = "barney"
@@ -11611,7 +11619,7 @@ itself an array and not a scalar:
a[4] = "An element in a jagged array"
- The terms "dimension", "row" and "column" are meaningless when
+ The terms "dimension", "row", and "column" are meaningless when
applied to such an array, but we will use "dimension" henceforth to
imply the maximum number of indices needed to refer to an existing
element. The type of any element that has already been assigned cannot
@@ -11687,7 +11695,7 @@ the following code prints the elements of our main array `a':
}
*Note Walking Arrays::, for a user-defined function that "walks" an
-arbitrarily-dimensioned array of arrays.
+arbitrarily dimensioned array of arrays.
Recall that a reference to an uninitialized array element yields a
value of `""', the null string. This has one important implication when
@@ -11728,11 +11736,11 @@ File: gawk.info, Node: Arrays Summary, Prev: Arrays of Arrays, Up: Arrays
`gawk' lets you control the order by assigning special predefined
values to `PROCINFO["sorted_in"]'.
- * Use `delete ARRAY[INDX]' to delete an individual element. You may
- also use `delete ARRAY' to delete all of the elements in the
- array. This latter feature has been a common extension for many
- years and is now standard, but may not be supported by all
- commercial versions of `awk'.
+ * Use `delete ARRAY[INDX]' to delete an individual element. To
+ delete all of the elements in an array, use `delete ARRAY'. This
+ latter feature has been a common extension for many years and is
+ now standard, but may not be supported by all commercial versions
+ of `awk'.
* Standard `awk' simulates multidimensional arrays by separating
subscript values with a comma. The values are concatenated into a
@@ -11776,7 +11784,7 @@ major node describes these "user-defined" functions.

File: gawk.info, Node: Built-in, Next: User-defined, Up: Functions
-9.1 Built-in Functions
+9.1 Built-In Functions
======================
"Built-in" functions are always available for your `awk' program to
@@ -11801,7 +11809,7 @@ for your convenience.

File: gawk.info, Node: Calling Built-in, Next: Numeric Functions, Up: Built-in
-9.1.1 Calling Built-in Functions
+9.1.1 Calling Built-In Functions
--------------------------------
To call one of `awk''s built-in functions, write the name of the
@@ -11809,7 +11817,7 @@ function followed by arguments in parentheses. For example, `atan2(y +
z, 1)' is a call to the function `atan2()' and has two arguments.
Whitespace is ignored between the built-in function name and the
-open parenthesis, but nonetheless it is good practice to avoid using
+opening parenthesis, but nonetheless it is good practice to avoid using
whitespace there. User-defined functions do not permit whitespace in
this way, and it is easier to avoid mistakes by following a simple
convention that always works--no whitespace after a function name.
@@ -11866,10 +11874,8 @@ brackets ([ ]):
`int(X)'
Return the nearest integer to X, located between X and zero and
- truncated toward zero.
-
- For example, `int(3)' is 3, `int(3.9)' is 3, `int(-3.9)' is -3,
- and `int(-3)' is -3 as well.
+ truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is
+ 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well.
`log(X)'
Return the natural logarithm of X, if X is positive; otherwise,
@@ -11960,7 +11966,7 @@ numbers.
(2) `mawk' uses a different seed each time.
(3) Computer-generated random numbers really are not truly random.
-They are technically known as "pseudorandom." This means that while
+They are technically known as "pseudorandom." This means that although
the numbers in a sequence appear to be random, you can in fact generate
the same sequence of random numbers over and over again.
@@ -11991,7 +11997,8 @@ with character indices, and not byte indices.
In the following list, optional parameters are enclosed in square
brackets ([ ]). Several functions perform string substitution; the
full discussion is provided in the description of the `sub()' function,
-which comes towards the end since the list is presented alphabetically.
+which comes toward the end, because the list is presented
+alphabetically.
Those functions that are specific to `gawk' are marked with a pound
sign (`#'). They are not available in compatibility mode (*note
@@ -12009,10 +12016,10 @@ Options::):
together.
NOTE: The following description ignores the third argument,
- HOW, since it requires understanding features that we have
- not discussed yet. Thus, the discussion here is a deliberate
- simplification. (We do provide all the details later on:
- *Note Array Sorting Functions::, for the full story.)
+ HOW, as it requires understanding features that we have not
+ discussed yet. Thus, the discussion here is a deliberate
+ simplification. (We do provide all the details later on; see
+ *note Array Sorting Functions::, for the full story.)
Both functions return the number of elements in the array SOURCE.
For `asort()', `gawk' sorts the values of SOURCE and replaces the
@@ -12251,7 +12258,7 @@ Options::):
-| 9 7
There may not be subscripts for the start and index for every
- parenthesized subexpression, since they may not all have matched
+ parenthesized subexpression, because they may not all have matched
text; thus they should be tested for with the `in' operator (*note
Reference to Elements::).
@@ -12290,8 +12297,8 @@ Options::):
`SEPS[I]' being the separator string between `ARRAY[I]' and
`ARRAY[I+1]'. If FIELDSEP is a single space then any leading
whitespace goes into `SEPS[0]' and any trailing whitespace goes
- into `SEPS[N]' where N is the return value of `split()' (that is,
- the number of elements in ARRAY).
+ into `SEPS[N]' where N is the return value of `split()' (i.e., the
+ number of elements in ARRAY).
The `split()' function splits strings into pieces in a manner
similar to the way input lines are split into fields. For example:
@@ -12315,7 +12322,7 @@ Options::):
As with input field-splitting, when the value of FIELDSEP is
`" "', leading and trailing whitespace is ignored in values
assigned to the elements of ARRAY but not in SEPS, and the elements
- are separated by runs of whitespace. Also as with input
+ are separated by runs of whitespace. Also, as with input
field-splitting, if FIELDSEP is the null string, each individual
character in the string is split into its own array element.
(c.e.)
@@ -12524,7 +12531,7 @@ is number zero.

File: gawk.info, Node: Gory Details, Up: String Functions
-9.1.3.1 More About `\' and `&' with `sub()', `gsub()', and `gensub()'
+9.1.3.1 More about `\' and `&' with `sub()', `gsub()', and `gensub()'
.....................................................................
CAUTION: This subsubsection has been reported to cause headaches.
@@ -12567,7 +12574,7 @@ is illustrated in *note table-sub-escapes::.
`\\\\\\&' `\\\&' A literal `\\&'
`\\q' `\q' A literal `\q'
-Table 9.1: Historical Escape Sequence Processing for `sub()' and
+Table 9.1: Historical escape sequence processing for `sub()' and
`gsub()'
This table shows both the lexical-level processing, where an odd number
@@ -12597,7 +12604,7 @@ This is shown in *note table-sub-proposed::.
`\\q' `\q' A literal `\q'
`\\\\' `\\' `\\'
-Table 9.2: GNU `awk' Rules For `sub()' And Backslash
+Table 9.2: GNU `awk' rules for `sub()' and backslash
In a nutshell, at the runtime level, there are now three special
sequences of characters (`\\\&', `\\&' and `\&') whereas historically
@@ -12624,20 +12631,19 @@ rules are presented in *note table-posix-sub::.
`\\q' `\q' A literal `\q'
`\\\\' `\\' `\'
-Table 9.3: POSIX Rules For `sub()' And `gsub()'
+Table 9.3: POSIX rules for `sub()' and `gsub()'
The only case where the difference is noticeable is the last one:
`\\\\' is seen as `\\' and produces `\' instead of `\\'.
Starting with version 3.1.4, `gawk' followed the POSIX rules when
`--posix' is specified (*note Options::). Otherwise, it continued to
-follow the proposed rules, since that had been its behavior for many
-years.
+follow the proposed rules, as that had been its behavior for many years.
When version 4.0.0 was released, the `gawk' maintainer made the
POSIX rules the default, breaking well over a decade's worth of
-backwards compatibility.(1) Needless to say, this was a bad idea, and
-as of version 4.0.1, `gawk' resumed its historical behavior, and only
+backward compatibility.(1) Needless to say, this was a bad idea, and as
+of version 4.0.1, `gawk' resumed its historical behavior, and only
follows the POSIX rules when `--posix' is given.
The rules for `gensub()' are considerably simpler. At the runtime
@@ -12656,7 +12662,7 @@ the `\' does not, as shown in *note table-gensub-escapes::.
`\\\\\\&' `\\\&' A literal `\&'
`\\q' `\q' A literal `q'
-Table 9.4: Escape Sequence Processing For `gensub()'
+Table 9.4: Escape sequence processing for `gensub()'
Because of the complexity of the lexical and runtime level processing
and the special cases for `sub()' and `gsub()', we recommend the use of
@@ -12700,23 +12706,23 @@ parameters are enclosed in square brackets ([ ]):
either a file opened for writing or a shell command for
redirecting output to a pipe or coprocess.
- Many utility programs "buffer" their output; i.e., they save
+ Many utility programs "buffer" their output (i.e., they save
information to write to a disk file or the screen in memory until
there is enough for it to be worthwhile to send the data to the
- output device. This is often more efficient than writing every
+ output device). This is often more efficient than writing every
little bit of information as soon as it is ready. However,
sometimes it is necessary to force a program to "flush" its
- buffers; that is, write the information to its destination, even
- if a buffer is not full. This is the purpose of the `fflush()'
+ buffers (i.e., write the information to its destination, even if a
+ buffer is not full). This is the purpose of the `fflush()'
function--`gawk' also buffers its output and the `fflush()'
function forces `gawk' to flush its buffers.
- Brian Kernighan added `fflush()' to his `awk' in April of 1992.
- For two decades, it was a common extension. In December, 2012, it
- was accepted for inclusion into the POSIX standard. See the
- Austin Group website (http://austingroupbugs.net/view.php?id=634).
+ Brian Kernighan added `fflush()' to his `awk' in April 1992. For
+ two decades, it was a common extension. In December 2012, it was
+ accepted for inclusion into the POSIX standard. See the Austin
+ Group website (http://austingroupbugs.net/view.php?id=634).
- POSIX standardizes `fflush()' as follows: If there is no argument,
+ POSIX standardizes `fflush()' as follows: if there is no argument,
or if the argument is the null string (`""'), then `awk' flushes
the buffers for _all_ open output files and pipes.
@@ -12741,6 +12747,38 @@ parameters are enclosed in square brackets ([ ]):
or if FILENAME is not an open file, pipe, or coprocess. In such a
case, `fflush()' returns -1, as well.
+ Interactive Versus Noninteractive Buffering
+
+ As a side point, buffering issues can be even more confusing,
+ depending upon whether your program is "interactive" (i.e.,
+ communicating with a user sitting at a keyboard).(1)
+
+ Interactive programs generally "line buffer" their output (i.e.,
+ they write out every line). Noninteractive programs wait until
+ they have a full buffer, which may be many lines of output. Here
+ is an example of the difference:
+
+ $ awk '{ print $1 + $2 }'
+ 1 1
+ -| 2
+ 2 3
+ -| 5
+ Ctrl-d
+
+ Each line of output is printed immediately. Compare that behavior
+ with this example:
+
+ $ awk '{ print $1 + $2 }' | cat
+ 1 1
+ 2 3
+ Ctrl-d
+ -| 2
+ -| 5
+
+ Here, no output is printed until after the `Ctrl-d' is typed,
+ because it is all buffered and sent down the pipe to `cat' in one
+ shot.
+
`system(COMMAND)'
Execute the operating-system command COMMAND and then return to
the `awk' program. Return COMMAND's exit status.
@@ -12774,37 +12812,6 @@ parameters are enclosed in square brackets ([ ]):
is disabled (*note Options::).
- Interactive Versus Noninteractive Buffering
-
- As a side point, buffering issues can be even more confusing,
-depending upon whether your program is "interactive", i.e.,
-communicating with a user sitting at a keyboard.(1)
-
- Interactive programs generally "line buffer" their output; i.e., they
-write out every line. Noninteractive programs wait until they have a
-full buffer, which may be many lines of output. Here is an example of
-the difference:
-
- $ awk '{ print $1 + $2 }'
- 1 1
- -| 2
- 2 3
- -| 5
- Ctrl-d
-
-Each line of output is printed immediately. Compare that behavior with
-this example:
-
- $ awk '{ print $1 + $2 }' | cat
- 1 1
- 2 3
- Ctrl-d
- -| 2
- -| 5
-
-Here, no output is printed until after the `Ctrl-d' is typed, because
-it is all buffered and sent down the pipe to `cat' in one shot.
-
Controlling Output Buffering with `system()'
The `fflush()' function provides explicit control over output
@@ -12818,8 +12825,8 @@ argument:
`gawk' treats this use of the `system()' function as a special case and
is smart enough not to run a shell (or other command interpreter) with
the empty command. Therefore, with `gawk', this idiom is not only
-useful, it is also efficient. While this method should work with other
-`awk' implementations, it does not necessarily avoid starting an
+useful, it is also efficient. Although this method should work with
+other `awk' implementations, it does not necessarily avoid starting an
unnecessary shell. (Other implementations may only flush the buffer
associated with the standard output and not necessarily all buffered
output.)
@@ -12910,14 +12917,14 @@ enclosed in square brackets ([ ]):
Otherwise, the value is formatted for the local time zone. The
TIMESTAMP is in the same format as the value returned by the
`systime()' function. If no TIMESTAMP argument is supplied,
- `gawk' uses the current time of day as the timestamp. If no
- FORMAT argument is supplied, `strftime()' uses the value of
+ `gawk' uses the current time of day as the timestamp. Without a
+ FORMAT argument, `strftime()' uses the value of
`PROCINFO["strftime"]' as the format string (*note Built-in
Variables::). The default string value is
`"%a %b %e %H:%M:%S %Z %Y"'. This format string produces output
that is equivalent to that of the `date' utility. You can assign
a new value to `PROCINFO["strftime"]' to change the default
- format; see below for the various format directives.
+ format; see the following list for the various format directives.
`systime()'
Return the current time as the number of seconds since the system
@@ -12981,9 +12988,9 @@ the following date format specifications:
`%g'
The year modulo 100 of the ISO 8601 week number, as a decimal
- number (00-99). For example, January 1, 2012 is in week 53 of
+ number (00-99). For example, January 1, 2012, is in week 53 of
2011. Thus, the year of its ISO 8601 week number is 2011, even
- though its year is 2012. Similarly, December 31, 2012 is in week
+ though its year is 2012. Similarly, December 31, 2012, is in week
1 of 2013. Thus, the year of its ISO week number is 2013, even
though its year is 2012.
@@ -13077,15 +13084,15 @@ the following date format specifications:
`%Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH'
`%OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy'
- "Alternate representations" for the specifications that use only
+ "Alternative representations" for the specifications that use only
the second letter (`%c', `%C', and so on).(5) (These facilitate
compliance with the POSIX `date' utility.)
`%%'
A literal `%'.
- If a conversion specifier is not one of the above, the behavior is
-undefined.(6)
+ If a conversion specifier is not one of those just listed, the
+behavior is undefined.(6)
For systems that are not yet fully standards-compliant, `gawk'
supplies a copy of `strftime()' from the GNU C Library. It supports
@@ -13105,8 +13112,8 @@ format specifications are available:
The time as a decimal timestamp in seconds since the epoch.
- Additionally, the alternate representations are recognized but their
-normal representations are used.
+ Additionally, the alternative representations are recognized but
+their normal representations are used.
The following example is an `awk' implementation of the POSIX `date'
utility. Normally, the `date' utility prints the current date and time
@@ -13194,7 +13201,7 @@ table-bitwise-ops::.
0 | 0 0 | 0 1 | 0 1
1 | 0 1 | 1 1 | 1 0
-Table 9.5: Bitwise Operations
+Table 9.5: Bitwise operations
As you can see, the result of an AND operation is 1 only when _both_
bits are 1. The result of an OR operation is 1 if _either_ bit is 1.
@@ -13231,7 +13238,7 @@ are enclosed in square brackets ([ ]):
Return the bitwise XOR of the arguments. There must be at least
two.
- For all of these functions, first the double precision
+ For all of these functions, first the double-precision
floating-point value is converted to the widest C unsigned integer
type, then the bitwise operation is performed. If the result cannot be
represented exactly as a C `double', leading nonzero bits are removed
@@ -13289,7 +13296,7 @@ or not. If so, a `"1"' is concatenated onto the front of the string.
Otherwise, a `"0"' is added. The value is then shifted right by one
bit and the loop continues until there are no more 1 bits.
- If the initial value is zero it returns a simple `"0"'. Otherwise,
+ If the initial value is zero, it returns a simple `"0"'. Otherwise,
at the end, it pads the value with zeros to represent multiples of
8-bit quantities. This is typical in modern computers.
@@ -13325,11 +13332,11 @@ user-defined function (not discussed yet; *note User-defined::), to
test if a parameter is an array or not.
NOTE: Using `isarray()' at the global level to test variables
- makes no sense. Since you are the one writing the program, you are
- supposed to know if your variables are arrays or not. And in fact,
- due to the way `gawk' works, if you pass the name of a variable
- that has not been previously used to `isarray()', `gawk' ends up
- turning it into a scalar.
+ makes no sense. Because you are the one writing the program, you
+ are supposed to know if your variables are arrays or not. And in
+ fact, due to the way `gawk' works, if you pass the name of a
+ variable that has not been previously used to `isarray()', `gawk'
+ ends up turning it into a scalar.

File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in
@@ -13375,8 +13382,8 @@ File: gawk.info, Node: User-defined, Next: Indirect Calls, Prev: Built-in, U
Complicated `awk' programs can often be simplified by defining your own
functions. User-defined functions can be called just like built-in
-ones (*note Function Calls::), but it is up to you to define them,
-i.e., to tell `awk' what they should do.
+ones (*note Function Calls::), but it is up to you to define them
+(i.e., to tell `awk' what they should do).
* Menu:
@@ -13489,7 +13496,7 @@ function:
func foo() { a = sqrt($1) ; print a }
-Instead it defines a rule that, for each record, concatenates the value
+Instead, it defines a rule that, for each record, concatenates the value
of the variable `func' with the return value of the function `foo'. If
the resulting string is non-null, the action is executed. This is
probably not what is desired. (`awk' accepts this input as
@@ -13501,7 +13508,7 @@ keyword `function' when defining a function.
---------- Footnotes ----------
- (1) This program won't actually run, since `foo()' is undefined.
+ (1) This program won't actually run, because `foo()' is undefined.

File: gawk.info, Node: Function Example, Next: Function Caveats, Prev: Definition Syntax, Up: User-defined
@@ -13555,7 +13562,7 @@ POSIX standard.)
string as an input parameter and returns the string in backwards order.
Recursive functions must always have a test that stops the recursion.
In this case, the recursion terminates when the input string is already
-empty.
+empty:
function rev(str)
{
@@ -13591,9 +13598,9 @@ an `awk' version of `ctime()':
}
You might think that `ctime()' could use `PROCINFO["strftime"]' for
-its format string. That would be a mistake, since `ctime()' is supposed
-to return the time formatted in a standard fashion, and user-level code
-could have changed `PROCINFO["strftime"]'.
+its format string. That would be a mistake, because `ctime()' is
+supposed to return the time formatted in a standard fashion, and
+user-level code could have changed `PROCINFO["strftime"]'.
---------- Footnotes ----------
@@ -13618,7 +13625,7 @@ the function.

File: gawk.info, Node: Calling A Function, Next: Variable Scope, Up: Function Caveats
-9.2.3.1 Writing A Function Call
+9.2.3.1 Writing a Function Call
...............................
A function call consists of the function name followed by the arguments
@@ -13631,10 +13638,10 @@ string concatenation):
foo(x y, "lose", 4 * z)
CAUTION: Whitespace characters (spaces and TABs) are not allowed
- between the function name and the open-parenthesis of the argument
- list. If you write whitespace by mistake, `awk' might think that
- you mean to concatenate a variable with an expression in
- parentheses. However, it notices that you used a function name
+ between the function name and the opening parenthesis of the
+ argument list. If you write whitespace by mistake, `awk' might
+ think that you mean to concatenate a variable with an expression
+ in parentheses. However, it notices that you used a function name
and not a variable name, and reports an error.

@@ -13687,7 +13694,7 @@ variable instance:
top's i=3
If you want `i' to be local to both `foo()' and `bar()' do as
-follows (the extra-space before `i' is a coding convention to indicate
+follows (the extra space before `i' is a coding convention to indicate
that `i' is a local variable, not an argument):
function bar( i)
@@ -13760,20 +13767,17 @@ create new arrays. Consider this example:

File: gawk.info, Node: Pass By Value/Reference, Prev: Variable Scope, Up: Function Caveats
-9.2.3.3 Passing Function Arguments By Value Or By Reference
+9.2.3.3 Passing Function Arguments by Value Or by Reference
...........................................................
In `awk', when you declare a function, there is no way to declare
explicitly whether the arguments are passed "by value" or "by
reference".
- Instead the passing convention is determined at runtime when the
-function is called according to the following rule:
-
- * If the argument is an array variable, then it is passed by
- reference,
-
- * Otherwise the argument is passed by value.
+ Instead, the passing convention is determined at runtime when the
+function is called according to the following rule: if the argument is
+an array variable, then it is passed by reference. Otherwise, the
+argument is passed by value.
Passing an argument by value means that when a function is called, it
is given a _copy_ of the value of this argument. The caller may use a
@@ -13850,7 +13854,7 @@ undefined functions.
Some `awk' implementations generate a runtime error if you use
either the `next' statement or the `nextfile' statement (*note Next
-Statement::, also *note Nextfile Statement::) inside a user-defined
+Statement::, and *note Nextfile Statement::) inside a user-defined
function. `gawk' does not have this limitation.

@@ -13899,11 +13903,12 @@ a value for the largest number among the elements of an array:
}
You call `maxelt()' with one argument, which is an array name. The
-local variables `i' and `ret' are not intended to be arguments; while
-there is nothing to stop you from passing more than one argument to
-`maxelt()', the results would be strange. The extra space before `i'
-in the function parameter list indicates that `i' and `ret' are local
-variables. You should follow this convention when defining functions.
+local variables `i' and `ret' are not intended to be arguments; there
+is nothing to stop you from passing more than one argument to
+`maxelt()' but the results would be strange. The extra space before
+`i' in the function parameter list indicates that `i' and `ret' are
+local variables. You should follow this convention when defining
+functions.
The following program uses the `maxelt()' function. It loads an
array, calls `maxelt()', and then reports the maximum number in that
@@ -14017,15 +14022,15 @@ function calls, you tell `gawk' to use the _value_ of a variable as the
_name_ of the function to call.
The syntax is similar to that of a regular function call: an
-identifier immediately followed by a left parenthesis, any arguments,
-and then a closing right parenthesis, with the addition of a leading `@'
-character:
+identifier immediately followed by an opening parenthesis, any
+arguments, and then a closing parenthesis, with the addition of a
+leading `@' character:
the_func = "sum"
result = @the_func() # calls the sum() function
Here is a full program that processes the previously shown data,
-using indirect function calls.
+using indirect function calls:
# indirectcall.awk --- Demonstrate indirect function calls
@@ -14053,7 +14058,7 @@ using indirect function calls.
These two functions expect to work on fields; thus the parameters
`first' and `last' indicate where in the fields to start and end.
-Otherwise they perform the expected computations and are not unusual.
+Otherwise they perform the expected computations and are not unusual:
# For each record, print the class name and the requested statistics
{
@@ -14330,7 +14335,7 @@ File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions
* POSIX `awk' provides three kinds of built-in functions: numeric,
string, and I/O. `gawk' provides functions that sort arrays, work
with values representing time, do bit manipulation, determine
- variable type (array vs. scalar), and internationalize and
+ variable type (array versus scalar), and internationalize and
localize programs. `gawk' also provides several extensions to
some of standard functions, typically in the form of additional
arguments.
@@ -14420,8 +14425,8 @@ functions and would like to contribute them to the `awk' user
community, see *note How To Contribute::, for more information.
The programs in this major node and in *note Sample Programs::,
-freely use features that are `gawk'-specific. Rewriting these programs
-for different implementations of `awk' is pretty straightforward.
+freely use `gawk'-specific features. Rewriting these programs for
+different implementations of `awk' is pretty straightforward:
* Diagnostic error messages are sent to `/dev/stderr'. Use `| "cat
1>&2"' instead of `> "/dev/stderr"' if your system does not have a
@@ -14479,8 +14484,8 @@ specific function). There is no intermediate state analogous to
Library functions often need to have global variables that they can
use to preserve state information between calls to the function--for
example, `getopt()''s variable `_opti' (*note Getopt Function::). Such
-variables are called "private", since the only functions that need to
-use them are the ones in the library.
+variables are called "private", as the only functions that need to use
+them are the ones in the library.
When writing a library function, you should try to choose names for
your private variables that will not conflict with any variables used by
@@ -14497,7 +14502,7 @@ will be accidentally shared with the user's program.
In addition, several of the library functions use a prefix that helps
indicate what function or set of functions use the variables--for
example, `_pw_byname()' in the user database routines (*note Passwd
-Functions::). This convention is recommended, since it even further
+Functions::). This convention is recommended, as it even further
decreases the chance of inadvertent conflict among variable names.
Note that this convention is used equally well for variable names and
for private function names.(1)
@@ -14538,9 +14543,9 @@ merely recommend that you do so.
---------- Footnotes ----------
- (1) While all the library routines could have been rewritten to use
-this convention, this was not done, in order to show how our own `awk'
-programming style has evolved and to provide some basis for this
+ (1) Although all the library routines could have been rewritten to
+use this convention, this was not done, in order to show how our own
+`awk' programming style has evolved and to provide some basis for this
discussion.
(2) `gawk''s `--dump-variables' command-line option is useful for
@@ -14574,7 +14579,7 @@ programming use.

File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions
-10.2.1 Converting Strings To Numbers
+10.2.1 Converting Strings to Numbers
------------------------------------
The `strtonum()' function (*note String Functions::) is a `gawk'
@@ -14641,8 +14646,8 @@ then `mystrtonum()' loops through each character in the string. It
sets `k' to the index in `"1234567"' of the current octal digit. The
return value will either be the same number as the digit, or zero if
the character is not there, which will be true for a `0'. This is
-safe, since the regexp test in the `if' ensures that only octal values
-are converted.
+safe, because the regexp test in the `if' ensures that only octal
+values are converted.
Similar logic applies to the code that checks for and converts a
hexadecimal value, which starts with `0x' or `0X'. The use of
@@ -14871,8 +14876,8 @@ distant past, at least one minicomputer manufacturer used ASCII, but
with mark parity, meaning that the leftmost bit in the byte is always
1. This means that on those systems, characters have numeric values
from 128 to 255. Finally, large mainframe systems use the EBCDIC
-character set, which uses all 256 values. While there are other
-character sets in use on some older systems, they are not really worth
+character set, which uses all 256 values. There are other character
+sets in use on some older systems, but they are not really worth
worrying about:
function ord(str, c)
@@ -14930,7 +14935,7 @@ application programs (*note Sample Programs::).
but it should also have a reasonable default behavior. It is called
with an array as well as the beginning and ending indices of the
elements in the array to be merged. This assumes that the array
-indices are numeric--a reasonable assumption since the array was likely
+indices are numeric--a reasonable assumption, as the array was likely
created with `split()' (*note String Functions::):
# join.awk --- join an array into a string
@@ -14970,7 +14975,7 @@ File: gawk.info, Node: Getlocaltime Function, Next: Readfile Function, Prev:
The `systime()' and `strftime()' functions described in *note Time
Functions::, provide the minimum functionality necessary for dealing
-with the time of day in human readable form. While `strftime()' is
+with the time of day in human-readable form. Although `strftime()' is
extensive, the control formats are not necessarily easy to remember or
intuitively obvious when reading a program.
@@ -15047,7 +15052,7 @@ optional timestamp value to use instead of the current time.

File: gawk.info, Node: Readfile Function, Next: Shell Quoting, Prev: Getlocaltime Function, Up: General Functions
-10.2.8 Reading A Whole File At Once
+10.2.8 Reading a Whole File At Once
-----------------------------------
Often, it is convenient to have the entire contents of a file available
@@ -15110,7 +15115,7 @@ also reads an entire file into memory.

File: gawk.info, Node: Shell Quoting, Prev: Readfile Function, Up: General Functions
-10.2.9 Quoting Strings to Pass to The Shell
+10.2.9 Quoting Strings to Pass to the Shell
-------------------------------------------
Michael Brennan offers the following programming pattern, which he uses
@@ -15138,7 +15143,7 @@ frequently:
Note the need for shell quoting. The function `shell_quote()' does
it. `SINGLE' is the one-character string `"'"' and `QSINGLE' is the
-three-character string `"\"'\""'.
+three-character string `"\"'\""':
# shell_quote --- quote an argument for passing to the shell
@@ -15182,7 +15187,7 @@ File: gawk.info, Node: Filetrans Function, Next: Rewind Function, Up: Data Fi
10.3.1 Noting Data File Boundaries
----------------------------------
-The `BEGIN' and `END' rules are each executed exactly once at the
+The `BEGIN' and `END' rules are each executed exactly once, at the
beginning and end of your `awk' program, respectively (*note
BEGIN/END::). We (the `gawk' authors) once had a user who mistakenly
thought that the `BEGIN' rule is executed at the beginning of each data
@@ -15242,7 +15247,7 @@ again the value of multiple `BEGIN' and `END' rules should be clear.
pass and at the beginning of the second pass. The following version
solves the problem:
- # ftrans.awk --- handle data file transitions
+ # ftrans.awk --- handle datafile transitions
#
# user supplies beginfile() and endfile() functions
@@ -15258,7 +15263,7 @@ solves the problem:
*note Wc Program::, shows how this library function can be used and
how it simplifies writing the main program.
- So Why Does `gawk' have `BEGINFILE' and `ENDFILE'?
+ So Why Does `gawk' Have `BEGINFILE' and `ENDFILE'?
You are probably wondering, if `beginfile()' and `endfile()'
functions can do the job, why does `gawk' have `BEGINFILE' and
@@ -15266,7 +15271,7 @@ functions can do the job, why does `gawk' have `BEGINFILE' and
Good question. Normally, if `awk' cannot open a file, this causes
an immediate fatal error. In this case, there is no way for a
-user-defined function to deal with the problem, since the mechanism for
+user-defined function to deal with the problem, as the mechanism for
calling it relies on the file being open and at the first record. Thus,
the main reason for `BEGINFILE' is to give you a "hook" to catch files
that cannot be processed. `ENDFILE' exists for symmetry, and because
@@ -15310,8 +15315,8 @@ over with it from the top. For lack of a better name, we'll call it
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!)
+anyway, because `gawk' goes to the next file as soon as an `ENDFILE'
+rule finishes!)

File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management
@@ -15339,12 +15344,12 @@ following program to your `awk' program:
}
This works, because the `getline' won't be fatal. Removing the
-element from `ARGV' with `delete' skips the file (since it's no longer
-in the list). See also *note ARGC and ARGV::.
+element from `ARGV' with `delete' skips the file (because 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.
+ Because `awk' variable names only allow the English letters, the
+regular expression check purposely does not use character classes such
+as `[:alpha:]' and `[:alnum:]' (*note Bracket Expressions::)
---------- Footnotes ----------
@@ -15452,11 +15457,11 @@ File: gawk.info, Node: Getopt Function, Next: Passwd Functions, Prev: Data Fi
10.4 Processing Command-Line Options
====================================
-Most utilities on POSIX compatible systems take options on the command
+Most utilities on POSIX-compatible systems take options on the command
line that can be used to change the way a program behaves. `awk' is an
example of such a program (*note Options::). Often, options take
-"arguments"; i.e., data that the program needs to correctly obey the
-command-line option. For example, `awk''s `-F' option requires a
+"arguments" (i.e., data that the program needs to correctly obey the
+command-line option). For example, `awk''s `-F' option requires a
string to use as the field separator. The first occurrence on the
command line of either `--' or a string that does not begin with `-'
ends the options.
@@ -15681,10 +15686,10 @@ next element in `argv'. If neither condition is true, then only
on the next call to `getopt()'.
The `BEGIN' rule initializes both `Opterr' and `Optind' to one.
-`Opterr' is set to one, since the default behavior is for `getopt()' to
-print a diagnostic message upon seeing an invalid option. `Optind' is
-set to one, since there's no reason to look at the program name, which
-is in `ARGV[0]':
+`Opterr' is set to one, because the default behavior is for `getopt()'
+to print a diagnostic message upon seeing an invalid option. `Optind'
+is set to one, because there's no reason to look at the program name,
+which is in `ARGV[0]':
BEGIN {
Opterr = 1 # default is to diagnose
@@ -15724,14 +15729,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, user level code must clear out
+ 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::).
+your program's options and `gawk''s options, as `-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.
@@ -15740,7 +15745,7 @@ use `getopt()' to process their arguments.
(1) This function was written before `gawk' acquired the ability to
split strings into single characters using `""' as the separator. We
-have left it alone, since using `substr()' is more portable.
+have left it alone, as using `substr()' is more portable.

File: gawk.info, Node: Passwd Functions, Next: Group Functions, Prev: Getopt Function, Up: Library Functions
@@ -15765,7 +15770,7 @@ function is `getpwent()', for "get password entry." The "password"
comes from the original user database file, `/etc/passwd', which stores
user information, along with the encrypted passwords (hence the name).
- While an `awk' program could simply read `/etc/passwd' directly,
+ Although an `awk' program could simply read `/etc/passwd' directly,
this file may not contain complete information about the system's set
of users.(1) To be sure you are able to produce a readable and complete
version of the user database, it is necessary to write a small C
@@ -15810,13 +15815,13 @@ Encrypted password
systems.
User-ID
- The user's numeric user ID number. (On some systems it's a C
+ The user's numeric user ID number. (On some systems, it's a C
`long', and not an `int'. Thus we cast it to `long' for all
cases.)
Group-ID
The user's numeric group ID number. (Similar comments about
- `long' vs. `int' apply here.)
+ `long' versus `int' apply here.)
Full name
The user's full name, and perhaps other information associated
@@ -15894,14 +15899,14 @@ you might want it to be in a different directory on your system.
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.
+efficiency, as `_pw_init()' needs to be called only once.
Because this function uses `getline' to read information from
`pwcat', it first saves the values of `FS', `RS', and `$0'. It notes
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. This makes it
+is in effect or not. Doing so is necessary, as 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. 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.
@@ -15972,8 +15977,8 @@ simplifies the code but runs an extra process that may never be needed.)
once. If you are worried about squeezing every last cycle out of your
`awk' program, the check of `_pw_inited' could be moved out of
`_pw_init()' and duplicated in all the other functions. In practice,
-this is not necessary, since most `awk' programs are I/O-bound, and
-such a change would clutter up the code.
+this is not necessary, as most `awk' programs are I/O-bound, and such a
+change would clutter up the code.
The `id' program in *note Id Program::, uses these functions.
@@ -16043,7 +16048,7 @@ Group ID Number
cases.)
Group Member List
- A comma-separated list of user names. These users are members of
+ A comma-separated list of usernames. These users are members of
the group. Modern Unix systems allow users to be members of
several groups simultaneously. If your system does, then there
are elements `"group1"' through `"groupN"' in `PROCINFO' for those
@@ -16134,7 +16139,7 @@ used, and to restore the appropriate field splitting mechanism.
The group information is stored is several associative arrays. The
arrays are indexed by group name (`_gr_byname'), by group ID number
(`_gr_bygid'), and by position in the database (`_gr_bycount'). There
-is an additional array indexed by user name (`_gr_groupsbyuser'), which
+is an additional array indexed by username (`_gr_groupsbyuser'), which
is a space-separated list of groups to which each user belongs.
Unlike the user database, it is possible to have multiple records in
@@ -16146,7 +16151,7 @@ following:
tvpeople:*:101:david,conan,tom,joan
For this reason, `_gr_init()' looks to see if a group name or group
-ID number is already seen. If it is, then the user names are simply
+ID number is already seen. If it is, the usernames are simply
concatenated onto the previous list of users.(1)
Finally, `_gr_init()' closes the pipeline to `grcat', restores `FS'
@@ -16174,7 +16179,7 @@ looks up the information associated with that group ID:
}
The `getgruser()' function does not have a C counterpart. It takes a
-user name and returns the list of groups that have the user as a member:
+username and returns the list of groups that have the user as a member:
function getgruser(user)
{
@@ -16286,7 +16291,7 @@ File: gawk.info, Node: Library Functions Summary, Next: Library Exercises, Pr
* The functions presented here fit into the following categories:
General problems
- Number to string conversion, assertions, rounding, random
+ Number-to-string conversion, assertions, rounding, random
number generation, converting characters to numbers, joining
strings, getting easily usable time-of-day information, and
reading a whole file in one shot.
@@ -16415,7 +16420,7 @@ programming for "real world" tasks.

File: gawk.info, Node: Cut Program, Next: Egrep Program, Up: Clones
-11.2.1 Cutting out Fields and Columns
+11.2.1 Cutting Out Fields and Columns
-------------------------------------
The `cut' utility selects, or "cuts," characters or fields from its
@@ -16632,10 +16637,10 @@ filler fields:
nfields = j - 1
}
- Next is the rule that actually processes the data. If the `-s'
-option is given, then `suppress' is true. The first `if' statement
-makes sure that the input record does have the field separator. If
-`cut' is processing fields, `suppress' is true, and the field separator
+ Next is the rule that processes the data. If the `-s' option is
+given, then `suppress' is true. The first `if' statement makes sure
+that the input record does have the field separator. If `cut' is
+processing fields, `suppress' is true, and the field separator
character is not in the record, then the record is skipped.
If the record is valid, then `gawk' has split the data into fields,
@@ -16660,8 +16665,8 @@ out between the fields:
}
This version of `cut' relies on `gawk''s `FIELDWIDTHS' variable to
-do the character-based cutting. While it is possible in other `awk'
-implementations to use `substr()' (*note String Functions::), it is
+do the character-based cutting. It is possible in other `awk'
+implementations to use `substr()' (*note String Functions::), but it is
also extremely painful. The `FIELDWIDTHS' variable supplies an elegant
solution to the problem of picking the input line apart by characters.
@@ -16772,14 +16777,14 @@ the matched lines in the output:
# pattern = tolower(pattern)
}
- The last two lines are commented out, since they are not needed in
+ The last two lines are commented out, as they are not needed in
`gawk'. They should be uncommented if you have to use another version
of `awk'.
The next set of lines should be uncommented if you are not using
`gawk'. This rule translates all the characters in the input line into
lowercase if the `-i' option is specified.(1) The rule is commented out
-since it is not necessary with `gawk':
+as it is not necessary with `gawk':
#{
# if (IGNORECASE)
@@ -16891,7 +16896,7 @@ the translated line, not the original.

File: gawk.info, Node: Id Program, Next: Split Program, Prev: Egrep Program, Up: Clones
-11.2.3 Printing out User Information
+11.2.3 Printing Out User Information
------------------------------------
The `id' utility lists a user's real and effective user ID numbers,
@@ -16975,7 +16980,7 @@ and the group numbers:
The test in the `for' loop is worth noting. Any supplementary
groups in the `PROCINFO' array have the indices `"group1"' through
-`"groupN"' for some N, i.e., the total number of supplementary groups.
+`"groupN"' for some N (i.e., the total number of supplementary groups).
However, we don't know in advance how many of these groups there are.
This loop works by starting at one, concatenating the value with
@@ -17004,11 +17009,11 @@ is as follows:(1)
`split' [`-COUNT'] [FILE] [PREFIX]
By default, the output files are named `xaa', `xab', and so on. Each
-file has 1000 lines in it, with the likely exception of the last file.
+file has 1,000 lines in it, with the likely exception of the last file.
To change the number of lines in each file, supply a number on the
-command line preceded with a minus; e.g., `-500' for files with 500
-lines in them instead of 1000. To change the name of the output files
-to something like `myfileaa', `myfileab', and so on, supply an
+command line preceded with a minus (e.g., `-500' for files with 500
+lines in them instead of 1,000). To change the name of the output
+files to something like `myfileaa', `myfileab', and so on, supply an
additional argument that specifies the file name prefix.
Here is a version of `split' in `awk'. It uses the `ord()' and
@@ -17041,7 +17046,7 @@ output file names:
}
# test argv in case reading from stdin instead of file
if (i in ARGV)
- i++ # skip data file name
+ i++ # skip datafile name
if (i in ARGV) {
outfile = ARGV[i]
ARGV[i] = ""
@@ -17113,8 +17118,8 @@ files named on the command line. Its usage is as follows:
truncating them and starting over.
The `BEGIN' rule first makes a copy of all the command-line arguments
-into an array named `copy'. `ARGV[0]' is not copied, since it is not
-needed. `tee' cannot use `ARGV' directly, since `awk' attempts to
+into an array named `copy'. `ARGV[0]' is not needed, so it is not
+copied. `tee' cannot use `ARGV' directly, because `awk' attempts to
process each file name in `ARGV' as input data.
If the first argument is `-a', then the flag variable `append' is
@@ -17146,7 +17151,7 @@ input by setting `ARGV[1]' to `"-"' and `ARGC' to two:
ARGC = 2
}
- The following single rule does all the work. Since there is no
+ The following single rule does all the work. Because there is no
pattern, it is executed for each line of input. The body of the rule
simply prints the line into each file on the command line, and then to
the standard output:
@@ -17170,11 +17175,12 @@ It is also possible to write the loop this way:
else
print > copy[i]
-This is more concise but it is also less efficient. The `if' is tested
-for each record and for each output file. By duplicating the loop
-body, the `if' is only tested once for each input record. If there are
-N input records and M output files, the first method only executes N
-`if' statements, while the second executes N`*'M `if' statements.
+This is more concise, but it is also less efficient. The `if' is
+tested for each record and for each output file. By duplicating the
+loop body, the `if' is only tested once for each input record. If
+there are N input records and M output files, the first method only
+executes N `if' statements, while the second executes N`*'M `if'
+statements.
Finally, the `END' rule cleans up by closing all the output files:
@@ -17352,13 +17358,13 @@ to.
depending upon the results of `are_equal()''s comparison. If `uniq' is
counting repeated lines, and the lines are equal, then it increments
the `count' variable. Otherwise, it prints the line and resets `count',
-since the two lines are not equal.
+because the two lines are not equal.
If `uniq' is not counting, and if the lines are equal, `count' is
-incremented. Nothing is printed, since the point is to remove
-duplicates. Otherwise, if `uniq' is counting repeated lines and more
-than one line is seen, or if `uniq' is counting nonrepeated lines and
-only one line is seen, then the line is printed, and `count' is reset.
+incremented. Nothing is printed, as the point is to remove duplicates.
+Otherwise, if `uniq' is counting repeated lines and more than one line
+is seen, or if `uniq' is counting nonrepeated lines and only one line
+is seen, then the line is printed, and `count' is reset.
Finally, similar logic is used in the `END' rule to print the final
line of input data:
@@ -17430,10 +17436,10 @@ follows:
`-c'
Count only characters.
- Implementing `wc' in `awk' is particularly elegant, since `awk' does
-a lot of the work for us; it splits lines into words (i.e., fields) and
-counts them, it counts lines (i.e., records), and it can easily tell us
-how long a line is.
+ Implementing `wc' in `awk' is particularly elegant, because `awk'
+does a lot of the work for us; it splits lines into words (i.e.,
+fields) and counts them, it counts lines (i.e., records), and it can
+easily tell us how long a line is.
This program uses the `getopt()' library function (*note Getopt
Function::) and the file-transition functions (*note Filetrans
@@ -17540,7 +17546,7 @@ in its length. Next, `lines' is incremented for each line read, and
---------- Footnotes ----------
- (1) Since `gawk' understands multibyte locales, this code counts
+ (1) Because `gawk' understands multibyte locales, this code counts
characters, not bytes.

@@ -17854,14 +17860,15 @@ record:
print
}
- While it is possible to do character transliteration in a user-level
-function, it is not necessarily efficient, and we (the `gawk' authors)
-started to consider adding a built-in function. However, shortly after
-writing this program, we learned that Brian Kernighan had added the
-`toupper()' and `tolower()' functions to his `awk' (*note String
-Functions::). These functions handle the vast majority of the cases
-where character transliteration is necessary, and so we chose to simply
-add those functions to `gawk' as well and then leave well enough alone.
+ It is possible to do character transliteration in a user-level
+function, but it is not necessarily efficient, and we (the `gawk'
+developers) started to consider adding a built-in function. However,
+shortly after writing this program, we learned that Brian Kernighan had
+added the `toupper()' and `tolower()' functions to his `awk' (*note
+String Functions::). These functions handle the vast majority of the
+cases where character transliteration is necessary, and so we chose to
+simply add those functions to `gawk' as well and then leave well enough
+alone.
An obvious improvement to this program would be to set up the `t_ar'
array only once, in a `BEGIN' rule. However, this assumes that the
@@ -17898,7 +17905,7 @@ been read.
The `BEGIN' rule simply sets `RS' to the empty string, so that `awk'
splits records at blank lines (*note Records::). It sets `MAXLINES' to
-100, since 100 is the maximum number of lines on the page (20 * 5 =
+100, because 100 is the maximum number of lines on the page (20 * 5 =
100).
Most of the work is done in the `printpage()' function. The label
@@ -18022,9 +18029,9 @@ on real text files:
* The `awk' language considers upper- and lowercase characters to be
distinct. Therefore, "bartender" and "Bartender" are not treated
- as the same word. This is undesirable, since in normal text, words
- are capitalized if they begin sentences, and a frequency analyzer
- should not be sensitive to capitalization.
+ as the same word. This is undesirable, because words are
+ capitalized if they begin sentences in normal text, and a
+ frequency analyzer should not be sensitive to capitalization.
* Words are detected using the `awk' convention that fields are
separated just by whitespace. Other characters in the input
@@ -18147,9 +18154,9 @@ File: gawk.info, Node: Extract Program, Next: Simple Sed, Prev: History Sorti
The nodes *note Library Functions::, and *note Sample Programs::, are
the top level nodes for a large number of `awk' programs. If you want
-to experiment with these programs, it is tedious to have to type them
-in by hand. Here we present a program that can extract parts of a
-Texinfo input file into separate files.
+to experiment with these programs, it is tedious to type them in by
+hand. Here we present a program that can extract parts of a Texinfo
+input file into separate files.
This Info file is written in Texinfo
(http://www.gnu.org/software/texinfo/), the GNU project's document
@@ -18206,7 +18213,7 @@ file looks something like this:
@example
@c file examples/messages.awk
- END @{ print "Always avoid bored archeologists!" @}
+ END @{ print "Always avoid bored archaeologists!" @}
@c end file
@end example
...
@@ -18342,15 +18349,15 @@ File: gawk.info, Node: Simple Sed, Next: Igawk Program, Prev: Extract Program
The `sed' utility is a stream editor, a program that reads a stream of
data, makes changes to it, and passes it on. It is often used to make
global changes to a large file or to a stream of data generated by a
-pipeline of commands. While `sed' is a complicated program in its own
-right, its most common use is to perform global substitutions in the
-middle of a pipeline:
+pipeline of commands. Although `sed' is a complicated program in its
+own right, its most common use is to perform global substitutions in
+the middle of a pipeline:
COMMAND1 < orig.data | sed 's/old/new/g' | COMMAND2 > result
Here, `s/old/new/g' tells `sed' to look for the regexp `old' on each
-input line and globally replace it with the text `new', i.e., all the
-occurrences on a line. This is similar to `awk''s `gsub()' function
+input line and globally replace it with the text `new' (i.e., all the
+occurrences on a line). This is similar to `awk''s `gsub()' function
(*note String Functions::).
The following program, `awksed.awk', accepts at least two
@@ -18411,7 +18418,7 @@ arguments and calling `usage()' if there is a problem. Then it sets
(*note ARGC and ARGV::).
The `usage()' function prints an error message and exits. Finally,
-the single rule handles the printing scheme outlined above, using
+the single rule handles the printing scheme outlined earlier, using
`print' or `printf' as appropriate, depending upon the value of `RT'.

@@ -18449,10 +18456,10 @@ to be able to write programs in the following manner:
The following program, `igawk.sh', provides this service. It
simulates `gawk''s searching of the `AWKPATH' variable and also allows
-"nested" includes; i.e., a file that is included with `@include' can
-contain further `@include' statements. `igawk' makes an effort to only
-include files once, so that nested includes don't accidentally include
-a library function twice.
+"nested" includes (i.e., a file that is included with `@include' can
+contain further `@include' statements). `igawk' makes an effort to
+only include files once, so that nested includes don't accidentally
+include a library function twice.
`igawk' should behave just like `gawk' externally. This means it
should accept all of `gawk''s command-line arguments, including the
@@ -18473,8 +18480,8 @@ language.(1) It works as follows:
b. Source file names, provided with `-f'. We use a neat trick
and append `@include FILENAME' to the shell variable's
- contents. Since the file-inclusion program works the way
- `gawk' does, this gets the text of the file included into the
+ contents. Because the file-inclusion program works the way
+ `gawk' does, this gets the text of the file included in the
program at the correct point.
3. Run an `awk' program (naturally) over the shell variable's
@@ -18734,13 +18741,13 @@ is saved as a single string, even if the results contain whitespace.
It's done in these steps:
1. Run `gawk' with the `@include'-processing program (the value of
- the `expand_prog' shell variable) on standard input.
+ the `expand_prog' shell variable) reading standard input.
2. Standard input is the contents of the user's program, from the
- shell variable `program'. Its contents are fed to `gawk' via a
- here document.
+ shell variable `program'. Feed its contents to `gawk' via a here
+ document.
- 3. The results of this processing are saved in the shell variable
+ 3. Save the results of this processing in the shell variable
`processed_program' by using command substitution.
The last step is to call `gawk' with the expanded program, along
@@ -18797,23 +18804,23 @@ use of `awk' programs as Web CGI scripts.

File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs
-11.3.10 Finding Anagrams From A Dictionary
+11.3.10 Finding Anagrams from a Dictionary
------------------------------------------
An interesting programming challenge is to search for "anagrams" in a
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").
+(e.g., "babbling" and "blabbing").
- Column 2, Problem C of Jon Bentley's `Programming Pearls', second
-edition, presents an elegant algorithm. The idea is to give words that
+ 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
-order.
+order:
# anagram.awk --- An implementation of the anagram finding algorithm
# from Jon Bentley's "Programming Pearls", 2nd edition.
@@ -18850,8 +18857,8 @@ back together:
}
Finally, the `END' rule traverses the array and prints out the
-anagram lists. It sends the output to the system `sort' command, since
-otherwise the anagrams would appear in arbitrary order:
+anagram lists. It sends the output to the system `sort' command
+because otherwise the anagrams would appear in arbitrary order:
END {
sort = "sort"
@@ -18886,7 +18893,7 @@ otherwise the anagrams would appear in arbitrary order:

File: gawk.info, Node: Signature Program, Prev: Anagram Program, Up: Miscellaneous Programs
-11.3.11 And Now For Something Completely Different
+11.3.11 And Now for Something Completely Different
--------------------------------------------------
The following program was written by Davide Brini and is published on
@@ -19167,7 +19174,7 @@ in a particular order that you, the programmer, choose. `gawk' lets
you do this.
*note Controlling Scanning::, describes how you can assign special,
-pre-defined values to `PROCINFO["sorted_in"]' in order to control the
+predefined 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
@@ -19324,7 +19331,7 @@ Running the program produces the following output:
The comparison should normally always return the same value when
given a specific pair of array elements as its arguments. If
-inconsistent results are returned then the order is undefined. This
+inconsistent results are returned, then the order is undefined. This
behavior can be exploited to introduce random order into otherwise
seemingly ordered data:
@@ -19334,7 +19341,7 @@ seemingly ordered data:
return (2 - 4 * rand())
}
- As mentioned above, the order of the indices is arbitrary if two
+ As already mentioned, 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
@@ -19368,16 +19375,16 @@ such a function.
When string comparisons are made during a sort, either for element
values where one or both aren't numbers, or for element indices handled
as strings, the value of `IGNORECASE' (*note Built-in Variables::)
-controls whether the comparisons treat corresponding uppercase and
+controls whether the comparisons treat corresponding upper- and
lowercase letters as equivalent or distinct.
- Another point to keep in mind is that in the case of subarrays the
+ Another point to keep in mind is that in the case of subarrays, the
element values can themselves be arrays; a production comparison
function should use the `isarray()' function (*note Type Functions::),
to check for this, and choose a defined sorting order for subarrays.
All sorting based on `PROCINFO["sorted_in"]' is disabled in POSIX
-mode, since the `PROCINFO' array is not special in that case.
+mode, because the `PROCINFO' array is not special in that case.
As a side note, sorting the array indices before traversing the
array has been reported to add 15% to 20% overhead to the execution
@@ -19396,10 +19403,10 @@ File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traver
---------------------------------------------------
In most `awk' implementations, sorting an array requires writing a
-`sort()' function. While this can be educational for exploring
-different sorting algorithms, usually that's not the point of the
-program. `gawk' provides the built-in `asort()' and `asorti()'
-functions (*note String Functions::) for sorting arrays. For example:
+`sort()' function. This can be educational for exploring different
+sorting algorithms, but usually that's not the point of the program.
+`gawk' provides the built-in `asort()' and `asorti()' functions (*note
+String Functions::) for sorting arrays. For example:
POPULATE THE ARRAY data
n = asort(data)
@@ -19480,8 +19487,8 @@ comparisons are based on character values only.(1)
---------- Footnotes ----------
(1) This is true because locale-based comparison occurs only when in
-POSIX compatibility mode, and since `asort()' and `asorti()' are `gawk'
-extensions, they are not available in that case.
+POSIX-compatibility mode, and because `asort()' and `asorti()' are
+`gawk' extensions, they are not available in that case.

File: gawk.info, Node: Two-way I/O, Next: TCP/IP Networking, Prev: Array Sorting, Up: Advanced Features
@@ -19510,7 +19517,7 @@ the program be run in a directory that cannot be shared among users;
for example, `/tmp' will not do, as another user might happen to be
using a temporary file with the same name.(1) However, with `gawk', it
is possible to open a _two-way_ pipe to another process. The second
-process is termed a "coprocess", since it runs in parallel with `gawk'.
+process is termed a "coprocess", as it runs in parallel with `gawk'.
The two-way connection is created using the `|&' operator (borrowed
from the Korn shell, `ksh'):(2)
@@ -19626,7 +19633,7 @@ connection.
You can think of this as just a _very long_ two-way pipeline to a
coprocess. The way `gawk' decides that you want to use TCP/IP
networking is by recognizing special file names that begin with one of
-`/inet/', `/inet4/' or `/inet6/'.
+`/inet/', `/inet4/', or `/inet6/'.
The full syntax of the special file name is
`/NET-TYPE/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT'. The
@@ -19652,7 +19659,7 @@ LOCAL-PORT
`getaddrinfo()' function.
REMOTE-HOST
- The IP address or fully-qualified domain name of the Internet host
+ The IP address or fully qualified domain name of the Internet host
to which you want to connect.
REMOTE-PORT
@@ -19700,7 +19707,7 @@ used to change the name of the file where `gawk' will write the profile:
gawk --profile=myprog.prof -f myprog.awk data1 data2
-In the above example, `gawk' places the profile in `myprog.prof'
+In the preceding example, `gawk' places the profile in `myprog.prof'
instead of in `awkprof.out'.
Here is a sample session showing a simple `awk' program, its input
@@ -19831,9 +19838,9 @@ output. They are as follows:
* Parentheses are used only where needed, as indicated by the
structure of the program and the precedence rules. For example,
- `(3 + 5) * 4' means add three plus five, then multiply the total
- by four. However, `3 + 5 * 4' has no parentheses, and means `3 +
- (5 * 4)'.
+ `(3 + 5) * 4' means add three and five, then multiply the total by
+ four. However, `3 + 5 * 4' has no parentheses, and means `3 + (5
+ * 4)'.
* Parentheses are used around the arguments to `print' and `printf'
only when the `print' or `printf' statement is followed by a
@@ -20023,12 +20030,12 @@ components--programs written in C or C++, as well as scripts written in
named `guide'. Internationalization consists of the following steps,
in this order:
- 1. The programmer goes through the source for all of `guide''s
- components and marks each string that is a candidate for
- translation. For example, `"`-F': option required"' is a good
- candidate for translation. A table with strings of option names
- is not (e.g., `gawk''s `--profile' option should remain the same,
- no matter what the local language).
+ 1. The programmer reviews the source for all of `guide''s components
+ and marks each string that is a candidate for translation. For
+ example, `"`-F': option required"' is a good candidate for
+ translation. A table with strings of option names is not (e.g.,
+ `gawk''s `--profile' option should remain the same, no matter what
+ the local language).
2. The programmer indicates the application's text domain (`"guide"')
to the `gettext' library, by calling the `textdomain()' function.
@@ -20097,8 +20104,8 @@ are:
a different category.)
`LC_COLLATE'
- Text-collation information; i.e., how different characters and/or
- groups of characters sort in a given language.
+ Text-collation information (i.e., how different characters and/or
+ groups of characters sort in a given language).
`LC_CTYPE'
Character-type information (alphabetic, digit, upper- or
@@ -20403,7 +20410,7 @@ them to other versions of `awk'. Consider this program:
As written, it won't work on other versions of `awk'. However, it is
actually almost portable, requiring very little change:
- * Assignments to `TEXTDOMAIN' won't have any effect, since
+ * Assignments to `TEXTDOMAIN' won't have any effect, because
`TEXTDOMAIN' is not special in other `awk' implementations.
* Non-GNU versions of `awk' treat marked strings as the
@@ -20439,10 +20446,10 @@ actually almost portable, requiring very little change:
and arguments unchanged to the underlying C library version of
`sprintf()', but only one format and argument at a time. What
happens if a positional specification is used is anybody's guess.
- However, since the positional specifications are primarily for use
- in _translated_ format strings, and since non-GNU `awk's never
- retrieve the translated string, this should not be a problem in
- practice.
+ However, because the positional specifications are primarily for
+ use in _translated_ format strings, and because non-GNU `awk's
+ never retrieve the translated string, this should not be a problem
+ in practice.
---------- Footnotes ----------
@@ -20505,7 +20512,7 @@ Following are the translations:
The next step is to make the directory to hold the binary message
object file and then to create the `guide.mo' file. We pretend that
-our file is to be used in the `en_US.UTF-8' locale, since we have to
+our file is to be used in the `en_US.UTF-8' locale, because we have to
use a locale name known to the C `gettext' routines. The directory
layout shown here is standard for GNU `gettext' on GNU/Linux systems.
Other versions of `gettext' may use a different layout:
@@ -20526,7 +20533,7 @@ proper directory (using the `-o' option) so that `gawk' can find it:
-| Like, the scoop is 42
-| Pardon me, Zaphod who?
- If the three replacement functions for `dcgettext()', `dcngettext()'
+ If the three replacement functions for `dcgettext()', `dcngettext()',
and `bindtextdomain()' (*note I18N Portability::) are in a file named
`libintl.awk', then we can run `guide.awk' unchanged as follows:
@@ -20615,7 +20622,7 @@ program is easy.

File: gawk.info, Node: Debugging, Next: Sample Debugging Session, Up: Debugger
-14.1 Introduction to The `gawk' Debugger
+14.1 Introduction to the `gawk' Debugger
========================================
This minor node introduces debugging in general and begins the
@@ -20637,9 +20644,9 @@ File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debuggi
ahead to the next section on the specific features of the `gawk'
debugger.)
- Of course, a debugging program cannot remove bugs for you, since it
-has no way of knowing what you or your users consider a "bug" and what
-is a "feature." (Sometimes, we humans have a hard time with this
+ Of course, a debugging program cannot remove bugs for you, because
+it has no way of knowing what you or your users consider a "bug" versus
+a "feature." (Sometimes, we humans have a hard time with this
ourselves.) In that case, what can you expect from such a tool? The
answer to that depends on the language being debugged, but in general,
you can expect at least the following:
@@ -20655,7 +20662,7 @@ you can expect at least the following:
* The chance to see the values of data in the program at any point in
execution, and also to change that data on the fly, to see how that
- affects what happens afterwards. (This often includes the ability
+ affects what happens afterward. (This often includes the ability
to look at internal data structures besides the variables you
actually defined in your code.)
@@ -20675,9 +20682,9 @@ File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging
Before diving in to the details, we need to introduce several important
concepts that apply to just about all debuggers. The following list
-defines terms used throughout the rest of this major node.
+defines terms used throughout the rest of this major node:
-"Stack Frame"
+"Stack frame"
Programs generally call functions during the course of their
execution. One function can call another, or a function can call
itself (recursion). You can view the chain of called functions
@@ -20713,11 +20720,11 @@ defines terms used throughout the rest of this major node.
breakpoints are oriented around the code: stop when a certain
point in the code is reached. A watchpoint, however, specifies
that program execution should stop when a _data value_ is changed.
- This is useful, since sometimes it happens that a variable
- receives an erroneous value, and it's hard to track down where
- this happens just by looking at the code. By using a watchpoint,
- you can stop whenever a variable is assigned to, and usually find
- the errant code quite quickly.
+ This is useful, as sometimes it happens that a variable receives
+ an erroneous value, and it's hard to track down where this happens
+ just by looking at the code. By using a watchpoint, you can stop
+ whenever a variable is assigned to, and usually find the errant
+ code quite quickly.

File: gawk.info, Node: Awk Debugging, Prev: Debugging Terms, Up: Debugging
@@ -20728,16 +20735,16 @@ File: gawk.info, Node: Awk Debugging, Prev: Debugging Terms, Up: Debugging
Debugging an `awk' program has some specific aspects that are not
shared with other programming languages.
- First of all, the fact that `awk' programs usually take input
-line-by-line from a file or files and operate on those lines using
-specific rules makes it especially useful to organize viewing the
-execution of the program in terms of these rules. As we will see, each
-`awk' rule is treated almost like a function call, with its own
-specific block of instructions.
+ First of all, the fact that `awk' programs usually take input line
+by line from a file or files and operate on those lines using specific
+rules makes it especially useful to organize viewing the execution of
+the program in terms of these rules. As we will see, each `awk' rule
+is treated almost like a function call, with its own specific block of
+instructions.
- In addition, since `awk' is by design a very concise language, it is
-easy to lose sight of everything that is going on "inside" each line of
-`awk' code. The debugger provides the opportunity to look at the
+ In addition, because `awk' is by design a very concise language, it
+is easy to lose sight of everything that is going on "inside" each line
+of `awk' code. The debugger provides the opportunity to look at the
individual primitive instructions carried out by the higher-level `awk'
commands.
@@ -20848,8 +20855,8 @@ the current stack frames:
-| #1 in main() at `awklib/eg/prog/uniq.awk':88
This tells us that `are_equal()' was called by the main program at
-line 88 of `uniq.awk'. (This is not a big surprise, since this is the
-only call to `are_equal()' in the program, but in more complex
+line 88 of `uniq.awk'. (This is not a big surprise, because this is
+the only call to `are_equal()' in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -20861,7 +20868,7 @@ Actually, the debugger gives us:
gawk> p n
-| n = untyped variable
-In this case, `n' is an uninitialized local variable, since the
+In this case, `n' is an uninitialized local variable, because the
function was called without arguments (*note Function Calls::).
A more useful variable to display might be the current record:
@@ -20869,8 +20876,8 @@ function was called without arguments (*note Function Calls::).
gawk> p $0
-| $0 = "gawk is a wonderful program!"
-This might be a bit puzzling at first since this is the second line of
-our test input above. Let's look at `NR':
+This might be a bit puzzling at first, as this is the second line of
+our test input. Let's look at `NR':
gawk> p NR
-| NR = 2
@@ -20901,7 +20908,7 @@ typing `n' (for "next"):
This tells us that `gawk' is now ready to execute line 66, which
decides whether to give the lines the special "field skipping" treatment
indicated by the `-1' command-line option. (Notice that we skipped
-from where we were before at line 63 to here, since the condition in
+from where we were before at line 63 to here, because the condition in
line 63 `if (fcount == 0 && charcount == 0)' was false.)
Continuing to step, we now get to the splitting of the current and
@@ -20926,9 +20933,9 @@ split into, so we try to look:
This is kind of disappointing, though. All we found out is that
there are five elements in `alast'; `m' and `aline' don't have values
-since we are at line 68 but haven't executed it yet. This information
-is useful enough (we now know that none of the words were accidentally
-left out), but what if we want to see inside the array?
+because we are at line 68 but haven't executed it yet. This
+information is useful enough (we now know that none of the words were
+accidentally left out), but what if we want to see inside the array?
The first choice would be to use subscripts:
@@ -21010,7 +21017,7 @@ abbreviation on a second description line. A debugger command name may
also be truncated if that partial name is unambiguous. The debugger has
the built-in capability to automatically repeat the previous command
just by hitting <Enter>. This works for the commands `list', `next',
-`nexti', `step', `stepi' and `continue' executed without any argument.
+`nexti', `step', `stepi', and `continue' executed without any argument.
* Menu:
@@ -21028,10 +21035,10 @@ File: gawk.info, Node: Breakpoint Control, Next: Debugger Execution Control,
14.3.1 Control of Breakpoints
-----------------------------
-As we saw above, the first thing you probably want to do in a debugging
-session is to get your breakpoints set up, since otherwise your program
-will just run as if it was not under the debugger. The commands for
-controlling breakpoints are:
+As we saw earlier, the first thing you probably want to do in a
+debugging session is to get your breakpoints set up, because your
+program will otherwise just run as if it was not under the debugger.
+The commands for controlling breakpoints are:
`break' [[FILENAME`:']N | FUNCTION] [`"EXPRESSION"']
`b' [[FILENAME`:']N | FUNCTION] [`"EXPRESSION"']
@@ -21083,8 +21090,8 @@ controlling breakpoints are:
reached. If the condition is true, then the debugger stops
execution and prompts for a command. Otherwise, the debugger
continues executing the program. If the condition expression is
- not specified, any existing condition is removed; i.e., the
- breakpoint or watchpoint is made unconditional.
+ not specified, any existing condition is removed (i.e., the
+ breakpoint or watchpoint is made unconditional).
`delete' [N1 N2 ...] [N-M]
`d' [N1 N2 ...] [N-M]
@@ -21175,7 +21182,7 @@ execution of the program than we saw in our earlier example:
Cancel execution of a function call. If VALUE (either a string or a
number) is specified, it is used as the function's return value.
If used in a frame other than the innermost one (the currently
- executing function, i.e., frame number 0), discard all inner
+ executing function; i.e., frame number 0), discard all inner
frames in addition to the selected one, and the caller of that
frame becomes the innermost frame.
@@ -21223,7 +21230,7 @@ The commands for viewing and changing variables inside of `gawk' are:
gawk> display x
-| 10: x = 1
- displays the assigned item number, the variable name and its
+ This displays the assigned item number, the variable name, and its
current value. If the display variable refers to a function
parameter, it is silently deleted from the list as soon as the
execution reaches a context where no such variable of the given
@@ -21272,7 +21279,7 @@ AWK STATEMENTS
(`"'...`"').
You can also set special `awk' variables, such as `FS', `NF',
- `NR', etc.
+ `NR', and son on.
`watch' VAR | `$'N [`"EXPRESSION"']
`w' VAR | `$'N [`"EXPRESSION"']
@@ -21316,8 +21323,8 @@ are:
innermost COUNT frames if COUNT > 0. Print the outermost COUNT
frames if COUNT < 0. The backtrace displays the name and
arguments to each function, the source file name, and the line
- number. The alias `where' for `backtrace' is provided for
- long-time GDB users who may be used to that command.
+ number. The alias `where' for `backtrace' is provided for longtime
+ GDB users who may be used to that command.
`down' [COUNT]
Move COUNT (default 1) frames down the stack toward the innermost
@@ -21339,7 +21346,7 @@ are:

File: gawk.info, Node: Debugger Info, Next: Miscellaneous Debugger Commands, Prev: Execution Stack, Up: List of Debugger Commands
-14.3.5 Obtaining Information about the Program and the Debugger State
+14.3.5 Obtaining Information About the Program and the Debugger State
---------------------------------------------------------------------
Besides looking at the values of variables, there is often a need to get
@@ -21465,39 +21472,39 @@ categories, as follows:
gawk> dump
-| # BEGIN
-|
- -| [ 1:0xfcd340] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
- -| [ 1:0xfcc240] Op_push_i : "~" [MALLOC|STRING|STRCUR]
- -| [ 1:0xfcc2a0] Op_push_i : "~" [MALLOC|STRING|STRCUR]
- -| [ 1:0xfcc280] Op_match :
- -| [ 1:0xfcc1e0] Op_store_var : O
- -| [ 1:0xfcc2e0] Op_push_i : "==" [MALLOC|STRING|STRCUR]
- -| [ 1:0xfcc340] Op_push_i : "==" [MALLOC|STRING|STRCUR]
- -| [ 1:0xfcc320] Op_equal :
- -| [ 1:0xfcc200] Op_store_var : o
- -| [ 1:0xfcc380] Op_push : o
- -| [ 1:0xfcc360] Op_plus_i : 0 [MALLOC|NUMCUR|NUMBER]
- -| [ 1:0xfcc220] Op_push_lhs : o [do_reference = true]
- -| [ 1:0xfcc300] Op_assign_plus :
- -| [ :0xfcc2c0] Op_pop :
- -| [ 1:0xfcc400] Op_push : O
- -| [ 1:0xfcc420] Op_push_i : "" [MALLOC|STRING|STRCUR]
- -| [ :0xfcc4a0] Op_no_op :
- -| [ 1:0xfcc480] Op_push : O
- -| [ :0xfcc4c0] Op_concat : [expr_count = 3] [concat_flag = 0]
- -| [ 1:0xfcc3c0] Op_store_var : x
- -| [ 1:0xfcc440] Op_push_lhs : X [do_reference = true]
- -| [ 1:0xfcc3a0] Op_postincrement :
- -| [ 1:0xfcc4e0] Op_push : x
- -| [ 1:0xfcc540] Op_push : o
- -| [ 1:0xfcc500] Op_plus :
- -| [ 1:0xfcc580] Op_push : o
- -| [ 1:0xfcc560] Op_plus :
- -| [ 1:0xfcc460] Op_leq :
- -| [ :0xfcc5c0] Op_jmp_false : [target_jmp = 0xfcc5e0]
- -| [ 1:0xfcc600] Op_push_i : "%c" [MALLOC|STRING|STRCUR]
- -| [ :0xfcc660] Op_no_op :
- -| [ 1:0xfcc520] Op_assign_concat : c
- -| [ :0xfcc620] Op_jmp : [target_jmp = 0xfcc440]
+ -| [ 1:0xfcd340] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
+ -| [ 1:0xfcc240] Op_push_i : "~" [MALLOC|STRING|STRCUR]
+ -| [ 1:0xfcc2a0] Op_push_i : "~" [MALLOC|STRING|STRCUR]
+ -| [ 1:0xfcc280] Op_match :
+ -| [ 1:0xfcc1e0] Op_store_var : O
+ -| [ 1:0xfcc2e0] Op_push_i : "==" [MALLOC|STRING|STRCUR]
+ -| [ 1:0xfcc340] Op_push_i : "==" [MALLOC|STRING|STRCUR]
+ -| [ 1:0xfcc320] Op_equal :
+ -| [ 1:0xfcc200] Op_store_var : o
+ -| [ 1:0xfcc380] Op_push : o
+ -| [ 1:0xfcc360] Op_plus_i : 0 [MALLOC|NUMCUR|NUMBER]
+ -| [ 1:0xfcc220] Op_push_lhs : o [do_reference = true]
+ -| [ 1:0xfcc300] Op_assign_plus :
+ -| [ :0xfcc2c0] Op_pop :
+ -| [ 1:0xfcc400] Op_push : O
+ -| [ 1:0xfcc420] Op_push_i : "" [MALLOC|STRING|STRCUR]
+ -| [ :0xfcc4a0] Op_no_op :
+ -| [ 1:0xfcc480] Op_push : O
+ -| [ :0xfcc4c0] Op_concat : [expr_count = 3] [concat_flag = 0]
+ -| [ 1:0xfcc3c0] Op_store_var : x
+ -| [ 1:0xfcc440] Op_push_lhs : X [do_reference = true]
+ -| [ 1:0xfcc3a0] Op_postincrement :
+ -| [ 1:0xfcc4e0] Op_push : x
+ -| [ 1:0xfcc540] Op_push : o
+ -| [ 1:0xfcc500] Op_plus :
+ -| [ 1:0xfcc580] Op_push : o
+ -| [ 1:0xfcc560] Op_plus :
+ -| [ 1:0xfcc460] Op_leq :
+ -| [ :0xfcc5c0] Op_jmp_false : [target_jmp = 0xfcc5e0]
+ -| [ 1:0xfcc600] Op_push_i : "%c" [MALLOC|STRING|STRCUR]
+ -| [ :0xfcc660] Op_no_op :
+ -| [ 1:0xfcc520] Op_assign_concat : c
+ -| [ :0xfcc620] Op_jmp : [target_jmp = 0xfcc440]
-|
...
-|
@@ -21548,10 +21555,10 @@ categories, as follows:
`q'
Exit the debugger. Debugging is great fun, but sometimes we all
have to tend to other obligations in life, and sometimes we find
- the bug, and are free to go on to the next one! As we saw above,
- if you are running a program, the debugger warns you if you
- accidentally type `q' or `quit', to make sure you really want to
- quit.
+ the bug, and are free to go on to the next one! As we saw
+ earlier, if you are running a program, the debugger warns you if
+ you accidentally type `q' or `quit', to make sure you really want
+ to quit.
`trace' [`on' | `off']
Turn on or off a continuous printing of instructions which are
@@ -21610,7 +21617,8 @@ some limitations. A few which are worth being aware of are:
Commands:: (or if you are already familiar with `gawk' internals),
you will realize that much of the internal manipulation of data in
`gawk', as in many interpreters, is done on a stack. `Op_push',
- `Op_pop', etc., are the "bread and butter" of most `gawk' code.
+ `Op_pop', and the like, are the "bread and butter" of most `gawk'
+ code.
Unfortunately, as of now, the `gawk' debugger does not allow you
to examine the stack's contents. That is, the intermediate
@@ -21622,7 +21630,7 @@ some limitations. A few which are worth being aware of are:
* There is no way to look "inside" the process of compiling regular
expressions to see if you got it right. As an `awk' programmer,
- you are expected to know what `/[^[:alnum:][:blank:]]/' means.
+ you are expected to know the meaning of `/[^[:alnum:][:blank:]]/'.
* The `gawk' debugger is designed to be used by running a program
(with all its parameters) on the command line, as described in
@@ -21666,17 +21674,17 @@ File: gawk.info, Node: Debugging Summary, Prev: Limitations, Up: Debugger

File: gawk.info, Node: Arbitrary Precision Arithmetic, Next: Dynamic Extensions, Prev: Debugger, Up: Top
-15 Arithmetic and Arbitrary Precision Arithmetic with `gawk'
+15 Arithmetic and Arbitrary-Precision Arithmetic with `gawk'
************************************************************
This major node introduces some basic concepts relating to how
computers do arithmetic and defines some important terms. It then
proceeds to describe floating-point arithmetic, which is what `awk'
-uses for all its computations, including a discussion of arbitrary
-precision floating point arithmetic, which is a feature available only
-in `gawk'. It continues on to present arbitrary precision integers, and
-concludes with a description of some points where `gawk' and the POSIX
-standard are not quite in agreement.
+uses for all its computations, including a discussion of
+arbitrary-precision floating-point arithmetic, which is a feature
+available only in `gawk'. It continues on to present
+arbitrary-precision integers, and concludes with a description of some
+points where `gawk' and the POSIX standard are not quite in agreement.
NOTE: Most users of `gawk' can safely skip this chapter. But if
you want to do scientific calculations with `gawk', this is the
@@ -21736,37 +21744,37 @@ Integer arithmetic
In computers, integer values come in two flavors: "signed" and
"unsigned". Signed values may be negative or positive, whereas
- unsigned values are always positive (that is, greater than or equal
+ unsigned values are always positive (i.e., greater than or equal
to zero).
In computer systems, integer arithmetic is exact, but the possible
range of values is limited. Integer arithmetic is generally
- faster than floating point arithmetic.
+ faster than floating-point arithmetic.
-Floating point arithmetic
+Floating-point arithmetic
Floating-point numbers represent what were called in school "real"
- numbers; i.e., those that have a fractional part, such as
- 3.1415927. The advantage to floating-point numbers is that they
+ numbers (i.e., those that have a fractional part, such as
+ 3.1415927). The advantage to floating-point numbers is that they
can represent a much larger range of values than can integers.
The disadvantage is that there are numbers that they cannot
represent exactly.
- Modern systems support floating point arithmetic in hardware, with
+ Modern systems support floating-point arithmetic in hardware, with
a limited range of values. There are software libraries that allow
- the use of arbitrary precision floating point calculations.
+ the use of arbitrary-precision floating-point calculations.
- POSIX `awk' uses "double precision" floating-point numbers, which
- can hold more digits than "single precision" floating-point
- numbers. `gawk' has facilities for performing arbitrary precision
- floating point arithmetic, which we describe in more detail
+ POSIX `awk' uses "double-precision" floating-point numbers, which
+ can hold more digits than "single-precision" floating-point
+ numbers. `gawk' has facilities for performing arbitrary-precision
+ floating-point arithmetic, which we describe in more detail
shortly.
- Computers work with integer and floating point values of different
-ranges. Integer values are usually either 32 or 64 bits in size. Single
-precision floating point values occupy 32 bits, whereas double precision
-floating point values occupy 64 bits. Floating point values are always
-signed. The possible ranges of values are shown in *note
-table-numeric-ranges::.
+ Computers work with integer and floating-point values of different
+ranges. Integer values are usually either 32 or 64 bits in size.
+Single-precision floating-point values occupy 32 bits, whereas
+double-precision floating-point values occupy 64 bits. Floating-point
+values are always signed. The possible ranges of values are shown in
+*note table-numeric-ranges::.
Numeric representation Minimum value Maximum value
---------------------------------------------------------------------------
@@ -21774,14 +21782,14 @@ Numeric representation Minimum value Maximum value
32-bit unsigned integer 0 4,294,967,295
64-bit signed integer -9,223,372,036,854,775,8089,223,372,036,854,775,807
64-bit unsigned integer 0 18,446,744,073,709,551,615
-Single precision `1.175494e-38' `3.402823e+38'
+Single-precision `1.175494e-38' `3.402823e+38'
floating point
(approximate)
-Double precision `2.225074e-308' `1.797693e+308'
+Double-precision `2.225074e-308' `1.797693e+308'
floating point
(approximate)
-Table 15.1: Value Ranges for Different Numeric Representations
+Table 15.1: Value ranges for different numeric representations
---------- Footnotes ----------
@@ -21790,7 +21798,7 @@ Table 15.1: Value Ranges for Different Numeric Representations

File: gawk.info, Node: Math Definitions, Next: MPFR features, Prev: Computer Arithmetic, Up: Arbitrary Precision Arithmetic
-15.2 Other Stuff To Know
+15.2 Other Stuff to Know
========================
The rest of this major node uses a number of terms. Here are some
@@ -21849,7 +21857,7 @@ material here.
are provided later.
"Significand"
- A floating point value consists the significand multiplied by 10
+ A floating-point value consists the significand multiplied by 10
to the power of the exponent. For example, in `1.2345e67', the
significand is `1.2345'.
@@ -21865,10 +21873,10 @@ information on some of those terms.
On modern systems, floating-point hardware uses the representation
and operations defined by the IEEE 754 standard. Three of the standard
-IEEE 754 types are 32-bit single precision, 64-bit double precision and
-128-bit quadruple precision. The standard also specifies extended
+IEEE 754 types are 32-bit single precision, 64-bit double precision,
+and 128-bit quadruple precision. The standard also specifies extended
precision formats to allow greater precisions and larger exponent
-ranges. (`awk' uses only the 64-bit double precision format.)
+ranges. (`awk' uses only the 64-bit double-precision format.)
*note table-ieee-formats:: lists the precision and exponent field
values for the basic IEEE 754 binary formats:
@@ -21880,7 +21888,7 @@ Single 32 24 -126 +127
Double 64 53 -1022 +1023
Quadruple 128 113 -16382 +16383
-Table 15.2: Basic IEEE Format Values
+Table 15.2: Basic IEEE format values
NOTE: The precision numbers include the implied leading one that
gives them one extra bit of significand.
@@ -21893,13 +21901,13 @@ paraphrased, and for the examples.

File: gawk.info, Node: MPFR features, Next: FP Math Caution, Prev: Math Definitions, Up: Arbitrary Precision Arithmetic
-15.3 Arbitrary Precision Arithmetic Features In `gawk'
+15.3 Arbitrary-Precision Arithmetic Features in `gawk'
======================================================
-By default, `gawk' uses the double precision floating-point values
+By default, `gawk' uses the double-precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do so, `gawk' uses the `http://www.mpfr.org GNU MPFR' and
-GNU MP (http://gmplib.org) (GMP) libraries for arbitrary precision
+compiled to do so, `gawk' uses the GNU MPFR (http://www.mpfr.org) and
+GNU MP (http://gmplib.org) (GMP) libraries for arbitrary-precision
arithmetic on numbers. You can see if MPFR support is available like
so:
@@ -21931,7 +21939,7 @@ more information.

File: gawk.info, Node: FP Math Caution, Next: Arbitrary Precision Integers, Prev: MPFR features, Up: Arbitrary Precision Arithmetic
-15.4 Floating Point Arithmetic: Caveat Emptor!
+15.4 Floating-Point Arithmetic: Caveat Emptor!
==============================================
Math class is tough! -- Teen Talk Barbie, July 1992
@@ -21965,7 +21973,7 @@ in computer science.

File: gawk.info, Node: Inexactness of computations, Next: Getting Accuracy, Up: FP Math Caution
-15.4.1 Floating Point Arithmetic Is Not Exact
+15.4.1 Floating-Point Arithmetic Is Not Exact
---------------------------------------------
Binary floating-point representations and arithmetic are inexact.
@@ -21973,9 +21981,10 @@ Simple values like 0.1 cannot be precisely represented using binary
floating-point numbers, and the limited precision of floating-point
numbers means that slight changes in the order of operations or the
precision of intermediate storage can change the result. To make
-matters worse, with arbitrary precision floating-point, you can set the
-precision before starting a computation, but then you cannot be sure of
-the number of significant decimal places in the final result.
+matters worse, with arbitrary-precision floating-point arithmetic, you
+can set the precision before starting a computation, but then you
+cannot be sure of the number of significant decimal places in the final
+result.
* Menu:
@@ -21997,8 +22006,8 @@ the following example:
y = 0.425
Unlike the number in `y', the number stored in `x' is exactly
-representable in binary since it can be written as a finite sum of one
-or more fractions whose denominators are all powers of two. When
+representable in binary because it can be written as a finite sum of
+one or more fractions whose denominators are all powers of two. When
`gawk' reads a floating-point number from program source, it
automatically rounds that number to whatever precision your machine
supports. If you try to print the numeric content of a variable using
@@ -22031,7 +22040,7 @@ work like you would expect:
The general wisdom when comparing floating-point values is to see if
they are within some small range of each other (called a "delta", or
"tolerance"). You have to decide how small a delta is important to
-you. Code to do this looks something like this:
+you. Code to do this looks something like the following:
delta = 0.00001 # for example
difference = abs(a) - abs(b) # subtract the two values
@@ -22051,7 +22060,7 @@ File: gawk.info, Node: Errors accumulate, Prev: Comparing FP Values, Up: Inex
The loss of accuracy during a single computation with floating-point
numbers usually isn't enough to worry about. However, if you compute a
-value which is the result of a sequence of floating point operations,
+value which is the result of a sequence of floating-point operations,
the error can accumulate and greatly affect the computation itself.
Here is an attempt to compute the value of pi using one of its many
series representations:
@@ -22094,10 +22103,10 @@ representations yield an unexpected result:

File: gawk.info, Node: Getting Accuracy, Next: Try To Round, Prev: Inexactness of computations, Up: FP Math Caution
-15.4.2 Getting The Accuracy You Need
+15.4.2 Getting the Accuracy You Need
------------------------------------
-Can arbitrary precision arithmetic give exact results? There are no
+Can arbitrary-precision arithmetic give exact results? There are no
easy answers. The standard rules of algebra often do not apply when
using floating-point arithmetic. Among other things, the distributive
and associative laws do not hold completely, and order of operation may
@@ -22105,7 +22114,7 @@ be important for your computation. Rounding error, cumulative precision
loss and underflow are often troublesome.
When `gawk' tests the expressions `0.1 + 12.2' and `12.3' for
-equality using the machine double precision arithmetic, it decides that
+equality using the machine double-precision arithmetic, it decides that
they are not equal! (*Note Comparing FP Values::.) You can get the
result you want by increasing the precision; 56 bits in this case does
the job:
@@ -22124,15 +22133,15 @@ value of `PREC':
forget that the finite number of bits used to store the value is often
just an approximation after proper rounding. The test for equality
succeeds if and only if _all_ bits in the two operands are exactly the
-same. Since this is not necessarily true after floating-point
+same. Because this is not necessarily true after floating-point
computations with a particular precision and effective rounding mode, a
straight test for equality may not work. Instead, compare the two
numbers to see if they are within the desirable delta of each other.
In applications where 15 or fewer decimal places suffice, hardware
-double precision arithmetic can be adequate, and is usually much faster.
+double-precision arithmetic can be adequate, and is usually much faster.
But you need to keep in mind that every floating-point operation can
-suffer a new rounding error with catastrophic consequences as
+suffer a new rounding error with catastrophic consequences, as
illustrated by our earlier attempt to compute the value of pi. Extra
precision can greatly enhance the stability and the accuracy of your
computation in such cases.
@@ -22154,10 +22163,10 @@ hand is often the correct approach in such situations.

File: gawk.info, Node: Try To Round, Next: Setting precision, Prev: Getting Accuracy, Up: FP Math Caution
-15.4.3 Try A Few Extra Bits of Precision and Rounding
+15.4.3 Try a Few Extra Bits of Precision and Rounding
-----------------------------------------------------
-Instead of arbitrary precision floating-point arithmetic, often all you
+Instead of arbitrary-precision floating-point arithmetic, often all you
need is an adjustment of your logic or a different order for the
operations in your calculation. The stability and the accuracy of the
computation of pi in the earlier example can be enhanced by using the
@@ -22165,7 +22174,7 @@ following simple algebraic transformation:
(sqrt(x * x + 1) - 1) / x == x / (sqrt(x * x + 1) + 1)
-After making this, change the program converges to pi in under 30
+After making this change, the program converges to pi in under 30
iterations:
$ gawk -f pi2.awk
@@ -22181,7 +22190,7 @@ iterations:

File: gawk.info, Node: Setting precision, Next: Setting the rounding mode, Prev: Try To Round, Up: FP Math Caution
-15.4.4 Setting The Precision
+15.4.4 Setting the Precision
----------------------------
`gawk' uses a global working precision; it does not keep track of the
@@ -22195,13 +22204,13 @@ binary format.
`PREC' IEEE 754 Binary Format
---------------------------------------------------
-`"half"' 16-bit half-precision.
-`"single"' Basic 32-bit single precision.
-`"double"' Basic 64-bit double precision.
-`"quad"' Basic 128-bit quadruple precision.
-`"oct"' 256-bit octuple precision.
+`"half"' 16-bit half-precision
+`"single"' Basic 32-bit single precision
+`"double"' Basic 64-bit double precision
+`"quad"' Basic 128-bit quadruple precision
+`"oct"' 256-bit octuple precision
-Table 15.3: Predefined Precision Strings For `PREC'
+Table 15.3: Predefined precision strings for `PREC'
The following example illustrates the effects of changing precision
on arithmetic operations:
@@ -22238,7 +22247,7 @@ on arithmetic operations:

File: gawk.info, Node: Setting the rounding mode, Prev: Setting precision, Up: FP Math Caution
-15.4.5 Setting The Rounding Mode
+15.4.5 Setting the Rounding Mode
--------------------------------
The `ROUNDMODE' variable provides program level control over the
@@ -22254,13 +22263,13 @@ Round toward zero `roundTowardZero' `"Z"' or `"z"'
Round to nearest, ties away `roundTiesToAway' `"A"' or `"a"'
from zero
-Table 15.4: `gawk' Rounding Modes
+Table 15.4: `gawk' rounding modes
`ROUNDMODE' has the default value `"N"', which selects the IEEE 754
rounding mode `roundTiesToEven'. In *note Table 15.4:
table-gawk-rounding-modes, the value `"A"' selects `roundTiesToAway'.
This is only available if your version of the MPFR library supports it;
-otherwise setting `ROUNDMODE' to `"A"' has no effect.
+otherwise, setting `ROUNDMODE' to `"A"' has no effect.
The default mode `roundTiesToEven' is the most preferred, but the
least intuitive. This method does the obvious thing for most values, by
@@ -22328,16 +22337,16 @@ to round halfway cases for `printf'.

File: gawk.info, Node: Arbitrary Precision Integers, Next: POSIX Floating Point Problems, Prev: FP Math Caution, Up: Arbitrary Precision Arithmetic
-15.5 Arbitrary Precision Integer Arithmetic with `gawk'
+15.5 Arbitrary-Precision Integer Arithmetic with `gawk'
=======================================================
When given the `-M' option, `gawk' performs all integer arithmetic
-using GMP arbitrary precision integers. Any number that looks like an
-integer in a source or data file is stored as an arbitrary precision
+using GMP arbitrary-precision integers. Any number that looks like an
+integer in a source or data file is stored as an arbitrary-precision
integer. The size of the integer is limited only by the available
memory. For example, the following computes 5^4^3^2, the result of
-which is beyond the limits of ordinary hardware double precision
-floating point values:
+which is beyond the limits of ordinary hardware double-precision
+floating-point values:
$ gawk -M 'BEGIN {
> x = 5^4^3^2
@@ -22347,10 +22356,10 @@ floating point values:
-| number of digits = 183231
-| 62060698786608744707 ... 92256259918212890625
- If instead you were to compute the same value using arbitrary
-precision floating-point values, the precision needed for correct
-output (using the formula `prec = 3.322 * dps'), would be 3.322 x
-183231, or 608693.
+ If instead you were to compute the same value using
+arbitrary-precision floating-point values, the precision needed for
+correct output (using the formula `prec = 3.322 * dps'), would be 3.322
+x 183231, or 608693.
The result from an arithmetic operation with an integer and a
floating-point value is a floating-point value with a precision equal
@@ -22373,10 +22382,10 @@ case), or replace the floating-point constant `2.0' with an integer, to
perform all computations using integer arithmetic to get the correct
output.
- Sometimes `gawk' must implicitly convert an arbitrary precision
-integer into an arbitrary precision floating-point value. This is
+ Sometimes `gawk' must implicitly convert an arbitrary-precision
+integer into an arbitrary-precision floating-point value. This is
primarily because the MPFR library does not always provide the relevant
-interface to process arbitrary precision integers or mixed-mode numbers
+interface to process arbitrary-precision integers or mixed-mode numbers
as needed by an operation or function. In such a case, the precision is
set to the minimum value necessary for exact conversion, and the working
precision is not used for this purpose. If this is not what you need or
@@ -22390,8 +22399,8 @@ floating-point value to begin with:
gawk -M 'BEGIN { n = 13.0; print n % 2.0 }'
- Note that for the particular example above, it is likely best to
-just use the following:
+ Note that for this particular example, it is likely best to just use
+the following:
gawk -M 'BEGIN { n = 13; print n % 2 }'
@@ -22417,12 +22426,12 @@ that `awk' only understands decimal numbers (base 10), and not octal
interpreted to imply that `awk' should support additional features.
These features are:
- * Interpretation of floating point data values specified in
+ * Interpretation of floating-point data values specified in
hexadecimal notation (e.g., `0xDEADBEEF'). (Note: data values,
_not_ source code constants.)
- * Support for the special IEEE 754 floating point values "Not A
- Number" (NaN), positive Infinity ("inf") and negative Infinity
+ * Support for the special IEEE 754 floating-point values "Not A
+ Number" (NaN), positive Infinity ("inf"), and negative Infinity
("-inf"). In particular, the format for these values is as
specified by the ISO 1999 C standard, which ignores case and can
allow implementation-dependent additional characters after the
@@ -22431,9 +22440,9 @@ These features are:
The first problem is that both of these are clear changes to
historical practice:
- * The `gawk' maintainer feels that supporting hexadecimal floating
- point values, in particular, is ugly, and was never intended by the
- original designers to be part of the language.
+ * The `gawk' maintainer feels that supporting hexadecimal
+ floating-point values, in particular, is ugly, and was never
+ intended by the original designers to be part of the language.
* Allowing completely alphabetic strings to have valid numeric
values is also a very severe departure from historical practice.
@@ -22444,10 +22453,10 @@ interpretation of the standard, which requires a certain amount of
intended by the standard developers. In other words, "we see how you
got where you are, but we don't think that that's where you want to be."
- Recognizing the above issues, but attempting to provide compatibility
+ Recognizing these issues, but attempting to provide compatibility
with the earlier versions of the standard, the 2008 POSIX standard
added explicit wording to allow, but not require, that `awk' support
-hexadecimal floating point values and special values for "Not A Number"
+hexadecimal floating-point values and special values for "Not A Number"
and infinity.
Although the `gawk' maintainer continues to feel that providing
@@ -22496,11 +22505,11 @@ File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Prob
============
* Most computer arithmetic is done using either integers or
- floating-point values. Standard `awk' uses double precision
+ floating-point values. Standard `awk' uses double-precision
floating-point values.
- * In the early 1990's, Barbie mistakenly said "Math class is tough!"
- While math isn't tough, floating-point arithmetic isn't the same
+ * In the early 1990s, Barbie mistakenly said "Math class is tough!"
+ Although math isn't tough, floating-point arithmetic isn't the same
as pencil and paper math, and care must be taken:
- Not all numbers can be represented exactly.
@@ -22521,7 +22530,7 @@ File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Prob
set the precision in bits, and `ROUNDMODE' to set the IEEE 754
rounding mode.
- * With `-M', `gawk' performs arbitrary precision integer arithmetic
+ * With `-M', `gawk' performs arbitrary-precision integer arithmetic
using the GMP library. This is faster and more space efficient
than using MPFR for the same calculations.
@@ -22533,7 +22542,7 @@ File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Prob
results from floating-point arithmetic. The lesson to remember is
that floating-point arithmetic is always more complex than
arithmetic using pencil and paper. In order to take advantage of
- the power of computer floating-point, you need to know its
+ the power of computer floating point, you need to know its
limitations and work within them. For most casual use of
floating-point arithmetic, you will often get the expected result
if you simply round the display of your final results to the
@@ -22595,8 +22604,8 @@ routines that could be of use. As with most software, "the sky is the
limit;" if you can imagine something that you might want to do and can
write in C or C++, you can write an extension to do it!
- Extensions are written in C or C++, using the "Application
-Programming Interface" (API) defined for this purpose by the `gawk'
+ Extensions are written in C or C++, using the "application
+programming interface" (API) defined for this purpose by the `gawk'
developers. The rest of this major node explains the facilities that
the API provides and how to use them, and presents a small example
extension. In addition, it documents the sample extensions included in
@@ -22627,7 +22636,7 @@ the symbol exists in the global scope. Something like this is enough:

File: gawk.info, Node: Extension Mechanism Outline, Next: Extension API Description, Prev: Plugin License, Up: Dynamic Extensions
-16.3 At A High Level How It Works
+16.3 How It Works at a High Level
=================================
Communication between `gawk' and an extension is two-way. First, when
@@ -22659,7 +22668,7 @@ figure-load-extension::.
+-------+-+---+-+---+-+------------------+--------------------+
gawk Main Program Address Space Extension
-Figure 16.1: Loading The Extension
+Figure 16.1: Loading the extension
The extension can call functions inside `gawk' through these
function pointers, at runtime, without needing (link-time) access to
@@ -22679,7 +22688,7 @@ figure-register-new-function::.
+-------+-+---+-+---+-+------------------+--------------+-+---+
gawk Main Program Address Space Extension
-Figure 16.2: Registering A New Function
+Figure 16.2: Registering a new function
In the other direction, the extension registers its new functions
with `gawk' by passing function pointers to the functions that provide
@@ -22700,7 +22709,7 @@ calling convention. This is shown in *note figure-call-new-function::.
+-------+-+---+-+---+-+------------------+--------------+-+---+
gawk Main Program Address Space Extension
-Figure 16.3: Calling The New Function
+Figure 16.3: Calling the new function
The `do_XXX()' function, in turn, then uses the function pointers in
the API `struct' to do its work, such as updating variables or arrays,
@@ -22773,17 +22782,19 @@ operations:
* Allocating, reallocating, and releasing memory.
* Registration functions. You may register:
- - extension functions,
- - exit callbacks,
+ - Extension functions
- - a version string,
+ - Exit callbacks
- - input parsers,
+ - A version string
- - output wrappers,
+ - Input parsers
+
+ - Output wrappers
+
+ - Two-way processors
- - and two-way processors.
All of these are discussed in detail, later in this major node.
* Printing fatal, warning, and "lint" warning messages.
@@ -22815,8 +22826,8 @@ operations:
Some points about using the API:
- * The following types and/or macros and/or functions are referenced
- in `gawkapi.h'. For correct use, you must therefore include the
+ * The following types, macros, and/or functions are referenced in
+ `gawkapi.h'. For correct use, you must therefore include the
corresponding standard header file _before_ including `gawkapi.h':
C Entity Header File
@@ -22855,7 +22866,7 @@ operations:
* The API defines several simple `struct's that map values as seen
from `awk'. A value can be a `double', a string, or an array (as
in multidimensional arrays, or when creating a new array). String
- values maintain both pointer and length since embedded NUL
+ values maintain both pointer and length, because embedded NUL
characters are allowed.
NOTE: By intent, strings are maintained using the current
@@ -22876,16 +22887,16 @@ operations:
message (such as "scalar passed where array expected").
- While you may call the API functions by using the function pointers
-directly, the interface is not so pretty. To make extension code look
-more like regular code, the `gawkapi.h' header file defines several
+ You may call the API functions by using the function pointers
+directly, but the interface is not so pretty. To make extension code
+look more like regular code, the `gawkapi.h' header file defines several
macros that you should use in your code. This minor node presents the
macros as if they were functions.

File: gawk.info, Node: General Data Types, Next: Memory Allocation Functions, Prev: Extension API Functions Introduction, Up: Extension API Description
-16.4.2 General Purpose Data Types
+16.4.2 General-Purpose Data Types
---------------------------------
I have a true love/hate relationship with unions. -- Arnold
@@ -22894,10 +22905,10 @@ File: gawk.info, Node: General Data Types, Next: Memory Allocation Functions,
That's the thing about unions: the compiler will arrange things so
they can accommodate both love and hate. -- Chet Ramey
- The extension API defines a number of simple types and structures
-for general purpose use. Additional, more specialized, data structures
-are introduced in subsequent minor nodes, together with the functions
-that use them.
+ The extension API defines a number of simple types and structures for
+general-purpose use. Additional, more specialized, data structures are
+introduced in subsequent minor nodes, together with the functions that
+use them.
`typedef void *awk_ext_id_t;'
A value of this type is received from `gawk' when an extension is
@@ -22922,8 +22933,8 @@ that use them.
`} awk_string_t;'
This represents a mutable string. `gawk' owns the memory pointed
to if it supplied the value. Otherwise, it takes ownership of the
- memory pointed to. *Such memory must come from calling one of the
- `gawk_malloc()', `gawk_calloc()', or `gawk_realloc()' functions!*
+ memory pointed to. _Such memory must come from calling one of the
+ `gawk_malloc()', `gawk_calloc()', or `gawk_realloc()' functions!_
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -22964,13 +22975,13 @@ that use them.
`typedef void *awk_scalar_t;'
Scalars can be represented as an opaque type. These values are
obtained from `gawk' and then passed back into it. This is
- discussed in a general fashion below, and in more detail in *note
- Symbol table by cookie::.
+ discussed in a general fashion in the text following this list,
+ and in more detail in *note Symbol table by cookie::.
`typedef void *awk_value_cookie_t;'
A "value cookie" is an opaque type representing a cached value.
- This is also discussed in a general fashion below, and in more
- detail in *note Cached values::.
+ This is also discussed in a general fashion in the text following
+ this list, and in more detail in *note Cached values::.
Scalar values in `awk' are either numbers or strings. The
@@ -22978,7 +22989,7 @@ that use them.
indicates what is in the `union'.
Representing numbers is easy--the API uses a C `double'. Strings
-require more work. Since `gawk' allows embedded NUL bytes in string
+require more work. Because `gawk' allows embedded NUL bytes in string
values, a string must be represented as a pair containing a
data-pointer and length. This is the `awk_string_t' type.
@@ -22990,15 +23001,14 @@ Manipulation::.
The various macros listed earlier make it easier to use the elements
of the `union' as if they were fields in a `struct'; this is a common
-coding practice in C. Such code is easier to write and to read,
-however it remains _your_ responsibility to make sure that the
-`val_type' member correctly reflects the type of the value in the
-`awk_value_t'.
+coding practice in C. Such code is easier to write and to read, but it
+remains _your_ responsibility to make sure that the `val_type' member
+correctly reflects the type of the value in the `awk_value_t'.
Conceptually, the first three members of the `union' (number, string,
and array) are all that is needed for working with `awk' values.
-However, since the API provides routines for accessing and changing the
-value of global scalar variables only by using the variable's name,
+However, because the API provides routines for accessing and changing
+the value of global scalar variables only by using the variable's name,
there is a performance penalty: `gawk' must find the variable each time
it is accessed and changed. This turns out to be a real issue, not
just a theoretical one.
@@ -23036,7 +23046,7 @@ File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Function
The API provides a number of "memory allocation" functions for
allocating memory that can be passed to `gawk', as well as a number of
convenience macros. This node presents them all as function
-prototypes, in the way that extension code would use them.
+prototypes, in the way that extension code would use them:
`void *gawk_malloc(size_t size);'
Call the correct version of `malloc()' to allocate storage that may
@@ -23073,8 +23083,8 @@ as if they were procedure calls that do not return a value.
The pointer variable to point at the allocated storage.
`type'
- The type of the pointer variable, used to create a cast for
- the call to `gawk_malloc()'.
+ The type of the pointer variable. This is used to create a
+ cast for the call to `gawk_malloc()'.
`size'
The total number of bytes to be allocated.
@@ -23112,7 +23122,7 @@ File: gawk.info, Node: Constructor Functions, Next: Registration Functions, P
The API provides a number of "constructor" functions for creating
string and numeric values, as well as a number of convenience macros.
This node presents them all as function prototypes, in the way that
-extension code would use them.
+extension code would use them:
`static inline awk_value_t *'
`make_const_string(const char *string, size_t length, awk_value_t *result)'
@@ -23189,7 +23199,7 @@ Extension functions are described by the following record:
functionality. The function must fill in `*result' with either a
number or a string. `gawk' takes ownership of any string memory.
As mentioned earlier, string memory *must* come from one of
- `gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'.
+ `gawk_malloc()', `gawk_calloc()', or `gawk_realloc()'.
The `num_actual_args' argument tells the C function how many
actual parameters were passed from the calling `awk' code.
@@ -23222,7 +23232,7 @@ An "exit callback" function is a function that `gawk' calls before it
exits. Such functions are useful if you have general "cleanup" tasks
that should be performed in your extension (such as closing database
connections or other resource deallocations). You can register such a
-function with `gawk' using the following function.
+function with `gawk' using the following function:
`void awk_atexit(void (*funcp)(void *data, int exit_status),'
` void *arg0);'
@@ -23238,7 +23248,7 @@ function with `gawk' using the following function.
A pointer to private data which `gawk' saves in order to pass
to the function pointed to by `funcp'.
- Exit callback functions are called in Last-In-First-Out (LIFO)
+ Exit callback functions are called in last-in-first-out (LIFO)
order--that is, in the reverse order in which they are registered with
`gawk'.
@@ -23252,8 +23262,9 @@ You can register a version string which indicates the name and version
of your extension, with `gawk', as follows:
`void register_ext_version(const char *version);'
- Register the string pointed to by `version' with `gawk'. `gawk'
- does _not_ copy the `version' string, so it should not be changed.
+ Register the string pointed to by `version' with `gawk'. Note
+ that `gawk' does _not_ copy the `version' string, so it should not
+ be changed.
`gawk' prints all registered extension version strings when it is
invoked with the `--version' option.
@@ -23326,7 +23337,7 @@ used for `RT', if any.
2. When your extension is loaded, register your input parser with
`gawk' using the `register_input_parser()' API function (described
- below).
+ next).
An `awk_input_buf_t' looks like this:
@@ -23364,14 +23375,14 @@ decide if the input parser should be used for the file. The decision
can be made based upon `gawk' state (the value of a variable defined
previously by the extension and set by `awk' code), the name of the
file, whether or not the file descriptor is valid, the information in
-the `struct stat', or any combination of the above.
+the `struct stat', or any combination of these factors.
Once `XXX_can_take_file()' has returned true, and `gawk' has decided
to use your input parser, it calls `XXX_take_control_of()'. That
function then fills one of either the `get_record' field or the
`read_func' field in the `awk_input_buf_t'. It must also ensure that
-`fd' is _not_ set to `INVALID_HANDLE'. All of the fields that may be
-filled by `XXX_take_control_of()' are as follows:
+`fd' is _not_ set to `INVALID_HANDLE'. The following list describes
+the fields that may be filled by `XXX_take_control_of()':
`void *opaque;'
This is used to hold any state information needed by the input
@@ -23385,13 +23396,13 @@ filled by `XXX_take_control_of()' are as follows:
` size_t *rt_len);'
This function pointer should point to a function that creates the
input records. Said function is the core of the input parser.
- Its behavior is described below.
+ Its behavior is described in the text following this list.
`ssize_t (*read_func)();'
This function pointer should point to function that has the same
behavior as the standard POSIX `read()' system call. It is an
alternative to the `get_record' pointer. Its behavior is also
- described below.
+ described in the text following this list.
`void (*close_func)(struct awk_input *iobuf);'
This function pointer should point to a function that does the
@@ -23516,8 +23527,8 @@ an extension to take over the output to a file opened with the `>' or
The function pointed to by this field is called when `gawk'
decides to let the output wrapper take control of the file. It
should fill in appropriate members of the `awk_output_buf_t'
- structure, as described below, and return true if successful,
- false otherwise.
+ structure, as described next, and return true if successful, false
+ otherwise.
`awk_const struct output_wrapper *awk_const next;'
This is for use by `gawk'; therefore it is marked `awk_const' so
@@ -23648,8 +23659,8 @@ File: gawk.info, Node: Printing Messages, Next: Updating `ERRNO', Prev: Regis
------------------------
You can print different kinds of warning messages from your extension,
-as described below. Note that for these functions, you must pass in
-the extension id received from `gawk' when the extension was loaded.(1)
+as described here. Note that for these functions, you must pass in the
+extension id received from `gawk' when the extension was loaded:(1)
`void fatal(awk_ext_id_t id, const char *format, ...);'
Print a message and then cause `gawk' to exit immediately.
@@ -23709,7 +23720,7 @@ message, or reissue the request for the actual value type, as
appropriate. This behavior is summarized in *note
table-value-types-returned::.
- Type of Actual Value:
+ Type of Actual Value
--------------------------------------------------------------------------
String Number Array Undefined
@@ -23719,12 +23730,12 @@ table-value-types-returned::.
be converted,
else false
Type Array false false Array false
-Requested: Scalar Scalar Scalar false false
+Requested Scalar Scalar Scalar false false
Undefined String Number Array Undefined
Value false false false false
Cookie
-Table 16.1: API Value Types Returned
+Table 16.1: API value types returned

File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Requesting Values, Up: Extension API Description
@@ -23805,8 +23816,8 @@ cannot change any of those variables.
CAUTION: It is possible for the lookup of `PROCINFO' to fail. This
happens if the `awk' program being run does not reference
- `PROCINFO'; in this case `gawk' doesn't bother to create the array
- and populate it.
+ `PROCINFO'; in this case, `gawk' doesn't bother to create the
+ array and populate it.

File: gawk.info, Node: Symbol table by cookie, Next: Cached values, Prev: Symbol table by name, Up: Symbol Table Access
@@ -23817,9 +23828,9 @@ File: gawk.info, Node: Symbol table by cookie, Next: Cached values, Prev: Sym
A "scalar cookie" is an opaque handle that provides access to a global
variable or array. It is an optimization that avoids looking up
variables in `gawk''s symbol table every time access is needed. This
-was discussed earlier, in *note General Data Types::.
+was discussed earlier in *note General Data Types::.
- The following functions let you work with scalar cookies.
+ The following functions let you work with scalar cookies:
`awk_bool_t sym_lookup_scalar(awk_scalar_t cookie,'
` awk_valtype_t wanted,'
@@ -23860,7 +23871,7 @@ variable based on the result of that evaluation, like so:
This code looks (and is) simple and straightforward. So what's the
problem?
- Consider what happens if `awk'-level code associated with your
+ Well, consider what happens if `awk'-level code associated with your
extension calls the `magic()' function (implemented in C by
`do_magic()'), once per record, while processing hundreds of thousands
or millions of records. The `MAGIC_VAR' variable is looked up in the
@@ -23935,7 +23946,7 @@ variables using `sym_update()' or `sym_update_scalar()', as you like.
However, you can understand the point of cached values if you
remember that _every_ string value's storage _must_ come from
-`gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'. If you have 20
+`gawk_malloc()', `gawk_calloc()', or `gawk_realloc()'. If you have 20
variables, all of which have the same string value, you must create 20
identical copies of the string.(1)
@@ -23947,8 +23958,8 @@ follows:
`awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);'
Create a cached string or numeric value from `value' for efficient
later assignment. Only values of type `AWK_NUMBER' and
- `AWK_STRING' are allowed. Any other type is rejected. While
- `AWK_UNDEFINED' could be allowed, doing so would result in
+ `AWK_STRING' are allowed. Any other type is rejected.
+ `AWK_UNDEFINED' could be allowed, but doing so would result in
inferior performance.
`awk_bool_t release_value(awk_value_cookie_t vc);'
@@ -23995,7 +24006,7 @@ of variables:
...
}
-Using value cookies in this way saves considerable storage, since all of
+Using value cookies in this way saves considerable storage, as all of
`VAR1' through `VAR100' share the same value.
You might be wondering, "Is this sharing problematic? What happens
@@ -24043,7 +24054,7 @@ arrays of arrays (*note General Data Types::).
---------- Footnotes ----------
- (1) Okay, the only data structure.
+ (1) OK, the only data structure.

File: gawk.info, Node: Array Data Types, Next: Array Functions, Up: Array Manipulation
@@ -24051,7 +24062,7 @@ File: gawk.info, Node: Array Data Types, Next: Array Functions, Up: Array Man
16.4.11.1 Array Data Types
..........................
-The data types associated with arrays are listed below.
+The data types associated with arrays are as follows:
`typedef void *awk_array_t;'
If you request the value of an array variable, you get back an
@@ -24196,7 +24207,7 @@ File: gawk.info, Node: Flattening Arrays, Next: Creating Arrays, Prev: Array
16.4.11.3 Working With All The Elements of an Array
...................................................
-To "flatten" an array is create a structure that represents the full
+To "flatten" an array is to create a structure that represents the full
array in a fashion that makes it easy for C code to traverse the entire
array. Test code in `extension/testext.c' does this, and also serves
as a nice example showing how to use the APIs.
@@ -24342,7 +24353,7 @@ this code) once you have called `release_flattened_array()':
goto out;
}
- Finally, since everything was successful, the function sets the
+ Finally, because everything was successful, the function sets the
return value to success, and returns:
make_number(1.0, result);
@@ -24377,7 +24388,7 @@ them and manipulate them.
There are two important points about creating arrays from extension
code:
- 1. You must install a new array into `gawk''s symbol table
+ * You must install a new array into `gawk''s symbol table
immediately upon creating it. Once you have done so, you can then
populate the array.
@@ -24391,7 +24402,7 @@ code:
previously existing array using `set_array_element()'. We show
example code shortly.
- 2. Due to gawk internals, after using `sym_update()' to install an
+ * Due to gawk internals, after using `sym_update()' to install an
array into `gawk', you have to retrieve the array cookie from the
value passed in to `sym_update()' before doing anything else with
it, like so:
@@ -24475,7 +24486,7 @@ Note how `a_cookie' is reset from the `array_cookie' field in the
}
}
- Here is sample script that loads the extension and then dumps the
+ Here is a sample script that loads the extension and then dumps the
array:
@load "subarray"
@@ -24614,8 +24625,8 @@ File: gawk.info, Node: Extension API Boilerplate, Prev: Extension API Variable
As mentioned earlier (*note Extension Mechanism Outline::), the function
definitions as presented are really macros. To use these macros, your
extension must provide a small amount of boilerplate code (variables and
-functions) towards the top of your source file, using pre-defined names
-as described below. The boilerplate needed is also provided in comments
+functions) toward the top of your source file, using predefined names
+as described here. The boilerplate needed is also provided in comments
in the `gawkapi.h' header file:
/* Boiler plate code: */
@@ -24689,9 +24700,9 @@ in the `gawkapi.h' header file:
This macro expands to a `dl_load()' function that performs all the
necessary initializations.
- The point of the all the variables and arrays is to let the
-`dl_load()' function (from the `dl_load_func()' macro) do all the
-standard work. It does the following:
+ The point of all the variables and arrays is to let the `dl_load()'
+function (from the `dl_load_func()' macro) do all the standard work. It
+does the following:
1. Check the API versions. If the extension major version does not
match `gawk''s, or if the extension minor version is greater than
@@ -24725,7 +24736,7 @@ File: gawk.info, Node: Extension Example, Next: Extension Samples, Prev: Find
16.6 Example: Some File Functions
=================================
- No matter where you go, there you are. -- Buckaroo Bonzai
+ No matter where you go, there you are. -- Buckaroo Banzai
Two useful functions that are not in `awk' are `chdir()' (so that an
`awk' program can change its directory) and `stat()' (so that an `awk'
@@ -24881,7 +24892,7 @@ Here is the C code for these extensions.(1)
includes the `gawkapi.h' header file which provides the API definitions.
Those are followed by the necessary variable declarations to make use
of the API macros and boilerplate code (*note Extension API
-Boilerplate::).
+Boilerplate::):
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -24918,7 +24929,7 @@ Boilerplate::).
implements it is called `do_foo()'. The function should have two
arguments: the first is an `int' usually called `nargs', that
represents the number of actual arguments for the function. The second
-is a pointer to an `awk_value_t', usually named `result'.
+is a pointer to an `awk_value_t', usually named `result':
/* do_chdir --- provide dynamically loaded chdir() function for gawk */
@@ -24936,11 +24947,11 @@ is a pointer to an `awk_value_t', usually named `result'.
"expecting 1"));
The `newdir' variable represents the new directory to change to,
-retrieved with `get_argument()'. Note that the first argument is
-numbered zero.
+which is retrieved with `get_argument()'. Note that the first argument
+is numbered zero.
If the argument is retrieved successfully, the function calls the
-`chdir()' system call. If the `chdir()' fails, `ERRNO' is updated.
+`chdir()' system call. If the `chdir()' fails, `ERRNO' is updated:
if (get_argument(0, AWK_STRING, & newdir)) {
ret = chdir(newdir.str_value.str);
@@ -25121,7 +25132,7 @@ initialized to point to `lstat()' (instead of `stat()') to get the file
information, in case the file is a symbolic link. However, if there
were three arguments, `statfunc' is set point to `stat()', instead.
- Here is the `do_stat()' function. It starts with variable
+ Here is the `do_stat()' function, which starts with variable
declarations and argument checking:
/* do_stat --- provide a stat() function for gawk */
@@ -25227,7 +25238,7 @@ version.

File: gawk.info, Node: Using Internal File Ops, Prev: Internal File Ops, Up: Extension Example
-16.6.3 Integrating The Extensions
+16.6.3 Integrating the Extensions
---------------------------------
Now that the code is written, it must be possible to add it at runtime
@@ -25239,7 +25250,7 @@ create a GNU/Linux shared library:
$ gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -IIDIR filefuncs.c
$ gcc -o filefuncs.so -shared filefuncs.o
- Once the library exists, it is loaded by using the `@load' keyword.
+ Once the library exists, it is loaded by using the `@load' keyword:
# file testff.awk
@load "filefuncs"
@@ -25300,21 +25311,21 @@ directory and run the program:
---------- Footnotes ----------
- (1) In practice, you would probably want to use the GNU
-Autotools--Automake, Autoconf, Libtool, and `gettext'--to configure and
-build your libraries. Instructions for doing so are beyond the scope of
-this Info file. *Note gawkextlib::, for Internet links to the tools.
+ (1) In practice, you would probably want to use the GNU Autotools
+(Automake, Autoconf, Libtool, and `gettext') to configure and build
+your libraries. Instructions for doing so are beyond the scope of this
+Info file. *Note gawkextlib::, for Internet links to the tools.

File: gawk.info, Node: Extension Samples, Next: gawkextlib, Prev: Extension Example, Up: Dynamic Extensions
-16.7 The Sample Extensions In The `gawk' Distribution
+16.7 The Sample Extensions in the `gawk' Distribution
=====================================================
This minor node provides brief overviews of the sample extensions that
come in the `gawk' distribution. Some of them are intended for
-production use, such the `filefuncs', `readdir' and `inplace'
-extensions. Others mainly provide example code that shows how to use
+production use (e.g., the `filefuncs', `readdir' and `inplace'
+extensions). Others mainly provide example code that shows how to use
the extension API.
* Menu:
@@ -25338,11 +25349,11 @@ the extension API.

File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample Fnmatch, Up: Extension Samples
-16.7.1 File Related Functions
+16.7.1 File-Related Functions
-----------------------------
The `filefuncs' extension provides three different functions, as
-follows: The usage is:
+follows. The usage is:
`@load "filefuncs"'
This is how you load the extension.
@@ -25350,13 +25361,13 @@ follows: The usage is:
`result = chdir("/some/directory")'
The `chdir()' function is a direct hook to the `chdir()' system
call to change the current directory. It returns zero upon
- success or less than zero upon error. In the latter case it
+ success or less than zero upon error. In the latter case, it
updates `ERRNO'.
`result = stat("/some/path", statdata' [`, follow']`)'
The `stat()' function provides a hook into the `stat()' system
call. It returns zero upon success or less than zero upon error.
- In the latter case it updates `ERRNO'.
+ In the latter case, it updates `ERRNO'.
By default, it uses the `lstat()' system call. However, if passed
a third argument, it uses `stat()' instead.
@@ -25399,9 +25410,9 @@ follows: The usage is:
`flags = or(FTS_PHYSICAL, ...)'
`result = fts(pathlist, flags, filedata)'
Walk the file trees provided in `pathlist' and fill in the
- `filedata' array as described below. `flags' is the bitwise OR of
- several predefined values, also described below. Return zero if
- there were no errors, otherwise return -1.
+ `filedata' array as described next. `flags' is the bitwise OR of
+ several predefined values, also described in a moment. Return
+ zero if there were no errors, otherwise return -1.
The `fts()' function provides a hook to the C library `fts()'
routines for traversing file hierarchies. Instead of returning data
@@ -25445,7 +25456,7 @@ requested hierarchies.
By default, the C library `fts()' routines do not return
entries for `.' (dot) and `..' (dot-dot). This option causes
entries for dot-dot to also be included. (The extension
- always includes an entry for dot, see below.)
+ always includes an entry for dot; more on this in a moment.)
`FTS_XDEV'
During a traversal, do not cross onto a different mounted
@@ -25455,7 +25466,7 @@ requested hierarchies.
The `filedata' array is first cleared. Then, `fts()' creates an
element in `filedata' for every element in `pathlist'. The index
is the name of the directory or file given in `pathlist'. The
- element for this index is itself an array. There are two cases.
+ element for this index is itself an array. There are two cases:
_The path is a file_
In this case, the array contains two or three elements:
@@ -25478,10 +25489,10 @@ requested hierarchies.
_The path is a directory_
In this case, the array contains one element for each entry
- in the directory. If an entry is a file, that element is as
- for files, just described. If the entry is a directory, that
- element is (recursively), an array describing the
- subdirectory. If `FTS_SEEDOT' was provided in the flags,
+ in the directory. If an entry is a file, that element is the
+ same as for files, just described. If the entry is a
+ directory, that element is (recursively) an array describing
+ the subdirectory. If `FTS_SEEDOT' was provided in the flags,
then there will also be an element named `".."'. This
element will be an array containing the data as provided by
`stat()'.
@@ -25497,8 +25508,8 @@ Otherwise it returns -1.
of the C library `fts()' routines, choosing instead to provide an
interface that is based on associative arrays, which is more
comfortable to use from an `awk' program. This includes the lack
- of a comparison function, since `gawk' already provides powerful
- array sorting facilities. While an `fts_read()'-like interface
+ of a comparison function, because `gawk' already provides powerful
+ array sorting facilities. Although an `fts_read()'-like interface
could have been provided, this felt less natural than simply
creating a multidimensional array to represent the file hierarchy
and its information.
@@ -25509,7 +25520,7 @@ the `fts()' extension function.

File: gawk.info, Node: Extension Sample Fnmatch, Next: Extension Sample Fork, Prev: Extension Sample File Functions, Up: Extension Samples
-16.7.2 Interface To `fnmatch()'
+16.7.2 Interface to `fnmatch()'
-------------------------------
This extension provides an interface to the C library `fnmatch()'
@@ -25520,11 +25531,12 @@ function. The usage is:
`result = fnmatch(pattern, string, flags)'
The return value is zero on success, `FNM_NOMATCH' if the string
- did not match the pattern, or a different non-zero value if an
+ did not match the pattern, or a different nonzero value if an
error occurred.
- Besides the `fnmatch()' function, the `fnmatch' extension adds one
-constant (`FNM_NOMATCH'), and an array of flag values named `FNM'.
+ In addition to the `fnmatch()' function, the `fnmatch' extension
+adds one constant (`FNM_NOMATCH'), and an array of flag values named
+`FNM'.
The arguments to `fnmatch()' are:
@@ -25538,7 +25550,7 @@ constant (`FNM_NOMATCH'), and an array of flag values named `FNM'.
Either zero, or the bitwise OR of one or more of the flags in the
`FNM' array.
- The flags are follows:
+ The flags are as follows:
Array element Corresponding flag defined by `fnmatch()'
--------------------------------------------------------------------------
@@ -25560,10 +25572,10 @@ Array element Corresponding flag defined by `fnmatch()'

File: gawk.info, Node: Extension Sample Fork, Next: Extension Sample Inplace, Prev: Extension Sample Fnmatch, Up: Extension Samples
-16.7.3 Interface To `fork()', `wait()' and `waitpid()'
-------------------------------------------------------
+16.7.3 Interface to `fork()', `wait()', and `waitpid()'
+-------------------------------------------------------
-The `fork' extension adds three functions, as follows.
+The `fork' extension adds three functions, as follows:
`@load "fork"'
This is how you load the extension.
@@ -25646,7 +25658,7 @@ File: gawk.info, Node: Extension Sample Ord, Next: Extension Sample Readdir,
--------------------------------------------------------
The `ordchr' extension adds two functions, named `ord()' and `chr()',
-as follows.
+as follows:
`@load "ordchr"'
This is how you load the extension.
@@ -25699,7 +25711,7 @@ Letter File Type
`s' Socket
`u' Anything else (unknown)
-Table 16.2: File Types Returned By The `readdir' Extension
+Table 16.2: File types returned by the `readdir' extension
On systems without the file type information, the third field is
always `u'.
@@ -25724,7 +25736,7 @@ File: gawk.info, Node: Extension Sample Revout, Next: Extension Sample Rev2way
-----------------------
The `revoutput' extension adds a simple output wrapper that reverses
-the characters in each output line. It's main purpose is to show how to
+the characters in each output line. Its main purpose is to show how to
write an output wrapper, although it may be mildly amusing for the
unwary. Here is an example:
@@ -25745,9 +25757,9 @@ File: gawk.info, Node: Extension Sample Rev2way, Next: Extension Sample Read w
The `revtwoway' extension adds a simple two-way processor that reverses
the characters in each line sent to it for reading back by the `awk'
-program. It's main purpose is to show how to write a two-way
-processor, although it may also be mildly amusing. The following
-example shows how to use it:
+program. Its main purpose is to show how to write a two-way processor,
+although it may also be mildly amusing. The following example shows
+how to use it:
@load "revtwoway"
@@ -25764,7 +25776,7 @@ example shows how to use it:

File: gawk.info, Node: Extension Sample Read write array, Next: Extension Sample Readfile, Prev: Extension Sample Rev2way, Up: Extension Samples
-16.7.9 Dumping and Restoring An Array
+16.7.9 Dumping and Restoring an Array
-------------------------------------
The `rwarray' extension adds two functions, named `writea()' and
@@ -25787,15 +25799,15 @@ The `rwarray' extension adds two functions, named `writea()' and
The array created by `reada()' is identical to that written by
`writea()' in the sense that the contents are the same. However, due to
-implementation issues, the array traversal order of the recreated array
-is likely to be different from that of the original array. As array
-traversal order in `awk' is by default undefined, this is (technically)
-not a problem. If you need to guarantee a particular traversal order,
-use the array sorting features in `gawk' to do so (*note Array
-Sorting::).
+implementation issues, the array traversal order of the re-created
+array is likely to be different from that of the original array. As
+array traversal order in `awk' is by default undefined, this is
+(technically) not a problem. If you need to guarantee a particular
+traversal order, use the array sorting features in `gawk' to do so
+(*note Array Sorting::).
The file contains binary data. All integral values are written in
-network byte order. However, double precision floating-point values
+network byte order. However, double-precision floating-point values
are written as native binary data. Thus, arrays containing only string
data can theoretically be dumped on systems with one byte order and
restored on systems with a different one, but this has not been tried.
@@ -25811,7 +25823,7 @@ restored on systems with a different one, but this has not been tried.

File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample Time, Prev: Extension Sample Read write array, Up: Extension Samples
-16.7.10 Reading An Entire File
+16.7.10 Reading an Entire File
------------------------------
The `readfile' extension adds a single function named `readfile()', and
@@ -25855,7 +25867,7 @@ The `time' extension adds two functions, named `gettimeofday()' and
`the_time = gettimeofday()'
Return the time in seconds that has elapsed since 1970-01-01 UTC
- as a floating point value. If the time is unavailable on this
+ as a floating-point value. If the time is unavailable on this
platform, return -1 and set `ERRNO'. The returned time should
have sub-second precision, but the actual precision may vary based
on the platform. If the standard C `gettimeofday()' system call
@@ -25897,17 +25909,17 @@ project.
As of this writing, there are five extensions:
- * GD graphics library extension.
+ * GD graphics library extension
- * PDF extension.
+ * PDF extension
- * PostgreSQL extension.
+ * PostgreSQL extension
- * MPFR library extension. This provides access to a number of MPFR
- functions which `gawk''s native MPFR support does not.
+ * MPFR library extension (this provides access to a number of MPFR
+ functions which `gawk''s native MPFR support does not)
* XML parser extension, using the Expat
- (http://expat.sourceforge.net) XML parsing library.
+ (http://expat.sourceforge.net) XML parsing library
You can check out the code for the `gawkextlib' project using the
Git (http://git-scm.com) distributed source code control system. The
@@ -25947,8 +25959,8 @@ You may also need to use the `sudo' utility to install both `gawk' and
`gawkextlib', depending upon how your system works.
If you write an extension that you wish to share with other `gawk'
-users, please consider doing so through the `gawkextlib' project. See
-the project's web site for more information.
+users, consider doing so through the `gawkextlib' project. See the
+project's website for more information.

File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: gawkextlib, Up: Dynamic Extensions
@@ -25957,7 +25969,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
============
* You can write extensions (sometimes called plug-ins) for `gawk' in
- C or C++ using the Application Programming Interface (API) defined
+ C or C++ using the application programming interface (API) defined
by the `gawk' developers.
* Extensions must have a license compatible with the GNU General
@@ -25983,31 +25995,31 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* API function pointers are provided for the following kinds of
operations:
- * Allocating, reallocating, and releasing memory.
+ * Allocating, reallocating, and releasing memory
- * Registration functions. You may register extension functions,
+ * Registration functions (you may register extension functions,
exit callbacks, a version string, input parsers, output
- wrappers, and two-way processors.
+ wrappers, and two-way processors)
- * Printing fatal, warning, and "lint" warning messages.
+ * Printing fatal, warning, and "lint" warning messages
- * Updating `ERRNO', or unsetting it.
+ * Updating `ERRNO', or unsetting it
* Accessing parameters, including converting an undefined
- parameter into an array.
+ parameter into an array
- * Symbol table access: retrieving a global variable, creating
- one, or changing one.
+ * Symbol table access (retrieving a global variable, creating
+ one, or changing one)
* Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and can be
- a big performance win.
+ a big performance win
- * Manipulating arrays: retrieving, adding, deleting, and
+ * Manipulating arrays (retrieving, adding, deleting, and
modifying elements; getting the count of elements in an array;
creating a new array; clearing an array; and flattening an
array for easy C style looping over all its indices and
- elements.
+ elements)
* The API defines a number of standard data types for representing
`awk' values, array elements, and arrays.
@@ -26066,7 +26078,7 @@ Appendix A The Evolution of the `awk' Language
**********************************************
This Info file describes the GNU implementation of `awk', which follows
-the POSIX specification. Many long-time `awk' users learned `awk'
+the POSIX specification. Many longtime `awk' users learned `awk'
programming with the original `awk' implementation in Version 7 Unix.
(This implementation was the basis for `awk' in Berkeley Unix, through
4.3-Reno. Subsequent versions of Berkeley Unix, and, for a while, some
@@ -26248,7 +26260,7 @@ Brian Kernighan has made his version available via his home page (*note
Other Versions::).
This minor node describes common extensions that originally appeared
-in his version of `awk'.
+in his version of `awk':
* The `**' and `**=' operators (*note Arithmetic Ops:: and *note
Assignment Ops::).
@@ -26290,7 +26302,7 @@ the current version of `gawk'.
- The `/inet', `/inet4', and `/inet6' special files for TCP/IP
networking using `|&' to specify which version of the IP
- protocol to use. (*note TCP/IP Networking::).
+ protocol to use (*note TCP/IP Networking::).
* Changes and/or additions to the language:
@@ -26316,7 +26328,7 @@ the current version of `gawk'.
* New keywords:
- - The `BEGINFILE' and `ENDFILE' special patterns. (*note
+ - The `BEGINFILE' and `ENDFILE' special patterns (*note
BEGINFILE/ENDFILE::).
- The `switch' statement (*note Switch Statement::).
@@ -26341,7 +26353,7 @@ the current version of `gawk'.
translations easier (*note Printf Ordering::).
- The `split()' function's additional optional fourth argument
- which is an array to hold the text of the field separators.
+ which is an array to hold the text of the field separators
(*note String Functions::).
* Additional functions only in `gawk':
@@ -26812,7 +26824,7 @@ A.7 Common Extensions Summary
=============================
The following table summarizes the common extensions supported by
-`gawk', Brian Kernighan's `awk', and `mawk', the three most widely-used
+`gawk', Brian Kernighan's `awk', and `mawk', the three most widely used
freely available versions of `awk' (*note Other Versions::).
Feature BWK Awk Mawk GNU Awk Now standard
@@ -26830,7 +26842,7 @@ Feature BWK Awk Mawk GNU Awk Now standard
`func' keyword X X
`BINMODE' variable X X
`RS' as regexp X X
-Time related functions X X
+Time-related functions X X

File: gawk.info, Node: Ranges and Locales, Next: Contributors, Prev: Common Extensions, Up: Language History
@@ -26848,7 +26860,7 @@ first character in the range and the last character in the range,
inclusive. Ordering was based on the numeric value of each character
in the machine's native character set. Thus, on ASCII-based systems,
`[a-z]' matched all the lowercase letters, and only the lowercase
-letters, since the numeric values for the letters from `a' through `z'
+letters, as the numeric values for the letters from `a' through `z'
were contiguous. (On an EBCDIC system, the range `[a-z]' includes
additional, non-alphabetic characters as well.)
@@ -26859,9 +26871,9 @@ as working in this fashion, and in particular, would teach that the
this was true.(1)
The 1992 POSIX standard introduced the idea of locales (*note
-Locales::). Since many locales include other letters besides the plain
-twenty-six letters of the American English alphabet, the POSIX standard
-added character classes (*note Bracket Expressions::) as a way to match
+Locales::). Because many locales include other letters besides the
+plain 26 letters of the English alphabet, the POSIX standard added
+character classes (*note Bracket Expressions::) as a way to match
different kinds of characters besides the traditional ones in the ASCII
character set.
@@ -26876,7 +26888,7 @@ than `B'. In other words, these locales sort characters in dictionary
order, and `[a-dx-z]' is typically not equivalent to `[abcdxyz]';
instead it might be equivalent to `[ABCXYabcdxyz]', for example.
- This point needs to be emphasized: Much literature teaches that you
+ This point needs to be emphasized: much literature teaches that you
should use `[a-z]' to match a lowercase character. But on systems with
non-ASCII locales, this also matches all of the uppercase characters
except `A' or `Z'! This was a continuous cause of confusion, even well
@@ -26889,9 +26901,9 @@ the intent is to remove trailing uppercase characters:
$ echo something1234abc | gawk-3.1.8 '{ sub("[A-Z]*$", ""); print }'
-| something1234a
-This output is unexpected, since the `bc' at the end of
-`something1234abc' should not normally match `[A-Z]*'. This result is
-due to the locale setting (and thus you may not see it on your system).
+This output is unexpected, as the `bc' at the end of `something1234abc'
+should not normally match `[A-Z]*'. This result is due to the locale
+setting (and thus you may not see it on your system).
Similar considerations apply to other ranges. For example, `["-/]'
is perfectly valid in ASCII, but is not valid in many Unicode locales,
@@ -26908,7 +26920,7 @@ like "why does `[A-Z]' match lowercase letters?!?"
This situation existed for close to 10 years, if not more, and the
`gawk' maintainer grew weary of trying to explain that `gawk' was being
-nicely standards-compliant, and that the issue was in the user's
+nicely standards compliant, and that the issue was in the user's
locale. During the development of version 4.0, he modified `gawk' to
always treat ranges in the original, pre-POSIX fashion, unless
`--posix' was used (*note Options::).(2)
@@ -27039,7 +27051,7 @@ Info file, in approximate chronological order:
statements.
* Patrick T.J. McPhee contributed the code for dynamic loading in
- Windows32 environments. (This is no longer supported)
+ Windows32 environments. (This is no longer supported.)
* Anders Wallin helped keep the VMS port going for several years.
@@ -27053,8 +27065,8 @@ Info file, in approximate chronological order:
- The addition of true arrays of arrays.
- - The additional modifications for support of arbitrary
- precision arithmetic.
+ - The additional modifications for support of
+ arbitrary-precision arithmetic.
- The initial text of *note Arbitrary Precision Arithmetic::.
@@ -27093,7 +27105,7 @@ A.10 Summary
============
* The `awk' language has evolved over time. The first release was
- with V7 Unix circa 1978. In 1987 for System V Release 3.1, major
+ with V7 Unix circa 1978. In 1987, for System V Release 3.1, major
additions, including user-defined functions, were made to the
language. Additional changes were made for System V Release 4, in
1989. Since then, further minor changes happen under the auspices
@@ -27127,8 +27139,8 @@ Appendix B Installing `gawk'
This appendix provides instructions for installing `gawk' on the
various platforms that are supported by the developers. The primary
developer supports GNU/Linux (and Unix), whereas the other ports are
-contributed. *Note Bugs::, for the electronic mail addresses of the
-people who maintain the respective ports.
+contributed. *Note Bugs::, for the email addresses of the people who
+maintain the respective ports.
* Menu:
@@ -27174,7 +27186,7 @@ There are two ways to get GNU software:
wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.2.tar.gz
The GNU software archive is mirrored around the world. The
-up-to-date list of mirror sites is available from the main FSF web site
+up-to-date list of mirror sites is available from the main FSF website
(http://www.gnu.org/order/ftp.html). Try to use one of the mirrors;
they will be less busy, and you can usually find one closer to your
site.
@@ -27190,9 +27202,9 @@ compression programs: `gzip', `bzip2', and `xz'. For simplicity, the
rest of these instructions assume you are using the one compressed with
the GNU Zip program, `gzip'.
- Once you have the distribution (for example, `gawk-4.1.2.tar.gz'),
-use `gzip' to expand the file and then use `tar' to extract it. You
-can use the following pipeline to produce the `gawk' distribution:
+ Once you have the distribution (e.g., `gawk-4.1.2.tar.gz'), use
+`gzip' to expand the file and then use `tar' to extract it. You can
+use the following pipeline to produce the `gawk' distribution:
gzip -d -c gawk-4.1.2.tar.gz | tar -xvpf -
@@ -27270,7 +27282,7 @@ Various `.c', `.y', and `.h' files
`doc/awkforai.txt'
Pointers to the original draft of a short article describing why
- `gawk' is a good language for Artificial Intelligence (AI)
+ `gawk' is a good language for artificial intelligence (AI)
programming.
`doc/bc_notes'
@@ -27394,7 +27406,7 @@ Various `.c', `.y', and `.h' files

File: gawk.info, Node: Unix Installation, Next: Non-Unix Installation, Prev: Gawk Distribution, Up: Installation
-B.2 Compiling and Installing `gawk' on Unix-like Systems
+B.2 Compiling and Installing `gawk' on Unix-Like Systems
========================================================
Usually, you can compile and install `gawk' by typing only two
@@ -27410,7 +27422,7 @@ configure `gawk' for your system yourself.

File: gawk.info, Node: Quick Installation, Next: Additional Configuration Options, Up: Unix Installation
-B.2.1 Compiling `gawk' for Unix-like Systems
+B.2.1 Compiling `gawk' for Unix-Like Systems
--------------------------------------------
The normal installation steps should work on all modern commercial
@@ -27453,8 +27465,7 @@ That's all there is to it! To verify that `gawk' is working properly,
run `make check'. All of the tests should succeed. If these steps do
not work, or if any of the tests fail, check the files in the
`README_d' directory to see if you've found a known problem. If the
-failure is not described there, please send in a bug report (*note
-Bugs::).
+failure is not described there, send in a bug report (*note Bugs::).
Of course, once you've built `gawk', it is likely that you will wish
to install it. To do so, you need to run the command `make install',
@@ -27504,7 +27515,7 @@ command line when compiling `gawk' from scratch, including:
for deficient systems.
Use the command `./configure --help' to see the full list of options
-that `configure' supplies.
+supplied by `configure'.

File: gawk.info, Node: Configuration Philosophy, Prev: Additional Configuration Options, Up: Unix Installation
@@ -27538,15 +27549,15 @@ element in the `stat' structure. In this case,
It is possible for your C compiler to lie to `configure'. It may do
so by not exiting with an error when a library function is not
-available. To get around this, edit the file `custom.h'. Use an
+available. To get around this, edit the `custom.h' file. Use an
`#ifdef' that is appropriate for your system, and either `#define' any
constants that `configure' should have defined but didn't, or `#undef'
-any constants that `configure' defined and should not have. `custom.h'
-is automatically included by `config.h'.
+any constants that `configure' defined and should not have. The
+`custom.h' file is automatically included by the `config.h' file.
It is also possible that the `configure' program generated by
Autoconf will not work on your system in some other fashion. If you do
-have a problem, the file `configure.ac' is the input for Autoconf. You
+have a problem, the `configure.ac' file is the input for Autoconf. You
may be able to change this file and generate a new version of
`configure' that works on your system (*note Bugs::, for information on
how to report problems in configuring `gawk'). The same mechanism may
@@ -27582,8 +27593,8 @@ Microsoft Windows-95/98/ME/NT/2000/XP/Vista/7/8.
operating systems) has meant that various "DOS extenders" are often
used with programs such as `gawk'. The varying capabilities of
Microsoft Windows 3.1 and Windows32 can add to the confusion. For an
-overview of the considerations, please refer to `README_d/README.pc' in
-the distribution.
+overview of the considerations, refer to `README_d/README.pc' in the
+distribution.
* Menu:
@@ -27712,8 +27723,8 @@ other set of (self-consistent) environment variables and compiler flags.
---------- Footnotes ----------
- (1) As of May, 2014, this site is still there, but the author could
-not find a package for GNU Make.
+ (1) As of November 2014, this site is still there, but the author
+could not find a package for GNU Make.

File: gawk.info, Node: PC Testing, Next: PC Using, Prev: PC Compiling, Up: PC Installation
@@ -27866,7 +27877,7 @@ use the `BINMODE' variable.
This can cause problems with other Unix-like components that have
been ported to MS-Windows that expect `gawk' to do automatic
-translation of `"\r\n"', since it won't.
+translation of `"\r\n"', because it won't.

File: gawk.info, Node: VMS Installation, Prev: PC Installation, Up: Non-Unix Installation
@@ -27934,7 +27945,7 @@ B.3.2.2 Compiling `gawk' Dynamic Extensions on VMS
..................................................
The extensions that have been ported to VMS can be built using one of
-the following commands.
+the following commands:
$ MMS/DESCRIPTION=[.vms]descrip.mms extensions
@@ -27946,7 +27957,7 @@ or:
logical name to find the dynamic extensions.
Dynamic extensions need to be compiled with the same compiler
-options for floating point, pointer size, and symbol name handling as
+options for floating-point, pointer size, and symbol name handling as
were used to compile `gawk' itself. Alpha and Itanium should use IEEE
floating point. The pointer size is 32 bits, and the symbol name
handling should be exact case with CRC shortening for symbols longer
@@ -28062,12 +28073,11 @@ Note that uppercase and mixed-case text must be quoted.
The VMS port of `gawk' includes a `DCL'-style interface in addition
to the original shell-style interface (see the help entry for details).
One side effect of dual command-line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
-becomes ambiguous. To work around this, the normally optional `--'
-flag is required to force Unix-style parsing rather than `DCL' parsing.
-If any other dash-type options (or multiple parameters such as data
-files to process) are present, there is no ambiguity and `--' can be
-omitted.
+single parameter (as in the quoted string program), the command becomes
+ambiguous. To work around this, the normally optional `--' flag is
+required to force Unix-style parsing rather than `DCL' parsing. If any
+other dash-type options (or multiple parameters such as data files to
+process) are present, there is no ambiguity and `--' can be omitted.
The `exit' value is a Unix-style value and is encoded into a VMS exit
status value when the program exits.
@@ -28143,17 +28153,17 @@ File: gawk.info, Node: Bugs, Next: Other Versions, Prev: Non-Unix Installatio
B.4 Reporting Problems and Bugs
===============================
- There is nothing more dangerous than a bored archeologist. -- The
- Hitchhiker's Guide to the Galaxy
+ There is nothing more dangerous than a bored archaeologist. --
+ Douglas Adams, `The Hitchhiker's Guide to the Galaxy'
If you have problems with `gawk' or think that you have found a bug,
-please report it to the developers; we cannot promise to do anything
-but we might well want to fix it.
+report it to the developers; we cannot promise to do anything but we
+might well want to fix it.
- Before reporting a bug, please make sure you have really found a
-genuine bug. Carefully reread the documentation and see if it says you
-can do what you're trying to do. If it's not clear whether you should
-be able to do something or not, report that too; it's a bug in the
+ Before reporting a bug, make sure you have really found a genuine
+bug. Carefully reread the documentation and see if it says you can do
+what you're trying to do. If it's not clear whether you should be able
+to do something or not, report that too; it's a bug in the
documentation!
Before reporting a bug or trying to fix it yourself, try to isolate
@@ -28164,48 +28174,46 @@ compile `gawk', and the exact results `gawk' gave you. Also say what
you expected to occur; this helps us decide whether the problem is
really in the documentation.
- Please include the version number of `gawk' you are using. You can
-get this information with the command `gawk --version'.
+ Make sure to include the version number of `gawk' you are using.
+You can get this information with the command `gawk --version'.
Once you have a precise problem description, send email to
<bug-gawk@gnu.org>.
The `gawk' maintainers subscribe to this address and thus they will
receive your bug report. Although you can send mail to the maintainers
-directly, the bug reporting address is preferred since the email list
+directly, the bug reporting address is preferred because the email list
is archived at the GNU Project. _All email must be in English. This is
the only language understood in common by all the maintainers._
CAUTION: Do _not_ try to report bugs in `gawk' by posting to the
- Usenet/Internet newsgroup `comp.lang.awk'. While the `gawk'
- developers do occasionally read this newsgroup, there is no
- guarantee that we will see your posting. The steps described
- above are the only official recognized way for reporting bugs.
- Really.
+ Usenet/Internet newsgroup `comp.lang.awk'. The `gawk' developers
+ do occasionally read this newsgroup, but there is no guarantee
+ that we will see your posting. The steps described here are the
+ only officially recognized way for reporting bugs. Really.
NOTE: Many distributions of GNU/Linux and the various BSD-based
operating systems have their own bug reporting systems. If you
- report a bug using your distribution's bug reporting system,
- _please_ also send a copy to <bug-gawk@gnu.org>.
+ report a bug using your distribution's bug reporting system, you
+ should also send a copy to <bug-gawk@gnu.org>.
- This is for two reasons. First, while some distributions forward
- bug reports "upstream" to the GNU mailing list, many don't, so
- there is a good chance that the `gawk' maintainers won't even see
- the bug report! Second, mail to the GNU list is archived, and
- having everything at the GNU project keeps things self-contained
- and not dependant on other organizations.
+ This is for two reasons. First, although some distributions
+ forward bug reports "upstream" to the GNU mailing list, many
+ don't, so there is a good chance that the `gawk' maintainers
+ won't even see the bug report! Second, mail to the GNU list is
+ archived, and having everything at the GNU project keeps things
+ self-contained and not dependant on other organizations.
Non-bug suggestions are always welcome as well. If you have
questions about things that are unclear in the documentation or are
just obscure features, ask on the bug list; we will try to help you out
if we can.
- If you find bugs in one of the non-Unix ports of `gawk', please send
-an electronic mail message to the bug list, with a copy to the person
-who maintains that port. They are named in the following list, as well
-as in the `README' file in the `gawk' distribution. Information in the
-`README' file should be considered authoritative if it conflicts with
-this Info file.
+ If you find bugs in one of the non-Unix ports of `gawk', send an
+email to the bug list, with a copy to the person who maintains that
+port. They are named in the following list, as well as in the `README'
+file in the `gawk' distribution. Information in the `README' file
+should be considered authoritative if it conflicts with this Info file.
The people maintaining the various `gawk' ports are:
@@ -28216,8 +28224,8 @@ OS/2 Andreas Buening, <andreas.buening@nexgo.de>.
VMS John Malmberg, <wb8tyw@qsl.net>.
z/OS (OS/390) Dave Pitts, <dpitts@cozx.com>.
- If your bug is also reproducible under Unix, please send a copy of
-your report to the <bug-gawk@gnu.org> email list as well.
+ If your bug is also reproducible under Unix, send a copy of your
+report to the <bug-gawk@gnu.org> email list as well.

File: gawk.info, Node: Other Versions, Next: Installation summary, Prev: Bugs, Up: Installation
@@ -28235,7 +28243,7 @@ This minor node briefly describes where to get them:
Unix `awk'
Brian Kernighan, one of the original designers of Unix `awk', has
made his implementation of `awk' freely available. You can
- retrieve this version via the World Wide Web from his home page
+ retrieve this version via his home page
(http://www.cs.princeton.edu/~bwk). It is available in several
archive formats:
@@ -28252,10 +28260,10 @@ Unix `awk'
git clone git://github.com/onetrueawk/awk bwkawk
- The above command creates a copy of the Git
- (http://www.git-scm.com) repository in a directory named `bwkawk'.
- If you leave that argument off the `git' command line, the
- repository copy is created in a directory named `awk'.
+ This command creates a copy of the Git (http://www.git-scm.com)
+ repository in a directory named `bwkawk'. If you leave that
+ argument off the `git' command line, the repository copy is
+ created in a directory named `awk'.
This version requires an ISO C (1990 standard) compiler; the C
compiler from GCC (the GNU Compiler Collection) works quite nicely.
@@ -28263,6 +28271,10 @@ Unix `awk'
*Note Common Extensions::, for a list of extensions in this `awk'
that are not in POSIX `awk'.
+ As a side note, Dan Bornstein has created a Git repository tracking
+ all the versions of BWK `awk' that he could find. It's available
+ at `git://github.com/onetrueawk/awk'.
+
`mawk'
Michael Brennan wrote an independent implementation of `awk',
called `mawk'. It is available under the GPL (*note Copying::),
@@ -28324,8 +28336,8 @@ The OpenSolaris POSIX `awk'
Automake) would take more work, and this has not been done, at
least to our knowledge.
- The source code used to be available from the OpenSolaris web site.
- However, that project was ended and the web site shut down.
+ The source code used to be available from the OpenSolaris website.
+ However, that project was ended and the website shut down.
Fortunately, the Illumos project
(http://wiki.illumos.org/display/illumos/illumos+Home) makes this
implementation available. You can view the files one at a time
@@ -28341,7 +28353,7 @@ The OpenSolaris POSIX `awk'
Libmawk
This is an embeddable `awk' interpreter derived from `mawk'. For
- more information see `http://repo.hu/projects/libmawk/'.
+ more information, see `http://repo.hu/projects/libmawk/'.
`pawk'
This is a Python module that claims to bring `awk'-like features
@@ -28350,7 +28362,7 @@ Libmawk
version of BWK `awk', described earlier.)
QSE Awk
- This is an embeddable `awk' interpreter. For more information see
+ This is an embeddable `awk' interpreter. For more information, see
`http://code.google.com/p/qse/' and `http://awk.info/?tools/qse'.
`QTawk'
@@ -28363,9 +28375,10 @@ QSE Awk
The project may also be frozen; no new code changes have been made
since approximately 2008.
-Other Versions
- See also the Wikipedia article
- (http://en.wikipedia.org/wiki/Awk_language#Versions_and_implementations),
+Other versions
+ See also the "Versions and implementations" section of the
+ Wikipedia article
+ (http://en.wikipedia.org/wiki/Awk_language#Versions_and_implementations)
for information on additional versions.
@@ -28534,9 +28547,8 @@ possible to include them:
document describes how GNU software should be written. If you
haven't read it, please do so, preferably _before_ starting to
modify `gawk'. (The `GNU Coding Standards' are available from the
- GNU Project's web site
- (http://www.gnu.org/prep/standards_toc.html). Texinfo, Info, and
- DVI versions are also available.)
+ GNU Project's website (http://www.gnu.org/prep/standards_toc.html).
+ Texinfo, Info, and DVI versions are also available.)
5. Use the `gawk' coding style. The C code for `gawk' follows the
instructions in the `GNU Coding Standards', with minor exceptions.
@@ -31269,7 +31281,7 @@ Index
* * (asterisk), * operator, as regexp operator: Regexp Operators.
(line 89)
* * (asterisk), * operator, null strings, matching: String Functions.
- (line 535)
+ (line 536)
* * (asterisk), ** operator <1>: Precedence. (line 49)
* * (asterisk), ** operator: Arithmetic Ops. (line 81)
* * (asterisk), **= operator <1>: Precedence. (line 95)
@@ -31319,23 +31331,23 @@ Index
* --non-decimal-data option: Options. (line 211)
* --non-decimal-data option, strtonum() function and: Nondecimal Data.
(line 35)
-* --optimize option: Options. (line 239)
+* --optimize option: Options. (line 238)
* --posix option: Options. (line 256)
* --posix option, --traditional option and: Options. (line 275)
-* --pretty-print option: Options. (line 226)
+* --pretty-print option: Options. (line 225)
* --profile option <1>: Profiling. (line 12)
* --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)
+ (line 128)
* --sandbox option, input redirection with getline: Getline. (line 19)
* --sandbox option, output redirection with print, printf: Redirection.
(line 6)
* --source option: Options. (line 117)
* --traditional option: Options. (line 81)
* --traditional option, --posix option and: Options. (line 275)
-* --use-lc-numeric option: Options. (line 221)
+* --use-lc-numeric option: Options. (line 220)
* --version option: Options. (line 302)
* --with-whiny-user-strftime configuration option: Additional Configuration Options.
(line 35)
@@ -31360,10 +31372,10 @@ Index
* -L option: Options. (line 297)
* -l option: Options. (line 173)
* -M option: Options. (line 205)
-* -N option: Options. (line 221)
+* -N option: Options. (line 220)
* -n option: Options. (line 211)
-* -O option: Options. (line 239)
-* -o option: Options. (line 226)
+* -O option: Options. (line 238)
+* -o option: Options. (line 225)
* -P option: Options. (line 256)
* -p option: Options. (line 244)
* -r option: Options. (line 281)
@@ -31474,7 +31486,7 @@ Index
* \ (backslash), in bracket expressions: Bracket Expressions. (line 17)
* \ (backslash), in escape sequences: Escape Sequences. (line 6)
* \ (backslash), in escape sequences, POSIX and: Escape Sequences.
- (line 118)
+ (line 105)
* \ (backslash), in regexp constants: Computed Regexps. (line 29)
* \ (backslash), in shell commands: Quoting. (line 48)
* \ (backslash), regexp operator: Regexp Operators. (line 18)
@@ -31506,14 +31518,14 @@ Index
* Ada programming language: Glossary. (line 19)
* adding, features to gawk: Adding Code. (line 6)
* adding, fields: Changing Fields. (line 53)
-* advanced features, fixed-width data: Constant Size. (line 10)
+* advanced features, fixed-width data: Constant Size. (line 6)
* advanced features, gawk: Advanced Features. (line 6)
* advanced features, network programming: TCP/IP Networking. (line 6)
* advanced features, nondecimal input data: Nondecimal Data. (line 6)
* advanced features, processes, communicating with: Two-way I/O.
(line 6)
* advanced features, specifying field content: Splitting By Content.
- (line 10)
+ (line 9)
* Aho, Alfred <1>: Contributors. (line 11)
* Aho, Alfred: History. (line 17)
* alarm clock example program: Alarm Program. (line 11)
@@ -31543,7 +31555,7 @@ Index
(line 6)
* arbitrary precision integers: Arbitrary Precision Integers.
(line 6)
-* archeologists: Bugs. (line 6)
+* archaeologists: Bugs. (line 6)
* arctangent: Numeric Functions. (line 11)
* ARGC/ARGV variables: Auto-set. (line 15)
* ARGC/ARGV variables, command-line arguments: Other Arguments.
@@ -31565,13 +31577,13 @@ Index
(line 6)
* array scanning order, controlling: Controlling Scanning.
(line 14)
-* array, number of elements: String Functions. (line 200)
+* array, number of elements: String Functions. (line 201)
* arrays: Arrays. (line 6)
* arrays of arrays: Arrays of Arrays. (line 6)
* arrays, an example of using: Array Example. (line 6)
* arrays, and IGNORECASE variable: Array Intro. (line 94)
* arrays, as parameters to functions: Pass By Value/Reference.
- (line 47)
+ (line 44)
* arrays, associative: Array Intro. (line 50)
* arrays, associative, library functions and: Library Names. (line 58)
* arrays, deleting entire contents: Delete. (line 39)
@@ -31581,7 +31593,7 @@ Index
* arrays, elements, deleting: Delete. (line 6)
* arrays, elements, order of access by in operator: Scanning an Array.
(line 48)
-* arrays, elements, retrieving number of: String Functions. (line 41)
+* arrays, elements, retrieving number of: String Functions. (line 42)
* arrays, for statement and: Scanning an Array. (line 20)
* arrays, indexing: Array Intro. (line 50)
* arrays, merging into strings: Join Function. (line 6)
@@ -31607,12 +31619,12 @@ Index
* ASCII: Ordinal Functions. (line 45)
* asort <1>: Array Sorting Functions.
(line 6)
-* asort: String Functions. (line 41)
+* asort: String Functions. (line 42)
* asort() function (gawk), arrays, sorting: Array Sorting Functions.
(line 6)
* asorti <1>: Array Sorting Functions.
(line 6)
-* asorti: String Functions. (line 41)
+* asorti: String Functions. (line 42)
* asorti() function (gawk), arrays, sorting: Array Sorting Functions.
(line 6)
* assert() function (C library): Assert Function. (line 6)
@@ -31630,7 +31642,7 @@ Index
* asterisk (*), * operator, as regexp operator: Regexp Operators.
(line 89)
* asterisk (*), * operator, null strings, matching: String Functions.
- (line 535)
+ (line 536)
* asterisk (*), ** operator <1>: Precedence. (line 49)
* asterisk (*), ** operator: Arithmetic Ops. (line 81)
* asterisk (*), **= operator <1>: Precedence. (line 95)
@@ -31691,7 +31703,7 @@ Index
* awk, versions of, See Also Brian Kernighan's awk <1>: Other Versions.
(line 13)
* awk, versions of, See Also Brian Kernighan's awk: BTL. (line 6)
-* awka compiler for awk: Other Versions. (line 64)
+* awka compiler for awk: Other Versions. (line 68)
* AWKLIBPATH environment variable: AWKLIBPATH Variable. (line 6)
* AWKPATH environment variable <1>: PC Using. (line 10)
* AWKPATH environment variable: AWKPATH Variable. (line 6)
@@ -31743,12 +31755,12 @@ Index
* backslash (\), in bracket expressions: Bracket Expressions. (line 17)
* backslash (\), in escape sequences: Escape Sequences. (line 6)
* backslash (\), in escape sequences, POSIX and: Escape Sequences.
- (line 118)
+ (line 105)
* backslash (\), in regexp constants: Computed Regexps. (line 29)
* backslash (\), in shell commands: Quoting. (line 48)
* backslash (\), regexp operator: Regexp Operators. (line 18)
* backtrace debugger command: Execution Stack. (line 13)
-* Beebe, Nelson H.F. <1>: Other Versions. (line 78)
+* Beebe, Nelson H.F. <1>: Other Versions. (line 82)
* Beebe, Nelson H.F.: Acknowledgments. (line 60)
* BEGIN pattern <1>: Using BEGIN/END. (line 6)
* BEGIN pattern <2>: BEGIN/END. (line 6)
@@ -31765,7 +31777,7 @@ Index
* BEGIN pattern, next/nextfile statements and: I/O And BEGIN/END.
(line 37)
* BEGIN pattern, OFS/ORS variables, assigning values to: Output Separators.
- (line 20)
+ (line 21)
* 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)
@@ -31834,10 +31846,10 @@ Index
* Brennan, Michael <3>: Delete. (line 56)
* Brennan, Michael <4>: Acknowledgments. (line 78)
* Brennan, Michael <5>: Foreword4. (line 30)
-* Brennan, Michael: Foreword3. (line 83)
+* Brennan, Michael: Foreword3. (line 84)
* Brian Kernighan's awk <1>: I/O Functions. (line 43)
* Brian Kernighan's awk <2>: Gory Details. (line 19)
-* Brian Kernighan's awk <3>: String Functions. (line 491)
+* Brian Kernighan's awk <3>: String Functions. (line 492)
* Brian Kernighan's awk <4>: Delete. (line 51)
* Brian Kernighan's awk <5>: Nextfile Statement. (line 47)
* Brian Kernighan's awk <6>: Continue Statement. (line 44)
@@ -31848,8 +31860,8 @@ Index
* Brian Kernighan's awk <11>: Regexp Field Splitting.
(line 67)
* Brian Kernighan's awk <12>: GNU Regexp Operators.
- (line 83)
-* Brian Kernighan's awk <13>: Escape Sequences. (line 122)
+ (line 82)
+* Brian Kernighan's awk <13>: Escape Sequences. (line 109)
* Brian Kernighan's awk: When. (line 21)
* Brian Kernighan's awk, extensions: BTL. (line 6)
* Brian Kernighan's awk, source code: Other Versions. (line 13)
@@ -31859,12 +31871,12 @@ Index
* Brown, Martin: Contributors. (line 82)
* BSD-based operating systems: Glossary. (line 611)
* bt debugger command (alias for backtrace): Execution Stack. (line 13)
-* Buening, Andreas <1>: Bugs. (line 72)
+* Buening, Andreas <1>: Bugs. (line 70)
* Buening, Andreas <2>: Contributors. (line 92)
* Buening, Andreas: Acknowledgments. (line 60)
* buffering, input/output <1>: Two-way I/O. (line 52)
-* buffering, input/output: I/O Functions. (line 139)
-* buffering, interactive vs. noninteractive: I/O Functions. (line 108)
+* buffering, input/output: I/O Functions. (line 140)
+* buffering, interactive vs. noninteractive: I/O Functions. (line 75)
* buffers, flushing: I/O Functions. (line 32)
* buffers, operators for: GNU Regexp Operators.
(line 48)
@@ -31872,12 +31884,12 @@ Index
* bug-gawk@gnu.org bug reporting address: Bugs. (line 30)
* built-in functions: Functions. (line 6)
* built-in functions, evaluation order: Calling Built-in. (line 30)
-* Busybox Awk: Other Versions. (line 88)
+* Busybox Awk: Other Versions. (line 92)
* c.e., See common extensions: Conventions. (line 51)
* call by reference: Pass By Value/Reference.
- (line 47)
+ (line 44)
* call by value: Pass By Value/Reference.
- (line 18)
+ (line 15)
* call stack, display in debugger: Execution Stack. (line 13)
* caret (^), ^ operator: Precedence. (line 49)
* caret (^), ^= operator <1>: Precedence. (line 95)
@@ -31890,7 +31902,7 @@ Index
* case sensitivity, and regexps: User-modified. (line 76)
* case sensitivity, and string comparisons: User-modified. (line 76)
* case sensitivity, array indices and: Array Intro. (line 94)
-* case sensitivity, converting case: String Functions. (line 521)
+* case sensitivity, converting case: String Functions. (line 522)
* case sensitivity, example programs: Library Functions. (line 53)
* case sensitivity, gawk: Case-sensitivity. (line 26)
* case sensitivity, regexps and: Case-sensitivity. (line 6)
@@ -31926,7 +31938,7 @@ Index
* close() function, portability: Close Files And Pipes.
(line 81)
* close() function, return value: Close Files And Pipes.
- (line 132)
+ (line 133)
* close() function, two-way pipes and: Two-way I/O. (line 59)
* Close, Diane <1>: Contributors. (line 20)
* Close, Diane: Manual History. (line 34)
@@ -31970,7 +31982,7 @@ Index
* common extensions, delete to delete entire arrays: Delete. (line 39)
* common extensions, func keyword: Definition Syntax. (line 93)
* common extensions, length() applied to an array: String Functions.
- (line 200)
+ (line 201)
* common extensions, RS as a regexp: gawk split records. (line 6)
* common extensions, single character fields: Single Character Fields.
(line 6)
@@ -32019,9 +32031,9 @@ Index
* control statements: Statements. (line 6)
* controlling array scanning order: Controlling Scanning.
(line 14)
-* convert string to lower case: String Functions. (line 522)
-* convert string to number: String Functions. (line 389)
-* convert string to upper case: String Functions. (line 528)
+* convert string to lower case: String Functions. (line 523)
+* convert string to number: String Functions. (line 390)
+* convert string to upper case: String Functions. (line 529)
* converting integer array subscripts: Numeric Array Subscripts.
(line 31)
* converting, dates to timestamps: Time Functions. (line 76)
@@ -32068,7 +32080,7 @@ Index
(line 43)
* dark corner, break statement: Break Statement. (line 51)
* dark corner, close() function: Close Files And Pipes.
- (line 132)
+ (line 133)
* dark corner, command-line arguments: Assignment Options. (line 43)
* dark corner, continue statement: Continue Statement. (line 44)
* dark corner, CONVFMT variable: Strings And Numbers. (line 40)
@@ -32076,34 +32088,33 @@ Index
* dark corner, escape sequences, for metacharacters: Escape Sequences.
(line 140)
* dark corner, exit statement: Exit Statement. (line 30)
-* dark corner, field separators: Field Splitting Summary.
- (line 46)
+* dark corner, field separators: Full Line Fields. (line 22)
* dark corner, FILENAME variable <1>: Auto-set. (line 90)
* dark corner, FILENAME variable: Getline Notes. (line 19)
-* dark corner, FNR/NR variables: Auto-set. (line 313)
+* dark corner, FNR/NR variables: Auto-set. (line 314)
* dark corner, format-control characters: Control Letters. (line 18)
* dark corner, FS as null string: Single Character Fields.
(line 20)
* dark corner, input files: awk split records. (line 111)
* dark corner, invoking awk: Command Line. (line 16)
-* dark corner, length() function: String Functions. (line 186)
+* dark corner, length() function: String Functions. (line 187)
* dark corner, locale's decimal point character: Locale influences conversions.
(line 17)
* dark corner, multiline records: Multiple Line. (line 35)
* dark corner, NF variable, decrementing: Changing Fields. (line 107)
* dark corner, OFMT variable: OFMT. (line 27)
* dark corner, regexp as second argument to index(): String Functions.
- (line 164)
+ (line 165)
* dark corner, regexp constants: Using Constant Regexps.
(line 6)
* dark corner, regexp constants, /= operator and: Assignment Ops.
(line 148)
* dark corner, regexp constants, as arguments to user-defined functions: Using Constant Regexps.
(line 43)
-* dark corner, split() function: String Functions. (line 360)
+* dark corner, split() function: String Functions. (line 361)
* dark corner, strings, storing: gawk split records. (line 83)
* dark corner, value of ARGV[0]: Auto-set. (line 39)
-* data, fixed-width: Constant Size. (line 10)
+* data, fixed-width: Constant Size. (line 6)
* data-driven languages: Basic High Level. (line 85)
* database, group, reading: Group Functions. (line 6)
* database, users, reading: Passwd Functions. (line 6)
@@ -32233,7 +32244,7 @@ Index
* 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 72)
+* Deifik, Scott <1>: Bugs. (line 70)
* Deifik, Scott <2>: Contributors. (line 53)
* Deifik, Scott: Acknowledgments. (line 60)
* delete ARRAY: Delete. (line 39)
@@ -32247,7 +32258,7 @@ Index
* deleting entire arrays: Delete. (line 39)
* Demaille, Akim: Acknowledgments. (line 60)
* describe call stack frame, in debugger: Debugger Info. (line 27)
-* differences between gawk and awk: String Functions. (line 200)
+* differences between gawk and awk: String Functions. (line 201)
* differences in awk and gawk, ARGC/ARGV variables: ARGC and ARGV.
(line 90)
* differences in awk and gawk, ARGIND variable: Auto-set. (line 44)
@@ -32274,7 +32285,7 @@ Index
* differences in awk and gawk, FIELDWIDTHS variable: User-modified.
(line 37)
* differences in awk and gawk, FPAT variable: User-modified. (line 43)
-* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 115)
+* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 116)
* differences in awk and gawk, function arguments (gawk): Calling Built-in.
(line 16)
* differences in awk and gawk, getline command: Getline. (line 19)
@@ -32294,10 +32305,10 @@ Index
(line 34)
* differences in awk and gawk, LINT variable: User-modified. (line 88)
* differences in awk and gawk, match() function: String Functions.
- (line 262)
+ (line 263)
* differences in awk and gawk, print/printf statements: Format Modifiers.
(line 13)
-* differences in awk and gawk, PROCINFO array: Auto-set. (line 129)
+* differences in awk and gawk, PROCINFO array: Auto-set. (line 130)
* differences in awk and gawk, read timeouts: Read Timeout. (line 6)
* differences in awk and gawk, record separators: awk split records.
(line 125)
@@ -32307,15 +32318,15 @@ Index
(line 26)
* differences in awk and gawk, RS/RT variables: gawk split records.
(line 58)
-* differences in awk and gawk, RT variable: Auto-set. (line 264)
+* differences in awk and gawk, RT variable: Auto-set. (line 265)
* differences in awk and gawk, single-character fields: Single Character Fields.
(line 6)
* differences in awk and gawk, split() function: String Functions.
- (line 348)
+ (line 349)
* differences in awk and gawk, strings: Scalar Constants. (line 20)
* differences in awk and gawk, strings, storing: gawk split records.
(line 77)
-* differences in awk and gawk, SYMTAB variable: Auto-set. (line 268)
+* differences in awk and gawk, SYMTAB variable: Auto-set. (line 269)
* differences in awk and gawk, TEXTDOMAIN variable: User-modified.
(line 151)
* differences in awk and gawk, trunc-mod operation: Arithmetic Ops.
@@ -32355,8 +32366,8 @@ Index
* dynamically loaded extensions: Dynamic Extensions. (line 6)
* e debugger command (alias for enable): Breakpoint Control. (line 73)
* EBCDIC: Ordinal Functions. (line 45)
-* effective group ID of gawk user: Auto-set. (line 134)
-* effective user ID of gawk user: Auto-set. (line 138)
+* effective group ID of gawk user: Auto-set. (line 135)
+* effective user ID of gawk user: Auto-set. (line 139)
* egrep utility <1>: Egrep Program. (line 6)
* egrep utility: Bracket Expressions. (line 26)
* egrep.awk program: Egrep Program. (line 54)
@@ -32414,7 +32425,7 @@ Index
* ERRNO variable: Auto-set. (line 74)
* ERRNO variable, with BEGINFILE pattern: BEGINFILE/ENDFILE. (line 26)
* ERRNO variable, with close() function: Close Files And Pipes.
- (line 140)
+ (line 141)
* ERRNO variable, with getline command: Getline. (line 19)
* error handling: Special FD. (line 19)
* error handling, ERRNO variable and: Auto-set. (line 74)
@@ -32447,7 +32458,7 @@ Index
* exclamation point (!), !~ operator: Regexp Usage. (line 19)
* exit statement: Exit Statement. (line 6)
* exit status, of gawk: Exit Status. (line 6)
-* exit status, of VMS: VMS Running. (line 29)
+* exit status, of VMS: VMS Running. (line 28)
* exit the debugger: Miscellaneous Debugger Commands.
(line 99)
* exp: Numeric Functions. (line 18)
@@ -32471,7 +32482,7 @@ Index
(line 6)
* extension API version: Extension Versioning.
(line 6)
-* extension API, version number: Auto-set. (line 231)
+* extension API, version number: Auto-set. (line 232)
* extension example: Extension Example. (line 6)
* extension registration: Registration Functions.
(line 6)
@@ -32492,7 +32503,7 @@ Index
* extensions, common, fflush() function: I/O Functions. (line 43)
* extensions, common, func keyword: Definition Syntax. (line 93)
* extensions, common, length() applied to an array: String Functions.
- (line 200)
+ (line 201)
* extensions, common, RS as a regexp: gawk split records. (line 6)
* extensions, common, single character fields: Single Character Fields.
(line 6)
@@ -32520,8 +32531,7 @@ Index
* field separator, in multiline records: Multiple Line. (line 41)
* field separator, on command line: Command Line Field Separator.
(line 6)
-* field separator, POSIX and: Field Splitting Summary.
- (line 40)
+* field separator, POSIX and: Full Line Fields. (line 16)
* field separators <1>: User-modified. (line 50)
* field separators: Field Separators. (line 15)
* field separators, choice of: Field Separators. (line 51)
@@ -32547,7 +32557,7 @@ Index
* fields, single-character: Single Character Fields.
(line 6)
* FIELDWIDTHS variable <1>: User-modified. (line 37)
-* FIELDWIDTHS variable: Constant Size. (line 23)
+* FIELDWIDTHS variable: Constant Size. (line 22)
* file descriptors: Special FD. (line 6)
* file inclusion, @include directive: Include Files. (line 8)
* file names, distinguishing: Auto-set. (line 56)
@@ -32607,23 +32617,23 @@ Index
* files, source, search path for: Programs Exercises. (line 70)
* files, splitting: Split Program. (line 6)
* files, Texinfo, extracting programs from: Extract Program. (line 6)
-* find substring in string: String Functions. (line 155)
+* find substring in string: String Functions. (line 156)
* finding extensions: Finding Extensions. (line 6)
* finish debugger command: Debugger Execution Control.
(line 39)
* Fish, Fred: Contributors. (line 50)
-* fixed-width data: Constant Size. (line 10)
+* fixed-width data: Constant Size. (line 6)
* flag variables <1>: Tee Program. (line 20)
* flag variables: Boolean Ops. (line 69)
* floating-point, numbers, arbitrary precision: Arbitrary Precision Arithmetic.
(line 6)
-* floating-point, VAX/VMS: VMS Running. (line 51)
+* floating-point, VAX/VMS: VMS Running. (line 50)
* flush buffered output: I/O Functions. (line 28)
* fnmatch() extension function: Extension Sample Fnmatch.
(line 12)
-* FNR variable <1>: Auto-set. (line 99)
+* FNR variable <1>: Auto-set. (line 100)
* FNR variable: Records. (line 6)
-* FNR variable, changing: Auto-set. (line 313)
+* FNR variable, changing: Auto-set. (line 314)
* for statement: For Statement. (line 6)
* for statement, looping over arrays: Scanning an Array. (line 20)
* fork() extension function: Extension Sample Fork.
@@ -32637,7 +32647,7 @@ Index
* format time string: Time Functions. (line 48)
* formats, numeric output: OFMT. (line 6)
* formatting output: Printf. (line 6)
-* formatting strings: String Functions. (line 382)
+* formatting strings: String Functions. (line 383)
* forward slash (/) to enclose regular expressions: Regexp. (line 10)
* forward slash (/), / operator: Precedence. (line 55)
* forward slash (/), /= operator <1>: Precedence. (line 95)
@@ -32647,7 +32657,7 @@ Index
* forward slash (/), patterns and: Expression Patterns. (line 24)
* FPAT variable <1>: User-modified. (line 43)
* FPAT variable: Splitting By Content.
- (line 27)
+ (line 26)
* frame debugger command: Execution Stack. (line 27)
* Free Documentation License (FDL): GNU Free Documentation License.
(line 7)
@@ -32673,14 +32683,14 @@ Index
* FSF (Free Software Foundation): Manual History. (line 6)
* fts() extension function: Extension Sample File Functions.
(line 61)
-* FUNCTAB array: Auto-set. (line 115)
+* FUNCTAB array: Auto-set. (line 116)
* function calls: Function Calls. (line 6)
* function calls, indirect: Indirect Calls. (line 6)
* function calls, indirect, @-notation for: Indirect Calls. (line 47)
* function definition example: Function Example. (line 6)
* function pointers: Indirect Calls. (line 6)
* functions, arrays as parameters to: Pass By Value/Reference.
- (line 47)
+ (line 44)
* functions, built-in <1>: Functions. (line 6)
* functions, built-in: Function Calls. (line 10)
* functions, built-in, evaluation order: Calling Built-in. (line 30)
@@ -32711,7 +32721,7 @@ Index
* functions, recursive: Definition Syntax. (line 83)
* functions, string-translation: I18N Functions. (line 6)
* functions, undefined: Pass By Value/Reference.
- (line 71)
+ (line 68)
* functions, user-defined: User-defined. (line 6)
* functions, user-defined, calling: Function Caveats. (line 6)
* functions, user-defined, counts, in a profile: Profiling. (line 137)
@@ -32723,14 +32733,14 @@ Index
* G-d: Acknowledgments. (line 94)
* Garfinkle, Scott: Contributors. (line 34)
* gawk program, dynamic profiling: Profiling. (line 179)
-* gawk version: Auto-set. (line 206)
+* gawk version: Auto-set. (line 207)
* gawk, ARGIND variable in: Other Arguments. (line 15)
* gawk, awk and <1>: This Manual. (line 14)
* gawk, awk and: Preface. (line 21)
* gawk, bitwise operations in: Bitwise Functions. (line 40)
* gawk, break statement in: Break Statement. (line 51)
* gawk, character classes and: Bracket Expressions. (line 100)
-* gawk, coding style in: Adding Code. (line 39)
+* gawk, coding style in: Adding Code. (line 38)
* gawk, command-line options, and regular expressions: GNU Regexp Operators.
(line 70)
* gawk, configuring: Configuration Philosophy.
@@ -32744,26 +32754,26 @@ Index
* gawk, ERRNO variable in <2>: Auto-set. (line 74)
* gawk, ERRNO variable in <3>: BEGINFILE/ENDFILE. (line 26)
* gawk, ERRNO variable in <4>: Close Files And Pipes.
- (line 140)
+ (line 141)
* gawk, ERRNO variable in: Getline. (line 19)
-* gawk, escape sequences: Escape Sequences. (line 130)
+* gawk, escape sequences: Escape Sequences. (line 117)
* 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)
* gawk, FIELDWIDTHS variable in <1>: User-modified. (line 37)
-* gawk, FIELDWIDTHS variable in: Constant Size. (line 23)
+* gawk, FIELDWIDTHS variable in: Constant Size. (line 22)
* gawk, file names in: Special Files. (line 6)
* gawk, format-control characters: Control Letters. (line 18)
* gawk, FPAT variable in <1>: User-modified. (line 43)
* gawk, FPAT variable in: Splitting By Content.
- (line 27)
-* gawk, FUNCTAB array in: Auto-set. (line 115)
+ (line 26)
+* gawk, FUNCTAB array in: Auto-set. (line 116)
* gawk, function arguments and: Calling Built-in. (line 16)
* gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42)
* gawk, IGNORECASE variable in <1>: Array Sorting Functions.
(line 83)
-* gawk, IGNORECASE variable in <2>: String Functions. (line 57)
+* gawk, IGNORECASE variable in <2>: String Functions. (line 58)
* gawk, IGNORECASE variable in <3>: Array Intro. (line 94)
* gawk, IGNORECASE variable in <4>: User-modified. (line 76)
* gawk, IGNORECASE variable in: Case-sensitivity. (line 26)
@@ -32790,7 +32800,7 @@ Index
* gawk, predefined variables and: Built-in Variables. (line 14)
* gawk, PROCINFO array in <1>: Two-way I/O. (line 99)
* gawk, PROCINFO array in <2>: Time Functions. (line 47)
-* gawk, PROCINFO array in: Auto-set. (line 129)
+* gawk, PROCINFO array in: Auto-set. (line 130)
* gawk, regexp constants and: Using Constant Regexps.
(line 28)
* gawk, regular expressions, case sensitivity: Case-sensitivity.
@@ -32798,14 +32808,14 @@ Index
* gawk, regular expressions, operators: GNU Regexp Operators.
(line 6)
* gawk, regular expressions, precedence: Regexp Operators. (line 161)
-* gawk, RT variable in <1>: Auto-set. (line 264)
+* gawk, RT variable in <1>: Auto-set. (line 265)
* gawk, RT variable in <2>: Multiple Line. (line 129)
* gawk, RT variable in: awk split records. (line 125)
* gawk, See Also awk: Preface. (line 34)
* gawk, source code, obtaining: Getting. (line 6)
-* gawk, splitting fields and: Constant Size. (line 88)
+* gawk, splitting fields and: Constant Size. (line 87)
* gawk, string-translation functions: I18N Functions. (line 6)
-* gawk, SYMTAB array in: Auto-set. (line 268)
+* gawk, SYMTAB array in: Auto-set. (line 269)
* gawk, TEXTDOMAIN variable in: User-modified. (line 151)
* gawk, timestamps: Time Functions. (line 6)
* gawk, uses for: Preface. (line 34)
@@ -32818,7 +32828,7 @@ Index
* General Public License (GPL): Glossary. (line 305)
* General Public License, See GPL: Manual History. (line 11)
* generate time values: Time Functions. (line 25)
-* gensub <1>: String Functions. (line 89)
+* gensub <1>: String Functions. (line 90)
* gensub: Using Constant Regexps.
(line 43)
* gensub() function (gawk), escape processing: Gory Details. (line 6)
@@ -32863,7 +32873,7 @@ Index
* gettext() function (C library): Explaining gettext. (line 63)
* gettimeofday() extension function: Extension Sample Time.
(line 12)
-* git utility <1>: Adding Code. (line 112)
+* git utility <1>: Adding Code. (line 111)
* git utility <2>: Accessing The Source.
(line 10)
* git utility <3>: Other Versions. (line 29)
@@ -32891,12 +32901,12 @@ Index
* Grigera, Juan: Contributors. (line 57)
* group database, reading: Group Functions. (line 6)
* group file: Group Functions. (line 6)
-* group ID of gawk user: Auto-set. (line 179)
+* group ID of gawk user: Auto-set. (line 180)
* groups, information about: Group Functions. (line 6)
-* gsub <1>: String Functions. (line 139)
+* gsub <1>: String Functions. (line 140)
* gsub: Using Constant Regexps.
(line 43)
-* gsub() function, arguments of: String Functions. (line 461)
+* gsub() function, arguments of: String Functions. (line 462)
* gsub() function, escape processing: Gory Details. (line 6)
* h debugger command (alias for help): Miscellaneous Debugger Commands.
(line 66)
@@ -32938,8 +32948,8 @@ Index
(line 53)
* IGNORECASE variable, with ~ and !~ operators: Case-sensitivity.
(line 26)
-* Illumos: Other Versions. (line 105)
-* Illumos, POSIX-compliant awk: Other Versions. (line 105)
+* Illumos: Other Versions. (line 109)
+* Illumos, POSIX-compliant awk: Other Versions. (line 109)
* implementation issues, gawk: Notes. (line 6)
* implementation issues, gawk, debugging: Compatibility Mode. (line 6)
* implementation issues, gawk, limits <1>: Redirection. (line 129)
@@ -32956,7 +32966,7 @@ Index
* in operator, use in loops: Scanning an Array. (line 17)
* including files, @include directive: Include Files. (line 8)
* increment operators: Increment Ops. (line 6)
-* index: String Functions. (line 155)
+* index: String Functions. (line 156)
* indexing arrays: Array Intro. (line 50)
* indirect function calls: Indirect Calls. (line 6)
* indirect function calls, @-notation: Indirect Calls. (line 47)
@@ -32975,7 +32985,7 @@ Index
* input files, running awk without: Read Terminal. (line 6)
* input files, variable assignments and: Other Arguments. (line 26)
* input pipeline: Getline/Pipe. (line 9)
-* input record, length of: String Functions. (line 177)
+* input record, length of: String Functions. (line 178)
* input redirection: Getline/File. (line 6)
* input, data, nondecimal: Nondecimal Data. (line 6)
* input, explicit: Getline. (line 6)
@@ -32999,7 +33009,7 @@ Index
* integers, arbitrary precision: Arbitrary Precision Integers.
(line 6)
* integers, unsigned: Computer Arithmetic. (line 41)
-* interacting with other programs: I/O Functions. (line 74)
+* interacting with other programs: I/O Functions. (line 106)
* internationalization <1>: I18N and L10N. (line 6)
* internationalization: I18N Functions. (line 6)
* internationalization, localization <1>: Internationalization.
@@ -33020,7 +33030,7 @@ Index
* interpreted programs: Basic High Level. (line 15)
* interval expressions, regexp operator: Regexp Operators. (line 116)
* inventory-shipped file: Sample Data Files. (line 32)
-* invoke shell command: I/O Functions. (line 74)
+* invoke shell command: I/O Functions. (line 106)
* isarray: Type Functions. (line 11)
* ISO: Glossary. (line 367)
* ISO 8859-1: Glossary. (line 133)
@@ -33028,9 +33038,9 @@ Index
* Jacobs, Andrew: Passwd Functions. (line 90)
* Jaegermann, Michal <1>: Contributors. (line 45)
* Jaegermann, Michal: Acknowledgments. (line 60)
-* Java implementation of awk: Other Versions. (line 113)
+* Java implementation of awk: Other Versions. (line 117)
* Java programming language: Glossary. (line 379)
-* jawk: Other Versions. (line 113)
+* jawk: Other Versions. (line 117)
* Jedi knights: Undocumented. (line 6)
* Johansen, Chris: Signature Program. (line 25)
* join() user-defined function: Join Function. (line 18)
@@ -33076,12 +33086,12 @@ Index
* left shift: Bitwise Functions. (line 47)
* left shift, bitwise: Bitwise Functions. (line 32)
* leftmost longest match: Multiple Line. (line 26)
-* length: String Functions. (line 170)
-* length of input record: String Functions. (line 177)
-* length of string: String Functions. (line 170)
+* length: String Functions. (line 171)
+* length of input record: String Functions. (line 178)
+* length of string: String Functions. (line 171)
* Lesser General Public License (LGPL): Glossary. (line 396)
* LGPL (Lesser General Public License): Glossary. (line 396)
-* libmawk: Other Versions. (line 121)
+* libmawk: Other Versions. (line 125)
* libraries of awk functions: Library Functions. (line 6)
* libraries of awk functions, assertions: Assert Function. (line 6)
* libraries of awk functions, associative arrays and: Library Names.
@@ -33123,7 +33133,7 @@ Index
* lint checking, POSIXLY_CORRECT environment variable: Options.
(line 341)
* lint checking, undefined functions: Pass By Value/Reference.
- (line 88)
+ (line 85)
* LINT variable: User-modified. (line 88)
* Linux <1>: Glossary. (line 611)
* Linux <2>: I18N Example. (line 55)
@@ -33142,9 +33152,9 @@ Index
* localization: I18N and L10N. (line 6)
* localization, See internationalization, localization: I18N and L10N.
(line 6)
-* log: Numeric Functions. (line 30)
+* log: Numeric Functions. (line 28)
* log files, timestamps in: Time Functions. (line 6)
-* logarithm: Numeric Functions. (line 30)
+* logarithm: Numeric Functions. (line 28)
* logical false/true: Truth Values. (line 6)
* logical operators, See Boolean expressions: Boolean Ops. (line 6)
* login information: Passwd Functions. (line 16)
@@ -33165,7 +33175,7 @@ Index
* mail-list file: Sample Data Files. (line 6)
* mailing labels, printing: Labels Program. (line 6)
* mailing list, GNITS: Acknowledgments. (line 52)
-* Malmberg, John <1>: Bugs. (line 72)
+* Malmberg, John <1>: Bugs. (line 70)
* Malmberg, John: Acknowledgments. (line 60)
* Malmberg, John E.: Contributors. (line 137)
* mark parity: Ordinal Functions. (line 45)
@@ -33173,20 +33183,20 @@ Index
(line 6)
* marked strings, extracting: String Extraction. (line 6)
* Marx, Groucho: Increment Ops. (line 60)
-* match: String Functions. (line 210)
-* match regexp in string: String Functions. (line 210)
+* match: String Functions. (line 211)
+* match regexp in string: String Functions. (line 211)
* match() function, RSTART/RLENGTH variables: String Functions.
- (line 227)
+ (line 228)
* matching, expressions, See comparison expressions: Typing and Comparison.
(line 9)
* matching, leftmost longest: Multiple Line. (line 26)
-* matching, null strings: String Functions. (line 535)
-* mawk utility <1>: Other Versions. (line 44)
+* matching, null strings: String Functions. (line 536)
+* mawk utility <1>: Other Versions. (line 48)
* mawk utility <2>: Nextfile Statement. (line 47)
* mawk utility <3>: Concatenation. (line 36)
* mawk utility <4>: Getline/Pipe. (line 62)
-* mawk utility: Escape Sequences. (line 130)
-* maximum precision supported by MPFR library: Auto-set. (line 220)
+* mawk utility: Escape Sequences. (line 117)
+* maximum precision supported by MPFR library: Auto-set. (line 221)
* McIlroy, Doug: Glossary. (line 149)
* McPhee, Patrick: Contributors. (line 100)
* message object files: Explaining gettext. (line 42)
@@ -33199,7 +33209,7 @@ Index
* messages from extensions: Printing Messages. (line 6)
* metacharacters in regular expressions: Regexp Operators. (line 6)
* metacharacters, escape sequences for: Escape Sequences. (line 136)
-* minimum precision supported by MPFR library: Auto-set. (line 223)
+* minimum precision supported by MPFR library: Auto-set. (line 224)
* mktime: Time Functions. (line 25)
* modifiers, in format specifiers: Format Modifiers. (line 6)
* monetary information, localization: Explaining gettext. (line 104)
@@ -33248,7 +33258,7 @@ Index
(line 47)
* nexti debugger command: Debugger Execution Control.
(line 49)
-* NF variable <1>: Auto-set. (line 104)
+* NF variable <1>: Auto-set. (line 105)
* NF variable: Fields. (line 33)
* NF variable, decrementing: Changing Fields. (line 107)
* ni debugger command (alias for nexti): Debugger Execution Control.
@@ -33257,9 +33267,9 @@ Index
* non-existent array elements: Reference to Elements.
(line 23)
* not Boolean-logic operator: Boolean Ops. (line 6)
-* NR variable <1>: Auto-set. (line 124)
+* NR variable <1>: Auto-set. (line 125)
* NR variable: Records. (line 6)
-* NR variable, changing: Auto-set. (line 313)
+* NR variable, changing: Auto-set. (line 314)
* null strings <1>: Basic Data Typing. (line 26)
* null strings <2>: Truth Values. (line 6)
* null strings <3>: Regexp Field Splitting.
@@ -33271,9 +33281,9 @@ Index
(line 43)
* null strings, converting numbers to strings: Strings And Numbers.
(line 21)
-* null strings, matching: String Functions. (line 535)
+* null strings, matching: String Functions. (line 536)
* number as string of bits: Bitwise Functions. (line 110)
-* number of array elements: String Functions. (line 200)
+* number of array elements: String Functions. (line 201)
* number sign (#), #! (executable scripts): Executable Scripts.
(line 6)
* number sign (#), commenting: Comments. (line 6)
@@ -33304,7 +33314,7 @@ Index
* OFS variable <2>: Output Separators. (line 6)
* OFS variable: Changing Fields. (line 64)
* OpenBSD: Glossary. (line 611)
-* OpenSolaris: Other Versions. (line 96)
+* OpenSolaris: Other Versions. (line 100)
* operating systems, BSD-based: Manual History. (line 28)
* operating systems, PC, gawk on: PC Using. (line 6)
* operating systems, PC, gawk on, installing: PC Installation.
@@ -33354,10 +33364,10 @@ Index
* ord() user-defined function: Ordinal Functions. (line 16)
* order of evaluation, concatenation: Concatenation. (line 41)
* ORS variable <1>: User-modified. (line 118)
-* ORS variable: Output Separators. (line 20)
+* ORS variable: Output Separators. (line 21)
* output field separator, See OFS variable: Changing Fields. (line 64)
* output record separator, See ORS variable: Output Separators.
- (line 20)
+ (line 21)
* output redirection: Redirection. (line 6)
* output wrapper: Output Wrappers. (line 6)
* output, buffering: I/O Functions. (line 32)
@@ -33368,16 +33378,16 @@ Index
* output, formatted: Printf. (line 6)
* output, pipes: Redirection. (line 57)
* output, printing, See printing: Printing. (line 6)
-* output, records: Output Separators. (line 20)
+* output, records: Output Separators. (line 21)
* output, standard: Special FD. (line 6)
* p debugger command (alias for print): Viewing And Changing Data.
(line 36)
* Papadopoulos, Panos: Contributors. (line 128)
-* parent process ID of gawk process: Auto-set. (line 188)
+* parent process ID of gawk process: Auto-set. (line 189)
* parentheses (), in a profile: Profiling. (line 146)
* parentheses (), regexp operator: Regexp Operators. (line 81)
* password file: Passwd Functions. (line 16)
-* patsplit: String Functions. (line 296)
+* patsplit: String Functions. (line 297)
* patterns: Patterns and Actions.
(line 6)
* patterns, comparison expressions as: Expression Patterns. (line 14)
@@ -33389,8 +33399,8 @@ Index
* patterns, regexp constants as: Expression Patterns. (line 34)
* patterns, types of: Pattern Overview. (line 15)
* pawk (profiling version of Brian Kernighan's awk): Other Versions.
- (line 78)
-* pawk, awk-like facilities for Python: Other Versions. (line 125)
+ (line 82)
+* pawk, awk-like facilities for Python: Other Versions. (line 129)
* PC operating systems, gawk on: PC Using. (line 6)
* PC operating systems, gawk on, installing: PC Installation. (line 6)
* percent sign (%), % operator: Precedence. (line 55)
@@ -33404,7 +33414,7 @@ Index
(line 6)
* pipe, input: Getline/Pipe. (line 9)
* pipe, output: Redirection. (line 57)
-* Pitts, Dave <1>: Bugs. (line 72)
+* Pitts, Dave <1>: Bugs. (line 70)
* Pitts, Dave: Acknowledgments. (line 60)
* Plauger, P.J.: Library Functions. (line 12)
* plug-in: Extension Intro. (line 6)
@@ -33422,7 +33432,7 @@ Index
* portability, ARGV variable: Executable Scripts. (line 59)
* portability, backslash continuation and: Statements/Lines. (line 30)
* portability, backslash in escape sequences: Escape Sequences.
- (line 118)
+ (line 105)
* portability, close() function and: Close Files And Pipes.
(line 81)
* portability, data files as single record: gawk split records.
@@ -33433,15 +33443,15 @@ Index
* portability, gawk: New Ports. (line 6)
* portability, gettext library and: Explaining gettext. (line 11)
* portability, internationalization and: I18N Portability. (line 6)
-* portability, length() function: String Functions. (line 179)
+* portability, length() function: String Functions. (line 180)
* portability, new awk vs. old awk: Strings And Numbers. (line 57)
* portability, next statement in user-defined functions: Pass By Value/Reference.
- (line 91)
+ (line 88)
* 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 361)
-* portability, substr() function: String Functions. (line 511)
+* portability, substr() function: String Functions. (line 512)
* portable object files <1>: Translator i18n. (line 6)
* portable object files: Explaining gettext. (line 37)
* portable object files, converting to message object files: I18N Example.
@@ -33461,7 +33471,7 @@ Index
* POSIX awk, < operator and: Getline/File. (line 26)
* POSIX awk, arithmetic operators and: Arithmetic Ops. (line 30)
* POSIX awk, backslashes in string constants: Escape Sequences.
- (line 118)
+ (line 105)
* POSIX awk, BEGIN/END patterns: I/O And BEGIN/END. (line 16)
* POSIX awk, bracket expressions and: Bracket Expressions. (line 26)
* POSIX awk, bracket expressions and, character classes: Bracket Expressions.
@@ -33471,13 +33481,12 @@ Index
* POSIX awk, continue statement and: Continue Statement. (line 44)
* POSIX awk, CONVFMT variable and: User-modified. (line 30)
* POSIX awk, date utility and: Time Functions. (line 254)
-* POSIX awk, field separators and <1>: Field Splitting Summary.
- (line 40)
+* POSIX awk, field separators and <1>: Full Line Fields. (line 16)
* POSIX awk, field separators and: Fields. (line 6)
* POSIX awk, FS variable and: User-modified. (line 60)
* POSIX awk, function keyword in: Definition Syntax. (line 93)
* POSIX awk, functions and, gsub()/sub(): Gory Details. (line 90)
-* POSIX awk, functions and, length(): String Functions. (line 179)
+* POSIX awk, functions and, length(): String Functions. (line 180)
* POSIX awk, GNU long options and: Options. (line 15)
* POSIX awk, interval expressions in: Regexp Operators. (line 135)
* POSIX awk, next/nextfile statements and: Next Statement. (line 44)
@@ -33540,24 +33549,24 @@ Index
* printing, unduplicated lines of text: Uniq Program. (line 6)
* printing, user information: Id Program. (line 6)
* private variables: Library Names. (line 11)
-* process group idIDof gawk process: Auto-set. (line 182)
-* process ID of gawk process: Auto-set. (line 185)
+* process group idIDof gawk process: Auto-set. (line 183)
+* process ID of gawk process: Auto-set. (line 186)
* processes, two-way communications with: Two-way I/O. (line 6)
* processing data: Basic High Level. (line 6)
* PROCINFO array <1>: Passwd Functions. (line 6)
* PROCINFO array <2>: Time Functions. (line 47)
-* PROCINFO array: Auto-set. (line 129)
+* PROCINFO array: Auto-set. (line 130)
* PROCINFO array, and communications via ptys: Two-way I/O. (line 99)
* 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 154)
-* PROCINFO array, uses: Auto-set. (line 241)
+* PROCINFO array, uses: Auto-set. (line 242)
* PROCINFO, values of sorted_in: Controlling Scanning.
(line 26)
* profiling awk programs: Profiling. (line 6)
* profiling awk programs, dynamically: Profiling. (line 179)
-* program identifiers: Auto-set. (line 147)
+* program identifiers: Auto-set. (line 148)
* program, definition of: Getting Started. (line 21)
* programming conventions, --non-decimal-data option: Nondecimal Data.
(line 35)
@@ -33583,13 +33592,13 @@ Index
* pwcat program: Passwd Functions. (line 23)
* q debugger command (alias for quit): Miscellaneous Debugger Commands.
(line 99)
-* QSE Awk: Other Versions. (line 131)
+* QSE Awk: Other Versions. (line 135)
* Quanstrom, Erik: Alarm Program. (line 8)
* question mark (?), ?: operator: Precedence. (line 92)
* question mark (?), regexp operator <1>: GNU Regexp Operators.
(line 59)
* question mark (?), regexp operator: Regexp Operators. (line 111)
-* QuikTrim Awk: Other Versions. (line 135)
+* QuikTrim Awk: Other Versions. (line 139)
* quit debugger command: Miscellaneous Debugger Commands.
(line 99)
* QUIT signal (MS-Windows): Profiling. (line 214)
@@ -33601,12 +33610,12 @@ Index
* Rakitzis, Byron: History Sorting. (line 25)
* Ramey, Chet <1>: General Data Types. (line 6)
* Ramey, Chet: Acknowledgments. (line 60)
-* rand: Numeric Functions. (line 35)
+* rand: Numeric Functions. (line 33)
* random numbers, Cliff: Cliff Random Function.
(line 6)
* random numbers, rand()/srand() functions: Numeric Functions.
- (line 35)
-* random numbers, seed of: Numeric Functions. (line 65)
+ (line 33)
+* random numbers, seed of: Numeric Functions. (line 63)
* range expressions (regexps): Bracket Expressions. (line 6)
* range patterns: Ranges. (line 6)
* range patterns, line continuation and: Ranges. (line 65)
@@ -33691,12 +33700,12 @@ Index
* regular expressions, searching for: Egrep Program. (line 6)
* relational operators, See comparison operators: Typing and Comparison.
(line 9)
-* replace in string: String Functions. (line 407)
+* replace in string: String Functions. (line 408)
* return debugger command: Debugger Execution Control.
(line 54)
* return statement, user-defined functions: Return Statement. (line 6)
* return value, close() function: Close Files And Pipes.
- (line 132)
+ (line 133)
* rev() user-defined function: Function Example. (line 54)
* revoutput extension: Extension Sample Revout.
(line 11)
@@ -33715,10 +33724,10 @@ Index
* right shift: Bitwise Functions. (line 53)
* right shift, bitwise: Bitwise Functions. (line 32)
* Ritchie, Dennis: Basic Data Typing. (line 54)
-* RLENGTH variable: Auto-set. (line 251)
-* RLENGTH variable, match() function and: String Functions. (line 227)
+* RLENGTH variable: Auto-set. (line 252)
+* RLENGTH variable, match() function and: String Functions. (line 228)
* Robbins, Arnold <1>: Future Extensions. (line 6)
-* Robbins, Arnold <2>: Bugs. (line 72)
+* Robbins, Arnold <2>: Bugs. (line 70)
* Robbins, Arnold <3>: Contributors. (line 144)
* Robbins, Arnold <4>: General Data Types. (line 6)
* Robbins, Arnold <5>: Alarm Program. (line 6)
@@ -33741,9 +33750,9 @@ Index
* RS variable: awk split records. (line 12)
* RS variable, multiline records and: Multiple Line. (line 17)
* rshift: Bitwise Functions. (line 53)
-* RSTART variable: Auto-set. (line 257)
-* RSTART variable, match() function and: String Functions. (line 227)
-* RT variable <1>: Auto-set. (line 264)
+* RSTART variable: Auto-set. (line 258)
+* RSTART variable, match() function and: String Functions. (line 228)
+* RT variable <1>: Auto-set. (line 265)
* RT variable <2>: Multiple Line. (line 129)
* RT variable: awk split records. (line 125)
* Rubin, Paul <1>: Contributors. (line 15)
@@ -33763,17 +33772,17 @@ Index
* scanning arrays: Scanning an Array. (line 6)
* scanning multidimensional arrays: Multiscanning. (line 11)
* Schorr, Andrew <1>: Contributors. (line 133)
-* Schorr, Andrew <2>: Auto-set. (line 296)
+* Schorr, Andrew <2>: Auto-set. (line 297)
* Schorr, Andrew: Acknowledgments. (line 60)
* Schreiber, Bert: Acknowledgments. (line 38)
* Schreiber, Rita: Acknowledgments. (line 38)
-* search and replace in strings: String Functions. (line 89)
-* search in string: String Functions. (line 155)
-* search paths <1>: VMS Running. (line 58)
+* search and replace in strings: String Functions. (line 90)
+* search in string: String Functions. (line 156)
+* search paths <1>: VMS Running. (line 57)
* search paths <2>: PC Using. (line 10)
* search paths: Programs Exercises. (line 70)
* search paths, for loadable extensions: AWKLIBPATH Variable. (line 6)
-* search paths, for source files <1>: VMS Running. (line 58)
+* search paths, for source files <1>: VMS Running. (line 57)
* search paths, for source files <2>: PC Using. (line 10)
* search paths, for source files <3>: Programs Exercises. (line 70)
* search paths, for source files: AWKPATH Variable. (line 6)
@@ -33781,9 +33790,8 @@ Index
* searching, for words: Dupword Program. (line 6)
* sed utility <1>: Glossary. (line 11)
* sed utility <2>: Simple Sed. (line 6)
-* sed utility: Field Splitting Summary.
- (line 46)
-* seeding random number generator: Numeric Functions. (line 65)
+* sed utility: Full Line Fields. (line 22)
+* seeding random number generator: Numeric Functions. (line 63)
* semicolon (;), AWKPATH variable and: PC Using. (line 10)
* semicolon (;), separating statements in actions <1>: Statements.
(line 10)
@@ -33844,26 +33852,26 @@ Index
* sidebar, A Constant's Base Does Not Affect Its Value: Nondecimal-numbers.
(line 64)
* sidebar, Backslash Before Regular Characters: Escape Sequences.
- (line 116)
-* sidebar, Changing FS Does Not Affect the Fields: Field Splitting Summary.
- (line 38)
-* sidebar, Changing NR and FNR: Auto-set. (line 311)
+ (line 103)
+* sidebar, Changing FS Does Not Affect the Fields: Full Line Fields.
+ (line 14)
+* sidebar, Changing NR and FNR: Auto-set. (line 312)
* sidebar, Controlling Output Buffering with system(): I/O Functions.
- (line 137)
+ (line 138)
* sidebar, Escape Sequences for Metacharacters: Escape Sequences.
(line 134)
* sidebar, FS and IGNORECASE: Field Splitting Summary.
- (line 64)
+ (line 38)
* sidebar, Interactive Versus Noninteractive Buffering: I/O Functions.
- (line 106)
-* sidebar, Matching the Null String: String Functions. (line 533)
+ (line 73)
+* sidebar, Matching the Null String: String Functions. (line 534)
* sidebar, Operator Evaluation Order: Increment Ops. (line 58)
* sidebar, Piping into sh: Redirection. (line 134)
-* sidebar, Pre-POSIX awk Used OFMT For String Conversion: Strings And Numbers.
+* sidebar, Pre-POSIX awk Used OFMT for String Conversion: Strings And Numbers.
(line 55)
-* sidebar, Recipe For A Programming Language: History. (line 6)
+* sidebar, Recipe for a Programming Language: History. (line 6)
* sidebar, RS = "\0" Is Not Portable: gawk split records. (line 63)
-* sidebar, So Why Does gawk have BEGINFILE and ENDFILE?: Filetrans Function.
+* sidebar, So Why Does gawk Have BEGINFILE and ENDFILE?: Filetrans Function.
(line 82)
* sidebar, Syntactic Ambiguities Between /= and Regular Expressions: Assignment Ops.
(line 146)
@@ -33872,7 +33880,7 @@ Index
* sidebar, Using \n in Bracket Expressions of Dynamic Regexps: Computed Regexps.
(line 57)
* sidebar, Using close()'s Return Value: Close Files And Pipes.
- (line 130)
+ (line 131)
* SIGHUP signal, for dynamic profiling: Profiling. (line 211)
* SIGINT signal (MS-Windows): Profiling. (line 214)
* signals, HUP/SIGHUP, for profiling: Profiling. (line 211)
@@ -33884,8 +33892,8 @@ Index
* SIGUSR1 signal, for dynamic profiling: Profiling. (line 188)
* silent debugger command: Debugger Execution Control.
(line 10)
-* sin: Numeric Functions. (line 76)
-* sine: Numeric Functions. (line 76)
+* sin: Numeric Functions. (line 74)
+* sine: Numeric Functions. (line 74)
* single quote ('): One-shot. (line 15)
* single quote (') in gawk command lines: Long. (line 35)
* single quote ('), in shell commands: Quoting. (line 48)
@@ -33899,46 +33907,46 @@ Index
* sleep utility: Alarm Program. (line 110)
* sleep() extension function: Extension Sample Time.
(line 22)
-* Solaris, POSIX-compliant awk: Other Versions. (line 96)
-* sort array: String Functions. (line 41)
-* sort array indices: String Functions. (line 41)
+* Solaris, POSIX-compliant awk: Other Versions. (line 100)
+* sort array: String Functions. (line 42)
+* sort array indices: String Functions. (line 42)
* sort function, arrays, sorting: Array Sorting Functions.
(line 6)
* sort utility: Word Sorting. (line 50)
* sort utility, coprocesses and: Two-way I/O. (line 65)
* sorting characters in different languages: Explaining gettext.
(line 94)
-* source code, awka: Other Versions. (line 64)
+* source code, awka: Other Versions. (line 68)
* source code, Brian Kernighan's awk: Other Versions. (line 13)
-* source code, Busybox Awk: Other Versions. (line 88)
+* source code, Busybox Awk: Other Versions. (line 92)
* source code, gawk: Gawk Distribution. (line 6)
-* source code, Illumos awk: Other Versions. (line 105)
-* source code, jawk: Other Versions. (line 113)
-* source code, libmawk: Other Versions. (line 121)
-* source code, mawk: Other Versions. (line 44)
+* source code, Illumos awk: Other Versions. (line 109)
+* source code, jawk: Other Versions. (line 117)
+* source code, libmawk: Other Versions. (line 125)
+* source code, mawk: Other Versions. (line 48)
* source code, mixing: Options. (line 117)
-* source code, pawk: Other Versions. (line 78)
-* source code, pawk (Python version): Other Versions. (line 125)
-* source code, QSE Awk: Other Versions. (line 131)
-* source code, QuikTrim Awk: Other Versions. (line 135)
-* source code, Solaris awk: Other Versions. (line 96)
+* source code, pawk: Other Versions. (line 82)
+* source code, pawk (Python version): Other Versions. (line 129)
+* source code, QSE Awk: Other Versions. (line 135)
+* source code, QuikTrim Awk: Other Versions. (line 139)
+* source code, Solaris awk: Other Versions. (line 100)
* source files, search path for: Programs Exercises. (line 70)
* sparse arrays: Array Intro. (line 72)
* Spencer, Henry: Glossary. (line 11)
-* split: String Functions. (line 315)
-* split string into array: String Functions. (line 296)
+* split: String Functions. (line 316)
+* split string into array: String Functions. (line 297)
* split utility: Split Program. (line 6)
* split() function, array elements, deleting: Delete. (line 61)
* split.awk program: Split Program. (line 30)
-* sprintf <1>: String Functions. (line 382)
+* sprintf <1>: String Functions. (line 383)
* sprintf: OFMT. (line 15)
* sprintf() function, OFMT variable and: User-modified. (line 113)
* sprintf() function, print/printf statements and: Round Function.
(line 6)
-* sqrt: Numeric Functions. (line 79)
+* sqrt: Numeric Functions. (line 77)
* square brackets ([]), regexp operator: Regexp Operators. (line 56)
-* square root: Numeric Functions. (line 79)
-* srand: Numeric Functions. (line 83)
+* square root: Numeric Functions. (line 77)
+* srand: Numeric Functions. (line 81)
* stack frame: Debugging Terms. (line 10)
* Stallman, Richard <1>: Glossary. (line 296)
* Stallman, Richard <2>: Contributors. (line 23)
@@ -33961,23 +33969,22 @@ Index
* stop automatic display, in debugger: Viewing And Changing Data.
(line 80)
* stream editors <1>: Simple Sed. (line 6)
-* stream editors: Field Splitting Summary.
- (line 46)
+* stream editors: Full Line Fields. (line 22)
* strftime: Time Functions. (line 48)
* string constants: Scalar Constants. (line 15)
* string constants, vs. regexp constants: Computed Regexps. (line 39)
* string extraction (internationalization): String Extraction.
(line 6)
-* string length: String Functions. (line 170)
+* string length: String Functions. (line 171)
* string operators: Concatenation. (line 8)
-* string, regular expression match: String Functions. (line 210)
+* string, regular expression match: String Functions. (line 211)
* string-manipulation functions: String Functions. (line 6)
* string-matching operators: Regexp Usage. (line 19)
* string-translation functions: I18N Functions. (line 6)
-* strings splitting, example: String Functions. (line 334)
+* strings splitting, example: String Functions. (line 335)
* strings, converting <1>: Bitwise Functions. (line 110)
* strings, converting: Strings And Numbers. (line 6)
-* strings, converting letter case: String Functions. (line 521)
+* strings, converting letter case: String Functions. (line 522)
* strings, converting, numbers to: User-modified. (line 30)
* strings, empty, See null strings: awk split records. (line 115)
* strings, extracting: String Extraction. (line 6)
@@ -33987,13 +33994,13 @@ Index
* strings, null: Regexp Field Splitting.
(line 43)
* strings, numeric: Variable Typing. (line 6)
-* strtonum: String Functions. (line 389)
+* strtonum: String Functions. (line 390)
* strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data.
(line 35)
-* sub <1>: String Functions. (line 407)
+* sub <1>: String Functions. (line 408)
* sub: Using Constant Regexps.
(line 43)
-* sub() function, arguments of: String Functions. (line 461)
+* sub() function, arguments of: String Functions. (line 462)
* sub() function, escape processing: Gory Details. (line 6)
* subscript separators: User-modified. (line 145)
* subscripts in arrays, multidimensional: Multidimensional. (line 10)
@@ -34006,16 +34013,16 @@ Index
* SUBSEP variable: User-modified. (line 145)
* SUBSEP variable, and multidimensional arrays: Multidimensional.
(line 16)
-* substitute in string: String Functions. (line 89)
-* substr: String Functions. (line 480)
-* substring: String Functions. (line 480)
-* Sumner, Andrew: Other Versions. (line 64)
-* supplementary groups of gawk process: Auto-set. (line 236)
+* substitute in string: String Functions. (line 90)
+* substr: String Functions. (line 481)
+* substring: String Functions. (line 481)
+* Sumner, Andrew: Other Versions. (line 68)
+* supplementary groups of gawk process: Auto-set. (line 237)
* switch statement: Switch Statement. (line 6)
-* SYMTAB array: Auto-set. (line 268)
+* SYMTAB array: Auto-set. (line 269)
* syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops.
(line 148)
-* system: I/O Functions. (line 74)
+* system: I/O Functions. (line 106)
* systime: Time Functions. (line 66)
* t debugger command (alias for tbreak): Breakpoint Control. (line 90)
* tbreak debugger command: Breakpoint Control. (line 90)
@@ -34029,7 +34036,7 @@ Index
* testbits.awk program: Bitwise Functions. (line 71)
* testext extension: Extension Sample API Tests.
(line 6)
-* Texinfo <1>: Adding Code. (line 100)
+* Texinfo <1>: Adding Code. (line 99)
* Texinfo <2>: Distribution contents.
(line 77)
* Texinfo <3>: Extract Program. (line 12)
@@ -34065,8 +34072,8 @@ Index
* timestamps, converting dates to: Time Functions. (line 76)
* timestamps, formatted: Getlocaltime Function.
(line 6)
-* tolower: String Functions. (line 522)
-* toupper: String Functions. (line 528)
+* tolower: String Functions. (line 523)
+* toupper: String Functions. (line 529)
* tr utility: Translate Program. (line 6)
* trace debugger command: Miscellaneous Debugger Commands.
(line 108)
@@ -34079,10 +34086,10 @@ Index
(line 37)
* troubleshooting, awk uses FS not IFS: Field Separators. (line 30)
* troubleshooting, backslash before nonspecial character: Escape Sequences.
- (line 118)
+ (line 105)
* troubleshooting, division: Arithmetic Ops. (line 44)
* troubleshooting, fatal errors, field widths, specifying: Constant Size.
- (line 23)
+ (line 22)
* troubleshooting, fatal errors, printf format strings: Format Modifiers.
(line 158)
* troubleshooting, fflush() function: I/O Functions. (line 62)
@@ -34092,8 +34099,8 @@ Index
* troubleshooting, gawk, fatal errors, function arguments: Calling Built-in.
(line 16)
* troubleshooting, getline function: File Checking. (line 25)
-* troubleshooting, gsub()/sub() functions: String Functions. (line 471)
-* troubleshooting, match() function: String Functions. (line 291)
+* troubleshooting, gsub()/sub() functions: String Functions. (line 472)
+* troubleshooting, match() function: String Functions. (line 292)
* troubleshooting, print statement, omitting commas: Print Examples.
(line 31)
* troubleshooting, printing: Redirection. (line 112)
@@ -34102,8 +34109,8 @@ Index
* troubleshooting, regexp constants vs. string constants: Computed Regexps.
(line 39)
* troubleshooting, string concatenation: Concatenation. (line 26)
-* troubleshooting, substr() function: String Functions. (line 498)
-* troubleshooting, system() function: I/O Functions. (line 96)
+* troubleshooting, substr() function: String Functions. (line 499)
+* troubleshooting, system() function: I/O Functions. (line 128)
* troubleshooting, typographical errors, global variables: Options.
(line 98)
* true, logical: Truth Values. (line 6)
@@ -34118,7 +34125,7 @@ Index
* unassigned array elements: Reference to Elements.
(line 18)
* undefined functions: Pass By Value/Reference.
- (line 71)
+ (line 68)
* underscore (_), C macro: Explaining gettext. (line 71)
* underscore (_), in names of private variables: Library Names.
(line 29)
@@ -34135,9 +34142,9 @@ Index
* uniq.awk program: Uniq Program. (line 65)
* Unix: Glossary. (line 611)
* Unix awk, backslashes in escape sequences: Escape Sequences.
- (line 130)
+ (line 117)
* Unix awk, close() function and: Close Files And Pipes.
- (line 132)
+ (line 133)
* Unix awk, password files, field separators and: Command Line Field Separator.
(line 62)
* Unix, awk scripts and: Executable Scripts. (line 6)
@@ -34189,10 +34196,10 @@ Index
* variables, uninitialized, as array subscripts: Uninitialized Subscripts.
(line 6)
* variables, user-defined: Variables. (line 6)
-* version of gawk: Auto-set. (line 206)
-* version of gawk extension API: Auto-set. (line 231)
-* version of GNU MP library: Auto-set. (line 217)
-* version of GNU MPFR library: Auto-set. (line 213)
+* version of gawk: Auto-set. (line 207)
+* version of gawk extension API: Auto-set. (line 232)
+* version of GNU MP library: Auto-set. (line 218)
+* version of GNU MPFR library: Auto-set. (line 214)
* vertical bar (|): Regexp Operators. (line 70)
* vertical bar (|), | operator (I/O) <1>: Precedence. (line 65)
* vertical bar (|), | operator (I/O): Getline/Pipe. (line 9)
@@ -34204,7 +34211,7 @@ Index
* Vinschen, Corinna: Acknowledgments. (line 60)
* w debugger command (alias for watch): Viewing And Changing Data.
(line 67)
-* w utility: Constant Size. (line 23)
+* w utility: Constant Size. (line 22)
* wait() extension function: Extension Sample Fork.
(line 22)
* waitpid() extension function: Extension Sample Fork.
@@ -34249,7 +34256,7 @@ Index
* xor: Bitwise Functions. (line 56)
* XOR bitwise operation: Bitwise Functions. (line 6)
* Yawitz, Efraim: Contributors. (line 131)
-* Zaretskii, Eli <1>: Bugs. (line 72)
+* Zaretskii, Eli <1>: Bugs. (line 70)
* Zaretskii, Eli <2>: Contributors. (line 55)
* Zaretskii, Eli: Acknowledgments. (line 60)
* zerofile.awk program: Empty Files. (line 21)
@@ -34266,7 +34273,7 @@ Index
* | (vertical bar), |& operator (I/O) <3>: Redirection. (line 96)
* | (vertical bar), |& operator (I/O): Getline/Coprocess. (line 6)
* | (vertical bar), |& operator (I/O), pipes, closing: Close Files And Pipes.
- (line 120)
+ (line 121)
* | (vertical bar), || operator <1>: Precedence. (line 89)
* | (vertical bar), || operator: Boolean Ops. (line 59)
* ~ (tilde), ~ operator <1>: Expression Patterns. (line 24)
@@ -34283,557 +34290,557 @@ Index
Tag Table:
Node: Top1204
Node: Foreword342156
-Node: Foreword446548
-Node: Preface47982
-Ref: Preface-Footnote-150853
-Ref: Preface-Footnote-250960
-Ref: Preface-Footnote-351193
-Node: History51335
-Node: Names53683
-Ref: Names-Footnote-154777
-Node: This Manual54923
-Ref: This Manual-Footnote-160752
-Node: Conventions60852
-Node: Manual History63192
-Ref: Manual History-Footnote-166183
-Ref: Manual History-Footnote-266224
-Node: How To Contribute66298
-Node: Acknowledgments67429
-Node: Getting Started72237
-Node: Running gawk74671
-Node: One-shot75861
-Node: Read Terminal77086
-Node: Long79113
-Node: Executable Scripts80629
-Ref: Executable Scripts-Footnote-183418
-Node: Comments83520
-Node: Quoting85993
-Node: DOS Quoting91499
-Node: Sample Data Files92174
-Node: Very Simple94767
-Node: Two Rules99658
-Node: More Complex101544
-Node: Statements/Lines104406
-Ref: Statements/Lines-Footnote-1108862
-Node: Other Features109127
-Node: When110058
-Ref: When-Footnote-1111814
-Node: Intro Summary111879
-Node: Invoking Gawk112762
-Node: Command Line114277
-Node: Options115068
-Ref: Options-Footnote-1130980
-Node: Other Arguments131005
-Node: Naming Standard Input133966
-Node: Environment Variables135059
-Node: AWKPATH Variable135617
-Ref: AWKPATH Variable-Footnote-1138917
-Ref: AWKPATH Variable-Footnote-2138962
-Node: AWKLIBPATH Variable139222
-Node: Other Environment Variables140365
-Node: Exit Status144085
-Node: Include Files144760
-Node: Loading Shared Libraries148348
-Node: Obsolete149775
-Node: Undocumented150472
-Node: Invoking Summary150739
-Node: Regexp152405
-Node: Regexp Usage153864
-Node: Escape Sequences155897
-Node: Regexp Operators161914
-Ref: Regexp Operators-Footnote-1169348
-Ref: Regexp Operators-Footnote-2169495
-Node: Bracket Expressions169593
-Ref: table-char-classes171610
-Node: Leftmost Longest174550
-Node: Computed Regexps175852
-Node: GNU Regexp Operators179249
-Node: Case-sensitivity182951
-Ref: Case-sensitivity-Footnote-1185841
-Ref: Case-sensitivity-Footnote-2186076
-Node: Regexp Summary186184
-Node: Reading Files187653
-Node: Records189747
-Node: awk split records190479
-Node: gawk split records195393
-Ref: gawk split records-Footnote-1199932
-Node: Fields199969
-Ref: Fields-Footnote-1202767
-Node: Nonconstant Fields202853
-Ref: Nonconstant Fields-Footnote-1205089
-Node: Changing Fields205291
-Node: Field Separators211223
-Node: Default Field Splitting213927
-Node: Regexp Field Splitting215044
-Node: Single Character Fields218394
-Node: Command Line Field Separator219453
-Node: Full Line Fields222665
-Ref: Full Line Fields-Footnote-1223173
-Node: Field Splitting Summary223219
-Ref: Field Splitting Summary-Footnote-1226350
-Node: Constant Size226451
-Node: Splitting By Content231057
-Ref: Splitting By Content-Footnote-1235130
-Node: Multiple Line235170
-Ref: Multiple Line-Footnote-1241059
-Node: Getline241238
-Node: Plain Getline243449
-Node: Getline/Variable246089
-Node: Getline/File247236
-Node: Getline/Variable/File248620
-Ref: Getline/Variable/File-Footnote-1250221
-Node: Getline/Pipe250308
-Node: Getline/Variable/Pipe252991
-Node: Getline/Coprocess254122
-Node: Getline/Variable/Coprocess255374
-Node: Getline Notes256113
-Node: Getline Summary258905
-Ref: table-getline-variants259317
-Node: Read Timeout260146
-Ref: Read Timeout-Footnote-1263960
-Node: Command-line directories264018
-Node: Input Summary264922
-Node: Input Exercises268174
-Node: Printing268902
-Node: Print270679
-Node: Print Examples272136
-Node: Output Separators274915
-Node: OFMT276933
-Node: Printf278287
-Node: Basic Printf279072
-Node: Control Letters280643
-Node: Format Modifiers284627
-Node: Printf Examples290634
-Node: Redirection293116
-Node: Special FD299955
-Ref: Special FD-Footnote-1303112
-Node: Special Files303186
-Node: Other Inherited Files303802
-Node: Special Network304802
-Node: Special Caveats305663
-Node: Close Files And Pipes306614
-Ref: Close Files And Pipes-Footnote-1313793
-Ref: Close Files And Pipes-Footnote-2313941
-Node: Output Summary314091
-Node: Output Exercises315087
-Node: Expressions315767
-Node: Values316952
-Node: Constants317628
-Node: Scalar Constants318308
-Ref: Scalar Constants-Footnote-1319167
-Node: Nondecimal-numbers319417
-Node: Regexp Constants322417
-Node: Using Constant Regexps322942
-Node: Variables326080
-Node: Using Variables326735
-Node: Assignment Options328645
-Node: Conversion330520
-Node: Strings And Numbers331044
-Ref: Strings And Numbers-Footnote-1334108
-Node: Locale influences conversions334217
-Ref: table-locale-affects336962
-Node: All Operators337550
-Node: Arithmetic Ops338180
-Node: Concatenation340685
-Ref: Concatenation-Footnote-1343504
-Node: Assignment Ops343610
-Ref: table-assign-ops348593
-Node: Increment Ops349871
-Node: Truth Values and Conditions353309
-Node: Truth Values354392
-Node: Typing and Comparison355441
-Node: Variable Typing356234
-Node: Comparison Operators359886
-Ref: table-relational-ops360296
-Node: POSIX String Comparison363811
-Ref: POSIX String Comparison-Footnote-1364883
-Node: Boolean Ops365021
-Ref: Boolean Ops-Footnote-1369500
-Node: Conditional Exp369591
-Node: Function Calls371318
-Node: Precedence375198
-Node: Locales378866
-Node: Expressions Summary380497
-Node: Patterns and Actions383071
-Node: Pattern Overview384191
-Node: Regexp Patterns385870
-Node: Expression Patterns386413
-Node: Ranges390193
-Node: BEGIN/END393299
-Node: Using BEGIN/END394061
-Ref: Using BEGIN/END-Footnote-1396798
-Node: I/O And BEGIN/END396904
-Node: BEGINFILE/ENDFILE399218
-Node: Empty402119
-Node: Using Shell Variables402436
-Node: Action Overview404712
-Node: Statements407039
-Node: If Statement408887
-Node: While Statement410385
-Node: Do Statement412413
-Node: For Statement413555
-Node: Switch Statement416710
-Node: Break Statement419098
-Node: Continue Statement421139
-Node: Next Statement422964
-Node: Nextfile Statement425344
-Node: Exit Statement427974
-Node: Built-in Variables430377
-Node: User-modified431510
-Ref: User-modified-Footnote-1439190
-Node: Auto-set439252
-Ref: Auto-set-Footnote-1452282
-Ref: Auto-set-Footnote-2452487
-Node: ARGC and ARGV452543
-Node: Pattern Action Summary456747
-Node: Arrays459174
-Node: Array Basics460503
-Node: Array Intro461347
-Ref: figure-array-elements463311
-Ref: Array Intro-Footnote-1465835
-Node: Reference to Elements465963
-Node: Assigning Elements468413
-Node: Array Example468904
-Node: Scanning an Array470662
-Node: Controlling Scanning473678
-Ref: Controlling Scanning-Footnote-1478867
-Node: Numeric Array Subscripts479183
-Node: Uninitialized Subscripts481368
-Node: Delete482985
-Ref: Delete-Footnote-1485729
-Node: Multidimensional485786
-Node: Multiscanning488881
-Node: Arrays of Arrays490470
-Node: Arrays Summary495231
-Node: Functions497336
-Node: Built-in498209
-Node: Calling Built-in499287
-Node: Numeric Functions501275
-Ref: Numeric Functions-Footnote-1505297
-Ref: Numeric Functions-Footnote-2505654
-Ref: Numeric Functions-Footnote-3505702
-Node: String Functions505971
-Ref: String Functions-Footnote-1529443
-Ref: String Functions-Footnote-2529572
-Ref: String Functions-Footnote-3529820
-Node: Gory Details529907
-Ref: table-sub-escapes531688
-Ref: table-sub-proposed533208
-Ref: table-posix-sub534572
-Ref: table-gensub-escapes536112
-Ref: Gory Details-Footnote-1536944
-Node: I/O Functions537095
-Ref: I/O Functions-Footnote-1544196
-Node: Time Functions544343
-Ref: Time Functions-Footnote-1554812
-Ref: Time Functions-Footnote-2554880
-Ref: Time Functions-Footnote-3555038
-Ref: Time Functions-Footnote-4555149
-Ref: Time Functions-Footnote-5555261
-Ref: Time Functions-Footnote-6555488
-Node: Bitwise Functions555754
-Ref: table-bitwise-ops556316
-Ref: Bitwise Functions-Footnote-1560624
-Node: Type Functions560793
-Node: I18N Functions561942
-Node: User-defined563587
-Node: Definition Syntax564391
-Ref: Definition Syntax-Footnote-1569797
-Node: Function Example569866
-Ref: Function Example-Footnote-1572783
-Node: Function Caveats572805
-Node: Calling A Function573323
-Node: Variable Scope574278
-Node: Pass By Value/Reference577266
-Node: Return Statement580776
-Node: Dynamic Typing583760
-Node: Indirect Calls584689
-Ref: Indirect Calls-Footnote-1595993
-Node: Functions Summary596121
-Node: Library Functions598820
-Ref: Library Functions-Footnote-1602438
-Ref: Library Functions-Footnote-2602581
-Node: Library Names602752
-Ref: Library Names-Footnote-1606212
-Ref: Library Names-Footnote-2606432
-Node: General Functions606518
-Node: Strtonum Function607621
-Node: Assert Function610641
-Node: Round Function613965
-Node: Cliff Random Function615506
-Node: Ordinal Functions616522
-Ref: Ordinal Functions-Footnote-1619587
-Ref: Ordinal Functions-Footnote-2619839
-Node: Join Function620050
-Ref: Join Function-Footnote-1621821
-Node: Getlocaltime Function622021
-Node: Readfile Function625762
-Node: Shell Quoting627732
-Node: Data File Management629133
-Node: Filetrans Function629765
-Node: Rewind Function633824
-Node: File Checking635209
-Ref: File Checking-Footnote-1636537
-Node: Empty Files636738
-Node: Ignoring Assigns638717
-Node: Getopt Function640268
-Ref: Getopt Function-Footnote-1651728
-Node: Passwd Functions651931
-Ref: Passwd Functions-Footnote-1660782
-Node: Group Functions660870
-Ref: Group Functions-Footnote-1668773
-Node: Walking Arrays668986
-Node: Library Functions Summary670589
-Node: Library Exercises671990
-Node: Sample Programs673270
-Node: Running Examples674040
-Node: Clones674768
-Node: Cut Program675992
-Node: Egrep Program685722
-Ref: Egrep Program-Footnote-1693226
-Node: Id Program693336
-Node: Split Program696980
-Ref: Split Program-Footnote-1700426
-Node: Tee Program700554
-Node: Uniq Program703341
-Node: Wc Program710762
-Ref: Wc Program-Footnote-1715010
-Node: Miscellaneous Programs715102
-Node: Dupword Program716315
-Node: Alarm Program718346
-Node: Translate Program723150
-Ref: Translate Program-Footnote-1727714
-Node: Labels Program727984
-Ref: Labels Program-Footnote-1731333
-Node: Word Sorting731417
-Node: History Sorting735487
-Node: Extract Program737323
-Node: Simple Sed744855
-Node: Igawk Program747917
-Ref: Igawk Program-Footnote-1762243
-Ref: Igawk Program-Footnote-2762444
-Ref: Igawk Program-Footnote-3762566
-Node: Anagram Program762681
-Node: Signature Program765743
-Node: Programs Summary766990
-Node: Programs Exercises768183
-Ref: Programs Exercises-Footnote-1772314
-Node: Advanced Features772405
-Node: Nondecimal Data774353
-Node: Array Sorting775943
-Node: Controlling Array Traversal776640
-Ref: Controlling Array Traversal-Footnote-1784971
-Node: Array Sorting Functions785089
-Ref: Array Sorting Functions-Footnote-1788981
-Node: Two-way I/O789175
-Ref: Two-way I/O-Footnote-1794119
-Ref: Two-way I/O-Footnote-2794305
-Node: TCP/IP Networking794387
-Node: Profiling797259
-Node: Advanced Features Summary804803
-Node: Internationalization806736
-Node: I18N and L10N808216
-Node: Explaining gettext808902
-Ref: Explaining gettext-Footnote-1813931
-Ref: Explaining gettext-Footnote-2814115
-Node: Programmer i18n814280
-Ref: Programmer i18n-Footnote-1819146
-Node: Translator i18n819195
-Node: String Extraction819989
-Ref: String Extraction-Footnote-1821120
-Node: Printf Ordering821206
-Ref: Printf Ordering-Footnote-1823992
-Node: I18N Portability824056
-Ref: I18N Portability-Footnote-1826505
-Node: I18N Example826568
-Ref: I18N Example-Footnote-1829368
-Node: Gawk I18N829440
-Node: I18N Summary830078
-Node: Debugger831417
-Node: Debugging832439
-Node: Debugging Concepts832880
-Node: Debugging Terms834737
-Node: Awk Debugging837312
-Node: Sample Debugging Session838204
-Node: Debugger Invocation838724
-Node: Finding The Bug840108
-Node: List of Debugger Commands846583
-Node: Breakpoint Control847915
-Node: Debugger Execution Control851607
-Node: Viewing And Changing Data854971
-Node: Execution Stack858336
-Node: Debugger Info859974
-Node: Miscellaneous Debugger Commands863991
-Node: Readline Support869183
-Node: Limitations870075
-Node: Debugging Summary872172
-Node: Arbitrary Precision Arithmetic873340
-Node: Computer Arithmetic874756
-Ref: table-numeric-ranges878357
-Ref: Computer Arithmetic-Footnote-1879216
-Node: Math Definitions879273
-Ref: table-ieee-formats882560
-Ref: Math Definitions-Footnote-1883164
-Node: MPFR features883269
-Node: FP Math Caution884940
-Ref: FP Math Caution-Footnote-1885990
-Node: Inexactness of computations886359
-Node: Inexact representation887307
-Node: Comparing FP Values888662
-Node: Errors accumulate889735
-Node: Getting Accuracy891168
-Node: Try To Round893827
-Node: Setting precision894726
-Ref: table-predefined-precision-strings895410
-Node: Setting the rounding mode897204
-Ref: table-gawk-rounding-modes897568
-Ref: Setting the rounding mode-Footnote-1901022
-Node: Arbitrary Precision Integers901201
-Ref: Arbitrary Precision Integers-Footnote-1904192
-Node: POSIX Floating Point Problems904341
-Ref: POSIX Floating Point Problems-Footnote-1908217
-Node: Floating point summary908255
-Node: Dynamic Extensions910447
-Node: Extension Intro911999
-Node: Plugin License913265
-Node: Extension Mechanism Outline914062
-Ref: figure-load-extension914490
-Ref: figure-register-new-function915970
-Ref: figure-call-new-function916974
-Node: Extension API Description918960
-Node: Extension API Functions Introduction920410
-Node: General Data Types925246
-Ref: General Data Types-Footnote-1930933
-Node: Memory Allocation Functions931232
-Ref: Memory Allocation Functions-Footnote-1934062
-Node: Constructor Functions934158
-Node: Registration Functions935892
-Node: Extension Functions936577
-Node: Exit Callback Functions938873
-Node: Extension Version String940121
-Node: Input Parsers940771
-Node: Output Wrappers950586
-Node: Two-way processors955102
-Node: Printing Messages957306
-Ref: Printing Messages-Footnote-1958383
-Node: Updating `ERRNO'958535
-Node: Requesting Values959275
-Ref: table-value-types-returned960003
-Node: Accessing Parameters960961
-Node: Symbol Table Access962192
-Node: Symbol table by name962706
-Node: Symbol table by cookie964686
-Ref: Symbol table by cookie-Footnote-1968825
-Node: Cached values968888
-Ref: Cached values-Footnote-1972392
-Node: Array Manipulation972483
-Ref: Array Manipulation-Footnote-1973581
-Node: Array Data Types973620
-Ref: Array Data Types-Footnote-1976277
-Node: Array Functions976369
-Node: Flattening Arrays980223
-Node: Creating Arrays987110
-Node: Extension API Variables991877
-Node: Extension Versioning992513
-Node: Extension API Informational Variables994414
-Node: Extension API Boilerplate995502
-Node: Finding Extensions999318
-Node: Extension Example999878
-Node: Internal File Description1000650
-Node: Internal File Ops1004717
-Ref: Internal File Ops-Footnote-11016375
-Node: Using Internal File Ops1016515
-Ref: Using Internal File Ops-Footnote-11018898
-Node: Extension Samples1019171
-Node: Extension Sample File Functions1020695
-Node: Extension Sample Fnmatch1028297
-Node: Extension Sample Fork1029779
-Node: Extension Sample Inplace1030992
-Node: Extension Sample Ord1032667
-Node: Extension Sample Readdir1033503
-Ref: table-readdir-file-types1034379
-Node: Extension Sample Revout1035190
-Node: Extension Sample Rev2way1035781
-Node: Extension Sample Read write array1036522
-Node: Extension Sample Readfile1038461
-Node: Extension Sample Time1039556
-Node: Extension Sample API Tests1040905
-Node: gawkextlib1041396
-Node: Extension summary1044046
-Node: Extension Exercises1047728
-Node: Language History1048450
-Node: V7/SVR3.11050107
-Node: SVR41052288
-Node: POSIX1053733
-Node: BTL1055122
-Node: POSIX/GNU1055856
-Node: Feature History1061425
-Node: Common Extensions1074523
-Node: Ranges and Locales1075847
-Ref: Ranges and Locales-Footnote-11080486
-Ref: Ranges and Locales-Footnote-21080513
-Ref: Ranges and Locales-Footnote-31080747
-Node: Contributors1080968
-Node: History summary1086508
-Node: Installation1087877
-Node: Gawk Distribution1088833
-Node: Getting1089317
-Node: Extracting1090141
-Node: Distribution contents1091783
-Node: Unix Installation1097500
-Node: Quick Installation1098117
-Node: Additional Configuration Options1100548
-Node: Configuration Philosophy1102288
-Node: Non-Unix Installation1104639
-Node: PC Installation1105097
-Node: PC Binary Installation1106423
-Node: PC Compiling1108271
-Ref: PC Compiling-Footnote-11111292
-Node: PC Testing1111397
-Node: PC Using1112573
-Node: Cygwin1116688
-Node: MSYS1117511
-Node: VMS Installation1118009
-Node: VMS Compilation1118801
-Ref: VMS Compilation-Footnote-11120023
-Node: VMS Dynamic Extensions1120081
-Node: VMS Installation Details1121765
-Node: VMS Running1124017
-Node: VMS GNV1126858
-Node: VMS Old Gawk1127592
-Node: Bugs1128062
-Node: Other Versions1131966
-Node: Installation summary1138179
-Node: Notes1139235
-Node: Compatibility Mode1140100
-Node: Additions1140882
-Node: Accessing The Source1141807
-Node: Adding Code1143243
-Node: New Ports1149415
-Node: Derived Files1153897
-Ref: Derived Files-Footnote-11159372
-Ref: Derived Files-Footnote-21159406
-Ref: Derived Files-Footnote-31160002
-Node: Future Extensions1160116
-Node: Implementation Limitations1160722
-Node: Extension Design1161970
-Node: Old Extension Problems1163124
-Ref: Old Extension Problems-Footnote-11164641
-Node: Extension New Mechanism Goals1164698
-Ref: Extension New Mechanism Goals-Footnote-11168058
-Node: Extension Other Design Decisions1168247
-Node: Extension Future Growth1170355
-Node: Old Extension Mechanism1171191
-Node: Notes summary1172953
-Node: Basic Concepts1174139
-Node: Basic High Level1174820
-Ref: figure-general-flow1175092
-Ref: figure-process-flow1175691
-Ref: Basic High Level-Footnote-11178920
-Node: Basic Data Typing1179105
-Node: Glossary1182433
-Node: Copying1207591
-Node: GNU Free Documentation License1245147
-Node: Index1270283
+Node: Foreword446598
+Node: Preface48031
+Ref: Preface-Footnote-150902
+Ref: Preface-Footnote-251009
+Ref: Preface-Footnote-351242
+Node: History51384
+Node: Names53730
+Ref: Names-Footnote-154824
+Node: This Manual54970
+Ref: This Manual-Footnote-161457
+Node: Conventions61557
+Node: Manual History63895
+Ref: Manual History-Footnote-166877
+Ref: Manual History-Footnote-266918
+Node: How To Contribute66992
+Node: Acknowledgments68121
+Node: Getting Started72925
+Node: Running gawk75358
+Node: One-shot76548
+Node: Read Terminal77796
+Node: Long79823
+Node: Executable Scripts81339
+Ref: Executable Scripts-Footnote-184128
+Node: Comments84231
+Node: Quoting86713
+Node: DOS Quoting92237
+Node: Sample Data Files92912
+Node: Very Simple95507
+Node: Two Rules100405
+Node: More Complex102291
+Node: Statements/Lines105153
+Ref: Statements/Lines-Footnote-1109608
+Node: Other Features109873
+Node: When110804
+Ref: When-Footnote-1112558
+Node: Intro Summary112623
+Node: Invoking Gawk113506
+Node: Command Line115020
+Node: Options115818
+Ref: Options-Footnote-1131749
+Node: Other Arguments131774
+Node: Naming Standard Input134722
+Node: Environment Variables135815
+Node: AWKPATH Variable136373
+Ref: AWKPATH Variable-Footnote-1139676
+Ref: AWKPATH Variable-Footnote-2139721
+Node: AWKLIBPATH Variable139981
+Node: Other Environment Variables141124
+Node: Exit Status144852
+Node: Include Files145528
+Node: Loading Shared Libraries149125
+Node: Obsolete150552
+Node: Undocumented151249
+Node: Invoking Summary151516
+Node: Regexp153180
+Node: Regexp Usage154634
+Node: Escape Sequences156671
+Node: Regexp Operators162682
+Ref: Regexp Operators-Footnote-1170108
+Ref: Regexp Operators-Footnote-2170255
+Node: Bracket Expressions170353
+Ref: table-char-classes172368
+Node: Leftmost Longest175292
+Node: Computed Regexps176594
+Node: GNU Regexp Operators179991
+Node: Case-sensitivity183664
+Ref: Case-sensitivity-Footnote-1186549
+Ref: Case-sensitivity-Footnote-2186784
+Node: Regexp Summary186892
+Node: Reading Files188359
+Node: Records190453
+Node: awk split records191186
+Node: gawk split records196101
+Ref: gawk split records-Footnote-1200641
+Node: Fields200678
+Ref: Fields-Footnote-1203454
+Node: Nonconstant Fields203540
+Ref: Nonconstant Fields-Footnote-1205783
+Node: Changing Fields205987
+Node: Field Separators211916
+Node: Default Field Splitting214621
+Node: Regexp Field Splitting215738
+Node: Single Character Fields219088
+Node: Command Line Field Separator220147
+Node: Full Line Fields223359
+Ref: Full Line Fields-Footnote-1224888
+Ref: Full Line Fields-Footnote-2224934
+Node: Field Splitting Summary225035
+Node: Constant Size227109
+Node: Splitting By Content231698
+Ref: Splitting By Content-Footnote-1235753
+Node: Multiple Line235793
+Ref: Multiple Line-Footnote-1241679
+Node: Getline241858
+Node: Plain Getline244070
+Node: Getline/Variable246710
+Node: Getline/File247858
+Node: Getline/Variable/File249242
+Ref: Getline/Variable/File-Footnote-1250845
+Node: Getline/Pipe250932
+Node: Getline/Variable/Pipe253615
+Node: Getline/Coprocess254746
+Node: Getline/Variable/Coprocess255998
+Node: Getline Notes256737
+Node: Getline Summary259529
+Ref: table-getline-variants259941
+Node: Read Timeout260770
+Ref: Read Timeout-Footnote-1264589
+Node: Command-line directories264647
+Node: Input Summary265552
+Node: Input Exercises268805
+Node: Printing269533
+Node: Print271310
+Node: Print Examples272767
+Node: Output Separators275546
+Node: OFMT277564
+Node: Printf278918
+Node: Basic Printf279703
+Node: Control Letters281272
+Node: Format Modifiers285256
+Node: Printf Examples291257
+Node: Redirection293743
+Node: Special FD300584
+Ref: Special FD-Footnote-1303744
+Node: Special Files303818
+Node: Other Inherited Files304435
+Node: Special Network305435
+Node: Special Caveats306297
+Node: Close Files And Pipes307248
+Ref: Close Files And Pipes-Footnote-1314430
+Ref: Close Files And Pipes-Footnote-2314578
+Node: Output Summary314728
+Node: Output Exercises315726
+Node: Expressions316406
+Node: Values317591
+Node: Constants318269
+Node: Scalar Constants318960
+Ref: Scalar Constants-Footnote-1319819
+Node: Nondecimal-numbers320069
+Node: Regexp Constants323087
+Node: Using Constant Regexps323612
+Node: Variables326755
+Node: Using Variables327410
+Node: Assignment Options329321
+Node: Conversion331196
+Node: Strings And Numbers331720
+Ref: Strings And Numbers-Footnote-1334785
+Node: Locale influences conversions334894
+Ref: table-locale-affects337641
+Node: All Operators338229
+Node: Arithmetic Ops338859
+Node: Concatenation341364
+Ref: Concatenation-Footnote-1344183
+Node: Assignment Ops344289
+Ref: table-assign-ops349268
+Node: Increment Ops350540
+Node: Truth Values and Conditions353978
+Node: Truth Values355063
+Node: Typing and Comparison356112
+Node: Variable Typing356922
+Node: Comparison Operators360575
+Ref: table-relational-ops360985
+Node: POSIX String Comparison364480
+Ref: POSIX String Comparison-Footnote-1365552
+Node: Boolean Ops365690
+Ref: Boolean Ops-Footnote-1370169
+Node: Conditional Exp370260
+Node: Function Calls371987
+Node: Precedence375867
+Node: Locales379528
+Node: Expressions Summary381160
+Node: Patterns and Actions383720
+Node: Pattern Overview384840
+Node: Regexp Patterns386519
+Node: Expression Patterns387062
+Node: Ranges390843
+Node: BEGIN/END393949
+Node: Using BEGIN/END394710
+Ref: Using BEGIN/END-Footnote-1397444
+Node: I/O And BEGIN/END397550
+Node: BEGINFILE/ENDFILE399864
+Node: Empty402765
+Node: Using Shell Variables403082
+Node: Action Overview405355
+Node: Statements407681
+Node: If Statement409529
+Node: While Statement411024
+Node: Do Statement413053
+Node: For Statement414197
+Node: Switch Statement417354
+Node: Break Statement419736
+Node: Continue Statement421777
+Node: Next Statement423604
+Node: Nextfile Statement425985
+Node: Exit Statement428615
+Node: Built-in Variables431018
+Node: User-modified432151
+Ref: User-modified-Footnote-1439832
+Node: Auto-set439894
+Ref: Auto-set-Footnote-1452929
+Ref: Auto-set-Footnote-2453134
+Node: ARGC and ARGV453190
+Node: Pattern Action Summary457408
+Node: Arrays459835
+Node: Array Basics461164
+Node: Array Intro462008
+Ref: figure-array-elements463972
+Ref: Array Intro-Footnote-1466498
+Node: Reference to Elements466626
+Node: Assigning Elements469078
+Node: Array Example469569
+Node: Scanning an Array471327
+Node: Controlling Scanning474343
+Ref: Controlling Scanning-Footnote-1479539
+Node: Numeric Array Subscripts479855
+Node: Uninitialized Subscripts482040
+Node: Delete483657
+Ref: Delete-Footnote-1486400
+Node: Multidimensional486457
+Node: Multiscanning489554
+Node: Arrays of Arrays491143
+Node: Arrays Summary495902
+Node: Functions497994
+Node: Built-in498867
+Node: Calling Built-in499945
+Node: Numeric Functions501936
+Ref: Numeric Functions-Footnote-1505953
+Ref: Numeric Functions-Footnote-2506310
+Ref: Numeric Functions-Footnote-3506358
+Node: String Functions506630
+Ref: String Functions-Footnote-1530105
+Ref: String Functions-Footnote-2530234
+Ref: String Functions-Footnote-3530482
+Node: Gory Details530569
+Ref: table-sub-escapes532350
+Ref: table-sub-proposed533870
+Ref: table-posix-sub535234
+Ref: table-gensub-escapes536770
+Ref: Gory Details-Footnote-1537602
+Node: I/O Functions537753
+Ref: I/O Functions-Footnote-1544971
+Node: Time Functions545118
+Ref: Time Functions-Footnote-1555606
+Ref: Time Functions-Footnote-2555674
+Ref: Time Functions-Footnote-3555832
+Ref: Time Functions-Footnote-4555943
+Ref: Time Functions-Footnote-5556055
+Ref: Time Functions-Footnote-6556282
+Node: Bitwise Functions556548
+Ref: table-bitwise-ops557110
+Ref: Bitwise Functions-Footnote-1561419
+Node: Type Functions561588
+Node: I18N Functions562739
+Node: User-defined564384
+Node: Definition Syntax565189
+Ref: Definition Syntax-Footnote-1570596
+Node: Function Example570667
+Ref: Function Example-Footnote-1573586
+Node: Function Caveats573608
+Node: Calling A Function574126
+Node: Variable Scope575084
+Node: Pass By Value/Reference578072
+Node: Return Statement581567
+Node: Dynamic Typing584548
+Node: Indirect Calls585477
+Ref: Indirect Calls-Footnote-1596779
+Node: Functions Summary596907
+Node: Library Functions599609
+Ref: Library Functions-Footnote-1603218
+Ref: Library Functions-Footnote-2603361
+Node: Library Names603532
+Ref: Library Names-Footnote-1606986
+Ref: Library Names-Footnote-2607209
+Node: General Functions607295
+Node: Strtonum Function608398
+Node: Assert Function611420
+Node: Round Function614744
+Node: Cliff Random Function616285
+Node: Ordinal Functions617301
+Ref: Ordinal Functions-Footnote-1620364
+Ref: Ordinal Functions-Footnote-2620616
+Node: Join Function620827
+Ref: Join Function-Footnote-1622596
+Node: Getlocaltime Function622796
+Node: Readfile Function626540
+Node: Shell Quoting628510
+Node: Data File Management629911
+Node: Filetrans Function630543
+Node: Rewind Function634599
+Node: File Checking635986
+Ref: File Checking-Footnote-1637318
+Node: Empty Files637519
+Node: Ignoring Assigns639498
+Node: Getopt Function641049
+Ref: Getopt Function-Footnote-1652511
+Node: Passwd Functions652711
+Ref: Passwd Functions-Footnote-1661560
+Node: Group Functions661648
+Ref: Group Functions-Footnote-1669542
+Node: Walking Arrays669755
+Node: Library Functions Summary671358
+Node: Library Exercises672759
+Node: Sample Programs674039
+Node: Running Examples674809
+Node: Clones675537
+Node: Cut Program676761
+Node: Egrep Program686480
+Ref: Egrep Program-Footnote-1693978
+Node: Id Program694088
+Node: Split Program697733
+Ref: Split Program-Footnote-1701181
+Node: Tee Program701309
+Node: Uniq Program704098
+Node: Wc Program711517
+Ref: Wc Program-Footnote-1715767
+Node: Miscellaneous Programs715861
+Node: Dupword Program717074
+Node: Alarm Program719105
+Node: Translate Program723909
+Ref: Translate Program-Footnote-1728474
+Node: Labels Program728744
+Ref: Labels Program-Footnote-1732095
+Node: Word Sorting732179
+Node: History Sorting736250
+Node: Extract Program738086
+Node: Simple Sed745611
+Node: Igawk Program748679
+Ref: Igawk Program-Footnote-1763003
+Ref: Igawk Program-Footnote-2763204
+Ref: Igawk Program-Footnote-3763326
+Node: Anagram Program763441
+Node: Signature Program766498
+Node: Programs Summary767745
+Node: Programs Exercises768938
+Ref: Programs Exercises-Footnote-1773069
+Node: Advanced Features773160
+Node: Nondecimal Data775108
+Node: Array Sorting776698
+Node: Controlling Array Traversal777395
+Ref: Controlling Array Traversal-Footnote-1785728
+Node: Array Sorting Functions785846
+Ref: Array Sorting Functions-Footnote-1789735
+Node: Two-way I/O789931
+Ref: Two-way I/O-Footnote-1794872
+Ref: Two-way I/O-Footnote-2795058
+Node: TCP/IP Networking795140
+Node: Profiling798013
+Node: Advanced Features Summary805560
+Node: Internationalization807493
+Node: I18N and L10N808973
+Node: Explaining gettext809659
+Ref: Explaining gettext-Footnote-1814684
+Ref: Explaining gettext-Footnote-2814868
+Node: Programmer i18n815033
+Ref: Programmer i18n-Footnote-1819899
+Node: Translator i18n819948
+Node: String Extraction820742
+Ref: String Extraction-Footnote-1821873
+Node: Printf Ordering821959
+Ref: Printf Ordering-Footnote-1824745
+Node: I18N Portability824809
+Ref: I18N Portability-Footnote-1827264
+Node: I18N Example827327
+Ref: I18N Example-Footnote-1830130
+Node: Gawk I18N830202
+Node: I18N Summary830840
+Node: Debugger832179
+Node: Debugging833201
+Node: Debugging Concepts833642
+Node: Debugging Terms835495
+Node: Awk Debugging838067
+Node: Sample Debugging Session838961
+Node: Debugger Invocation839481
+Node: Finding The Bug840865
+Node: List of Debugger Commands847340
+Node: Breakpoint Control848673
+Node: Debugger Execution Control852369
+Node: Viewing And Changing Data855733
+Node: Execution Stack859111
+Node: Debugger Info860748
+Node: Miscellaneous Debugger Commands864765
+Node: Readline Support869794
+Node: Limitations870686
+Node: Debugging Summary872800
+Node: Arbitrary Precision Arithmetic873968
+Node: Computer Arithmetic875384
+Ref: table-numeric-ranges878982
+Ref: Computer Arithmetic-Footnote-1879841
+Node: Math Definitions879898
+Ref: table-ieee-formats883186
+Ref: Math Definitions-Footnote-1883790
+Node: MPFR features883895
+Node: FP Math Caution885566
+Ref: FP Math Caution-Footnote-1886616
+Node: Inexactness of computations886985
+Node: Inexact representation887944
+Node: Comparing FP Values889301
+Node: Errors accumulate890383
+Node: Getting Accuracy891816
+Node: Try To Round894478
+Node: Setting precision895377
+Ref: table-predefined-precision-strings896061
+Node: Setting the rounding mode897850
+Ref: table-gawk-rounding-modes898214
+Ref: Setting the rounding mode-Footnote-1901669
+Node: Arbitrary Precision Integers901848
+Ref: Arbitrary Precision Integers-Footnote-1904834
+Node: POSIX Floating Point Problems904983
+Ref: POSIX Floating Point Problems-Footnote-1908856
+Node: Floating point summary908894
+Node: Dynamic Extensions911088
+Node: Extension Intro912640
+Node: Plugin License913906
+Node: Extension Mechanism Outline914703
+Ref: figure-load-extension915131
+Ref: figure-register-new-function916611
+Ref: figure-call-new-function917615
+Node: Extension API Description919601
+Node: Extension API Functions Introduction921051
+Node: General Data Types925875
+Ref: General Data Types-Footnote-1931614
+Node: Memory Allocation Functions931913
+Ref: Memory Allocation Functions-Footnote-1934752
+Node: Constructor Functions934848
+Node: Registration Functions936582
+Node: Extension Functions937267
+Node: Exit Callback Functions939564
+Node: Extension Version String940812
+Node: Input Parsers941477
+Node: Output Wrappers951354
+Node: Two-way processors955869
+Node: Printing Messages958073
+Ref: Printing Messages-Footnote-1959149
+Node: Updating `ERRNO'959301
+Node: Requesting Values960041
+Ref: table-value-types-returned960769
+Node: Accessing Parameters961726
+Node: Symbol Table Access962957
+Node: Symbol table by name963471
+Node: Symbol table by cookie965452
+Ref: Symbol table by cookie-Footnote-1969596
+Node: Cached values969659
+Ref: Cached values-Footnote-1973158
+Node: Array Manipulation973249
+Ref: Array Manipulation-Footnote-1974347
+Node: Array Data Types974384
+Ref: Array Data Types-Footnote-1977039
+Node: Array Functions977131
+Node: Flattening Arrays980985
+Node: Creating Arrays987877
+Node: Extension API Variables992646
+Node: Extension Versioning993282
+Node: Extension API Informational Variables995183
+Node: Extension API Boilerplate996271
+Node: Finding Extensions1000080
+Node: Extension Example1000640
+Node: Internal File Description1001412
+Node: Internal File Ops1005479
+Ref: Internal File Ops-Footnote-11017149
+Node: Using Internal File Ops1017289
+Ref: Using Internal File Ops-Footnote-11019672
+Node: Extension Samples1019945
+Node: Extension Sample File Functions1021471
+Node: Extension Sample Fnmatch1029109
+Node: Extension Sample Fork1030600
+Node: Extension Sample Inplace1031815
+Node: Extension Sample Ord1033490
+Node: Extension Sample Readdir1034326
+Ref: table-readdir-file-types1035202
+Node: Extension Sample Revout1036013
+Node: Extension Sample Rev2way1036603
+Node: Extension Sample Read write array1037343
+Node: Extension Sample Readfile1039283
+Node: Extension Sample Time1040378
+Node: Extension Sample API Tests1041727
+Node: gawkextlib1042218
+Node: Extension summary1044855
+Node: Extension Exercises1048532
+Node: Language History1049254
+Node: V7/SVR3.11050910
+Node: SVR41053091
+Node: POSIX1054536
+Node: BTL1055925
+Node: POSIX/GNU1056659
+Node: Feature History1062223
+Node: Common Extensions1075321
+Node: Ranges and Locales1076645
+Ref: Ranges and Locales-Footnote-11081263
+Ref: Ranges and Locales-Footnote-21081290
+Ref: Ranges and Locales-Footnote-31081524
+Node: Contributors1081745
+Node: History summary1087286
+Node: Installation1088656
+Node: Gawk Distribution1089602
+Node: Getting1090086
+Node: Extracting1090909
+Node: Distribution contents1092544
+Node: Unix Installation1098261
+Node: Quick Installation1098878
+Node: Additional Configuration Options1101302
+Node: Configuration Philosophy1103040
+Node: Non-Unix Installation1105409
+Node: PC Installation1105867
+Node: PC Binary Installation1107186
+Node: PC Compiling1109034
+Ref: PC Compiling-Footnote-11112055
+Node: PC Testing1112164
+Node: PC Using1113340
+Node: Cygwin1117455
+Node: MSYS1118278
+Node: VMS Installation1118778
+Node: VMS Compilation1119570
+Ref: VMS Compilation-Footnote-11120792
+Node: VMS Dynamic Extensions1120850
+Node: VMS Installation Details1122534
+Node: VMS Running1124786
+Node: VMS GNV1127622
+Node: VMS Old Gawk1128356
+Node: Bugs1128826
+Node: Other Versions1132709
+Node: Installation summary1139131
+Node: Notes1140187
+Node: Compatibility Mode1141052
+Node: Additions1141834
+Node: Accessing The Source1142759
+Node: Adding Code1144195
+Node: New Ports1150360
+Node: Derived Files1154842
+Ref: Derived Files-Footnote-11160317
+Ref: Derived Files-Footnote-21160351
+Ref: Derived Files-Footnote-31160947
+Node: Future Extensions1161061
+Node: Implementation Limitations1161667
+Node: Extension Design1162915
+Node: Old Extension Problems1164069
+Ref: Old Extension Problems-Footnote-11165586
+Node: Extension New Mechanism Goals1165643
+Ref: Extension New Mechanism Goals-Footnote-11169003
+Node: Extension Other Design Decisions1169192
+Node: Extension Future Growth1171300
+Node: Old Extension Mechanism1172136
+Node: Notes summary1173898
+Node: Basic Concepts1175084
+Node: Basic High Level1175765
+Ref: figure-general-flow1176037
+Ref: figure-process-flow1176636
+Ref: Basic High Level-Footnote-11179865
+Node: Basic Data Typing1180050
+Node: Glossary1183378
+Node: Copying1208536
+Node: GNU Free Documentation License1246092
+Node: Index1271228

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 52fd2003..a1781700 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -56,7 +56,7 @@
@set PATCHLEVEL 2
@ifset FOR_PRINT
-@set TITLE Effective AWK Programming
+@set TITLE Effective Awk Programming
@end ifset
@ifclear FOR_PRINT
@set TITLE GAWK: Effective AWK Programming
@@ -175,12 +175,24 @@
@macro DBREF{text}
@ref{\text\}
@end macro
+@macro DBXREF{text}
+@xref{\text\}
+@end macro
+@macro DBPXREF{text}
+@pxref{\text\}
+@end macro
@end ifdocbook
@ifnotdocbook
@macro DBREF{text}
@ref{\text\},
@end macro
+@macro DBXREF{text}
+@xref{\text\},
+@end macro
+@macro DBPXREF{text}
+@pxref{\text\},
+@end macro
@end ifnotdocbook
@ifclear FOR_PRINT
@@ -315,7 +327,7 @@ A copy of the license is included in the section entitled
A copy of the license
may be found on the Internet at
@uref{http://www.gnu.org/software/gawk/manual/html_node/GNU-Free-Documentation-License.html,
-the GNU Project's web site}.
+the GNU Project's website}.
@end ifset
@enumerate a
@@ -383,10 +395,10 @@ ISBN 1-882114-28-0 @*
@sp 9
@center @i{To my parents, for their love, and for the wonderful example they set for me.}
@sp 1
-@center @i{To my wife Miriam, for making me complete.
+@center @i{To my wife, Miriam, for making me complete.
Thank you for building your life together with me.}
@sp 1
-@center @i{To our children Chana, Rivka, Nachum and Malka, for enrichening our lives in innumerable ways.}
+@center @i{To our children, Chana, Rivka, Nachum, and Malka, for enrichening our lives in innumerable ways.}
@sp 1
@w{ }
@page
@@ -1075,7 +1087,7 @@ for enrichening our lives in innumerable ways.
<!-- can't put mawk into command tags. sigh. -->
<affiliation><jobtitle>Author of mawk</jobtitle></affiliation>
</author>
- <date>March, 2001</date>
+ <date>March 2001</date>
</prefaceinfo>
@end docbook
@@ -1087,21 +1099,23 @@ The circumstances started a couple of years
earlier. I was working at a new job and noticed an unplugged
Unix computer sitting in the corner. No one knew how to use it,
and neither did I. However,
-a couple of days later it was running, and
+a couple of days later, it was running, and
I was @code{root} and the one-and-only user.
That day, I began the transition from statistician to Unix programmer.
On one of many trips to the library or bookstore in search of
-books on Unix, I found the gray AWK book, a.k.a.@: Aho, Kernighan and
-Weinberger, @cite{The AWK Programming Language}, Addison-Wesley,
-1988. AWK's simple programming paradigm---find a pattern in the
+books on Unix, I found the gray AWK book, a.k.a.@:
+Alfred V.@: Aho, Brian W.@: Kernighan, and
+Peter J.@: Weinberger's @cite{The AWK Programming Language} (Addison-Wesley,
+1988). @command{awk}'s simple programming paradigm---find a pattern in the
input and then perform an action---often reduced complex or tedious
data manipulations to a few lines of code. I was excited to try my
hand at programming in AWK.
Alas, the @command{awk} on my computer was a limited version of the
-language described in the AWK book. I discovered that my computer
-had ``old @command{awk}'' and the AWK book described ``new @command{awk}.''
+language described in the gray book. I discovered that my computer
+had ``old @command{awk}'' and the book described
+``new @command{awk}.''
I learned that this was typical; the old version refused to step
aside or relinquish its name. If a system had a new @command{awk}, it was
invariably called @command{nawk}, and few systems had it.
@@ -1119,7 +1133,7 @@ My Unix system started out unplugged from the wall; it certainly was not
plugged into a network. So, oblivious to the existence of @command{gawk}
and the Unix community in general, and desiring a new @command{awk}, I wrote
my own, called @command{mawk}.
-Before I was finished I knew about @command{gawk},
+Before I was finished, I knew about @command{gawk},
but it was too late to stop, so I eventually posted
to a @code{comp.sources} newsgroup.
@@ -1128,7 +1142,7 @@ from Arnold introducing
himself. He suggested we share design and algorithms and
attached a draft of the POSIX standard so
that I could update @command{mawk} to support language extensions added
-after publication of the AWK book.
+after publication of @cite{The AWK Programming Language}.
Frankly, if our roles had
been reversed, I would not have been so open and we probably would
@@ -1147,7 +1161,7 @@ standard.
On the other hand, the novice AWK programmer can study
a wealth of practical programs that emphasize
the power of AWK's basic idioms:
-data driven control-flow, pattern matching with regular expressions,
+data-driven control flow, pattern matching with regular expressions,
and associative arrays.
Those looking for something new can try out @command{gawk}'s
interface to network protocols via special @file{/inet} files.
@@ -1208,7 +1222,7 @@ AWK or want to learn how, then read this book.
@display
Michael Brennan
Author of @command{mawk}
-March, 2001
+March 2001
@end display
@end ifnotdocbook
@@ -1226,7 +1240,7 @@ March, 2001
<!-- can't put mawk into command tags. sigh. -->
<affiliation><jobtitle>Author of mawk</jobtitle></affiliation>
</author>
- <date>October, 2014</date>
+ <date>October 2014</date>
</prefaceinfo>
@end docbook
@@ -1260,7 +1274,7 @@ details, and as expected, many examples to help you learn the ins and outs.
@display
Michael Brennan
Author of @command{mawk}
-October, 2014
+October 2014
@end display
@end ifnotdocbook
@@ -1280,9 +1294,9 @@ October, 2014
<firstname>Arnold</firstname>
<surname>Robbins</surname>
<affiliation><jobtitle>Nof Ayalon</jobtitle></affiliation>
- <affiliation><jobtitle>ISRAEL</jobtitle></affiliation>
+ <affiliation><jobtitle>Israel</jobtitle></affiliation>
</author>
- <date>December, 2014</date>
+ <date>December 2014</date>
</prefaceinfo>
@end docbook
@@ -1294,7 +1308,7 @@ The @command{awk} utility interprets a special-purpose programming
language that makes it easy to handle simple data-reformatting jobs.
The GNU implementation of @command{awk} is called @command{gawk}; if you
-invoke it with the proper options or environment variables
+invoke it with the proper options or environment variables,
it is fully compatible with
the POSIX@footnote{The 2008 POSIX standard is accessible online at
@w{@url{http://www.opengroup.org/onlinepubs/9699919799/}.}}
@@ -1401,10 +1415,10 @@ has been removed.}
@unnumberedsec History of @command{awk} and @command{gawk}
@cindex recipe for a programming language
@cindex programming language, recipe for
-@cindex sidebar, Recipe For A Programming Language
+@cindex sidebar, Recipe for a Programming Language
@ifdocbook
@docbook
-<sidebar><title>Recipe For A Programming Language</title>
+<sidebar><title>Recipe for a Programming Language</title>
@end docbook
@@ -1426,7 +1440,7 @@ more parts C. Document very well and release.
@ifnotdocbook
@cartouche
-@center @b{Recipe For A Programming Language}
+@center @b{Recipe for a Programming Language}
@@ -1448,7 +1462,7 @@ more parts C. Document very well and release.
@cindex Kernighan, Brian
@cindex @command{awk}, history of
The name @command{awk} comes from the initials of its designers: Alfred V.@:
-Aho, Peter J.@: Weinberger and Brian W.@: Kernighan. The original version of
+Aho, Peter J.@: Weinberger, and Brian W.@: Kernighan. The original version of
@command{awk} was written in 1977 at AT&T Bell Laboratories.
In 1985, a new version made the programming
language more powerful, introducing user-defined functions, multiple input
@@ -1474,7 +1488,7 @@ Circa 1994, I became the primary maintainer.
Current development focuses on bug fixes,
performance improvements, standards compliance and, occasionally, new features.
-In May of 1997, J@"urgen Kahrs felt the need for network access
+In May 1997, J@"urgen Kahrs felt the need for network access
from @command{awk}, and with a little help from me, set about adding
features to do this for @command{gawk}. At that time, he also
wrote the bulk of
@@ -1487,7 +1501,7 @@ John Haque rewrote the @command{gawk} internals, in the process providing
an @command{awk}-level debugger. This version became available as
@command{gawk} @value{PVERSION} 4.0, in 2011.
-@xref{Contributors},
+@DBXREF{Contributors}
for a full list of those who made important contributions to @command{gawk}.
@node Names
@@ -1497,7 +1511,7 @@ for a full list of those who made important contributions to @command{gawk}.
The @command{awk} language has evolved over the years. Full details are
provided in @ref{Language History}.
The language described in this @value{DOCUMENT}
-is often referred to as ``new @command{awk}''.
+is often referred to as ``new @command{awk}.''
By analogy, the original version of @command{awk} is
referred to as ``old @command{awk}.''
@@ -1576,12 +1590,15 @@ Most of the time, the examples use complete @command{awk} programs.
Some of the more advanced sections show only the part of the @command{awk}
program that illustrates the concept being described.
-While this @value{DOCUMENT} is aimed principally at people who have not been
+Although this @value{DOCUMENT} is aimed principally at people who have not been
exposed
to @command{awk}, there is a lot of information here that even the @command{awk}
expert should find useful. In particular, the description of POSIX
@command{awk} and the example programs in
-@ref{Library Functions}, and in
+@ref{Library Functions}, and
+@ifnotdocbook
+in
+@end ifnotdocbook
@ref{Sample Programs},
should be of interest.
@@ -1589,22 +1606,30 @@ This @value{DOCUMENT} is split into several parts, as follows:
@c FULLXREF ON
+@itemize @value{BULLET}
+@item
Part I describes the @command{awk} language and @command{gawk} program in detail.
It starts with the basics, and continues through all of the features of @command{awk}.
It contains the following chapters:
+@c nested
+@itemize @value{MINUS}
+@item
@ref{Getting Started},
provides the essentials you need to know to begin using @command{awk}.
+@item
@ref{Invoking Gawk},
describes how to run @command{gawk}, the meaning of its
command-line options, and how it finds @command{awk}
program source files.
+@item
@ref{Regexp},
introduces regular expressions in general, and in particular the flavors
supported by POSIX @command{awk} and @command{gawk}.
+@item
@ref{Reading Files},
describes how @command{awk} reads your data.
It introduces the concepts of records and fields, as well
@@ -1612,46 +1637,62 @@ as the @code{getline} command.
I/O redirection is first described here.
Network I/O is also briefly introduced here.
+@item
@ref{Printing},
describes how @command{awk} programs can produce output with
@code{print} and @code{printf}.
+@item
@ref{Expressions},
describes expressions, which are the basic building blocks
for getting most things done in a program.
+@item
@ref{Patterns and Actions},
describes how to write patterns for matching records, actions for
doing something when a record is matched, and the predefined variables
@command{awk} and @command{gawk} use.
+@item
@ref{Arrays},
covers @command{awk}'s one-and-only data structure: associative arrays.
Deleting array elements and whole arrays is also described, as well as
sorting arrays in @command{gawk}. It also describes how @command{gawk}
provides arrays of arrays.
+@item
@ref{Functions},
describes the built-in functions @command{awk} and @command{gawk} provide,
as well as how to define your own functions. It also discusses how
@command{gawk} lets you call functions indirectly.
+@end itemize
+@item
Part II shows how to use @command{awk} and @command{gawk} for problem solving.
There is lots of code here for you to read and learn from.
It contains the following chapters:
+@c nested
+@itemize @value{MINUS}
+@item
@ref{Library Functions}, which provides a number of functions meant to
be used from main @command{awk} programs.
+@item
@ref{Sample Programs},
which provides many sample @command{awk} programs.
+@end itemize
Reading these two chapters allows you to see @command{awk}
solving real problems.
+@item
Part III focuses on features specific to @command{gawk}.
It contains the following chapters:
+@c nested
+@itemize @value{MINUS}
+@item
@ref{Advanced Features},
describes a number of advanced features.
Of particular note
@@ -1660,18 +1701,24 @@ have two-way communications with another process,
perform TCP/IP networking, and
profile your @command{awk} programs.
+@item
@ref{Internationalization},
describes special features for translating program
messages into different languages at runtime.
+@item
@ref{Debugger}, describes the @command{gawk} debugger.
+@item
@ref{Arbitrary Precision Arithmetic},
describes advanced arithmetic facilities.
+@item
@ref{Dynamic Extensions}, describes how to add new variables and
functions to @command{gawk} by writing extensions in C or C++.
+@end itemize
+@item
@ifclear FOR_PRINT
Part IV provides the appendices, the Glossary, and two licenses that cover
the @command{gawk} source code and this @value{DOCUMENT}, respectively.
@@ -1682,11 +1729,14 @@ Part IV provides the following appendices,
including the GNU General Public License:
@end ifset
+@itemize @value{MINUS}
+@item
@ref{Language History},
describes how the @command{awk} language has evolved since
its first release to present. It also describes how @command{gawk}
has acquired features over time.
+@item
@ref{Installation},
describes how to get @command{gawk}, how to compile it
on POSIX-compatible systems,
@@ -1694,17 +1744,22 @@ and how to compile and use it on different
non-POSIX systems. It also describes how to report bugs
in @command{gawk} and where to get other freely
available @command{awk} implementations.
+@end itemize
@ifset FOR_PRINT
-
+@itemize @value{MINUS}
+@item
@ref{Copying},
presents the license that covers the @command{gawk} source code.
+@end itemize
The version of this @value{DOCUMENT} distributed with @command{gawk}
contains additional appendices and other end material.
To save space, we have omitted them from the
printed edition. You may find them online, as follows:
+@itemize @value{BULLET}
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/Notes.html,
The appendix on implementation notes}
describes how to disable @command{gawk}'s extensions, how to contribute
@@ -1712,44 +1767,54 @@ new code to @command{gawk}, where to find information on some possible
future directions for @command{gawk} development, and the design decisions
behind the extension API.
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/Basic-Concepts.html,
The appendix on basic concepts}
provides some very cursory background material for those who
are completely unfamiliar with computer programming.
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/Glossary.html,
The Glossary}
-defines most, if not all, the significant terms used
+defines most, if not all of, the significant terms used
throughout the @value{DOCUMENT}. If you find terms that you aren't familiar with,
try looking them up here.
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/GNU-Free-Documentation-License.html,
The GNU FDL}
is the license that covers this @value{DOCUMENT}.
+@end itemize
Some of the chapters have exercise sections; these have also been
omitted from the print edition but are available online.
@end ifset
@ifclear FOR_PRINT
+@itemize @value{MINUS}
+@item
@ref{Notes},
describes how to disable @command{gawk}'s extensions, as
well as how to contribute new code to @command{gawk},
and some possible future directions for @command{gawk} development.
+@item
@ref{Basic Concepts},
provides some very cursory background material for those who
are completely unfamiliar with computer programming.
-The @ref{Glossary}, defines most, if not all, the significant terms used
+The @ref{Glossary}, defines most, if not all of, the significant terms used
throughout the @value{DOCUMENT}. If you find terms that you aren't familiar with,
try looking them up here.
+@item
@ref{Copying}, and
@ref{GNU Free Documentation License},
present the licenses that cover the @command{gawk} source code
and this @value{DOCUMENT}, respectively.
+@end itemize
@end ifclear
+@end itemize
@c FULLXREF OFF
@@ -1812,7 +1877,7 @@ pressing the @kbd{d} key and finally releasing both keys.
For the sake of brevity, throughout this @value{DOCUMENT}, we refer to
Brian Kernighan's version of @command{awk} as ``BWK @command{awk}.''
-(@xref{Other Versions}, for information on his and other versions.)
+(@DBXREF{Other Versions} for information on his and other versions.)
@ifset FOR_PRINT
@quotation NOTE
@@ -1828,7 +1893,7 @@ Cautionary or warning notes look like this.
@unnumberedsubsec Dark Corners
@cindex Kernighan, Brian
@quotation
-@i{Dark corners are basically fractal --- no matter how much
+@i{Dark corners are basically fractal---no matter how much
you illuminate, there's always a smaller but darker one.}
@author Brian Kernighan
@end quotation
@@ -1898,7 +1963,7 @@ The GPL applies to the C language source code for @command{gawk}.
To find out more about the FSF and the GNU Project online,
see @uref{http://www.gnu.org, the GNU Project's home page}.
This @value{DOCUMENT} may also be read from
-@uref{http://www.gnu.org/software/gawk/manual/, their web site}.
+@uref{http://www.gnu.org/software/gawk/manual/, GNU's website}.
@ifclear FOR_PRINT
A shell, an editor (Emacs), highly portable optimizing C, C++, and
@@ -1935,10 +2000,10 @@ License in @ref{GNU Free Documentation License}.)
@cindex Close, Diane
The @value{DOCUMENT} itself has gone through multiple previous editions.
Paul Rubin wrote the very first draft of @cite{The GAWK Manual};
-it was around 40 pages in size.
+it was around 40 pages long.
Diane Close and Richard Stallman improved it, yielding a
version that was
-around 90 pages long and barely described the original, ``old''
+around 90 pages and barely described the original, ``old''
version of @command{awk}.
I started working with that version in the fall of 1988.
@@ -1971,17 +2036,17 @@ and the major new additions are @ref{Arbitrary Precision Arithmetic},
and @ref{Dynamic Extensions}.
This @value{DOCUMENT} will undoubtedly continue to evolve. If you
-find an error in this @value{DOCUMENT}, please report it! @xref{Bugs},
+find an error in this @value{DOCUMENT}, please report it! @DBXREF{Bugs}
for information on submitting problem reports electronically.
@ifset FOR_PRINT
@c fakenode --- for prepinfo
@unnumberedsec How to Stay Current
-It may be you have a version of @command{gawk} which is newer than the
+You may have a newer version of @command{gawk} than the
one described here. To find out what has changed,
you should first look at the @file{NEWS} file in the @command{gawk}
-distribution, which provides a high level summary of what changed in
+distribution, which provides a high-level summary of what changed in
each release.
You can then look at the @uref{http://www.gnu.org/software/gawk/manual/,
@@ -2006,13 +2071,13 @@ contributed code: the archive did not grow and the domain went unused
for several years.
Late in 2008, a volunteer took on the task of setting up
-an @command{awk}-related web site---@uref{http://awk.info}---and did a very
+an @command{awk}-related website---@uref{http://awk.info}---and did a very
nice job.
If you have written an interesting @command{awk} program, or have written
a @command{gawk} extension that you would like to share with the rest
of the world, please see @uref{http://awk.info/?contribute} for how to
-contribute it to the web site.
+contribute it to the website.
@ignore
As of this writing, this website is in search of a maintainer; please
@@ -2159,12 +2224,13 @@ portable program it is today. It has been and continues to be a pleasure
working with this team of fine people.
Notable code and documentation contributions were made by
-a number of people. @xref{Contributors}, for the full list.
+a number of people. @DBXREF{Contributors} for the full list.
@ifset FOR_PRINT
@cindex Oram, Andy
Thanks to Andy Oram, of O'Reilly Media, for initiating
the fourth edition and for his support during the work.
+Thanks to Jasmine Kwityn for her copy-editing work.
@end ifset
Thanks to Michael Brennan for the Foreword.
@@ -2178,7 +2244,7 @@ the Texinfo markup language sane.
@cindex Kernighan, Brian
@cindex Brennan, Michael
@cindex Day, Robert P.J.@:
-Robert P.J.@: Day, Michael Brennan and Brian Kernighan kindly acted as
+Robert P.J.@: Day, Michael Brennan, and Brian Kernighan kindly acted as
reviewers for the 2015 edition of this @value{DOCUMENT}. Their feedback
helped improve the final work.
@@ -2190,7 +2256,7 @@ or its documentation without his help.
Brian is in a class by himself as a programmer and technical
author. I have to thank him (yet again) for his ongoing friendship
-and the role model he has been for me for close to 30 years!
+and for being a role model to me for close to 30 years!
Having him as a reviewer is an exciting privilege. It has also
been extremely humbling@enddots{}
@@ -2211,8 +2277,8 @@ take advantage of those opportunities.
@noindent
Arnold Robbins @*
Nof Ayalon @*
-ISRAEL @*
-December, 2014
+Israel @*
+December 2014
@end iftex
@ifnotinfo
@@ -2229,31 +2295,31 @@ following chapters:
@itemize @value{BULLET}
@item
-@ref{Getting Started}.
+@ref{Getting Started}
@item
-@ref{Invoking Gawk}.
+@ref{Invoking Gawk}
@item
-@ref{Regexp}.
+@ref{Regexp}
@item
-@ref{Reading Files}.
+@ref{Reading Files}
@item
-@ref{Printing}.
+@ref{Printing}
@item
-@ref{Expressions}.
+@ref{Expressions}
@item
-@ref{Patterns and Actions}.
+@ref{Patterns and Actions}
@item
-@ref{Arrays}.
+@ref{Arrays}
@item
-@ref{Functions}.
+@ref{Functions}
@end itemize
@end ifdocbook
@@ -2268,17 +2334,17 @@ following chapters:
The basic function of @command{awk} is to search files for lines (or other
units of text) that contain certain patterns. When a line matches one
of the patterns, @command{awk} performs specified actions on that line.
-@command{awk} keeps processing input lines in this way until it reaches
+@command{awk} continues to process input lines in this way until it reaches
the end of the input files.
@cindex @command{awk}, uses for
@cindex programming languages@comma{} data-driven vs.@: procedural
@cindex @command{awk} programs
Programs in @command{awk} are different from programs in most other languages,
-because @command{awk} programs are @dfn{data-driven}; that is, you describe
-the data you want to work with and then what to do when you find it.
+because @command{awk} programs are @dfn{data driven} (i.e., you describe
+the data you want to work with and then what to do when you find it).
Most other languages are @dfn{procedural}; you have to describe, in great
-detail, every step the program is to take. When working with procedural
+detail, every step the program should take. When working with procedural
languages, it is usually much
harder to clearly describe the data your program will process.
For this reason, @command{awk} programs are often refreshingly easy to
@@ -2288,9 +2354,9 @@ read and write.
@cindex rule, definition of
When you run @command{awk}, you specify an @command{awk} @dfn{program} that
tells @command{awk} what to do. The program consists of a series of
-@dfn{rules}. (It may also contain @dfn{function definitions},
-an advanced feature that we will ignore for now.
-@xref{User-defined}.) Each rule specifies one
+@dfn{rules} (it may also contain @dfn{function definitions},
+an advanced feature that we will ignore for now;
+@pxref{User-defined}). Each rule specifies one
pattern to search for and one action to perform
upon finding the pattern.
@@ -2390,10 +2456,11 @@ programs from shell scripts, because it avoids the need for a separate
file for the @command{awk} program. A self-contained shell script is more
reliable because there are no other files to misplace.
+Later in this chapter,
+@ifdocbook
+the section
+@end ifdocbook
@ref{Very Simple},
-@ifnotinfo
-later in this @value{CHAPTER},
-@end ifnotinfo
presents several short,
self-contained programs.
@@ -2452,7 +2519,7 @@ startup file.
This next simple @command{awk} program
emulates the @command{cat} utility; it copies whatever you type on the
-keyboard to its standard output (why this works is explained shortly).
+keyboard to its standard output (why this works is explained shortly):
@example
$ @kbd{awk '@{ print @}'}
@@ -2537,7 +2604,7 @@ affect the execution of the @command{awk} program but it does make
Once you have learned @command{awk}, you may want to write self-contained
@command{awk} scripts, using the @samp{#!} script mechanism. You can do
this on many systems.@footnote{The @samp{#!} mechanism works on
-GNU/Linux systems, BSD-based systems and commercial Unix systems.}
+GNU/Linux systems, BSD-based systems, and commercial Unix systems.}
For example, you could update the file @file{advice} to look like this:
@example
@@ -2581,7 +2648,7 @@ according to the instructions in your program. (This is different
from a @dfn{compiled} language such as C, where your program is first
compiled into machine code that is executed directly by your system's
processor.) The @command{awk} utility is thus termed an @dfn{interpreter}.
-Many modern languages are interperted.
+Many modern languages are interpreted.
The line beginning with @samp{#!} lists the full @value{FN} of an
interpreter to run and a single optional initial command-line argument
@@ -2631,7 +2698,7 @@ according to the instructions in your program. (This is different
from a @dfn{compiled} language such as C, where your program is first
compiled into machine code that is executed directly by your system's
processor.) The @command{awk} utility is thus termed an @dfn{interpreter}.
-Many modern languages are interperted.
+Many modern languages are interpreted.
The line beginning with @samp{#!} lists the full @value{FN} of an
interpreter to run and a single optional initial command-line argument
@@ -2678,14 +2745,14 @@ can explain what the program does and how it works. Nearly all
programming languages have provisions for comments, as programs are
typically hard to understand without them.
-In the @command{awk} language, a comment starts with the sharp sign
+In the @command{awk} language, a comment starts with the number sign
character (@samp{#}) and continues to the end of the line.
The @samp{#} does not have to be the first character on the line. The
-@command{awk} language ignores the rest of a line following a sharp sign.
+@command{awk} language ignores the rest of a line following a number sign.
For example, we could have put the following into @file{advice}:
@example
-# This program prints a nice friendly message. It helps
+# This program prints a nice, friendly message. It helps
# keep novice users from being afraid of the computer.
BEGIN @{ print "Don't Panic!" @}
@end example
@@ -2701,7 +2768,8 @@ when reading it at a later time.
@quotation CAUTION
As mentioned in
@ref{One-shot},
-you can enclose small to medium programs in single quotes, in order to keep
+you can enclose short to medium-sized programs in single quotes,
+in order to keep
your shell scripts self-contained. When doing so, @emph{don't} put
an apostrophe (i.e., a single quote) into a comment (or anywhere else
in your program). The shell interprets the quote as the closing
@@ -2730,7 +2798,7 @@ $ @kbd{awk '@{ print "hello" @} # let's be cute'}
@cindex @code{\} (backslash)
@cindex backslash (@code{\})
Putting a backslash before the single quote in @samp{let's} wouldn't help,
-since backslashes are not special inside single quotes.
+because backslashes are not special inside single quotes.
The next @value{SUBSECTION} describes the shell's quoting rules.
@end quotation
@@ -2742,7 +2810,7 @@ The next @value{SUBSECTION} describes the shell's quoting rules.
* DOS Quoting:: Quoting in Windows Batch Files.
@end menu
-For short to medium length @command{awk} programs, it is most convenient
+For short to medium-length @command{awk} programs, it is most convenient
to enter the program on the @command{awk} command line.
This is best done by enclosing the entire program in single quotes.
This is true whether you are entering the program interactively at
@@ -2766,8 +2834,8 @@ or empty, string.
The null string is character data that has no value.
In other words, it is empty. It is written in @command{awk} programs
like this: @code{""}. In the shell, it can be written using single
-or double quotes: @code{""} or @code{''}. While the null string has
-no characters in it, it does exist. Consider this command:
+or double quotes: @code{""} or @code{''}. Although the null string has
+no characters in it, it does exist. For example, consider this command:
@example
$ @kbd{echo ""}
@@ -2777,8 +2845,7 @@ $ @kbd{echo ""}
Here, the @command{echo} utility receives a single argument, even
though that argument has no characters in it. In the rest of this
@value{DOCUMENT}, we use the terms @dfn{null string} and @dfn{empty string}
-interchangeably. Now, on to the quoting rules.
-
+interchangeably. Now, on to the quoting rules:
@itemize @value{BULLET}
@item
@@ -2801,7 +2868,7 @@ The shell does no interpretation of the quoted text, passing it on verbatim
to the command.
It is @emph{impossible} to embed a single quote inside single-quoted text.
Refer back to
-@ref{Comments},
+@DBREF{Comments}
for an example of what happens if you try.
@item
@@ -2811,7 +2878,7 @@ Double quotes protect most things between the opening and closing quotes.
The shell does at least variable and command substitution on the quoted text.
Different shells may do additional kinds of processing on double-quoted text.
-Since certain characters within double-quoted text are processed by the shell,
+Because certain characters within double-quoted text are processed by the shell,
they must be @dfn{escaped} within the text. Of note are the characters
@samp{$}, @samp{`}, @samp{\}, and @samp{"}, all of which must be preceded by
a backslash within double-quoted text if they are to be passed on literally
@@ -2873,7 +2940,7 @@ $ @kbd{awk 'BEGIN @{ print "Here is a single quote <'"'"'>" @}'}
@noindent
This program consists of three concatenated quoted strings. The first and the
-third are single-quoted, the second is double-quoted.
+third are single quoted, the second is double quoted.
This can be ``simplified'' to:
@@ -2918,7 +2985,7 @@ escapes mean.
A fourth option is to use command-line variable assignment, like this:
@example
-$ awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}'
+$ @kbd{awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}'}
@print{} Here is a single quote <'>
@end example
@@ -2989,7 +3056,7 @@ information about monthly shipments. In both files,
each line is considered to be one @dfn{record}.
In @file{mail-list}, each record contains the name of a person,
-his/her phone number, his/her email-address, and a code for their relationship
+his/her phone number, his/her email address, and a code for his/her relationship
with the author of the list.
The columns are aligned using spaces.
An @samp{A} in the last column
@@ -3110,8 +3177,8 @@ empty action that does nothing (i.e., no lines are printed).
Many practical @command{awk} programs are just a line or two. Following is a
collection of useful, short programs to get you started. Some of these
programs contain constructs that haven't been covered yet. (The description
-of the program will give you a good idea of what is going on, but please
-read the rest of the @value{DOCUMENT} to become an @command{awk} expert!)
+of the program will give you a good idea of what is going on, but you'll
+need to read the rest of the @value{DOCUMENT} to become an @command{awk} expert!)
Most of the examples use a @value{DF} named @file{data}. This is just a
placeholder; if you use these programs yourself, substitute
your own @value{FN}s for @file{data}.
@@ -3152,7 +3219,7 @@ expand data | awk '@{ if (x < length($0)) x = length($0) @}
@end example
This example differs slightly from the previous one:
-The input is processed by the @command{expand} utility to change TABs
+the input is processed by the @command{expand} utility to change TABs
into spaces, so the widths compared are actually the right-margin columns,
as opposed to the number of input characters on each line.
@@ -3406,7 +3473,7 @@ lines in the middle of a regular expression or a string.
with the C shell.} It works for @command{awk} programs in files and
for one-shot programs, @emph{provided} you are using a POSIX-compliant
shell, such as the Unix Bourne shell or Bash. But the C shell behaves
-differently! There, you must use two backslashes in a row, followed by
+differently! There you must use two backslashes in a row, followed by
a newline. Note also that when using the C shell, @emph{every} newline
in your @command{awk} program must be escaped with a backslash. To illustrate:
@@ -3447,9 +3514,9 @@ starts a comment, it ignores @emph{everything} on the rest of the
line. For example:
@example
-$ gawk 'BEGIN @{ print "dont panic" # a friendly \
-> BEGIN rule
-> @}'
+$ @kbd{gawk 'BEGIN @{ print "dont panic" # a friendly \}
+> @kbd{ BEGIN rule}
+> @kbd{@}'}
@error{} gawk: cmd. line:2: BEGIN rule
@error{} gawk: cmd. line:2: ^ syntax error
@end example
@@ -3499,7 +3566,7 @@ and array sorting.
As we develop our presentation of the @command{awk} language, we introduce
most of the variables and many of the functions. They are described
-systematically in @ref{Built-in Variables}, and in
+systematically in @DBREF{Built-in Variables} and in
@ref{Built-in}.
@node When
@@ -3533,8 +3600,8 @@ eight-bit microprocessors,
@end ifset
and a microcode assembler for a special-purpose Prolog
computer.
-While the original @command{awk}'s capabilities were strained by tasks
-of such complexity, modern versions are more capable.
+The original @command{awk}'s capabilities were strained by tasks
+of such complexity, but modern versions are more capable.
@cindex @command{awk} programs, complex
If you find yourself writing @command{awk} scripts of more than, say,
@@ -3589,7 +3656,7 @@ a comma, open brace, question mark, colon,
This @value{CHAPTER} covers how to run @command{awk}, both POSIX-standard
and @command{gawk}-specific command-line options, and what
@command{awk} and
-@command{gawk} do with non-option arguments.
+@command{gawk} do with nonoption arguments.
It then proceeds to cover how @command{gawk} searches for source files,
reading standard input along with other files, @command{gawk}'s
environment variables, @command{gawk}'s exit status, using include files,
@@ -3633,7 +3700,7 @@ enclosed in [@dots{}] in these templates are optional:
@cindex GNU long options
@cindex long options
@cindex options, long
-Besides traditional one-letter POSIX-style options, @command{gawk} also
+In addition to traditional one-letter POSIX-style options, @command{gawk} also
supports GNU long options.
@cindex dark corner, invoking @command{awk}
@@ -3696,7 +3763,7 @@ Set the @code{FS} variable to @var{fs}
@cindex @option{--file} option
@cindex @command{awk} programs, location of
Read @command{awk} program source from @var{source-file}
-instead of in the first non-option argument.
+instead of in the first nonoption argument.
This option may be given multiple times; the @command{awk}
program consists of the concatenation of the contents of
each specified @var{source-file}.
@@ -3956,7 +4023,7 @@ care to search for all occurrences of each inappropriate construct. As
@itemx @option{--bignum}
@cindex @option{-M} option
@cindex @option{--bignum} option
-Force arbitrary precision arithmetic on numbers. This option has no effect
+Force arbitrary-precision arithmetic on numbers. This option has no effect
if @command{gawk} is not compiled to use the GNU MPFR and MP libraries
(@pxref{Arbitrary Precision Arithmetic}).
@@ -3972,10 +4039,8 @@ values in input data
(@pxref{Nondecimal Data}).
@quotation CAUTION
-This option can severely break old programs.
-Use with care.
-
-This option may disappear in a future version of @command{gawk}.
+This option can severely break old programs. Use with care. Also note
+that this option may disappear in a future version of @command{gawk}.
@end quotation
@item @option{-N}
@@ -4009,7 +4074,7 @@ pretty-print the program and not run it.
@cindex @option{--optimize} option
@cindex @option{-O} option
Enable some optimizations on the internal representation of the program.
-At the moment this includes just simple constant folding.
+At the moment, this includes just simple constant folding.
@item @option{-p}[@var{file}]
@itemx @option{--profile}[@code{=}@var{file}]
@@ -4086,8 +4151,8 @@ Allow interval expressions
(@pxref{Regexp Operators})
in regexps.
This is now @command{gawk}'s default behavior.
-Nevertheless, this option remains both for backward compatibility,
-and for use in combination with @option{--traditional}.
+Nevertheless, this option remains (both for backward compatibility
+and for use in combination with @option{--traditional}).
@item @option{-S}
@itemx @option{--sandbox}
@@ -4140,7 +4205,7 @@ If it is, @command{awk} reads its program source from all of the named files, as
if they had been concatenated together into one big file. This is
useful for creating libraries of @command{awk} functions. These functions
can be written once and then retrieved from a standard place, instead
-of having to be included into each individual program.
+of having to be included in each individual program.
The @option{-i} option is similar in this regard.
(As mentioned in
@ref{Definition Syntax},
@@ -4151,7 +4216,7 @@ if the program is entered at the keyboard,
by specifying @samp{-f /dev/tty}. After typing your program,
type @kbd{Ctrl-d} (the end-of-file character) to terminate it.
(You may also use @samp{-f -} to read program source from the standard
-input but then you will not be able to also use the standard input as a
+input, but then you will not be able to also use the standard input as a
source of data.)
Because it is clumsy using the standard @command{awk} mechanisms to mix
@@ -4164,7 +4229,7 @@ options may also be used multiple times on the command line.
@cindex @option{-e} option
If no @option{-f} or @option{-e} option is specified, then @command{gawk}
-uses the first non-option command-line argument as the text of the
+uses the first nonoption command-line argument as the text of the
program source code.
@cindex @env{POSIXLY_CORRECT} environment variable
@@ -4231,7 +4296,7 @@ All the command-line arguments are made available to your @command{awk} program
and the program text (if present) are omitted from @code{ARGV}.
All other arguments, including variable assignments, are
included. As each element of @code{ARGV} is processed, @command{gawk}
-sets the variable @code{ARGIND} to the index in @code{ARGV} of the
+sets @code{ARGIND} to the index in @code{ARGV} of the
current element.
@c FIXME: One day, move the ARGC and ARGV node closer to here.
@@ -4408,7 +4473,7 @@ value of @env{AWKPATH}.
@code{ENVIRON["AWKPATH"]}. This provides access to the actual search
path value from within an @command{awk} program.
-While you can change @code{ENVIRON["AWKPATH"]} within your @command{awk}
+Although you can change @code{ENVIRON["AWKPATH"]} within your @command{awk}
program, this has no effect on the running program's behavior. This makes
sense: the @env{AWKPATH} environment variable is used to find the program
source files. Once your program is running, all the files have been
@@ -4444,7 +4509,7 @@ path value from within an @command{awk} program.
A number of other environment variables affect @command{gawk}'s
behavior, but they are more specialized. Those in the following
-list are meant to be used by regular users.
+list are meant to be used by regular users:
@table @env
@item GAWK_MSEC_SLEEP
@@ -4464,7 +4529,7 @@ retry a two-way TCP/IP (socket) connection before giving up.
@xref{TCP/IP Networking}.
@item POSIXLY_CORRECT
-Causes @command{gawk} to switch to POSIX compatibility
+Causes @command{gawk} to switch to POSIX-compatibility
mode, disabling all traditional and GNU extensions.
@xref{Options}.
@end table
@@ -4496,11 +4561,11 @@ for debugging problems on filesystems on non-POSIX operating systems
where I/O is performed in records, not in blocks.
@item GAWK_MSG_SRC
-If this variable exists, @command{gawk} includes the file
-name and line number within the @command{gawk} source code
+If this variable exists, @command{gawk} includes the @value{FN}
+and line number within the @command{gawk} source code
from which warning and/or fatal messages
are generated. Its purpose is to help isolate the source of a
-message, since there are multiple places which produce the
+message, as there are multiple places which produce the
same warning or error message.
@item GAWK_NO_DFA
@@ -4512,8 +4577,8 @@ supposed to be differences, but occasionally theory and practice don't
coordinate with each other.)
@item GAWK_NO_PP_RUN
-If this variable exists, then when invoked with the @option{--pretty-print}
-option, @command{gawk} skips running the program.
+When @command{gawk} is invoked with the @option{--pretty-print} option,
+it will not run the program if this environment variable exists.
@quotation CAUTION
This variable will not survive into the next major release.
@@ -4552,11 +4617,11 @@ If an error occurs, @command{gawk} exits with the value of
the C constant @code{EXIT_FAILURE}. This is usually one.
If @command{gawk} exits because of a fatal error, the exit
-status is 2. On non-POSIX systems, this value may be mapped
+status is two. On non-POSIX systems, this value may be mapped
to @code{EXIT_FAILURE}.
@node Include Files
-@section Including Other Files Into Your Program
+@section Including Other Files into Your Program
@c Panos Papadopoulos <panos1962@gmail.com> contributed the original
@c text for this section.
@@ -4605,9 +4670,9 @@ $ @kbd{gawk -f test2}
@print{} This is script test2.
@end example
-@code{gawk} runs the @file{test2} script which includes @file{test1}
+@code{gawk} runs the @file{test2} script, which includes @file{test1}
using the @code{@@include}
-keyword. So, to include external @command{awk} source files you just
+keyword. So, to include external @command{awk} source files, you just
use @code{@@include} followed by the name of the file to be included,
enclosed in double quotes.
@@ -4644,26 +4709,26 @@ The @value{FN} can, of course, be a pathname. For example:
@end example
@noindent
-or:
+and:
@example
@@include "/usr/awklib/network"
@end example
@noindent
-are valid. The @env{AWKPATH} environment variable can be of great
+are both valid. The @env{AWKPATH} environment variable can be of great
value when using @code{@@include}. The same rules for the use
of the @env{AWKPATH} variable in command-line file searches
(@pxref{AWKPATH Variable}) apply to
@code{@@include} also.
This is very helpful in constructing @command{gawk} function libraries.
-If you have a large script with useful, general purpose @command{awk}
+If you have a large script with useful, general-purpose @command{awk}
functions, you can break it down into library files and put those files
in a special directory. You can then include those ``libraries,'' using
either the full pathnames of the files, or by setting the @env{AWKPATH}
environment variable accordingly and then using @code{@@include} with
-just the file part of the full pathname. Of course you can have more
+just the file part of the full pathname. Of course, you can have more
than one directory to keep library files; the more complex the working
environment is, the more directories you may need to organize the files
to be included.
@@ -4681,7 +4746,7 @@ searched first for source files, before searching in @env{AWKPATH},
and this also applies to files named with @code{@@include}.
@node Loading Shared Libraries
-@section Loading Dynamic Extensions Into Your Program
+@section Loading Dynamic Extensions into Your Program
This @value{SECTION} describes a feature that is specific to @command{gawk}.
@@ -4691,7 +4756,7 @@ This @value{SECTION} describes a feature that is specific to @command{gawk}.
The @code{@@load} keyword can be used to read external @command{awk} extensions
(stored as system shared libraries).
This allows you to link in compiled code that may offer superior
-performance and/or give you access to extended capabilities not supported
+performance and/or give you access to extended capabilities not supported
by the @command{awk} language. The @env{AWKLIBPATH} variable is used to
search for the extension. Using @code{@@load} is completely equivalent
to using the @option{-l} command-line option.
@@ -4699,7 +4764,7 @@ to using the @option{-l} command-line option.
If the extension is not initially found in @env{AWKLIBPATH}, another
search is conducted after appending the platform's default shared library
suffix to the @value{FN}. For example, on GNU/Linux systems, the suffix
-@samp{.so} is used.
+@samp{.so} is used:
@example
$ @kbd{gawk '@@load "ordchr"; BEGIN @{print chr(65)@}'}
@@ -4834,13 +4899,13 @@ The three standard options for all versions of @command{awk} are
and many others, as well as corresponding GNU-style long options.
@item
-Non-option command-line arguments are usually treated as @value{FN}s,
+Nonoption command-line arguments are usually treated as @value{FN}s,
unless they have the form @samp{@var{var}=@var{value}}, in which case
they are taken as variable assignments to be performed at that point
in processing the input.
@item
-All non-option command-line arguments, excluding the program text,
+All nonoption command-line arguments, excluding the program text,
are placed in the @code{ARGV} array. Adjusting @code{ARGC} and @code{ARGV}
affects how @command{awk} processes input.
@@ -4889,7 +4954,7 @@ belongs to that set.
The simplest regular expression is a sequence of letters, numbers, or
both. Such a regexp matches any string that contains that sequence.
Thus, the regexp @samp{foo} matches any string containing @samp{foo}.
-Therefore, the pattern @code{/foo/} matches any input record containing
+Thus, the pattern @code{/foo/} matches any input record containing
the three adjacent characters @samp{foo} @emph{anywhere} in the record. Other
kinds of regexps let you specify more complicated classes of strings.
@@ -4952,17 +5017,16 @@ and @samp{!~} perform regular expression comparisons. Expressions
using these operators can be used as patterns, or in @code{if},
@code{while}, @code{for}, and @code{do} statements.
(@xref{Statements}.)
-For example:
+For example, the following is true if the expression @var{exp} (taken
+as a string) matches @var{regexp}:
@example
@var{exp} ~ /@var{regexp}/
@end example
@noindent
-is true if the expression @var{exp} (taken as a string)
-matches @var{regexp}. The following example matches, or selects,
-all input records with the uppercase letter @samp{J} somewhere in the
-first field:
+This example matches, or selects, all input records with the uppercase
+letter @samp{J} somewhere in the first field:
@example
$ @kbd{awk '$1 ~ /J/' inventory-shipped}
@@ -5032,9 +5096,9 @@ string or regexp. Thus, the string whose contents are the two characters
@samp{"} and @samp{\} must be written @code{"\"\\"}.
Other escape sequences represent unprintable characters
-such as TAB or newline. While there is nothing to stop you from entering most
+such as TAB or newline. There is nothing to stop you from entering most
unprintable characters directly in a string constant or regexp constant,
-they may look ugly.
+but they may look ugly.
The following list presents
all the escape sequences used in @command{awk} and
@@ -5107,7 +5171,7 @@ undefined results. (The @samp{\x} escape sequence is not allowed in
POSIX @command{awk}.)
@quotation CAUTION
-The next major relase of @command{gawk} will change, such
+The next major release of @command{gawk} will change, such
that a maximum of two hexadecimal digits following the
@samp{\x} will be used.
@end quotation
@@ -5119,7 +5183,7 @@ A literal slash (necessary for regexp constants only).
This sequence is used when you want to write a regexp
constant that contains a slash
(such as @code{/.*:\/home\/[[:alnum:]]+:.*/}; the @samp{[[:alnum:]]}
-notation is discussed shortly, in @ref{Bracket Expressions}).
+notation is discussed in @ref{Bracket Expressions}).
Because the regexp is delimited by
slashes, you need to escape any slash that is part of the pattern,
in order to tell @command{awk} to keep processing the rest of the regexp.
@@ -5142,7 +5206,7 @@ with a backslash have special meaning in regexps.
In a regexp, a backslash before any character that is not in the previous list
and not listed in
-@ref{GNU Regexp Operators},
+@DBREF{GNU Regexp Operators}
means that the next character should be taken literally, even if it would
normally be a regexp operator. For example, @code{/a\+b/} matches the three
characters @samp{a+b}.
@@ -5153,25 +5217,7 @@ characters @samp{a+b}.
For complete portability, do not use a backslash before any character not
shown in the previous list and that is not an operator.
-To summarize:
-
-@itemize @value{BULLET}
-@item
-The escape sequences in the list above are always processed first,
-for both string constants and regexp constants. This happens very early,
-as soon as @command{awk} reads your program.
-
-@item
-@command{gawk} processes both regexp constants and dynamic regexps
-(@pxref{Computed Regexps}),
-for the special operators listed in
-@ref{GNU Regexp Operators}.
-
-@item
-A backslash before any other character means to treat that character
-literally.
-@end itemize
-
+@c 11/2014: Moved so as to not stack sidebars
@cindex sidebar, Backslash Before Regular Characters
@ifdocbook
@docbook
@@ -5256,6 +5302,25 @@ In such implementations, typing @code{"a\qc"} is the same as typing
@end cartouche
@end ifnotdocbook
+To summarize:
+
+@itemize @value{BULLET}
+@item
+The escape sequences in the preceding list are always processed first,
+for both string constants and regexp constants. This happens very early,
+as soon as @command{awk} reads your program.
+
+@item
+@command{gawk} processes both regexp constants and dynamic regexps
+(@pxref{Computed Regexps}),
+for the special operators listed in
+@ref{GNU Regexp Operators}.
+
+@item
+A backslash before any other character means to treat that character
+literally.
+@end itemize
+
@cindex sidebar, Escape Sequences for Metacharacters
@ifdocbook
@docbook
@@ -5337,7 +5402,7 @@ sequences and that are not listed in the following stand for themselves:
@cindex backslash (@code{\}), regexp operator
@cindex @code{\} (backslash), regexp operator
@item @code{\}
-This is used to suppress the special meaning of a character when
+This suppresses the special meaning of a character when
matching. For example, @samp{\$}
matches the character @samp{$}.
@@ -5346,8 +5411,9 @@ matches the character @samp{$}.
@cindex @code{^} (caret), regexp operator
@cindex caret (@code{^}), regexp operator
@item @code{^}
-This matches the beginning of a string. For example, @samp{^@@chapter}
-matches @samp{@@chapter} at the beginning of a string and can be used
+This matches the beginning of a string. @samp{^@@chapter}
+matches @samp{@@chapter} at the beginning of a string,
+for example, and can be used
to identify chapter beginnings in Texinfo source files.
The @samp{^} is known as an @dfn{anchor}, because it anchors the pattern to
match only at the beginning of the string.
@@ -5453,7 +5519,7 @@ There are two subtle points to understand about how @samp{*} works.
First, the @samp{*} applies only to the single preceding regular expression
component (e.g., in @samp{ph*}, it applies just to the @samp{h}).
To cause @samp{*} to apply to a larger sub-expression, use parentheses:
-@samp{(ph)*} matches @samp{ph}, @samp{phph}, @samp{phphph} and so on.
+@samp{(ph)*} matches @samp{ph}, @samp{phph}, @samp{phphph}, and so on.
Second, @samp{*} finds as many repetitions as possible. If the text
to be matched is @samp{phhhhhhhhhhhhhhooey}, @samp{ph*} matches all of
@@ -5553,7 +5619,7 @@ expressions are not available in regular expressions.
@cindex range expressions (regexps)
@cindex character lists in regular expression
-As mentioned earlier, a bracket expression matches any character amongst
+As mentioned earlier, a bracket expression matches any character among
those listed between the opening and closing square brackets.
Within a bracket expression, a @dfn{range expression} consists of two
@@ -5611,23 +5677,23 @@ a keyword denoting the class, and @samp{:]}.
POSIX standard.
@float Table,table-char-classes
-@caption{POSIX Character Classes}
+@caption{POSIX character classes}
@multitable @columnfractions .15 .85
@headitem Class @tab Meaning
-@item @code{[:alnum:]} @tab Alphanumeric characters.
-@item @code{[:alpha:]} @tab Alphabetic characters.
-@item @code{[:blank:]} @tab Space and TAB characters.
-@item @code{[:cntrl:]} @tab Control characters.
-@item @code{[:digit:]} @tab Numeric characters.
-@item @code{[:graph:]} @tab Characters that are both printable and visible.
-(A space is printable but not visible, whereas an @samp{a} is both.)
-@item @code{[:lower:]} @tab Lowercase alphabetic characters.
-@item @code{[:print:]} @tab Printable characters (characters that are not control characters).
-@item @code{[:punct:]} @tab Punctuation characters (characters that are not letters, digits,
-control characters, or space characters).
-@item @code{[:space:]} @tab Space characters (such as space, TAB, and formfeed, to name a few).
-@item @code{[:upper:]} @tab Uppercase alphabetic characters.
-@item @code{[:xdigit:]} @tab Characters that are hexadecimal digits.
+@item @code{[:alnum:]} @tab Alphanumeric characters
+@item @code{[:alpha:]} @tab Alphabetic characters
+@item @code{[:blank:]} @tab Space and TAB characters
+@item @code{[:cntrl:]} @tab Control characters
+@item @code{[:digit:]} @tab Numeric characters
+@item @code{[:graph:]} @tab Characters that are both printable and visible
+(a space is printable but not visible, whereas an @samp{a} is both)
+@item @code{[:lower:]} @tab Lowercase alphabetic characters
+@item @code{[:print:]} @tab Printable characters (characters that are not control characters)
+@item @code{[:punct:]} @tab Punctuation characters (characters that are not letters, digits
+control characters, or space characters)
+@item @code{[:space:]} @tab Space characters (such as space, TAB, and formfeed, to name a few)
+@item @code{[:upper:]} @tab Uppercase alphabetic characters
+@item @code{[:xdigit:]} @tab Characters that are hexadecimal digits
@end multitable
@end float
@@ -5642,7 +5708,7 @@ and numeric characters in your character set.
@c Thanks to
@c Date: Tue, 01 Jul 2014 07:39:51 +0200
@c From: Hermann Peifer <peifer@gmx.eu>
-Some utilities that match regular expressions provide a non-standard
+Some utilities that match regular expressions provide a nonstandard
@code{[:ascii:]} character class; @command{awk} does not. However, you
can simulate such a construct using @code{[\x00-\x7F]}. This matches
all values numerically between zero and 127, which is the defined
@@ -5833,7 +5899,7 @@ $ @kbd{awk '$0 ~ "[ \t\n]"'}
@error{} ]...
@error{} source line number 1
@error{} context is
-@error{} $0 ~ "[ >>> \t\n]" <<<
+@error{} $0 ~ "[ >>> \t\n]" <<<
@end example
@cindex newlines, in regexp constants
@@ -5871,7 +5937,7 @@ $ @kbd{awk '$0 ~ "[ \t\n]"'}
@error{} ]...
@error{} source line number 1
@error{} context is
-@error{} $0 ~ "[ >>> \t\n]" <<<
+@error{} $0 ~ "[ >>> \t\n]" <<<
@end example
@cindex newlines, in regexp constants
@@ -5982,9 +6048,9 @@ word-constituent characters. For example,
@cindex regular expressions, operators, for buffers
@cindex operators, string-matching, for buffers
There are two other operators that work on buffers. In Emacs, a
-@dfn{buffer} is, naturally, an Emacs buffer. For other programs,
-@command{gawk}'s regexp library routines consider the entire
-string to match as the buffer.
+@dfn{buffer} is, naturally, an Emacs buffer.
+Other GNU programs, including @command{gawk},
+consider the entire string to match as the buffer.
The operators are:
@table @code
@@ -6045,16 +6111,16 @@ in @ref{Regexp Operators}.
@end ifnottex
@item @code{--posix}
-Only POSIX regexps are supported; the GNU operators are not special
+Match only POSIX regexps; the GNU operators are not special
(e.g., @samp{\w} matches a literal @samp{w}). Interval expressions
are allowed.
@cindex Brian Kernighan's @command{awk}
@item @code{--traditional}
-Traditional Unix @command{awk} regexps are matched. The GNU operators
+Match traditional Unix @command{awk} regexps. The GNU operators
are not special, and interval expressions are not available.
-The POSIX character classes (@samp{[[:alnum:]]}, etc.) are supported,
-as BWK @command{awk} supports them.
+Because BWK @command{awk} supports them,
+the POSIX character classes (@samp{[[:alnum:]]}, etc.) are available.
Characters described by octal and hexadecimal escape sequences are
treated literally, even if they represent regexp metacharacters.
@@ -6114,7 +6180,7 @@ When @code{IGNORECASE} is not zero, @emph{all} regexp and string
operations ignore case.
Changing the value of @code{IGNORECASE} dynamically controls the
-case-sensitivity of the program as it runs. Case is significant by
+case sensitivity of the program as it runs. Case is significant by
default because @code{IGNORECASE} (like most variables) is initialized
to zero:
@@ -6127,7 +6193,7 @@ if (x ~ /ab/) @dots{} # now it will succeed
@end example
In general, you cannot use @code{IGNORECASE} to make certain rules
-case-insensitive and other rules case-sensitive, because there is no
+case insensitive and other rules case sensitive, as there is no
straightforward way
to set @code{IGNORECASE} just for the pattern of
a particular rule.@footnote{Experienced C and C++ programmers will note
@@ -6138,13 +6204,13 @@ and
However, this is somewhat obscure and we don't recommend it.}
To do this, use either bracket expressions or @code{tolower()}. However, one
thing you can do with @code{IGNORECASE} only is dynamically turn
-case-sensitivity on or off for all the rules at once.
+case sensitivity on or off for all the rules at once.
@code{IGNORECASE} can be set on the command line or in a @code{BEGIN} rule
(@pxref{Other Arguments}; also
@pxref{Using BEGIN/END}).
Setting @code{IGNORECASE} from the command line is a way to make
-a program case-insensitive without having to edit it.
+a program case insensitive without having to edit it.
@c @cindex ISO 8859-1
@c @cindex ISO Latin-1
@@ -6181,12 +6247,12 @@ in conditional expressions, or as part of matching expressions
using the @samp{~} and @samp{!~} operators.
@item
-Escape sequences let you represent non-printable characters and
+Escape sequences let you represent nonprintable characters and
also let you represent regexp metacharacters as literal characters
to be matched.
@item
-Regexp operators provide grouping, alternation and repetition.
+Regexp operators provide grouping, alternation, and repetition.
@item
Bracket expressions give you a shorthand for specifying sets
@@ -6201,8 +6267,8 @@ the match, such as for text substitution and when the record separator
is a regexp.
@item
-Matching expressions may use dynamic regexps, that is, string values
-treated as regular expressions.
+Matching expressions may use dynamic regexps (i.e., string values
+treated as regular expressions).
@item
@command{gawk}'s @code{IGNORECASE} variable lets you control the
@@ -6276,7 +6342,7 @@ used with it do not have to be named on the @command{awk} command line
@command{awk} divides the input for your program into records and fields.
It keeps track of the number of records that have been read so far from
the current input file. This value is stored in a predefined variable
-called @code{FNR} which is reset to zero every time a new file is started.
+called @code{FNR}, which is reset to zero every time a new file is started.
Another predefined variable, @code{NR}, records the total number of input
records read so far from all @value{DF}s. It starts at zero, but is
never automatically reset to zero.
@@ -6287,7 +6353,7 @@ never automatically reset to zero.
@end menu
@node awk split records
-@subsection Record Splitting With Standard @command{awk}
+@subsection Record Splitting with Standard @command{awk}
@cindex separators, for records
@cindex record separators
@@ -6304,7 +6370,7 @@ the value of @code{RS} can be changed in the @command{awk} program
with the assignment operator, @samp{=}
(@pxref{Assignment Ops}).
The new record-separator character should be enclosed in quotation marks,
-which indicate a string constant. Often the right time to do this is
+which indicate a string constant. Often, the right time to do this is
at the beginning of execution, before any input is processed,
so that the very first record is read with the proper separator.
To do this, use the special @code{BEGIN} pattern
@@ -6318,7 +6384,7 @@ awk 'BEGIN @{ RS = "u" @}
@noindent
changes the value of @code{RS} to @samp{u}, before reading any input.
-This is a string whose first character is the letter ``u;'' as a result, records
+This is a string whose first character is the letter ``u''; as a result, records
are separated by the letter ``u.'' Then the input file is read, and the second
rule in the @command{awk} program (the action with no pattern) prints each
record. Because each @code{print} statement adds a newline at the end of
@@ -6366,7 +6432,7 @@ $ @kbd{awk 'BEGIN @{ RS = "u" @}}
@print{} m@@ny
@print{} .ed
@print{} R
-@print{}
+@print{}
@end example
@noindent
@@ -6412,7 +6478,7 @@ being fully POSIX-compliant (@pxref{Options}).
Then, the following (extreme) pipeline prints a surprising @samp{1}:
@example
-$ echo | gawk --posix 'BEGIN @{ RS = "a" @} ; @{ print NF @}'
+$ @kbd{echo | gawk --posix 'BEGIN @{ RS = "a" @} ; @{ print NF @}'}
@print{} 1
@end example
@@ -6434,7 +6500,7 @@ The empty string @code{""} (a string without any characters)
has a special meaning
as the value of @code{RS}. It means that records are separated
by one or more blank lines and nothing else.
-@xref{Multiple Line}, for more details.
+@DBXREF{Multiple Line} for more details.
If you change the value of @code{RS} in the middle of an @command{awk} run,
the new value is used to delimit subsequent records, but the record
@@ -6454,7 +6520,7 @@ sets the variable @code{RT} to the text in the input that matched
@code{RS}.
@node gawk split records
-@subsection Record Splitting With @command{gawk}
+@subsection Record Splitting with @command{gawk}
@cindex common extensions, @code{RS} as a regexp
@cindex extensions, common@comma{} @code{RS} as a regexp
@@ -6498,11 +6564,11 @@ $ @kbd{echo record 1 AAAA record 2 BBBB record 3 |}
The square brackets delineate the contents of @code{RT}, letting you
see the leading and trailing whitespace. The final value of
@code{RT} is a newline.
-@xref{Simple Sed}, for a more useful example
+@DBXREF{Simple Sed} for a more useful example
of @code{RS} as a regexp and @code{RT}.
If you set @code{RS} to a regular expression that allows optional
-trailing text, such as @samp{RS = "abc(XYZ)?"} it is possible, due
+trailing text, such as @samp{RS = "abc(XYZ)?"}, it is possible, due
to implementation constraints, that @command{gawk} may match the leading
part of the regular expression, but not the trailing part, particularly
if the input text that could match the trailing part is fairly long.
@@ -6570,9 +6636,9 @@ character as a record separator. However, this is a special case:
@cindex records, treating files as
@cindex treating files, as single records
-@xref{Readfile Function}, for an interesting way to read
-whole files. If you are using @command{gawk}, see @ref{Extension Sample
-Readfile}, for another option.
+@DBXREF{Readfile Function} for an interesting way to read
+whole files. If you are using @command{gawk}, see @DBREF{Extension Sample
+Readfile} for another option.
@docbook
</sidebar>
@@ -6621,9 +6687,9 @@ character as a record separator. However, this is a special case:
@cindex records, treating files as
@cindex treating files, as single records
-@xref{Readfile Function}, for an interesting way to read
-whole files. If you are using @command{gawk}, see @ref{Extension Sample
-Readfile}, for another option.
+@DBXREF{Readfile Function} for an interesting way to read
+whole files. If you are using @command{gawk}, see @DBREF{Extension Sample
+Readfile} for another option.
@end cartouche
@end ifnotdocbook
@c ENDOFRANGE inspl
@@ -6646,9 +6712,9 @@ called @dfn{fields}. By default, fields are separated by @dfn{whitespace},
like words in a line.
Whitespace in @command{awk} means any string of one or more spaces,
TABs, or newlines;@footnote{In POSIX @command{awk}, newlines are not
-considered whitespace for separating fields.} other characters, such as
-formfeed, vertical tab, etc., that are
-considered whitespace by other languages, are @emph{not} considered
+considered whitespace for separating fields.} other characters
+that are considered whitespace by other languages
+(such as formfeed, vertical tab, etc.) are @emph{not} considered
whitespace by @command{awk}.
The purpose of fields is to make it more convenient for you to refer to
@@ -6665,7 +6731,7 @@ to refer to a field in an @command{awk} program,
followed by the number of the field you want. Thus, @code{$1}
refers to the first field, @code{$2} to the second, and so on.
(Unlike the Unix shells, the field numbers are not limited to single digits.
-@code{$127} is the one hundred twenty-seventh field in the record.)
+@code{$127} is the 127th field in the record.)
For example, suppose the following is a line of input:
@example
@@ -6735,7 +6801,7 @@ awk '@{ print $NR @}'
@noindent
Recall that @code{NR} is the number of records read so far: one in the
-first record, two in the second, etc. So this example prints the first
+first record, two in the second, and so on. So this example prints the first
field of the first record, the second field of the second record, and so
on. For the twentieth record, field number 20 is printed; most likely,
the record has fewer than 20 fields, so this prints a blank line.
@@ -6752,7 +6818,7 @@ The parentheses are used so that the multiplication is done before the
@samp{$} operation; they are necessary whenever there is a binary
operator@footnote{A @dfn{binary operator}, such as @samp{*} for
multiplication, is one that takes two operands. The distinction
-is required, since @command{awk} also has unary (one-operand)
+is required, because @command{awk} also has unary (one-operand)
and ternary (three-operand) operators.}
in the field-number expression. This example, then, prints the
type of relationship (the fourth field) for every line of the file
@@ -6826,7 +6892,7 @@ $ @kbd{awk '@{ $2 = $2 - 10; print $0 @}' inventory-shipped}
@dots{}
@end example
-It is also possible to also assign contents to fields that are out
+It is also possible to assign contents to fields that are out
of range. For example:
@example
@@ -6877,9 +6943,9 @@ else
@noindent
should print @samp{everything is normal}, because @code{NF+1} is certain
-to be out of range. (@xref{If Statement},
+to be out of range. (@DBXREF{If Statement}
for more information about @command{awk}'s @code{if-else} statements.
-@xref{Typing and Comparison},
+@DBXREF{Typing and Comparison}
for more information about the @samp{!=} operator.)
It is important to note that making an assignment to an existing field
@@ -6919,8 +6985,8 @@ after the new value of @code{NF} and recomputes @code{$0}.
Here is an example:
@example
-$ echo a b c d e f | awk '@{ print "NF =", NF;
-> NF = 3; print $0 @}'
+$ @kbd{echo a b c d e f | awk '@{ print "NF =", NF;}
+> @kbd{ NF = 3; print $0 @}'}
@print{} NF = 6
@print{} a b c
@end example
@@ -6969,7 +7035,7 @@ in a record simply by setting @code{FS} and @code{OFS}, and then
expecting a plain @samp{print} or @samp{print $0} to print the
modified record.
-But this does not work, since nothing was done to change the record
+But this does not work, because nothing was done to change the record
itself. Instead, you must force the record to be rebuilt, typically
with a statement such as @samp{$1 = $1}, as described earlier.
@@ -6994,7 +7060,7 @@ in a record simply by setting @code{FS} and @code{OFS}, and then
expecting a plain @samp{print} or @samp{print $0} to print the
modified record.
-But this does not work, since nothing was done to change the record
+But this does not work, because nothing was done to change the record
itself. Instead, you must force the record to be rebuilt, typically
with a statement such as @samp{$1 = $1}, as described earlier.
@end cartouche
@@ -7047,7 +7113,7 @@ the Unix Bourne shell, @command{sh}, or Bash).
@cindex @code{FS} variable, changing value of
The value of @code{FS} can be changed in the @command{awk} program with the
assignment operator, @samp{=} (@pxref{Assignment Ops}).
-Often the right time to do this is at the beginning of execution
+Often, the right time to do this is at the beginning of execution
before any input has been processed, so that the very first record
is read with the proper separator. To do this, use the special
@code{BEGIN} pattern
@@ -7203,7 +7269,7 @@ statement prints the new @code{$0}.
@cindex dark corner, @code{^}, in @code{FS}
There is an additional subtlety to be aware of when using regular expressions
for field splitting.
-It is not well-specified in the POSIX standard, or anywhere else, what @samp{^}
+It is not well specified in the POSIX standard, or anywhere else, what @samp{^}
means when splitting fields. Does the @samp{^} match only at the beginning of
the entire record? Or is each field separator a new string? It turns out that
different @command{awk} versions answer this question differently, and you
@@ -7369,11 +7435,11 @@ awk -F: '$5 == ""' /etc/passwd
@end example
@node Full Line Fields
-@subsection Making The Full Line Be A Single Field
+@subsection Making the Full Line Be a Single Field
Occasionally, it's useful to treat the whole input line as a
single field. This can be done easily and portably simply by
-setting @code{FS} to @code{"\n"} (a newline).@footnote{Thanks to
+setting @code{FS} to @code{"\n"} (a newline):@footnote{Thanks to
Andrew Schorr for this tip.}
@example
@@ -7383,42 +7449,6 @@ awk -F'\n' '@var{program}' @var{files @dots{}}
@noindent
When you do this, @code{$1} is the same as @code{$0}.
-@node Field Splitting Summary
-@subsection Field-Splitting Summary
-
-It is important to remember that when you assign a string constant
-as the value of @code{FS}, it undergoes normal @command{awk} string
-processing. For example, with Unix @command{awk} and @command{gawk},
-the assignment @samp{FS = "\.."} assigns the character string @code{".."}
-to @code{FS} (the backslash is stripped). This creates a regexp meaning
-``fields are separated by occurrences of any two characters.''
-If instead you want fields to be separated by a literal period followed
-by any single character, use @samp{FS = "\\.."}.
-
-The following list summarizes how fields are split, based on the value
-of @code{FS} (@samp{==} means ``is equal to''):
-
-@table @code
-@item FS == " "
-Fields are separated by runs of whitespace. Leading and trailing
-whitespace are ignored. This is the default.
-
-@item FS == @var{any other single character}
-Fields are separated by each occurrence of the character. Multiple
-successive occurrences delimit empty fields, as do leading and
-trailing occurrences.
-The character can even be a regexp metacharacter; it does not need
-to be escaped.
-
-@item FS == @var{regexp}
-Fields are separated by occurrences of characters that match @var{regexp}.
-Leading and trailing matches of @var{regexp} delimit empty fields.
-
-@item FS == ""
-Each individual character in the record becomes a separate field.
-(This is a common extension; it is not specified by the POSIX standard.)
-@end table
-
@cindex sidebar, Changing @code{FS} Does Not Affect the Fields
@ifdocbook
@docbook
@@ -7523,6 +7553,42 @@ root:nSijPlPhZZwgE:0:0:Root:/:
@end cartouche
@end ifnotdocbook
+@node Field Splitting Summary
+@subsection Field-Splitting Summary
+
+It is important to remember that when you assign a string constant
+as the value of @code{FS}, it undergoes normal @command{awk} string
+processing. For example, with Unix @command{awk} and @command{gawk},
+the assignment @samp{FS = "\.."} assigns the character string @code{".."}
+to @code{FS} (the backslash is stripped). This creates a regexp meaning
+``fields are separated by occurrences of any two characters.''
+If instead you want fields to be separated by a literal period followed
+by any single character, use @samp{FS = "\\.."}.
+
+The following list summarizes how fields are split, based on the value
+of @code{FS} (@samp{==} means ``is equal to''):
+
+@table @code
+@item FS == " "
+Fields are separated by runs of whitespace. Leading and trailing
+whitespace are ignored. This is the default.
+
+@item FS == @var{any other single character}
+Fields are separated by each occurrence of the character. Multiple
+successive occurrences delimit empty fields, as do leading and
+trailing occurrences.
+The character can even be a regexp metacharacter; it does not need
+to be escaped.
+
+@item FS == @var{regexp}
+Fields are separated by occurrences of characters that match @var{regexp}.
+Leading and trailing matches of @var{regexp} delimit empty fields.
+
+@item FS == ""
+Each individual character in the record becomes a separate field.
+(This is a common extension; it is not specified by the POSIX standard.)
+@end table
+
@cindex sidebar, @code{FS} and @code{IGNORECASE}
@ifdocbook
@docbook
@@ -7546,7 +7612,7 @@ print $1
@noindent
The output is @samp{aCa}. If you really want to split fields on an
alphabetic character while ignoring case, use a regexp that will
-do it for you. E.g., @samp{FS = "[c]"}. In this case, @code{IGNORECASE}
+do it for you (e.g., @samp{FS = "[c]"}). In this case, @code{IGNORECASE}
will take effect.
@docbook
@@ -7576,7 +7642,7 @@ print $1
@noindent
The output is @samp{aCa}. If you really want to split fields on an
alphabetic character while ignoring case, use a regexp that will
-do it for you. E.g., @samp{FS = "[c]"}. In this case, @code{IGNORECASE}
+do it for you (e.g., @samp{FS = "[c]"}). In this case, @code{IGNORECASE}
will take effect.
@end cartouche
@end ifnotdocbook
@@ -7587,20 +7653,20 @@ will take effect.
@node Constant Size
@section Reading Fixed-Width Data
-@quotation NOTE
+@cindex data, fixed-width
+@cindex fixed-width data
+@cindex advanced features, fixed-width data
+
+@c O'Reilly doesn't like it as a note the first thing in the section.
This @value{SECTION} discusses an advanced
feature of @command{gawk}. If you are a novice @command{awk} user,
you might want to skip it on the first reading.
-@end quotation
-@cindex data, fixed-width
-@cindex fixed-width data
-@cindex advanced features, fixed-width data
-@command{gawk} provides a facility for dealing with
-fixed-width fields with no distinctive field separator. For example,
-data of this nature arises in the input for old Fortran programs where
-numbers are run together, or in the output of programs that did not
-anticipate the use of their output as input for other programs.
+@command{gawk} provides a facility for dealing with fixed-width fields
+with no distinctive field separator. For example, data of this nature
+arises in the input for old Fortran programs where numbers are run
+together, or in the output of programs that did not anticipate the use
+of their output as input for other programs.
An example of the latter is a table where all the columns are lined up by
the use of a variable number of spaces and @emph{empty fields are just
@@ -7639,15 +7705,10 @@ dave ttyq4 26Jun9115days 46 46 wnewmail
@end group
@end example
-The following program takes the above input, converts the idle time to
+The following program takes this input, converts the idle time to
number of seconds, and prints out the first two fields and the calculated
idle time:
-@quotation NOTE
-This program uses a number of @command{awk} features that
-haven't been introduced yet.
-@end quotation
-
@example
BEGIN @{ FIELDWIDTHS = "9 6 10 6 7 7 35" @}
NR > 2 @{
@@ -7666,6 +7727,11 @@ NR > 2 @{
@}
@end example
+@quotation NOTE
+The preceding program uses a number of @command{awk} features that
+haven't been introduced yet.
+@end quotation
+
Running the program on the data produces the following results:
@example
@@ -7711,17 +7777,16 @@ else
This information is useful when writing a function
that needs to temporarily change @code{FS} or @code{FIELDWIDTHS},
read some records, and then restore the original settings
-(@pxref{Passwd Functions},
+(@DBPXREF{Passwd Functions}
for an example of such a function).
@node Splitting By Content
-@section Defining Fields By Content
+@section Defining Fields by Content
-@quotation NOTE
+@c O'Reilly doesn't like it as a note the first thing in the section.
This @value{SECTION} discusses an advanced
feature of @command{gawk}. If you are a novice @command{awk} user,
you might want to skip it on the first reading.
-@end quotation
@cindex advanced features, specifying field content
Normally, when using @code{FS}, @command{gawk} defines the fields as the
@@ -7732,12 +7797,12 @@ However, there are times when you really want to define the fields by
what they are, and not by what they are not.
The most notorious such case
-is so-called @dfn{comma separated value} (CSV) data. Many spreadsheet programs,
+is so-called @dfn{comma-separated values} (CSV) data. Many spreadsheet programs,
for example, can export their data into text files, where each record is
terminated with a newline, and fields are separated by commas. If only
commas separated the data, there wouldn't be an issue. The problem comes when
-one of the fields contains an @emph{embedded} comma. While there is no
-formal standard specification for CSV data@footnote{At least, we don't know of one.},
+one of the fields contains an @emph{embedded} comma. Although there is no
+formal standard specification for CSV data,@footnote{At least, we don't know of one.}
in such cases, most programs embed the field in double quotes. So we might
have data like this:
@@ -7753,7 +7818,7 @@ The @code{FPAT} variable offers a solution for cases like this.
The value of @code{FPAT} should be a string that provides a regular expression.
This regular expression describes the contents of each field.
-In the case of CSV data as presented above, each field is either ``anything that
+In the case of CSV data as presented here, each field is either ``anything that
is not a comma,'' or ``a double quote, anything that is not a double quote, and a
closing double quote.'' If written as a regular expression constant
(@pxref{Regexp}),
@@ -7818,10 +7883,10 @@ will be @code{"FPAT"} if content-based field splitting is being used.
@quotation NOTE
Some programs export CSV data that contains embedded newlines between
the double quotes. @command{gawk} provides no way to deal with this.
-Since there is no formal specification for CSV data, there isn't much
+Because no formal specification for CSV data exists, there isn't much
more to be done;
the @code{FPAT} mechanism provides an elegant solution for the majority
-of cases, and the @command{gawk} developers are satisfied with that.
+of cases, and the @command{gawk} developers are satisfied with that.
@end quotation
As written, the regexp used for @code{FPAT} requires that each field
@@ -7975,7 +8040,7 @@ $ @kbd{awk -f addrs.awk addresses}
@dots{}
@end example
-@xref{Labels Program}, for a more realistic program that deals with
+@DBXREF{Labels Program} for a more realistic program dealing with
address lists. The following list summarizes how records are split,
based on the value of
@ifinfo
@@ -8070,7 +8135,7 @@ represents a shell command.
@quotation NOTE
When @option{--sandbox} is specified (@pxref{Options}),
-reading lines from files, pipes and coprocesses is disabled.
+reading lines from files, pipes, and coprocesses is disabled.
@end quotation
@menu
@@ -8213,7 +8278,7 @@ free
@end example
The @code{getline} command used in this way sets only the variables
-@code{NR}, @code{FNR} and @code{RT} (and of course, @var{var}).
+@code{NR}, @code{FNR}, and @code{RT} (and of course, @var{var}).
The record is not
split into fields, so the values of the fields (including @code{$0}) and
the value of @code{NF} do not change.
@@ -8267,7 +8332,7 @@ you want your program to be portable to all @command{awk} implementations.
Use @samp{getline @var{var} < @var{file}} to read input
from the file
-@var{file}, and put it in the variable @var{var}. As above, @var{file}
+@var{file}, and put it in the variable @var{var}. As earlier, @var{file}
is a string-valued expression that specifies the file from which to read.
In this version of @code{getline}, none of the predefined variables are
@@ -8303,7 +8368,7 @@ One deficiency of this program is that it does not process nested
@code{@@include} statements
(i.e., @code{@@include} statements in included files)
the way a true macro preprocessor would.
-@xref{Igawk Program}, for a program
+@DBXREF{Igawk Program} for a program
that does handle nested @code{@@include} statements.
@node Getline/Pipe
@@ -8602,7 +8667,7 @@ and whether the variant is standard or a @command{gawk} extension.
Note: for each variant, @command{gawk} sets the @code{RT} predefined variable.
@float Table,table-getline-variants
-@caption{@code{getline} Variants and What They Set}
+@caption{@code{getline} variants and what they set}
@multitable @columnfractions .33 .38 .27
@headitem Variant @tab Effect @tab @command{awk} / @command{gawk}
@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, @code{NR}, and @code{RT} @tab @command{awk}
@@ -8620,7 +8685,7 @@ Note: for each variant, @command{gawk} sets the @code{RT} predefined variable.
@c ENDOFRANGE infir
@node Read Timeout
-@section Reading Input With A Timeout
+@section Reading Input with a Timeout
@cindex timeout, reading input
@cindex differences in @command{awk} and @command{gawk}, read timeouts
@@ -8628,7 +8693,7 @@ This @value{SECTION} describes a feature that is specific to @command{gawk}.
You may specify a timeout in milliseconds for reading input from the keyboard,
a pipe, or two-way communication, including TCP/IP sockets. This can be done
-on a per input, command or connection basis, by setting a special element
+on a per input, command, or connection basis, by setting a special element
in the @code{PROCINFO} array (@pxref{Auto-set}):
@example
@@ -8702,11 +8767,11 @@ You should not assume that the read operation will block
exactly after the tenth record has been printed. It is possible that
@command{gawk} will read and buffer more than one record's
worth of data the first time. Because of this, changing the value
-of timeout like in the above example is not very useful.
+of timeout like in the preceding example is not very useful.
@end quotation
-If the @code{PROCINFO} element is not present and the environment
-variable @env{GAWK_READ_TIMEOUT} exists,
+If the @code{PROCINFO} element is not present and the
+@env{GAWK_READ_TIMEOUT} environment variable exists,
@command{gawk} uses its value to initialize the timeout value.
The exclusive use of the environment variable to specify timeout
has the disadvantage of not being able to control it
@@ -8727,7 +8792,7 @@ or the attempt to open a FIFO special file for reading can block
indefinitely until some other process opens it for writing.
@node Command-line directories
-@section Directories On The Command Line
+@section Directories on the Command Line
@cindex differences in @command{awk} and @command{gawk}, command-line directories
@cindex directories, command-line
@cindex command line, directories on
@@ -8742,14 +8807,14 @@ command line, but otherwise ignores it. This makes it easier to use
shell wildcards with your @command{awk} program:
@example
-$ @kbd{gawk -f whizprog.awk *} @ii{Directories could kill this progam}
+$ @kbd{gawk -f whizprog.awk *} @ii{Directories could kill this program}
@end example
If either of the @option{--posix}
or @option{--traditional} options is given, then @command{gawk} reverts
to treating a directory on the command line as a fatal error.
-@xref{Extension Sample Readdir}, for a way to treat directories
+@DBXREF{Extension Sample Readdir} for a way to treat directories
as usable data from an @command{awk} program.
@node Input Summary
@@ -8776,7 +8841,7 @@ The possibilities are as follows:
@item
After splitting the input into records, @command{awk} further splits
-the record into individual fields, named @code{$1}, @code{$2} and so
+the record into individual fields, named @code{$1}, @code{$2}, and so
on. @code{$0} is the whole record, and @code{NF} indicates how many
fields there are. The default way to split fields is between whitespace
characters.
@@ -8790,7 +8855,7 @@ greater than @code{NF} creates the field and rebuilds the record, using
thing. Decrementing @code{NF} throws away fields and rebuilds the record.
@item
-Field splitting is more complicated than record splitting.
+Field splitting is more complicated than record splitting:
@multitable @columnfractions .40 .45 .15
@headitem Field separator value @tab Fields are split @dots{} @tab @command{awk} / @command{gawk}
@@ -8863,7 +8928,7 @@ The @code{print} statement is not limited when
computing @emph{which} values to print. However, with two exceptions,
you cannot specify @emph{how} to print them---how many
columns, whether to use exponential notation or not, and so on.
-(For the exceptions, @pxref{Output Separators}, and
+(For the exceptions, @DBPXREF{Output Separators} and
@ref{OFMT}.)
For printing with specifications, you need the @code{printf} statement
(@pxref{Printf}).
@@ -9060,14 +9125,14 @@ separated by single spaces. However, this doesn't need to be the case;
a single space is simply the default. Any string of
characters may be used as the @dfn{output field separator} by setting the
predefined variable @code{OFS}. The initial value of this variable
-is the string @w{@code{" "}}---that is, a single space.
+is the string @w{@code{" "}} (i.e., a single space).
-The output from an entire @code{print} statement is called an
-@dfn{output record}. Each @code{print} statement outputs one output
-record, and then outputs a string called the @dfn{output record separator}
-(or @code{ORS}). The initial
-value of @code{ORS} is the string @code{"\n"}; i.e., a newline
-character. Thus, each @code{print} statement normally makes a separate line.
+The output from an entire @code{print} statement is called an @dfn{output
+record}. Each @code{print} statement outputs one output record, and
+then outputs a string called the @dfn{output record separator} (or
+@code{ORS}). The initial value of @code{ORS} is the string @code{"\n"}
+(i.e., a newline character). Thus, each @code{print} statement normally
+makes a separate line.
@cindex output, records
@cindex output record separator, See @code{ORS} variable
@@ -9090,27 +9155,27 @@ newline:
$ @kbd{awk 'BEGIN @{ OFS = ";"; ORS = "\n\n" @}}
> @kbd{@{ print $1, $2 @}' mail-list}
@print{} Amelia;555-5553
-@print{}
+@print{}
@print{} Anthony;555-3412
-@print{}
+@print{}
@print{} Becky;555-7685
-@print{}
+@print{}
@print{} Bill;555-1675
-@print{}
+@print{}
@print{} Broderick;555-0542
-@print{}
+@print{}
@print{} Camilla;555-2912
-@print{}
+@print{}
@print{} Fabius;555-1234
-@print{}
+@print{}
@print{} Julie;555-6699
-@print{}
+@print{}
@print{} Martin;555-6480
-@print{}
+@print{}
@print{} Samuel;555-3430
-@print{}
+@print{}
@print{} Jean-Paul;555-2127
-@print{}
+@print{}
@end example
If the value of @code{ORS} does not contain a newline, the program's output
@@ -9191,7 +9256,7 @@ printf @var{format}, @var{item1}, @var{item2}, @dots{}
@end example
@noindent
-As print @code{print}, the entire list of arguments may optionally be
+As for @code{print}, the entire list of arguments may optionally be
enclosed in parentheses. Here too, the parentheses are necessary if any
of the item expressions use the @samp{>} relational operator; otherwise,
it can be confused with an output redirection (@pxref{Redirection}).
@@ -9299,7 +9364,7 @@ which follow the decimal point.
(The @samp{4.3} represents two modifiers,
discussed in the next @value{SUBSECTION}.)
-On systems supporting IEEE 754 floating point format, values
+On systems supporting IEEE 754 floating-point format, values
representing negative
infinity are formatted as
@samp{-inf} or @samp{-infinity},
@@ -9330,7 +9395,7 @@ Print a string.
@item @code{%u}
Print an unsigned decimal integer.
(This format is of marginal use, because all numbers in @command{awk}
-are floating-point; it is provided primarily for compatibility with C.)
+are floating point; it is provided primarily for compatibility with C.)
@item @code{%x}, @code{%X}
Print an unsigned hexadecimal integer;
@@ -9423,7 +9488,7 @@ says to always supply a sign for numeric conversions, even if the data
to format is positive. The @samp{+} overrides the space modifier.
@item #
-Use an ``alternate form'' for certain control letters.
+Use an ``alternative form'' for certain control letters.
For @code{%o}, supply a leading zero.
For @code{%x} and @code{%X}, supply a leading @code{0x} or @samp{0X} for
a nonzero result.
@@ -9440,7 +9505,7 @@ value to print.
@item '
A single quote or apostrophe character is a POSIX extension to ISO C.
-It indicates that the integer part of a floating point value, or the
+It indicates that the integer part of a floating-point value, or the
entire part of an integer decimal value, should have a thousands-separator
character in it. This only works in locales that support such characters.
For example:
@@ -9521,7 +9586,7 @@ prints @samp{foob}.
@end table
The C library @code{printf}'s dynamic @var{width} and @var{prec}
-capability (for example, @code{"%*.*s"}) is supported. Instead of
+capability (e.g., @code{"%*.*s"}) is supported. Instead of
supplying explicit @var{width} and/or @var{prec} values in the format
string, they are passed in the argument list. For example:
@@ -9621,7 +9686,7 @@ awk 'BEGIN @{ print "Name Number"
@{ printf "%-10s %s\n", $1, $2 @}' mail-list
@end example
-The above example mixes @code{print} and @code{printf} statements in
+The preceding example mixes @code{print} and @code{printf} statements in
the same program. Using just @code{printf} statements can produce the
same results:
@@ -9768,7 +9833,7 @@ close(report)
The @code{close()} function is called here because it's a good idea to close
the pipe as soon as all the intended output has been sent to it.
-@xref{Close Files And Pipes},
+@DBXREF{Close Files And Pipes}
for more information.
This example also illustrates the use of a variable to represent
@@ -9792,9 +9857,9 @@ but subsidiary to, the @command{awk} program.
This feature is a @command{gawk} extension, and is not available in
POSIX @command{awk}.
-@xref{Getline/Coprocess},
+@DBXREF{Getline/Coprocess}
for a brief discussion.
-@xref{Two-way I/O},
+@DBXREF{Two-way I/O}
for a more complete discussion.
@end table
@@ -9818,7 +9883,7 @@ print "Avoid improbability generators" >> "guide.txt"
@noindent
This is indeed how redirections must be used from the shell. But in
@command{awk}, it isn't necessary. In this kind of case, a program should
-use @samp{>} for all the @code{print} statements, since the output file
+use @samp{>} for all the @code{print} statements, because the output file
is only opened once. (It happens that if you mix @samp{>} and @samp{>>}
that output is produced in the expected order. However, mixing the operators
for the same file is definitely poor style, and is confusing to readers
@@ -9872,7 +9937,7 @@ The program builds up a list of command lines,
using the @command{mv} utility to rename the files.
It then sends the list to the shell for execution.
-@xref{Shell Quoting}, for a function that can help in generating
+@DBXREF{Shell Quoting} for a function that can help in generating
command lines to be fed to the shell.
@docbook
@@ -9907,7 +9972,7 @@ The program builds up a list of command lines,
using the @command{mv} utility to rename the files.
It then sends the list to the shell for execution.
-@xref{Shell Quoting}, for a function that can help in generating
+@DBXREF{Shell Quoting} for a function that can help in generating
command lines to be fed to the shell.
@end cartouche
@end ifnotdocbook
@@ -9973,7 +10038,7 @@ that happens, writing to the screen is not correct. In fact, if
terminal at all.
Then opening @file{/dev/tty} fails.
-@command{gawk}, BWK @command{awk} and @command{mawk} provide
+@command{gawk}, BWK @command{awk}, and @command{mawk} provide
special @value{FN}s for accessing the three standard streams.
If the @value{FN} matches one of these special names when @command{gawk}
(or one of the others) redirects input or output, then it directly uses
@@ -10016,7 +10081,7 @@ It is a common error to omit the quotes, which leads
to confusing results.
@command{gawk} does not treat these @value{FN}s as special when
-in POSIX compatibility mode. However, since BWK @command{awk}
+in POSIX-compatibility mode. However, because BWK @command{awk}
supports them, @command{gawk} does support them even when
invoked with the @option{--traditional} option (@pxref{Options}).
@@ -10025,7 +10090,7 @@ invoked with the @option{--traditional} option (@pxref{Options}).
@c STARTOFRANGE gfn
@cindex @command{gawk}, file names in
-Besides access to standard input, stanard output, and standard error,
+Besides access to standard input, standard output, and standard error,
@command{gawk} provides access to any open file descriptor.
Additionally, there are special @value{FN}s reserved for
TCP/IP networking.
@@ -10074,7 +10139,7 @@ This is done using a special @value{FN} of the form:
@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}}
@end example
-The @var{net-type} is one of @samp{inet}, @samp{inet4} or @samp{inet6}.
+The @var{net-type} is one of @samp{inet}, @samp{inet4}, or @samp{inet6}.
The @var{protocol} is one of @samp{tcp} or @samp{udp},
and the other fields represent the other essential pieces of information
for making a networking connection.
@@ -10263,7 +10328,7 @@ is not closed and released until @code{close()} is called or
@command{awk} exits.
@code{close()} silently does nothing if given an argument that
-does not represent a file, pipe or coprocess that was opened with
+does not represent a file, pipe, or coprocess that was opened with
a redirection. In such a case, it returns a negative value,
indicating an error. In addition, @command{gawk} sets @code{ERRNO}
to a string indicating the error.
@@ -10302,9 +10367,10 @@ which describes it in more detail and gives an example.
@cindex Unix @command{awk}, @code{close()} function and
In many older versions of Unix @command{awk}, the @code{close()} function
-is actually a statement. It is a syntax error to try and use the return
-value from @code{close()}:
+is actually a statement.
@value{DARKCORNER}
+It is a syntax error to try and use the return
+value from @code{close()}:
@example
command = "@dots{}"
@@ -10358,9 +10424,10 @@ when closing a pipe.
@cindex Unix @command{awk}, @code{close()} function and
In many older versions of Unix @command{awk}, the @code{close()} function
-is actually a statement. It is a syntax error to try and use the return
-value from @code{close()}:
+is actually a statement.
@value{DARKCORNER}
+It is a syntax error to try and use the return
+value from @code{close()}:
@example
command = "@dots{}"
@@ -10424,11 +10491,11 @@ Output from both @code{print} and @code{printf} may be redirected to
files, pipes, and coprocesses.
@item
-@command{gawk} provides special file names for access to standard input,
-output and error, and for network communications.
+@command{gawk} provides special @value{FN}s for access to standard input,
+output, and error, and for network communications.
@item
-Use @code{close()} to close open file, pipe and coprocess redirections.
+Use @code{close()} to close open file, pipe, and coprocess redirections.
For coprocesses, it is possible to close only one direction of the
communications.
@@ -10496,7 +10563,7 @@ combinations of these with various operators.
@end menu
@node Values
-@section Constants, Variables and Conversions
+@section Constants, Variables, and Conversions
Expressions are built up from values and the operations performed
upon them. This @value{SECTION} describes the elementary objects
@@ -10522,7 +10589,7 @@ string, and regular expression.
Each is used in the appropriate context when you need a data
value that isn't going to change. Numeric constants can
-have different forms, but are stored identically internally.
+have different forms, but are internally stored in an identical manner.
@menu
* Scalar Constants:: Numeric and string constants.
@@ -10538,7 +10605,7 @@ have different forms, but are stored identically internally.
A @dfn{numeric constant} stands for a number. This number can be an
integer, a decimal fraction, or a number in scientific (exponential)
notation.@footnote{The internal representation of all numbers,
-including integers, uses double precision floating-point numbers.
+including integers, uses double-precision floating-point numbers.
On most modern systems, these are in IEEE 754 standard format.
@xref{Arbitrary Precision Arithmetic}, for much more information.}
Here are some examples of numeric constants that all
@@ -10552,7 +10619,7 @@ have the same value:
@cindex string constants
A string constant consists of a sequence of characters enclosed in
-double-quotation marks. For example:
+double quotation marks. For example:
@example
"parrot"
@@ -10574,13 +10641,13 @@ implementations may have difficulty with some character codes.
@cindex numbers, octal
@cindex numbers, hexadecimal
-In @command{awk}, all numbers are in decimal; i.e., base 10. Many other
+In @command{awk}, all numbers are in decimal (i.e., base 10). Many other
programming languages allow you to specify numbers in other bases, often
octal (base 8) and hexadecimal (base 16).
-In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc.
+In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on.
Just as @samp{11}, in decimal, is 1 times 10 plus 1, so
@samp{11}, in octal, is 1 times 8, plus 1. This equals 9 in decimal.
-In hexadecimal, there are 16 digits. Since the everyday decimal
+In hexadecimal, there are 16 digits. Because the everyday decimal
number system only has ten digits (@samp{0}--@samp{9}), the letters
@samp{a} through @samp{f} are used to represent the rest.
(Case in the letters is usually irrelevant; hexadecimal @samp{a} and @samp{A}
@@ -10632,11 +10699,12 @@ you can use the @code{strtonum()} function
to convert the data into a number.
Most of the time, you will want to use octal or hexadecimal constants
when working with the built-in bit manipulation functions;
-see @ref{Bitwise Functions},
+see @DBREF{Bitwise Functions}
for more information.
-Unlike some early C implementations, @samp{8} and @samp{9} are not valid
-in octal constants; e.g., @command{gawk} treats @samp{018} as decimal 18:
+Unlike some early C implementations, @samp{8} and @samp{9} are not
+valid in octal constants. For example, @command{gawk} treats @samp{018}
+as decimal 18:
@example
$ @kbd{gawk 'BEGIN @{ print "021 is", 021 ; print 018 @}'}
@@ -10722,7 +10790,7 @@ matched.
However, regexp constants (such as @code{/foo/}) may be used like simple expressions.
When a
regexp constant appears by itself, it has the same meaning as if it appeared
-in a pattern, i.e., @samp{($0 ~ /foo/)}
+in a pattern (i.e., @samp{($0 ~ /foo/)}).
@value{DARKCORNER}
@xref{Expression Patterns}.
This means that the following two code segments:
@@ -10819,7 +10887,7 @@ either @code{sub()} or @code{gsub()}. However, what really happens is that
the @code{pat} parameter is either one or zero, depending upon whether
or not @code{$0} matches @code{/hi/}.
@command{gawk} issues a warning when it sees a regexp constant used as
-a parameter to a user-defined function, since passing a truth value in
+a parameter to a user-defined function, because passing a truth value in
this way is probably not what was intended.
@c ENDOFRANGE rec
@@ -10859,7 +10927,7 @@ variable's current value. Variables are given new values with
@dfn{decrement operators}.
@xref{Assignment Ops}.
In addition, the @code{sub()} and @code{gsub()} functions can
-change a variable's value, and the @code{match()}, @code{split()}
+change a variable's value, and the @code{match()}, @code{split()},
and @code{patsplit()} functions can change the contents of their
array parameters. @xref{String Functions}.
@@ -10867,7 +10935,7 @@ array parameters. @xref{String Functions}.
@cindex variables, initializing
A few variables have special built-in meanings, such as @code{FS} (the
field separator), and @code{NF} (the number of fields in the current input
-record). @xref{Built-in Variables}, for a list of the predefined variables.
+record). @DBXREF{Built-in Variables} for a list of the predefined variables.
These predefined variables can be used and assigned just like all other
variables, but their values are also used or changed automatically by
@command{awk}. All predefined variables' names are entirely uppercase.
@@ -10908,7 +10976,7 @@ as in the following:
the variable is set at the very beginning, even before the
@code{BEGIN} rules execute. The @option{-v} option and its assignment
must precede all the @value{FN} arguments, as well as the program text.
-(@xref{Options}, for more information about
+(@DBXREF{Options} for more information about
the @option{-v} option.)
Otherwise, the variable assignment is performed at a time determined by
its position among the input file arguments---after the processing of the
@@ -10948,7 +11016,7 @@ sequences
@node Conversion
@subsection Conversion of Strings and Numbers
-Number to string and string to number conversion are generally
+Number-to-string and string-to-number conversion are generally
straightforward. There can be subtleties to be aware of;
this @value{SECTION} discusses this important facet of @command{awk}.
@@ -10959,7 +11027,7 @@ this @value{SECTION} discusses this important facet of @command{awk}.
@end menu
@node Strings And Numbers
-@subsubsection How @command{awk} Converts Between Strings And Numbers
+@subsubsection How @command{awk} Converts Between Strings and Numbers
@cindex converting, strings to numbers
@cindex strings, converting
@@ -10990,7 +11058,7 @@ string, concatenate that number with the empty string, @code{""}.
To force a string to be converted to a number, add zero to that string.
A string is converted to a number by interpreting any numeric prefix
of the string as numerals:
-@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1000, and @code{"25fix"}
+@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1,000, and @code{"25fix"}
has a numeric value of 25.
Strings that can't be interpreted as valid numbers convert to zero.
@@ -11030,10 +11098,10 @@ b = a ""
@code{b} has the value @code{"12"}, not @code{"12.00"}.
@value{DARKCORNER}
-@cindex sidebar, Pre-POSIX @command{awk} Used @code{OFMT} For String Conversion
+@cindex sidebar, Pre-POSIX @command{awk} Used @code{OFMT} for String Conversion
@ifdocbook
@docbook
-<sidebar><title>Pre-POSIX @command{awk} Used @code{OFMT} For String Conversion</title>
+<sidebar><title>Pre-POSIX @command{awk} Used @code{OFMT} for String Conversion</title>
@end docbook
@cindex POSIX @command{awk}, @code{OFMT} variable and
@@ -11047,7 +11115,7 @@ specifies the output format to use when printing numbers with @code{print}.
conversion from the semantics of printing. Both @code{CONVFMT} and
@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority
of cases, old @command{awk} programs do not change their behavior.
-@xref{Print}, for more information on the @code{print} statement.
+@DBXREF{Print} for more information on the @code{print} statement.
@docbook
</sidebar>
@@ -11056,7 +11124,7 @@ of cases, old @command{awk} programs do not change their behavior.
@ifnotdocbook
@cartouche
-@center @b{Pre-POSIX @command{awk} Used @code{OFMT} For String Conversion}
+@center @b{Pre-POSIX @command{awk} Used @code{OFMT} for String Conversion}
@cindex POSIX @command{awk}, @code{OFMT} variable and
@@ -11070,7 +11138,7 @@ specifies the output format to use when printing numbers with @code{print}.
conversion from the semantics of printing. Both @code{CONVFMT} and
@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority
of cases, old @command{awk} programs do not change their behavior.
-@xref{Print}, for more information on the @code{print} statement.
+@DBXREF{Print} for more information on the @code{print} statement.
@end cartouche
@end ifnotdocbook
@@ -11093,7 +11161,7 @@ The POSIX standard says that @command{awk} always uses the period as the decimal
point when reading the @command{awk} program source code, and for
command-line variable assignments (@pxref{Other Arguments}). However,
when interpreting input data, for @code{print} and @code{printf} output,
-and for number to string conversion, the local decimal point character
+and for number-to-string conversion, the local decimal point character
is used. @value{DARKCORNER} In all cases, numbers in source code and
in input data cannot have a thousands separator. Here are some examples
indicating the difference in behavior, on a GNU/Linux system:
@@ -11118,7 +11186,7 @@ as the full number including the fractional part, 4.321.
Some earlier versions of @command{gawk} fully complied with this aspect
of the standard. However, many users in non-English locales complained
-about this behavior, since their data used a period as the decimal
+about this behavior, because their data used a period as the decimal
point, so the default behavior was restored to use a period as the
decimal point character. You can use the @option{--use-lc-numeric}
option (@pxref{Options}) to force @command{gawk} to use the locale's
@@ -11131,7 +11199,7 @@ point character is used and when a period is used. Some of these
features have not been described yet.
@float Table,table-locale-affects
-@caption{Locale Decimal Point versus A Period}
+@caption{Locale decimal point versus a period}
@multitable @columnfractions .15 .20 .45
@headitem Feature @tab Default @tab @option{--posix} or @option{--use-lc-numeric}
@item @code{%'g} @tab Use locale @tab Use locale
@@ -11141,13 +11209,13 @@ features have not been described yet.
@end multitable
@end float
-Finally, modern day formal standards and IEEE standard floating point
+Finally, modern day formal standards and IEEE standard floating-point
representation can have an unusual but important effect on the way
@command{gawk} converts some special string values to numbers. The details
are presented in @ref{POSIX Floating Point Problems}.
@node All Operators
-@section Operators: Doing Something With Values
+@section Operators: Doing Something with Values
This @value{SECTION} introduces the @dfn{operators} which make use
of the values provided by constants and variables.
@@ -11226,7 +11294,7 @@ Multiplication.
Division; because all numbers in @command{awk} are floating-point
numbers, the result is @emph{not} rounded to an integer---@samp{3 / 4} has
the value 0.75. (It is a common mistake, especially for C programmers,
-to forget that @emph{all} numbers in @command{awk} are floating-point,
+to forget that @emph{all} numbers in @command{awk} are floating point,
and that division of integer-looking constants produces a real number,
not an integer.)
@@ -11311,7 +11379,7 @@ $ @kbd{awk '@{ print "Field number one:" $1 @}' mail-list}
@cindex troubleshooting, string concatenation
Because string concatenation does not have an explicit operator, it is
-often necessary to insure that it happens at the right time by using
+often necessary to ensure that it happens at the right time by using
parentheses to enclose the items to concatenate. For example,
you might expect that the
following code fragment concatenates @code{file} and @code{name}:
@@ -11573,7 +11641,14 @@ The indices of @code{bar} are practically guaranteed to be different, because
@code{rand()} returns different values each time it is called.
(Arrays and the @code{rand()} function haven't been covered yet.
@xref{Arrays},
-and see @ref{Numeric Functions}, for more information).
+and
+@ifnotdocbook
+@DBPXREF{Numeric Functions}
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Numeric Functions}
+@end ifdocbook
+for more information).
This example illustrates an important fact about assignment
operators: the lefthand expression is only evaluated @emph{once}.
@@ -11606,20 +11681,20 @@ to a number.
@cindex @code{*} (asterisk), @code{**=} operator
@cindex asterisk (@code{*}), @code{**=} operator
@float Table,table-assign-ops
-@caption{Arithmetic Assignment Operators}
+@caption{Arithmetic assignment operators}
@multitable @columnfractions .30 .70
@headitem Operator @tab Effect
-@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue}.
-@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue}.
-@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient}.
-@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor}.
-@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus}.
+@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue}
+@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue}
+@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient}
+@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor}
+@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus}
@cindex common extensions, @code{**=} operator
@cindex extensions, common@comma{} @code{**=} operator
@cindex @command{awk} language, POSIX version
@cindex POSIX @command{awk}
@item @var{lvalue} @code{^=} @var{power} @tab
-@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power}. @value{COMMONEXT}
+@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power} @value{COMMONEXT}
@end multitable
@end float
@@ -11655,7 +11730,7 @@ This is most notable in some commercial @command{awk} versions.
For example:
@example
-$ awk /==/ /dev/null
+$ @kbd{awk /==/ /dev/null}
@error{} awk: syntax error at source line 1
@error{} context is
@error{} >>> /= <<<
@@ -11701,7 +11776,7 @@ This is most notable in some commercial @command{awk} versions.
For example:
@example
-$ awk /==/ /dev/null
+$ @kbd{awk /==/ /dev/null}
@error{} awk: syntax error at source line 1
@error{} context is
@error{} >>> /= <<<
@@ -11754,7 +11829,7 @@ but with the side effect of incrementing it.
The post-increment @samp{foo++} is nearly the same as writing @samp{(foo
+= 1) - 1}. It is not perfectly equivalent because all numbers in
-@command{awk} are floating-point---in floating-point, @samp{foo + 1 - 1} does
+@command{awk} are floating point---in floating point, @samp{foo + 1 - 1} does
not necessarily equal @code{foo}. But the difference is minute as
long as you stick to numbers that are fairly small (less than
@iftex
@@ -11917,8 +11992,8 @@ You should avoid such things in your own programs.
@node Truth Values and Conditions
@section Truth Values and Conditions
-In certain contexts, expression values also serve as ``truth values;'' i.e.,
-they determine what should happen next as the program runs. This
+In certain contexts, expression values also serve as ``truth values''; (i.e.,
+they determine what should happen next as the program runs). This
@value{SECTION} describes how @command{awk} defines ``true'' and ``false''
and how values are compared.
@@ -11974,7 +12049,7 @@ the string constant @code{"0"} is actually true, because it is non-null.
@subsection Variable Typing and Comparison Expressions
@quotation
@i{The Guide is definitive. Reality is frequently inaccurate.}
-@author The Hitchhiker's Guide to the Galaxy
+@author Douglas Adams, @cite{The Hitchhiker's Guide to the Galaxy}
@end quotation
@c STARTOFRANGE comex
@@ -12002,7 +12077,7 @@ compares variables.
@end menu
@node Variable Typing
-@subsubsection String Type Versus Numeric Type
+@subsubsection String Type versus Numeric Type
@cindex numeric, strings
@cindex strings, numeric
@@ -12028,7 +12103,7 @@ attribute.
@item
Fields, @code{getline} input, @code{FILENAME}, @code{ARGV} elements,
@code{ENVIRON} elements, and the elements of an array created by
-@code{match()}, @code{split()} and @code{patsplit()} that are numeric
+@code{match()}, @code{split()}, and @code{patsplit()} that are numeric
strings have the @var{strnum} attribute. Otherwise, they have
the @var{string} attribute. Uninitialized variables also have the
@var{strnum} attribute.
@@ -12229,18 +12304,18 @@ operators}, which are a superset of those in C.
@cindex exclamation point (@code{!}), @code{!~} operator
@cindex @code{in} operator
@float Table,table-relational-ops
-@caption{Relational Operators}
+@caption{Relational operators}
@multitable @columnfractions .25 .75
@headitem Expression @tab Result
-@item @var{x} @code{<} @var{y} @tab True if @var{x} is less than @var{y}.
-@item @var{x} @code{<=} @var{y} @tab True if @var{x} is less than or equal to @var{y}.
-@item @var{x} @code{>} @var{y} @tab True if @var{x} is greater than @var{y}.
-@item @var{x} @code{>=} @var{y} @tab True if @var{x} is greater than or equal to @var{y}.
-@item @var{x} @code{==} @var{y} @tab True if @var{x} is equal to @var{y}.
-@item @var{x} @code{!=} @var{y} @tab True if @var{x} is not equal to @var{y}.
-@item @var{x} @code{~} @var{y} @tab True if the string @var{x} matches the regexp denoted by @var{y}.
-@item @var{x} @code{!~} @var{y} @tab True if the string @var{x} does not match the regexp denoted by @var{y}.
-@item @var{subscript} @code{in} @var{array} @tab True if the array @var{array} has an element with the subscript @var{subscript}.
+@item @var{x} @code{<} @var{y} @tab True if @var{x} is less than @var{y}
+@item @var{x} @code{<=} @var{y} @tab True if @var{x} is less than or equal to @var{y}
+@item @var{x} @code{>} @var{y} @tab True if @var{x} is greater than @var{y}
+@item @var{x} @code{>=} @var{y} @tab True if @var{x} is greater than or equal to @var{y}
+@item @var{x} @code{==} @var{y} @tab True if @var{x} is equal to @var{y}
+@item @var{x} @code{!=} @var{y} @tab True if @var{x} is not equal to @var{y}
+@item @var{x} @code{~} @var{y} @tab True if the string @var{x} matches the regexp denoted by @var{y}
+@item @var{x} @code{!~} @var{y} @tab True if the string @var{x} does not match the regexp denoted by @var{y}
+@item @var{subscript} @code{in} @var{array} @tab True if the array @var{array} has an element with the subscript @var{subscript}
@end multitable
@end float
@@ -12278,24 +12353,24 @@ The following list of expressions illustrates the kinds of comparisons
@table @code
@item 1.5 <= 2.0
-numeric comparison (true)
+Numeric comparison (true)
@item "abc" >= "xyz"
-string comparison (false)
+String comparison (false)
@item 1.5 != " +2"
-string comparison (true)
+String comparison (true)
@item "1e2" < "3"
-string comparison (true)
+String comparison (true)
@item a = 2; b = "2"
@itemx a == b
-string comparison (true)
+String comparison (true)
@item a = 2; b = " +2"
@itemx a == b
-string comparison (false)
+String comparison (false)
@end table
In this example:
@@ -12348,7 +12423,7 @@ dynamic regexp (@pxref{Regexp Usage}; also
@cindex @command{awk}, regexp constants and
@cindex regexp constants
A constant regular
-expression in slashes by itself is also an expression. The regexp
+expression in slashes by itself is also an expression.
@code{/@var{regexp}/} is an abbreviation for the following comparison expression:
@example
@@ -12362,7 +12437,7 @@ One special place where @code{/foo/} is @emph{not} an abbreviation for
where this is discussed in more detail.
@node POSIX String Comparison
-@subsubsection String Comparison With POSIX Rules
+@subsubsection String Comparison with POSIX Rules
The POSIX standard says that string comparison is performed based
on the locale's @dfn{collating order}. This is the order in which
@@ -12618,13 +12693,13 @@ example, the function @code{sqrt()} computes the square root of a number.
@cindex functions, built-in
A fixed set of functions are @dfn{built-in}, which means they are
available in every @command{awk} program. The @code{sqrt()} function is one
-of these. @xref{Built-in}, for a list of built-in
+of these. @DBXREF{Built-in} for a list of built-in
functions and their descriptions. In addition, you can define
functions for use in your program.
-@xref{User-defined},
+@DBXREF{User-defined}
for instructions on how to do this.
Finally, @command{gawk} lets you write functions in C or C++
-that may be called from your program: see @ref{Dynamic Extensions}.
+that may be called from your program (@pxref{Dynamic Extensions}).
@cindex arguments, in function calls
The way to use a function is with a @dfn{function call} expression,
@@ -12643,7 +12718,7 @@ rand() @ii{no arguments}
@cindex troubleshooting, function call syntax
@quotation CAUTION
-Do not put any space between the function name and the open-parenthesis!
+Do not put any space between the function name and the opening parenthesis!
A user-defined function name looks just like the name of a
variable---a space would make the expression look like concatenation of
a variable with an expression inside parentheses.
@@ -12664,7 +12739,7 @@ Some of the built-in functions have one or
more optional arguments.
If those arguments are not supplied, the functions
use a reasonable default value.
-@xref{Built-in}, for full details. If arguments
+@DBXREF{Built-in} for full details. If arguments
are omitted in calls to user-defined functions, then those arguments are
treated as local variables. Such local variables act like the
empty string if referenced where a string value is required,
@@ -12819,7 +12894,7 @@ Multiplication, division, remainder.
@item @code{+ -}
Addition, subtraction.
-@item String Concatenation
+@item String concatenation
There is no special symbol for concatenation.
The operands are simply written side by side
(@pxref{Concatenation}).
@@ -12858,7 +12933,7 @@ statements belong to the statement level, not to expressions. The
redirection does not produce an expression that could be the operand of
another operator. As a result, it does not make sense to use a
redirection operator near another operator of lower precedence without
-parentheses. Such combinations (for example, @samp{print foo > a ? b : c}),
+parentheses. Such combinations (e.g., @samp{print foo > a ? b : c}),
result in syntax errors.
The correct way to write this statement is @samp{print foo > (a ? b : c)}.
@@ -12916,7 +12991,7 @@ For maximum portability, do not use them.
@c ENDOFRANGE oppr
@node Locales
-@section Where You Are Makes A Difference
+@section Where You Are Makes a Difference
@cindex locale, definition of
Modern systems support the notion of @dfn{locales}: a way to tell the
@@ -12936,7 +13011,7 @@ character}, to find the record terminator.
Locales can affect how dates and times are formatted (@pxref{Time
Functions}). For example, a common way to abbreviate the date September
-4, 2015 in the United States is ``9/4/15.'' In many countries in
+4, 2015, in the United States is ``9/4/15.'' In many countries in
Europe, however, it is abbreviated ``4.9.15.'' Thus, the @code{%x}
specification in a @code{"US"} locale might produce @samp{9/4/15},
while in a @code{"EUROPE"} locale, it might produce @samp{4.9.15}.
@@ -12955,13 +13030,13 @@ in @ref{Conversion}.
@itemize @value{BULLET}
@item
Expressions are the basic elements of computation in programs. They are
-built from constants, variables, function calls and combinations of the
+built from constants, variables, function calls, and combinations of the
various kinds of values with operators.
@item
@command{awk} supplies three kinds of constants: numeric, string, and
regexp. @command{gawk} lets you specify numeric constants in octal
-and hexadecimal (bases 8 and 16) in addition to decimal (base 10).
+and hexadecimal (bases 8 and 16) as well as decimal (base 10).
In certain contexts, a standalone regexp constant such as @code{/foo/}
has the same meaning as @samp{$0 ~ /foo/}.
@@ -13003,8 +13078,8 @@ or numeric).
Function calls return a value which may be used as part of a larger
expression. Expressions used to pass parameter values are fully
evaluated before the function is called. @command{awk} provides
-built-in and user-defined functions; this is described later on in this
-@value{DOCUMENT}.
+built-in and user-defined functions; this is described in
+@ref{Functions}.
@item
Operator precedence specifies the order in which operations are performed,
@@ -13217,7 +13292,7 @@ The subexpressions of a Boolean operator in a pattern can be constant regular
expressions, comparisons, or any other @command{awk} expressions. Range
patterns are not expressions, so they cannot appear inside Boolean
patterns. Likewise, the special patterns @code{BEGIN}, @code{END},
-@code{BEGINFILE} and @code{ENDFILE},
+@code{BEGINFILE}, and @code{ENDFILE},
which never match any input record, are not expressions and cannot
appear inside Boolean patterns.
@@ -13328,7 +13403,7 @@ They supply startup and cleanup actions for @command{awk} programs.
@code{BEGIN} and @code{END} rules must have actions; there is no default
action for these rules because there is no current record when they run.
@code{BEGIN} and @code{END} rules are often referred to as
-``@code{BEGIN} and @code{END} blocks'' by long-time @command{awk}
+``@code{BEGIN} and @code{END} blocks'' by longtime @command{awk}
programmers.
@menu
@@ -13359,7 +13434,7 @@ $ @kbd{awk '}
This program finds the number of records in the input file @file{mail-list}
that contain the string @samp{li}. The @code{BEGIN} rule prints a title
for the report. There is no need to use the @code{BEGIN} rule to
-initialize the counter @code{n} to zero, since @command{awk} does this
+initialize the counter @code{n} to zero, as @command{awk} does this
automatically (@pxref{Variables}).
The second rule increments the variable @code{n} every time a
record containing the pattern @samp{li} is read. The @code{END} rule
@@ -13387,7 +13462,7 @@ The order in which library functions are named on the command line
controls the order in which their @code{BEGIN} and @code{END} rules are
executed. Therefore, you have to be careful when writing such rules in
library files so that the order in which they are executed doesn't matter.
-@xref{Options}, for more information on
+@DBXREF{Options} for more information on
using library functions.
@xref{Library Functions},
for a number of useful library functions.
@@ -13436,11 +13511,11 @@ of Unix @command{awk} do not.
The third point follows from the first two. The meaning of @samp{print}
inside a @code{BEGIN} or @code{END} rule is the same as always:
@samp{print $0}. If @code{$0} is the null string, then this prints an
-empty record. Many long time @command{awk} programmers use an unadorned
+empty record. Many longtime @command{awk} programmers use an unadorned
@samp{print} in @code{BEGIN} and @code{END} rules, to mean @samp{@w{print ""}},
relying on @code{$0} being null. Although one might generally get away with
this in @code{BEGIN} rules, it is a very bad idea in @code{END} rules,
-at least in @command{gawk}. It is also poor style, since if an empty
+at least in @command{gawk}. It is also poor style, because if an empty
line is needed in the output, the program should print one explicitly.
@cindex @code{next} statement, @code{BEGIN}/@code{END} patterns and
@@ -13450,9 +13525,14 @@ line is needed in the output, the program should print one explicitly.
Finally, the @code{next} and @code{nextfile} statements are not allowed
in a @code{BEGIN} rule, because the implicit
read-a-record-and-match-against-the-rules loop has not started yet. Similarly, those statements
-are not valid in an @code{END} rule, since all the input has been read.
-(@xref{Next Statement}, and see
-@ref{Nextfile Statement}.)
+are not valid in an @code{END} rule, because all the input has been read.
+(@DBXREF{Next Statement} and
+@ifnotdocbook
+@DBPXREF{Nextfile Statement}.)
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Nextfile Statement}.)
+@end ifdocbook
@c ENDOFRANGE beg
@c ENDOFRANGE end
@@ -13605,9 +13685,9 @@ awk "/$pattern/ "'@{ nmatches++ @}
@noindent
The @command{awk} program consists of two pieces of quoted text
that are concatenated together to form the program.
-The first part is double-quoted, which allows substitution of
+The first part is double quoted, which allows substitution of
the @code{pattern} shell variable inside the quotes.
-The second part is single-quoted.
+The second part is single quoted.
Variable substitution via quoting works, but can be potentially
messy. It requires a good understanding of the shell's quoting rules
@@ -13636,7 +13716,7 @@ The assignment @samp{-v pat="$pattern"} still requires double quotes,
in case there is whitespace in the value of @code{$pattern}.
The @command{awk} variable @code{pat} could be named @code{pattern}
too, but that would be more confusing. Using a variable also
-provides more flexibility, since the variable can be used anywhere inside
+provides more flexibility, as the variable can be used anywhere inside
the program---for printing, as an array subscript, or for any other
use---without requiring the quoting tricks at every point in the program.
@@ -13709,7 +13789,7 @@ is used in order to put several statements together in the body of an
Use the @code{getline} command
(@pxref{Getline}).
Also supplied in @command{awk} are the @code{next}
-statement (@pxref{Next Statement}),
+statement (@pxref{Next Statement})
and the @code{nextfile} statement
(@pxref{Nextfile Statement}).
@@ -13797,7 +13877,7 @@ else
print "x is odd"
@end example
-In this example, if the expression @samp{x % 2 == 0} is true (that is,
+In this example, if the expression @samp{x % 2 == 0} is true (i.e.,
if the value of @code{x} is evenly divisible by two), then the first
@code{print} statement is executed; otherwise, the second @code{print}
statement is executed.
@@ -13876,7 +13956,7 @@ field is printed. Then the @samp{i++} increments the value of @code{i}
and the loop repeats. The loop terminates when @code{i} reaches four.
A newline is not required between the condition and the
-body; however using one makes the program clearer unless the body is a
+body; however, using one makes the program clearer unless the body is a
compound statement or else is very simple. The newline after the open-brace
that begins the compound statement is not required either, but the
program is harder to read without it.
@@ -13923,7 +14003,7 @@ The following is an example of a @code{do} statement:
@noindent
This program prints each input record 10 times. However, it isn't a very
-realistic example, since in this case an ordinary @code{while} would do
+realistic example, because in this case an ordinary @code{while} would do
just as well. This situation reflects actual experience; only
occasionally is there a real use for a @code{do} statement.
@@ -14020,7 +14100,7 @@ very common in loops. It can be easier to think of this counting as part
of looping rather than as something to do inside the loop.
@cindex @code{in} operator
-There is an alternate version of the @code{for} loop, for iterating over
+There is an alternative version of the @code{for} loop, for iterating over
all the indices of an array:
@example
@@ -14029,7 +14109,7 @@ for (i in array)
@end example
@noindent
-@xref{Scanning an Array},
+@DBXREF{Scanning an Array}
for more information on this version of the @code{for} loop.
@node Switch Statement
@@ -14049,7 +14129,7 @@ are checked for a match in the order they are defined. If no suitable
Each @code{case} contains a single constant, be it numeric, string, or
regexp. The @code{switch} expression is evaluated, and then each
-@code{case}'s constant is compared against the result in turn. The type of constant
+@code{case}'s constant is compared against the result in turn. The type of constant
determines the comparison: numeric or string do the usual comparisons.
A regexp constant does a regular expression match against the string
value of the original expression. The general form of the @code{switch}
@@ -14096,9 +14176,9 @@ while ((c = getopt(ARGC, ARGV, "aksx")) != -1) @{
@}
@end example
-Note that if none of the statements specified above halt execution
+Note that if none of the statements specified here halt execution
of a matched @code{case} statement, execution falls through to the
-next @code{case} until execution halts. In the above example, the
+next @code{case} until execution halts. In this example, the
@code{case} for @code{"?"} falls through to the @code{default}
case, which is to call a function named @code{usage()}.
(The @code{getopt()} function being called here is
@@ -14225,7 +14305,7 @@ BEGIN @{
@end example
@noindent
-This program loops forever once @code{x} reaches 5, since
+This program loops forever once @code{x} reaches 5, because
the increment (@samp{x++}) is never reached.
@c @cindex @code{continue}, outside of loops
@@ -14286,7 +14366,7 @@ Because of the @code{next} statement,
the program's subsequent rules won't see the bad record. The error
message is redirected to the standard error output stream, as error
messages should be.
-For more detail see
+For more detail, see
@ref{Special Files}.
If the @code{next} statement causes the end of the input to be reached,
@@ -14352,7 +14432,7 @@ rule to skip over a file that would otherwise cause @command{gawk}
to exit with a fatal error. In this case, @code{ENDFILE} rules are not
executed. @xref{BEGINFILE/ENDFILE}.
-While one might think that @samp{close(FILENAME)} would accomplish
+Although it might seem that @samp{close(FILENAME)} would accomplish
the same as @code{nextfile}, this isn't true. @code{close()} is
reserved for closing files, pipes, and coprocesses that are
opened with redirections. It is not related to the main processing that
@@ -14360,7 +14440,7 @@ opened with redirections. It is not related to the main processing that
@quotation NOTE
For many years, @code{nextfile} was a
-common extension. In September, 2012, it was accepted for
+common extension. In September 2012, it was accepted for
inclusion into the POSIX standard.
See @uref{http://austingroupbugs.net/view.php?id=607, the Austin Group website}.
@end quotation
@@ -14409,7 +14489,7 @@ In such a case,
if you don't want the @code{END} rule to do its job, set a variable
to nonzero before the @code{exit} statement and check that variable in
the @code{END} rule.
-@xref{Assert Function},
+@DBXREF{Assert Function}
for an example that does this.
@cindex dark corner, @code{exit} statement
@@ -14420,7 +14500,7 @@ In the case where an argument
is supplied to a first @code{exit} statement, and then @code{exit} is
called a second time from an @code{END} rule with no argument,
@command{awk} uses the previously supplied exit value. @value{DARKCORNER}
-@xref{Exit Status}, for more information.
+@DBXREF{Exit Status} for more information.
@cindex programming conventions, @code{exit} statement
For example, suppose an error condition occurs that is difficult or
@@ -14480,7 +14560,7 @@ their areas of activity.
@end menu
@node User-modified
-@subsection Built-in Variables That Control @command{awk}
+@subsection Built-In Variables That Control @command{awk}
@c STARTOFRANGE bvaru
@cindex predefined variables, user-modifiable
@c STARTOFRANGE nmbv
@@ -14537,7 +14617,7 @@ A space-separated list of columns that tells @command{gawk}
how to split input with fixed columnar boundaries.
Assigning a value to @code{FIELDWIDTHS}
overrides the use of @code{FS} and @code{FPAT} for field splitting.
-@xref{Constant Size}, for more information.
+@DBXREF{Constant Size} for more information.
@cindex @command{gawk}, @code{FPAT} variable in
@cindex @code{FPAT} variable
@@ -14549,7 +14629,7 @@ A regular expression (as a string) that tells @command{gawk}
to create the fields based on text that matches the regular expression.
Assigning a value to @code{FPAT}
overrides the use of @code{FS} and @code{FIELDWIDTHS} for field splitting.
-@xref{Splitting By Content}, for more information.
+@DBXREF{Splitting By Content} for more information.
@cindex @code{FS} variable
@cindex separators, field
@@ -14659,12 +14739,12 @@ character. (@xref{Output Separators}.)
@cindex @code{PREC} variable
@item PREC #
-The working precision of arbitrary precision floating-point numbers,
+The working precision of arbitrary-precision floating-point numbers,
53 bits by default (@pxref{Setting precision}).
@cindex @code{ROUNDMODE} variable
@item ROUNDMODE #
-The rounding mode to use for arbitrary precision arithmetic on
+The rounding mode to use for arbitrary-precision arithmetic on
numbers, by default @code{"N"} (@samp{roundTiesToEven} in
the IEEE 754 standard; @pxref{Setting the rounding mode}).
@@ -14706,7 +14786,7 @@ really accesses @code{foo["A\034B"]}
Used for internationalization of programs at the
@command{awk} level. It sets the default text domain for specially
marked string constants in the source text, as well as for the
-@code{dcgettext()}, @code{dcngettext()} and @code{bindtextdomain()} functions
+@code{dcgettext()}, @code{dcngettext()}, and @code{bindtextdomain()} functions
(@pxref{Internationalization}).
The default value of @code{TEXTDOMAIN} is @code{"messages"}.
@end table
@@ -14716,7 +14796,7 @@ The default value of @code{TEXTDOMAIN} is @code{"messages"}.
@c ENDOFRANGE nmbv
@node Auto-set
-@subsection Built-in Variables That Convey Information
+@subsection Built-In Variables That Convey Information
@c STARTOFRANGE bvconi
@cindex predefined variables, conveying information
@@ -14729,7 +14809,7 @@ information to your program.
The variables that are specific to @command{gawk} are marked with a pound
sign (@samp{#}). These variables are @command{gawk} extensions. In other
@command{awk} implementations or if @command{gawk} is in compatibility
-mode (@pxref{Options}), they are not special.
+mode (@pxref{Options}), they are not special:
@c @asis for docbook
@table @asis
@@ -14770,7 +14850,7 @@ method of accessing command-line arguments.
The value of @code{ARGV[0]} can vary from system to system.
Also, you should note that the program text is @emph{not} included in
@code{ARGV}, nor are any of @command{awk}'s command-line options.
-@xref{ARGC and ARGV}, for information
+@DBXREF{ARGC and ARGV} for information
about how @command{awk} uses these variables.
@value{DARKCORNER}
@@ -14808,8 +14888,13 @@ Some operating systems may not have environment variables.
On such systems, the @code{ENVIRON} array is empty (except for
@w{@code{ENVIRON["AWKPATH"]}} and
@w{@code{ENVIRON["AWKLIBPATH"]}};
-@pxref{AWKPATH Variable}, and
+@DBPXREF{AWKPATH Variable} and
+@ifdocbook
+@DBREF{AWKLIBPATH Variable}).
+@end ifdocbook
+@ifnotdocbook
@pxref{AWKLIBPATH Variable}).
+@end ifnotdocbook
@cindex @command{gawk}, @code{ERRNO} variable in
@cindex @code{ERRNO} variable
@@ -14838,7 +14923,7 @@ The name of the current input file. When no @value{DF}s are listed
on the command line, @command{awk} reads from the standard input and
@code{FILENAME} is set to @code{"-"}. @code{FILENAME} changes each
time a new file is read (@pxref{Reading Files}). Inside a @code{BEGIN}
-rule, the value of @code{FILENAME} is @code{""}, since there are no input
+rule, the value of @code{FILENAME} is @code{""}, because there are no input
files being processed yet.@footnote{Some early implementations of Unix
@command{awk} initialized @code{FILENAME} to @code{"-"}, even if there
were @value{DF}s to be processed. This behavior was incorrect and should
@@ -14870,7 +14955,7 @@ current record. @xref{Changing Fields}.
@cindex differences in @command{awk} and @command{gawk}, @code{FUNCTAB} variable
@item @code{FUNCTAB #}
An array whose indices and corresponding values are the names of all
-the built-in, user-defined and extension functions in the program.
+the built-in, user-defined, and extension functions in the program.
@quotation NOTE
Attempting to use the @code{delete} statement with the @code{FUNCTAB}
@@ -14964,7 +15049,7 @@ The parent process ID of the current process.
If this element exists in @code{PROCINFO}, its value controls the
order in which array indices will be processed by
@samp{for (@var{indx} in @var{array})} loops.
-Since this is an advanced feature, we defer the
+This is an advanced feature, so we defer the
full description until later; see
@ref{Scanning an Array}.
@@ -14984,10 +15069,10 @@ The version of @command{gawk}.
The following additional elements in the array
are available to provide information about the MPFR and GMP libraries
-if your version of @command{gawk} supports arbitrary precision arithmetic
-(@pxref{Arbitrary Precision Arithmetic}):
+if your version of @command{gawk} supports arbitrary-precision arithmetic
+(@pxref{Arbitrary Precision Arithmetic}):
-@table @code
+@table @code
@cindex version of GNU MPFR library
@item PROCINFO["mpfr_version"]
The version of the GNU MPFR library.
@@ -15035,7 +15120,7 @@ The @code{PROCINFO} array has the following additional uses:
@item
It may be used to provide a timeout when reading from any
open input file, pipe, or coprocess.
-@xref{Read Timeout}, for more information.
+@DBXREF{Read Timeout} for more information.
@item
It may be used to cause coprocesses to communicate over pseudo-ttys
@@ -15280,8 +15365,14 @@ use the @code{delete} statement to remove elements from
All of these actions are typically done in the @code{BEGIN} rule,
before actual processing of the input begins.
-@xref{Split Program}, and see
-@ref{Tee Program}, for examples
+@DBXREF{Split Program} and
+@ifnotdocbook
+@DBPXREF{Tee Program}
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Tee Program}
+@end ifdocbook
+for examples
of each way of removing elements from @code{ARGV}.
To actually get options into an @command{awk} program,
@@ -15293,7 +15384,7 @@ awk -f myprog.awk -- -v -q file1 file2 @dots{}
@end example
The following fragment processes @code{ARGV} in order to examine, and
-then remove, the above command-line options:
+then remove, the previously mentioned command-line options:
@example
BEGIN @{
@@ -15329,14 +15420,21 @@ gawk -f myprog.awk -q -v file1 file2 @dots{}
@noindent
Because @option{-q} is not a valid @command{gawk} option, it and the
following @option{-v} are passed on to the @command{awk} program.
-(@xref{Getopt Function}, for an @command{awk} library function that
+(@DBXREF{Getopt Function} for an @command{awk} library function that
parses command-line options.)
When designing your program, you should choose options that don't
-conflict with @command{gawk}'s, since it will process any options
+conflict with @command{gawk}'s, because it will process any options
that it accepts before passing the rest of the command line on to
your program. Using @samp{#!} with the @option{-E} option may help
-(@pxref{Executable Scripts}, and @pxref{Options}).
+(@DBXREF{Executable Scripts}
+and
+@ifnotdocbook
+@DBPXREF{Options}).
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Options}).
+@end ifdocbook
@node Pattern Action Summary
@section Summary
@@ -15502,7 +15600,7 @@ as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}:
@ifnotdocbook
@float Figure,figure-array-elements
-@caption{A Contiguous Array}
+@caption{A contiguous array}
@ifinfo
@center @image{array-elements, , , Basic Program Stages, txt}
@end ifinfo
@@ -15514,7 +15612,7 @@ as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}:
@docbook
<figure id="figure-array-elements" float="0">
-<title>A Contiguous Array</title>
+<title>A contiguous array</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="array-elements.png" format="PNG"/></imageobject>
</mediaobject>
@@ -15533,7 +15631,7 @@ position with zero elements before it.
@cindex associative arrays
@cindex arrays, associative
Arrays in @command{awk} are different---they are @dfn{associative}. This means
-that each array is a collection of pairs: an index and its corresponding
+that each array is a collection of pairs---an index and its corresponding
array element value:
@ifnotdocbook
@@ -15714,7 +15812,7 @@ numbers and strings as indices.
There are some subtleties to how numbers work when used as
array subscripts; this is discussed in more detail in
@ref{Numeric Array Subscripts}.)
-Here, the number @code{1} isn't double-quoted, since @command{awk}
+Here, the number @code{1} isn't double quoted, because @command{awk}
automatically converts it to a string.
@cindex @command{gawk}, @code{IGNORECASE} variable in
@@ -15799,7 +15897,7 @@ This expression tests whether the particular index @var{indx} exists,
without the side effect of creating that element if it is not present.
The expression has the value one (true) if @code{@var{array}[@var{indx}]}
exists and zero (false) if it does not exist.
-(We use @var{indx} here, since @samp{index} is the name of a built-in
+(We use @var{indx} here, because @samp{index} is the name of a built-in
function.)
For example, this statement tests whether the array @code{frequencies}
contains the index @samp{2}:
@@ -15942,7 +16040,7 @@ the word as index. The second rule scans the elements of @code{used} to
find all the distinct words that appear in the input. It prints each
word that is more than 10 characters long and also prints the number of
such words.
-@xref{String Functions},
+@DBXREF{String Functions}
for more information on the built-in function @code{length()}.
@example
@@ -15965,7 +16063,7 @@ END @{
@end example
@noindent
-@xref{Word Sorting},
+@DBXREF{Word Sorting}
for a more detailed example of this type.
@cindex arrays, elements, order of access by @code{in} operator
@@ -16020,7 +16118,7 @@ $ @kbd{nawk -f loopcheck.awk}
@end example
@node Controlling Scanning
-@subsection Using Predefined Array Scanning Orders With @command{gawk}
+@subsection Using Predefined Array Scanning Orders with @command{gawk}
This @value{SUBSECTION} describes a feature that is specific to @command{gawk}.
@@ -16045,7 +16143,7 @@ We describe this now.
@item
Set @code{PROCINFO["sorted_in"]} to the name of a user-defined function
to use for comparison of array elements. This advanced feature
-is described later, in @ref{Array Sorting}.
+is described later in @ref{Array Sorting}.
@end itemize
@cindex @code{PROCINFO}, values of @code{sorted_in}
@@ -16063,7 +16161,7 @@ the index is @code{"10"} rather than numeric 10.)
@item "@@ind_num_asc"
Order by indices in ascending order but force them to be treated as numbers in the process.
-Any index with a non-numeric value will end up positioned as if it were zero.
+Any index with a non-numeric value will end up positioned as if it were zero.
@item "@@val_type_asc"
Order by element values in ascending order (rather than by indices).
@@ -16075,11 +16173,11 @@ which in turn come before all subarrays.
@pxref{Arrays of Arrays}.)
@item "@@val_str_asc"
-Order by element values in ascending order (rather than by indices). Scalar values are
+Order by element values in ascending order (rather than by indices). Scalar values are
compared as strings. Subarrays, if present, come out last.
@item "@@val_num_asc"
-Order by element values in ascending order (rather than by indices). Scalar values are
+Order by element values in ascending order (rather than by indices). Scalar values are
compared as numbers. Subarrays, if present, come out last.
When numeric values are equal, the string values are used to provide
an ordering: this guarantees consistent results across different
@@ -16140,11 +16238,11 @@ $ @kbd{gawk '}
When sorting an array by element values, if a value happens to be
a subarray then it is considered to be greater than any string or
numeric value, regardless of what the subarray itself contains,
-and all subarrays are treated as being equal to each other. Their
+and all subarrays are treated as being equal to each other. Their
order relative to each other is determined by their index strings.
Here are some additional things to bear in mind about sorted
-array traversal.
+array traversal:
@itemize @value{BULLET}
@item
@@ -16164,7 +16262,7 @@ if (save_sorted)
@end example
@item
-As mentioned, the default array traversal order is represented by
+As already mentioned, the default array traversal order is represented by
@code{"@@unsorted"}. You can also get the default behavior by assigning
the null string to @code{PROCINFO["sorted_in"]} or by just deleting the
@code{"sorted_in"} element from the @code{PROCINFO} array with
@@ -16209,7 +16307,7 @@ The program then changes
the value of @code{CONVFMT}. The test @samp{(xyz in data)} generates a new
string value from @code{xyz}---this time @code{"12.15"}---because the value of
@code{CONVFMT} only allows two significant digits. This test fails,
-since @code{"12.15"} is different from @code{"12.153"}.
+because @code{"12.15"} is different from @code{"12.153"}.
@cindex converting integer array subscripts
@cindex integer array indices
@@ -16227,19 +16325,19 @@ for (i = 1; i <= maxsub; i++)
The ``integer values always convert to strings as integers'' rule
has an additional consequence for array indexing.
Octal and hexadecimal constants
+@ifnotdocbook
(@pxref{Nondecimal-numbers})
+@end ifnotdocbook
+@ifdocbook
+(covered in @ref{Nondecimal-numbers})
+@end ifdocbook
are converted internally into numbers, and their original form
-is forgotten.
-This means, for example, that
-@code{array[17]},
-@code{array[021]},
-and
-@code{array[0x11]}
-all refer to the same element!
+is forgotten. This means, for example, that @code{array[17]},
+@code{array[021]}, and @code{array[0x11]} all refer to the same element!
As with many things in @command{awk}, the majority of the time
things work as you would expect them to. But it is useful to have a precise
-knowledge of the actual rules since they can sometimes have a subtle
+knowledge of the actual rules, as they can sometimes have a subtle
effect on your programs.
@node Uninitialized Subscripts
@@ -16382,7 +16480,7 @@ by a number of other implementations.
@cindex Brian Kernighan's @command{awk}
@quotation NOTE
For many years, using @code{delete} without a subscript was a common
-extension. In September, 2012, it was accepted for inclusion into the
+extension. In September 2012, it was accepted for inclusion into the
POSIX standard. See @uref{http://austingroupbugs.net/view.php?id=544,
the Austin Group website}.
@end quotation
@@ -16424,7 +16522,7 @@ a = 3
@cindex subscripts in arrays, multidimensional
@cindex arrays, multidimensional
-A multidimensional array is an array in which an element is identified
+A @dfn{multidimensional array} is an array in which an element is identified
by a sequence of indices instead of a single index. For example, a
two-dimensional array requires two indices. The usual way (in many
languages, including @command{awk}) to refer to an element of a
@@ -16466,7 +16564,7 @@ stored as @samp{foo["a@@b@@c"]}.
@cindex @code{in} operator, index existence in multidimensional arrays
To test whether a particular index sequence exists in a
multidimensional array, use the same operator (@code{in}) that is
-used for single dimensional arrays. Write the whole sequence of indices
+used for single-dimensional arrays. Write the whole sequence of indices
in parentheses, separated by commas, as the left operand:
@example
@@ -16590,7 +16688,7 @@ This simulates a true two-dimensional array. Each subarray element can
contain another subarray as a value, which in turn can hold other arrays
as well. In this way, you can create arrays of three or more dimensions.
The indices can be any @command{awk} expression, including scalars
-separated by commas (that is, a regular @command{awk} simulated
+separated by commas (i.e., a regular @command{awk} simulated
multidimensional subscript). So the following is valid in
@command{gawk}:
@@ -16608,8 +16706,8 @@ is itself an array and not a scalar:
@example
a[4] = "An element in a jagged array"
@end example
-
-The terms @dfn{dimension}, @dfn{row} and @dfn{column} are
+
+The terms @dfn{dimension}, @dfn{row}, and @dfn{column} are
meaningless when applied
to such an array, but we will use ``dimension'' henceforth to imply the
maximum number of indices needed to refer to an existing element. The
@@ -16665,14 +16763,14 @@ The @samp{for (item in array)} statement (@pxref{Scanning an Array})
can be nested to scan all the
elements of an array of arrays if it is rectangular in structure. In order
to print the contents (scalar values) of a two-dimensional array of arrays
-(i.e., in which each first-level element is itself an
-array, not necessarily of the same length)
+(i.e., in which each first-level element is itself an
+array, not necessarily of the same length)
you could use the following code:
@example
for (i in array)
for (j in array[i])
- print array[i][j]
+ print array[i][j]
@end example
The @code{isarray()} function (@pxref{Type Functions})
@@ -16682,7 +16780,7 @@ lets you test if an array element is itself an array:
for (i in array) @{
if (isarray(array[i]) @{
for (j in array[i]) @{
- print array[i][j]
+ print array[i][j]
@}
@}
else
@@ -16692,7 +16790,7 @@ for (i in array) @{
If the structure of a jagged array of arrays is known in advance,
you can often devise workarounds using control statements. For example,
-the following code prints the elements of our main array @code{a}:
+the following code prints the elements of our main array @code{a}:
@example
for (i in a) @{
@@ -16702,13 +16800,13 @@ for (i in a) @{
print a[i][j][k]
@} else
print a[i][j]
- @}
+ @}
@}
@end example
@noindent
-@xref{Walking Arrays}, for a user-defined function that ``walks'' an
-arbitrarily-dimensioned array of arrays.
+@DBXREF{Walking Arrays} for a user-defined function that ``walks'' an
+arbitrarily dimensioned array of arrays.
Recall that a reference to an uninitialized array element yields a value
of @code{""}, the null string. This has one important implication when you
@@ -16758,8 +16856,9 @@ special predefined values to @code{PROCINFO["sorted_in"]}.
@item
Use @samp{delete @var{array}[@var{indx}]} to delete an individual element.
-You may also use @samp{delete @var{array}} to delete all of the elements
-in the array. This latter feature has been a common extension for many
+To delete all of the elements in an array,
+use @samp{delete @var{array}}.
+This latter feature has been a common extension for many
years and is now standard, but may not be supported by all commercial
versions of @command{awk}.
@@ -16812,7 +16911,7 @@ The second half of this @value{CHAPTER} describes these
@end menu
@node Built-in
-@section Built-in Functions
+@section Built-In Functions
@dfn{Built-in} functions are always available for
your @command{awk} program to call. This @value{SECTION} defines all
@@ -16835,7 +16934,7 @@ but are summarized here for your convenience.
@end menu
@node Calling Built-in
-@subsection Calling Built-in Functions
+@subsection Calling Built-In Functions
To call one of @command{awk}'s built-in functions, write the name of
the function followed
@@ -16845,7 +16944,7 @@ is a call to the function @code{atan2()} and has two arguments.
@cindex programming conventions, functions, calling
@cindex whitespace, functions@comma{} calling
Whitespace is ignored between the built-in function name and the
-open parenthesis, but nonetheless it is good practice to avoid using whitespace
+opening parenthesis, but nonetheless it is good practice to avoid using whitespace
there. User-defined functions do not permit whitespace in this way, and
it is easier to avoid mistakes by following a simple
convention that always works---no whitespace after a function name.
@@ -16925,7 +17024,6 @@ depends on your machine's floating-point representation.
@cindex round to nearest integer
Return the nearest integer to @var{x}, located between @var{x} and zero and
truncated toward zero.
-
For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
is @minus{}3, and @code{int(-3)} is @minus{}3 as well.
@@ -17015,7 +17113,7 @@ for generating random numbers to the value @var{x}.
Each seed value leads to a particular sequence of random
numbers.@footnote{Computer-generated random numbers really are not truly
random. They are technically known as ``pseudorandom.'' This means
-that while the numbers in a sequence appear to be random, you can in
+that although the numbers in a sequence appear to be random, you can in
fact generate the same sequence of random numbers over and over again.}
Thus, if the seed is set to the same value a second time,
the same sequence of random numbers is produced again.
@@ -17065,7 +17163,7 @@ doing index calculations, particularly if you are used to C.
In the following list, optional parameters are enclosed in square brackets@w{ ([ ]).}
Several functions perform string substitution; the full discussion is
provided in the description of the @code{sub()} function, which comes
-towards the end since the list is presented alphabetically.
+toward the end, because the list is presented alphabetically.
Those functions that are specific to @command{gawk} are marked with a
pound sign (@samp{#}). They are not available in compatibility mode
@@ -17091,10 +17189,10 @@ These two functions are similar in behavior, so they are described
together.
@quotation NOTE
-The following description ignores the third argument, @var{how}, since it
+The following description ignores the third argument, @var{how}, as it
requires understanding features that we have not discussed yet. Thus,
the discussion here is a deliberate simplification. (We do provide all
-the details later on: @xref{Array Sorting Functions}, for the full story.)
+the details later on; see @DBREF{Array Sorting Functions} for the full story.)
@end quotation
Both functions return the number of elements in the array @var{source}.
@@ -17341,7 +17439,7 @@ at which that substring begins (one, if it starts at the beginning of
The @var{regexp} argument may be either a regexp constant
(@code{/}@dots{}@code{/}) or a string constant (@code{"}@dots{}@code{"}).
In the latter case, the string is treated as a regexp to be matched.
-@xref{Computed Regexps}, for a
+@DBXREF{Computed Regexps} for a
discussion of the difference between the two forms, and the
implications for writing your program correctly.
@@ -17434,7 +17532,7 @@ $ @kbd{echo foooobazbarrrrr |}
@end example
There may not be subscripts for the start and index for every parenthesized
-subexpression, since they may not all have matched text; thus they
+subexpression, because they may not all have matched text; thus they
should be tested for with the @code{in} operator
(@pxref{Reference to Elements}).
@@ -17481,15 +17579,15 @@ a regexp describing where to split @var{string} (much as @code{FS} can
be a regexp describing where to split input records).
If @var{fieldsep} is omitted, the value of @code{FS} is used.
@code{split()} returns the number of elements created.
-@var{seps} is a @command{gawk} extension with @code{@var{seps}[@var{i}]}
+@var{seps} is a @command{gawk} extension with @code{@var{seps}[@var{i}]}
being the separator string
-between @code{@var{array}[@var{i}]} and @code{@var{array}[@var{i}+1]}.
+between @code{@var{array}[@var{i}]} and @code{@var{array}[@var{i}+1]}.
If @var{fieldsep} is a single
-space then any leading whitespace goes into @code{@var{seps}[0]} and
+space then any leading whitespace goes into @code{@var{seps}[0]} and
any trailing
-whitespace goes into @code{@var{seps}[@var{n}]} where @var{n} is the
-return value of
-@code{split()} (that is, the number of elements in @var{array}).
+whitespace goes into @code{@var{seps}[@var{n}]} where @var{n} is the
+return value of
+@code{split()} (i.e., the number of elements in @var{array}).
The @code{split()} function splits strings into pieces in a
manner similar to the way input lines are split into fields. For example:
@@ -17525,7 +17623,7 @@ As with input field-splitting, when the value of @var{fieldsep} is
the elements of
@var{array} but not in @var{seps}, and the elements
are separated by runs of whitespace.
-Also as with input field-splitting, if @var{fieldsep} is the null string, each
+Also, as with input field-splitting, if @var{fieldsep} is the null string, each
individual character in the string is split into its own array element.
@value{COMMONEXT}
@@ -17539,7 +17637,7 @@ the third argument to be a regexp constant (@code{/abc/}) as well as a
string.
@value{DARKCORNER}
The POSIX standard allows this as well.
-@xref{Computed Regexps}, for a
+@DBXREF{Computed Regexps} for a
discussion of the difference between using a string constant or a regexp constant,
and the implications for writing your program correctly.
@@ -17590,7 +17688,7 @@ Using the @code{strtonum()} function is @emph{not} the same as adding zero
to a string value; the automatic coercion of strings to numbers
works only for decimal data, not for octal or hexadecimal.@footnote{Unless
you use the @option{--non-decimal-data} option, which isn't recommended.
-@xref{Nondecimal Data}, for more information.}
+@DBXREF{Nondecimal Data} for more information.}
Note also that @code{strtonum()} uses the current locale's decimal point
for recognizing numbers (@pxref{Locales}).
@@ -17608,7 +17706,7 @@ Return the number of substitutions made (zero or one).
The @var{regexp} argument may be either a regexp constant
(@code{/}@dots{}@code{/}) or a string constant (@code{"}@dots{}@code{"}).
In the latter case, the string is treated as a regexp to be matched.
-@xref{Computed Regexps}, for a
+@DBXREF{Computed Regexps} for a
discussion of the difference between the two forms, and the
implications for writing your program correctly.
@@ -17827,7 +17925,7 @@ Although this makes a certain amount of sense, it can be surprising.
@node Gory Details
-@subsubsection More About @samp{\} and @samp{&} with @code{sub()}, @code{gsub()}, and @code{gensub()}
+@subsubsection More about @samp{\} and @samp{&} with @code{sub()}, @code{gsub()}, and @code{gensub()}
@cindex escape processing, @code{gsub()}/@code{gensub()}/@code{sub()} functions
@cindex @code{sub()} function, escape processing
@@ -17874,7 +17972,7 @@ through unchanged. This is illustrated in @ref{table-sub-escapes}.
@c Thank to Karl Berry for help with the TeX stuff.
@float Table,table-sub-escapes
-@caption{Historical Escape Sequence Processing for @code{sub()} and @code{gsub()}}
+@caption{Historical escape sequence processing for @code{sub()} and @code{gsub()}}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -17946,7 +18044,7 @@ This is shown in
@ref{table-sub-proposed}.
@float Table,table-sub-proposed
-@caption{GNU @command{awk} Rules For @code{sub()} And Backslash}
+@caption{GNU @command{awk} rules for @code{sub()} and backslash}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -18009,7 +18107,7 @@ by anything else is not special; the @samp{\} is placed straight into the output
These rules are presented in @ref{table-posix-sub}.
@float Table,table-posix-sub
-@caption{POSIX Rules For @code{sub()} And @code{gsub()}}
+@caption{POSIX rules for @code{sub()} and @code{gsub()}}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -18058,12 +18156,12 @@ is seen as @samp{\\} and produces @samp{\} instead of @samp{\\}.
Starting with @value{PVERSION} 3.1.4, @command{gawk} followed the POSIX rules
when @option{--posix} is specified (@pxref{Options}). Otherwise,
-it continued to follow the proposed rules, since
+it continued to follow the proposed rules, as
that had been its behavior for many years.
When @value{PVERSION} 4.0.0 was released, the @command{gawk} maintainer
made the POSIX rules the default, breaking well over a decade's worth
-of backwards compatibility.@footnote{This was rather naive of him, despite
+of backward compatibility.@footnote{This was rather naive of him, despite
there being a note in this section indicating that the next major version
would move to the POSIX rules.} Needless to say, this was a bad idea,
and as of @value{PVERSION} 4.0.1, @command{gawk} resumed its historical
@@ -18078,7 +18176,7 @@ appears in the generated text and the @samp{\} does not,
as shown in @ref{table-gensub-escapes}.
@float Table,table-gensub-escapes
-@caption{Escape Sequence Processing For @code{gensub()}}
+@caption{Escape sequence processing for @code{gensub()}}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -18145,7 +18243,7 @@ Optional parameters are enclosed in square brackets ([ ]):
Close the file @var{filename} for input or output. Alternatively, the
argument may be a shell command that was used for creating a coprocess, or
for redirecting to or from a pipe; then the coprocess or pipe is closed.
-@xref{Close Files And Pipes},
+@DBXREF{Close Files And Pipes}
for more information.
When closing a coprocess, it is occasionally useful to first close
@@ -18169,13 +18267,13 @@ a pipe or coprocess.
@cindex buffers, flushing
@cindex output, buffering
-Many utility programs @dfn{buffer} their output; i.e., they save information
+Many utility programs @dfn{buffer} their output (i.e., they save information
to write to a disk file or the screen in memory until there is enough
-for it to be worthwhile to send the data to the output device.
+for it to be worthwhile to send the data to the output device).
This is often more efficient than writing
every little bit of information as soon as it is ready. However, sometimes
-it is necessary to force a program to @dfn{flush} its buffers; that is,
-write the information to its destination, even if a buffer is not full.
+it is necessary to force a program to @dfn{flush} its buffers (i.e.,
+write the information to its destination, even if a buffer is not full).
This is the purpose of the @code{fflush()} function---@command{gawk} also
buffers its output and the @code{fflush()} function forces
@command{gawk} to flush its buffers.
@@ -18183,11 +18281,11 @@ buffers its output and the @code{fflush()} function forces
@cindex extensions, common@comma{} @code{fflush()} function
@cindex Brian Kernighan's @command{awk}
Brian Kernighan added @code{fflush()} to his @command{awk} in April
-of 1992. For two decades, it was a common extension. In December,
+1992. For two decades, it was a common extension. In December
2012, it was accepted for inclusion into the POSIX standard.
See @uref{http://austingroupbugs.net/view.php?id=634, the Austin Group website}.
-POSIX standardizes @code{fflush()} as follows: If there
+POSIX standardizes @code{fflush()} as follows: if there
is no argument, or if the argument is the null string (@w{@code{""}}),
then @command{awk} flushes the buffers for @emph{all} open output files
and pipes.
@@ -18219,53 +18317,6 @@ a file or pipe that was opened for reading (such as with @code{getline}),
or if @var{filename} is not an open file, pipe, or coprocess.
In such a case, @code{fflush()} returns @minus{}1, as well.
-@item @code{system(@var{command})}
-@cindexawkfunc{system}
-@cindex invoke shell command
-@cindex interacting with other programs
-Execute the operating-system
-command @var{command} and then return to the @command{awk} program.
-Return @var{command}'s exit status.
-
-For example, if the following fragment of code is put in your @command{awk}
-program:
-
-@example
-END @{
- system("date | mail -s 'awk run done' root")
-@}
-@end example
-
-@noindent
-the system administrator is sent mail when the @command{awk} program
-finishes processing input and begins its end-of-input processing.
-
-Note that redirecting @code{print} or @code{printf} into a pipe is often
-enough to accomplish your task. If you need to run many commands, it
-is more efficient to simply print them down a pipeline to the shell:
-
-@example
-while (@var{more stuff to do})
- print @var{command} | "/bin/sh"
-close("/bin/sh")
-@end example
-
-@noindent
-@cindex troubleshooting, @code{system()} function
-@cindex @option{--sandbox} option, disabling @code{system()} function
-However, if your @command{awk}
-program is interactive, @code{system()} is useful for running large
-self-contained programs, such as a shell or an editor.
-Some operating systems cannot implement the @code{system()} function.
-@code{system()} causes a fatal error if it is not supported.
-
-@quotation NOTE
-When @option{--sandbox} is specified, the @code{system()} function is disabled
-(@pxref{Options}).
-@end quotation
-
-@end table
-
@cindex sidebar, Interactive Versus Noninteractive Buffering
@ifdocbook
@docbook
@@ -18275,15 +18326,15 @@ When @option{--sandbox} is specified, the @code{system()} function is disabled
@cindex buffering, interactive vs.@: noninteractive
As a side point, buffering issues can be even more confusing, depending
-upon whether your program is @dfn{interactive}, i.e., communicating
-with a user sitting at a keyboard.@footnote{A program is interactive
+upon whether your program is @dfn{interactive} (i.e., communicating
+with a user sitting at a keyboard).@footnote{A program is interactive
if the standard output is connected to a terminal device. On modern
systems, this means your keyboard and screen.}
@c Thanks to Walter.Mecky@dresdnerbank.de for this example, and for
@c motivating me to write this section.
-Interactive programs generally @dfn{line buffer} their output; i.e., they
-write out every line. Noninteractive programs wait until they have
+Interactive programs generally @dfn{line buffer} their output (i.e., they
+write out every line). Noninteractive programs wait until they have
a full buffer, which may be many lines of output.
Here is an example of the difference:
@@ -18326,15 +18377,15 @@ it is all buffered and sent down the pipe to @command{cat} in one shot.
@cindex buffering, interactive vs.@: noninteractive
As a side point, buffering issues can be even more confusing, depending
-upon whether your program is @dfn{interactive}, i.e., communicating
-with a user sitting at a keyboard.@footnote{A program is interactive
+upon whether your program is @dfn{interactive} (i.e., communicating
+with a user sitting at a keyboard).@footnote{A program is interactive
if the standard output is connected to a terminal device. On modern
systems, this means your keyboard and screen.}
@c Thanks to Walter.Mecky@dresdnerbank.de for this example, and for
@c motivating me to write this section.
-Interactive programs generally @dfn{line buffer} their output; i.e., they
-write out every line. Noninteractive programs wait until they have
+Interactive programs generally @dfn{line buffer} their output (i.e., they
+write out every line). Noninteractive programs wait until they have
a full buffer, which may be many lines of output.
Here is an example of the difference:
@@ -18366,6 +18417,53 @@ it is all buffered and sent down the pipe to @command{cat} in one shot.
@end cartouche
@end ifnotdocbook
+@item @code{system(@var{command})}
+@cindexawkfunc{system}
+@cindex invoke shell command
+@cindex interacting with other programs
+Execute the operating-system
+command @var{command} and then return to the @command{awk} program.
+Return @var{command}'s exit status.
+
+For example, if the following fragment of code is put in your @command{awk}
+program:
+
+@example
+END @{
+ system("date | mail -s 'awk run done' root")
+@}
+@end example
+
+@noindent
+the system administrator is sent mail when the @command{awk} program
+finishes processing input and begins its end-of-input processing.
+
+Note that redirecting @code{print} or @code{printf} into a pipe is often
+enough to accomplish your task. If you need to run many commands, it
+is more efficient to simply print them down a pipeline to the shell:
+
+@example
+while (@var{more stuff to do})
+ print @var{command} | "/bin/sh"
+close("/bin/sh")
+@end example
+
+@noindent
+@cindex troubleshooting, @code{system()} function
+@cindex @option{--sandbox} option, disabling @code{system()} function
+However, if your @command{awk}
+program is interactive, @code{system()} is useful for running large
+self-contained programs, such as a shell or an editor.
+Some operating systems cannot implement the @code{system()} function.
+@code{system()} causes a fatal error if it is not supported.
+
+@quotation NOTE
+When @option{--sandbox} is specified, the @code{system()} function is disabled
+(@pxref{Options}).
+@end quotation
+
+@end table
+
@cindex sidebar, Controlling Output Buffering with @code{system()}
@ifdocbook
@docbook
@@ -18389,7 +18487,7 @@ system("") # flush output
@command{gawk} treats this use of the @code{system()} function as a special
case and is smart enough not to run a shell (or other command
interpreter) with the empty command. Therefore, with @command{gawk}, this
-idiom is not only useful, it is also efficient. While this method should work
+idiom is not only useful, it is also efficient. Although this method should work
with other @command{awk} implementations, it does not necessarily avoid
starting an unnecessary shell. (Other implementations may only
flush the buffer associated with the standard output and not necessarily
@@ -18454,7 +18552,7 @@ system("") # flush output
@command{gawk} treats this use of the @code{system()} function as a special
case and is smart enough not to run a shell (or other command
interpreter) with the empty command. Therefore, with @command{gawk}, this
-idiom is not only useful, it is also efficient. While this method should work
+idiom is not only useful, it is also efficient. Although this method should work
with other @command{awk} implementations, it does not necessarily avoid
starting an unnecessary shell. (Other implementations may only
flush the buffer associated with the standard output and not necessarily
@@ -18594,14 +18692,14 @@ Mean Time). Otherwise, the value is formatted for the local time zone.
The @var{timestamp} is in the same format as the value returned by the
@code{systime()} function. If no @var{timestamp} argument is supplied,
@command{gawk} uses the current time of day as the timestamp.
-If no @var{format} argument is supplied, @code{strftime()} uses
+Without a @var{format} argument, @code{strftime()} uses
the value of @code{PROCINFO["strftime"]} as the format string
(@pxref{Built-in Variables}).
The default string value is
@code{@w{"%a %b %e %H:%M:%S %Z %Y"}}. This format string produces
output that is equivalent to that of the @command{date} utility.
You can assign a new value to @code{PROCINFO["strftime"]} to
-change the default format; see below for the various format directives.
+change the default format; see the following list for the various format directives.
@item @code{systime()}
@cindexgawkfunc{systime}
@@ -18678,9 +18776,9 @@ This is the ISO 8601 date format.
@item %g
The year modulo 100 of the ISO 8601 week number, as a decimal number (00--99).
-For example, January 1, 2012 is in week 53 of 2011. Thus, the year
+For example, January 1, 2012, is in week 53 of 2011. Thus, the year
of its ISO 8601 week number is 2011, even though its year is 2012.
-Similarly, December 31, 2012 is in week 1 of 2013. Thus, the year
+Similarly, December 31, 2012, is in week 1 of 2013. Thus, the year
of its ISO week number is 2013, even though its year is 2012.
@item %G
@@ -18776,7 +18874,7 @@ no time zone is determinable.
@item %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH
@itemx %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy
-``Alternate representations'' for the specifications
+``Alternative representations'' for the specifications
that use only the second letter (@code{%c}, @code{%C},
and so on).@footnote{If you don't understand any of this, don't worry about
it; these facilities are meant to make it easier to ``internationalize''
@@ -18789,7 +18887,7 @@ Other internationalization features are described in
A literal @samp{%}.
@end table
-If a conversion specifier is not one of the above, the behavior is
+If a conversion specifier is not one of those just listed, the behavior is
undefined.@footnote{This is because ISO C leaves the
behavior of the C version of @code{strftime()} undefined and @command{gawk}
uses the system's version of @code{strftime()} if it's there.
@@ -18833,7 +18931,7 @@ The date in VMS format (e.g., @samp{20-JUN-1991}).
@end table
@c ENDOFRANGE strf
-Additionally, the alternate representations are recognized but their
+Additionally, the alternative representations are recognized but their
normal representations are used.
@cindex @code{date} utility, POSIX
@@ -18847,7 +18945,7 @@ interprets the current time according to the format specifiers in
the string. For example:
@example
-$ date '+Today is %A, %B %d, %Y.'
+$ @kbd{date '+Today is %A, %B %d, %Y.'}
@print{} Today is Monday, September 22, 2014.
@end example
@@ -18911,8 +19009,10 @@ each successive pair of bits in the operands.
Three common operations are bitwise AND, OR, and XOR.
The operations are described in @ref{table-bitwise-ops}.
+@c 11/2014: Postprocessing turns the docbook informaltable
+@c into a table. Hurray for scripting!
@float Table,table-bitwise-ops
-@caption{Bitwise Operations}
+@caption{Bitwise operations}
@ifnottex
@ifnotdocbook
@display
@@ -19080,7 +19180,7 @@ Return the value of @var{val}, shifted right by @var{count} bits.
Return the bitwise XOR of the arguments. There must be at least two.
@end table
-For all of these functions, first the double precision floating-point value is
+For all of these functions, first the double-precision floating-point value is
converted to the widest C unsigned integer type, then the bitwise operation is
performed. If the result cannot be represented exactly as a C @code{double},
leading nonzero bits are removed one by one until it can be represented
@@ -19179,7 +19279,7 @@ Otherwise, a @code{"0"} is added.
The value is then shifted right by one bit and the loop continues
until there are no more 1 bits.
-If the initial value is zero it returns a simple @code{"0"}.
+If the initial value is zero, it returns a simple @code{"0"}.
Otherwise, at the end, it pads the value with zeros to represent multiples
of 8-bit quantities. This is typical in modern computers.
@@ -19216,8 +19316,8 @@ an array or not. The second is inside the body of a user-defined function
array or not.
@quotation NOTE
-Using @code{isarray()} at the global level to test
-variables makes no sense. Since you are the one writing the program, you
+Using @code{isarray()} at the global level to test
+variables makes no sense. Because you are the one writing the program, you
are supposed to know if your variables are arrays or not. And in fact,
due to the way @command{gawk} works, if you pass the name of a variable
that has not been previously used to @code{isarray()}, @command{gawk}
@@ -19285,7 +19385,7 @@ The default value for @var{category} is @code{"LC_MESSAGES"}.
Complicated @command{awk} programs can often be simplified by defining
your own functions. User-defined functions can be called just like
built-in ones (@pxref{Function Calls}), but it is up to you to define
-them, i.e., to tell @command{awk} what they should do.
+them (i.e., to tell @command{awk} what they should do).
@menu
* Definition Syntax:: How to write definitions and what they mean.
@@ -19424,13 +19524,13 @@ func foo() @{ a = sqrt($1) ; print a @}
@end example
@noindent
-Instead it defines a rule that, for each record, concatenates the value
+Instead, it defines a rule that, for each record, concatenates the value
of the variable @samp{func} with the return value of the function @samp{foo}.
If the resulting string is non-null, the action is executed.
This is probably not what is desired. (@command{awk} accepts this input as
syntactically valid, because functions may be used before they are defined
in @command{awk} programs.@footnote{This program won't actually run,
-since @code{foo()} is undefined.})
+because @code{foo()} is undefined.})
@cindex portability, functions@comma{} defining
To ensure that your @command{awk} programs are portable, always use the
@@ -19501,7 +19601,7 @@ The following is an example of a recursive function. It takes a string
as an input parameter and returns the string in backwards order.
Recursive functions must always have a test that stops the recursion.
In this case, the recursion terminates when the input string is
-already empty.
+already empty:
@c 8/2014: Thanks to Mike Brennan for the improved formulation
@cindex @code{rev()} user-defined function
@@ -19549,7 +19649,7 @@ function ctime(ts, format)
@end example
You might think that @code{ctime()} could use @code{PROCINFO["strftime"]}
-for its format string. That would be a mistake, since @code{ctime()} is
+for its format string. That would be a mistake, because @code{ctime()} is
supposed to return the time formatted in a standard fashion, and user-level
code could have changed @code{PROCINFO["strftime"]}.
@c ENDOFRANGE fdef
@@ -19570,7 +19670,7 @@ the function.
@end menu
@node Calling A Function
-@subsubsection Writing A Function Call
+@subsubsection Writing a Function Call
A function call consists of the function name followed by the arguments
in parentheses. @command{awk} expressions are what you write in the
@@ -19585,7 +19685,7 @@ foo(x y, "lose", 4 * z)
@quotation CAUTION
Whitespace characters (spaces and TABs) are not allowed
-between the function name and the open-parenthesis of the argument list.
+between the function name and the opening parenthesis of the argument list.
If you write whitespace by mistake, @command{awk} might think that you mean
to concatenate a variable with an expression in parentheses. However, it
notices that you used a function name and not a variable name, and reports
@@ -19625,7 +19725,7 @@ function foo(j)
print "foo's i=" i
@}
-BEGIN @{
+BEGIN @{
i = 10
print "top's i=" i
foo(0)
@@ -19648,13 +19748,13 @@ top's i=3
@end example
If you want @code{i} to be local to both @code{foo()} and @code{bar()} do as
-follows (the extra-space before @code{i} is a coding convention to
+follows (the extra space before @code{i} is a coding convention to
indicate that @code{i} is a local variable, not an argument):
@example
function bar( i)
@{
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++)
print "bar's i=" i
@}
@@ -19666,10 +19766,10 @@ function foo(j, i)
print "foo's i=" i
@}
-BEGIN @{
+BEGIN @{
i = 10
print "top's i=" i
- foo(0)
+ foo(0)
print "top's i=" i
@}
@end example
@@ -19728,21 +19828,16 @@ At level 2, index 2 is found in a
@end example
@node Pass By Value/Reference
-@subsubsection Passing Function Arguments By Value Or By Reference
+@subsubsection Passing Function Arguments by Value Or by Reference
In @command{awk}, when you declare a function, there is no way to
declare explicitly whether the arguments are passed @dfn{by value} or
@dfn{by reference}.
-Instead the passing convention is determined at runtime when
+Instead, the passing convention is determined at runtime when
the function is called according to the following rule:
-
-@itemize
-@item
-If the argument is an array variable, then it is passed by reference,
-@item
-Otherwise the argument is passed by value.
-@end itemize
+if the argument is an array variable, then it is passed by reference.
+Otherwise, the argument is passed by value.
@cindex call by value
Passing an argument by value means that when a function is called, it
@@ -19845,7 +19940,13 @@ If @option{--lint} is specified
Some @command{awk} implementations generate a runtime
error if you use either the @code{next} statement
or the @code{nextfile} statement
-(@pxref{Next Statement}, also @pxref{Nextfile Statement})
+(@pxref{Next Statement}, and
+@ifdocbook
+@ref{Nextfile Statement})
+@end ifdocbook
+@ifnotdocbook
+@pxref{Nextfile Statement})
+@end ifnotdocbook
inside a user-defined function.
@command{gawk} does not have this limitation.
@c ENDOFRANGE fudc
@@ -19901,8 +20002,8 @@ function maxelt(vec, i, ret)
@noindent
You call @code{maxelt()} with one argument, which is an array name. The local
variables @code{i} and @code{ret} are not intended to be arguments;
-while there is nothing to stop you from passing more than one argument
-to @code{maxelt()}, the results would be strange. The extra space before
+there is nothing to stop you from passing more than one argument
+to @code{maxelt()} but the results would be strange. The extra space before
@code{i} in the function parameter list indicates that @code{i} and
@code{ret} are local variables.
You should follow this convention when defining functions.
@@ -20039,8 +20140,8 @@ variable as the @emph{name} of the function to call.
@cindex indirect function calls, @code{@@}-notation
@cindex function calls, indirect, @code{@@}-notation for
The syntax is similar to that of a regular function call: an identifier
-immediately followed by a left parenthesis, any arguments, and then
-a closing right parenthesis, with the addition of a leading @samp{@@}
+immediately followed by an opening parenthesis, any arguments, and then
+a closing parenthesis, with the addition of a leading @samp{@@}
character:
@example
@@ -20049,7 +20150,7 @@ result = @@the_func() # calls the sum() function
@end example
Here is a full program that processes the previously shown data,
-using indirect function calls.
+using indirect function calls:
@example
@c file eg/prog/indirectcall.awk
@@ -20090,7 +20191,7 @@ function sum(first, last, ret, i)
These two functions expect to work on fields; thus the parameters
@code{first} and @code{last} indicate where in the fields to start and end.
-Otherwise they perform the expected computations and are not unusual.
+Otherwise they perform the expected computations and are not unusual:
@example
@c file eg/prog/indirectcall.awk
@@ -20135,11 +20236,11 @@ $ @kbd{gawk -f indirectcall.awk class_data1}
@print{} Biology 101:
@print{} sum: <352.8>
@print{} average: <88.2>
-@print{}
+@print{}
@print{} Chemistry 305:
@print{} sum: <356.4>
@print{} average: <89.1>
-@print{}
+@print{}
@print{} English 401:
@print{} sum: <376.1>
@print{} average: <94.025>
@@ -20261,7 +20362,7 @@ function do_sort(first, last, compare, data, i, retval)
retval = data[1]
for (i = 2; i in data; i++)
retval = retval " " data[i]
-
+
return retval
@}
@c endfile
@@ -20307,13 +20408,13 @@ $ @kbd{gawk -f quicksort.awk -f indirectcall.awk class_data2}
@print{} average: <88.2>
@print{} sort: <78.5 87.0 92.4 94.9>
@print{} rsort: <94.9 92.4 87.0 78.5>
-@print{}
+@print{}
@print{} Chemistry 305:
@print{} sum: <356.4>
@print{} average: <89.1>
@print{} sort: <75.2 88.2 94.7 98.3>
@print{} rsort: <98.3 94.7 88.2 75.2>
-@print{}
+@print{}
@print{} English 401:
@print{} sum: <376.1>
@print{} average: <94.025>
@@ -20416,7 +20517,7 @@ functions.
POSIX @command{awk} provides three kinds of built-in functions: numeric,
string, and I/O. @command{gawk} provides functions that sort arrays, work
with values representing time, do bit manipulation, determine variable
-type (array vs.@: scalar), and internationalize and localize programs.
+type (array versus scalar), and internationalize and localize programs.
@command{gawk} also provides several extensions to some of standard
functions, typically in the form of additional arguments.
@@ -20472,7 +20573,7 @@ program. This is equivalent to function pointers in C and C++.
@c ENDOFRANGE funcud
@ifnotinfo
-@part @value{PART2}Problem Solving With @command{awk}
+@part @value{PART2}Problem Solving with @command{awk}
@end ifnotinfo
@ifdocbook
@@ -20482,10 +20583,10 @@ It contains the following chapters:
@itemize @value{BULLET}
@item
-@ref{Library Functions}.
+@ref{Library Functions}
@item
-@ref{Sample Programs}.
+@ref{Sample Programs}
@end itemize
@end ifdocbook
@@ -20546,9 +20647,9 @@ and would like to contribute them to the @command{awk} user community, see
@cindex portability, example programs
The programs in this @value{CHAPTER} and in
@ref{Sample Programs},
-freely use features that are @command{gawk}-specific.
+freely use @command{gawk}-specific features.
Rewriting these programs for different implementations of @command{awk}
-is pretty straightforward.
+is pretty straightforward:
@itemize @value{BULLET}
@item
@@ -20618,7 +20719,7 @@ Library functions often need to have global variables that they can use to
preserve state information between calls to the function---for example,
@code{getopt()}'s variable @code{_opti}
(@pxref{Getopt Function}).
-Such variables are called @dfn{private}, since the only functions that need to
+Such variables are called @dfn{private}, as the only functions that need to
use them are the ones in the library.
When writing a library function, you should try to choose names for your
@@ -20640,10 +20741,10 @@ In addition, several of the library functions use a prefix that helps
indicate what function or set of functions use the variables---for example,
@code{_pw_byname()} in the user database routines
(@pxref{Passwd Functions}).
-This convention is recommended, since it even further decreases the
+This convention is recommended, as it even further decreases the
chance of inadvertent conflict among variable names. Note that this
convention is used equally well for variable names and for private
-function names.@footnote{While all the library routines could have
+function names.@footnote{Although all the library routines could have
been rewritten to use this convention, this was not done, in order to
show how our own @command{awk} programming style has evolved and to
provide some basis for this discussion.}
@@ -20716,7 +20817,7 @@ programming use.
@end menu
@node Strtonum Function
-@subsection Converting Strings To Numbers
+@subsection Converting Strings to Numbers
The @code{strtonum()} function (@pxref{String Functions})
is a @command{gawk} extension. The following function
@@ -20784,7 +20885,7 @@ function mystrtonum(str, ret, n, i, k, c)
# a[6] = "1.e3"
# a[7] = "1.32"
# a[8] = "1.32E2"
-#
+#
# for (i = 1; i in a; i++)
# print a[i], strtonum(a[i]), mystrtonum(a[i])
# @}
@@ -20798,7 +20899,7 @@ string. It sets @code{k} to the index in @code{"1234567"} of the current
octal digit.
The return value will either be the same number as the digit, or zero
if the character is not there, which will be true for a @samp{0}.
-This is safe, since the regexp test in the @code{if} ensures that
+This is safe, because the regexp test in the @code{if} ensures that
only octal values are converted.
Similar logic applies to the code that checks for and converts a
@@ -21145,7 +21246,7 @@ is always 1. This means that on those systems, characters
have numeric values from 128 to 255.
Finally, large mainframe systems use the EBCDIC character set, which
uses all 256 values.
-While there are other character sets in use on some older systems,
+There are other character sets in use on some older systems, but
they are not really worth worrying about:
@example
@@ -21199,7 +21300,7 @@ Good function design is important; this function needs to be general but it
should also have a reasonable default behavior. It is called with an array
as well as the beginning and ending indices of the elements in the array to be
merged. This assumes that the array indices are numeric---a reasonable
-assumption since the array was likely created with @code{split()}
+assumption, as the array was likely created with @code{split()}
(@pxref{String Functions}):
@cindex @code{join()} user-defined function
@@ -21252,7 +21353,7 @@ more difficult than they really need to be.}
The @code{systime()} and @code{strftime()} functions described in
@DBREF{Time Functions}
provide the minimum functionality necessary for dealing with the time of day
-in human readable form. While @code{strftime()} is extensive, the control
+in human-readable form. Although @code{strftime()} is extensive, the control
formats are not necessarily easy to remember or intuitively obvious when
reading a program.
@@ -21343,7 +21444,7 @@ allowed the user to supply an optional timestamp value to use instead
of the current time.
@node Readfile Function
-@subsection Reading A Whole File At Once
+@subsection Reading a Whole File At Once
Often, it is convenient to have the entire contents of a file available
in memory as a single string. A straightforward but naive way to
@@ -21403,7 +21504,7 @@ will never match if the file has contents. @command{gawk} reads data from
the file into @code{tmp} attempting to match @code{RS}. The match fails
after each read, but fails quickly, such that @command{gawk} fills
@code{tmp} with the entire contents of the file.
-(@xref{Records}, for information on @code{RT} and @code{RS}.)
+(@DBXREF{Records} for information on @code{RT} and @code{RS}.)
In the case that @code{file} is empty, the return value is the null
string. Thus calling code may use something like:
@@ -21421,7 +21522,7 @@ test would be @samp{contents == ""}.
also reads an entire file into memory.
@node Shell Quoting
-@subsection Quoting Strings to Pass to The Shell
+@subsection Quoting Strings to Pass to the Shell
@c included by permission
@ignore
@@ -21463,7 +21564,7 @@ chmod -w file.flac
Note the need for shell quoting. The function @code{shell_quote()}
does it. @code{SINGLE} is the one-character string @code{"'"} and
-@code{QSINGLE} is the three-character string @code{"\"'\""}.
+@code{QSINGLE} is the three-character string @code{"\"'\""}:
@example
@c file eg/lib/shellquote.awk
@@ -21523,7 +21624,7 @@ command-line @value{DF}s.
@cindex files, managing, data file boundaries
@cindex files, initialization and cleanup
-The @code{BEGIN} and @code{END} rules are each executed exactly once at
+The @code{BEGIN} and @code{END} rules are each executed exactly once, at
the beginning and end of your @command{awk} program, respectively
(@pxref{BEGIN/END}).
We (the @command{gawk} authors) once had a user who mistakenly thought that the
@@ -21595,7 +21696,7 @@ The following version solves the problem:
@example
@c file eg/lib/ftrans.awk
-# ftrans.awk --- handle data file transitions
+# ftrans.awk --- handle datafile transitions
#
# user supplies beginfile() and endfile() functions
@c endfile
@@ -21623,10 +21724,10 @@ END @{ endfile(_filename_) @}
shows how this library function can be used and
how it simplifies writing the main program.
-@cindex sidebar, So Why Does @command{gawk} have @code{BEGINFILE} and @code{ENDFILE}?
+@cindex sidebar, So Why Does @command{gawk} Have @code{BEGINFILE} and @code{ENDFILE}?
@ifdocbook
@docbook
-<sidebar><title>So Why Does @command{gawk} have @code{BEGINFILE} and @code{ENDFILE}?</title>
+<sidebar><title>So Why Does @command{gawk} Have @code{BEGINFILE} and @code{ENDFILE}?</title>
@end docbook
@@ -21636,7 +21737,7 @@ functions can do the job, why does @command{gawk} have
Good question. Normally, if @command{awk} cannot open a file, this
causes an immediate fatal error. In this case, there is no way for a
-user-defined function to deal with the problem, since the mechanism for
+user-defined function to deal with the problem, as the mechanism for
calling it relies on the file being open and at the first record. Thus,
the main reason for @code{BEGINFILE} is to give you a ``hook'' to catch
files that cannot be processed. @code{ENDFILE} exists for symmetry,
@@ -21649,7 +21750,7 @@ and because it provides an easy way to do per-file cleanup processing.
@ifnotdocbook
@cartouche
-@center @b{So Why Does @command{gawk} have @code{BEGINFILE} and @code{ENDFILE}?}
+@center @b{So Why Does @command{gawk} Have @code{BEGINFILE} and @code{ENDFILE}?}
@@ -21659,7 +21760,7 @@ functions can do the job, why does @command{gawk} have
Good question. Normally, if @command{awk} cannot open a file, this
causes an immediate fatal error. In this case, there is no way for a
-user-defined function to deal with the problem, since the mechanism for
+user-defined function to deal with the problem, as the mechanism for
calling it relies on the file being open and at the first record. Thus,
the main reason for @code{BEGINFILE} is to give you a ``hook'' to catch
files that cannot be processed. @code{ENDFILE} exists for symmetry,
@@ -21718,8 +21819,8 @@ 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!)
+(This isn't necessary anyway, because @command{gawk} goes to the next
+file as soon as an @code{ENDFILE} rule finishes!)
@node File Checking
@subsection Checking for Readable @value{DDF}s
@@ -21767,19 +21868,19 @@ BEGIN @{
@cindex troubleshooting, @code{getline} function
This works, because the @code{getline} won't be fatal.
Removing the element from @code{ARGV} with @code{delete}
-skips the file (since it's no longer in the list).
+skips the file (because it's no longer in the list).
See also @ref{ARGC and ARGV}.
-The regular expression check purposely does not use character classes
+Because @command{awk} variable names only allow the English letters,
+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
All known @command{awk} implementations silently skip over zero-length files.
-This is a by-product of @command{awk}'s implicit
+This is a by-product of @command{awk}'s implicit
read-a-record-and-match-against-the-rules loop: when @command{awk}
tries to read a record from an empty file, it immediately receives an
end of file indication, closes the file, and proceeds on to the next
@@ -21915,12 +22016,12 @@ are left alone.
@c STARTOFRANGE clibf
@cindex functions, library, C library
@cindex arguments, processing
-Most utilities on POSIX compatible systems take options on
+Most utilities on POSIX-compatible systems take options on
the command line that can be used to change the way a program behaves.
@command{awk} is an example of such a program
(@pxref{Options}).
-Often, options take @dfn{arguments}; i.e., data that the program needs to
-correctly obey the command-line option. For example, @command{awk}'s
+Often, options take @dfn{arguments} (i.e., data that the program needs to
+correctly obey the command-line option). For example, @command{awk}'s
@option{-F} option requires a string to use as the field separator.
The first occurrence on the command line of either @option{--} or a
string that does not begin with @samp{-} ends the options.
@@ -22024,7 +22125,7 @@ necessary for accessing individual characters
(@pxref{String Functions}).@footnote{This
function was written before @command{gawk} acquired the ability to
split strings into single characters using @code{""} as the separator.
-We have left it alone, since using @code{substr()} is more portable.}
+We have left it alone, as using @code{substr()} is more portable.}
The discussion that follows walks through the code a bit at a time:
@@ -22192,9 +22293,9 @@ next element in @code{argv}. If neither condition is true, then only
on the next call to @code{getopt()}.
The @code{BEGIN} rule initializes both @code{Opterr} and @code{Optind} to one.
-@code{Opterr} is set to one, since the default behavior is for @code{getopt()}
+@code{Opterr} is set to one, because the default behavior is for @code{getopt()}
to print a diagnostic message upon seeing an invalid option. @code{Optind}
-is set to one, since there's no reason to look at the program name, which is
+is set to one, because there's no reason to look at the program name, which is
in @code{ARGV[0]}:
@example
@@ -22244,16 +22345,22 @@ etc., as its own options.
@quotation NOTE
After @code{getopt()} is through,
-user level code must clear out all the elements of @code{ARGV} from 1
+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
+as @option{-E} causes @command{gawk} to abandon processing of
further options
-(@pxref{Executable Scripts}, and @pxref{Options}).
+(@DBPXREF{Executable Scripts} and
+@ifnotdocbook
+@pxref{Options}).
+@end ifnotdocbook
+@ifdocbook
+@ref{Options}).
+@end ifdocbook
Several of the sample programs presented in
@ref{Sample Programs},
@@ -22283,7 +22390,7 @@ However, because these are numbers, they do not provide very useful
information to the average user. There needs to be some way to find the
user information associated with the user and group ID numbers. This
@value{SECTION} presents a suite of functions for retrieving information from the
-user database. @xref{Group Functions},
+user database. @DBXREF{Group Functions}
for a similar suite that retrieves information from the group database.
@cindex @code{getpwent()} function (C library)
@@ -22302,7 +22409,7 @@ The ``password'' comes from the original user database file,
encrypted passwords (hence the name).
@cindex @command{pwcat} program
-While an @command{awk} program could simply read @file{/etc/passwd}
+Although an @command{awk} program could simply read @file{/etc/passwd}
directly, this file may not contain complete information about the
system's set of users.@footnote{It is often the case that password
information is stored in a network database.} To be sure you are able to
@@ -22397,12 +22504,12 @@ The user's encrypted password. This may not be available on some systems.
@item User-ID
The user's numeric user ID number.
-(On some systems it's a C @code{long}, and not an @code{int}. Thus
+(On some systems, it's a C @code{long}, and not an @code{int}. Thus
we cast it to @code{long} for all cases.)
@item Group-ID
The user's numeric group ID number.
-(Similar comments about @code{long} vs.@: @code{int} apply here.)
+(Similar comments about @code{long} versus @code{int} apply here.)
@item Full name
The user's full name, and perhaps other information associated with the
@@ -22503,7 +22610,7 @@ 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()}
+The variable @code{_pw_inited} is used for efficiency, as @code{_pw_init()}
needs to be called only once.
@cindex @code{PROCINFO} array, testing the field splitting
@@ -22512,7 +22619,7 @@ 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}.
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
+Doing so is necessary, as 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.
This makes it possible to restore the correct
@@ -22614,7 +22721,7 @@ In turn, calling @code{_pw_init()} is not too expensive, because the
once. If you are worried about squeezing every last cycle out of your
@command{awk} program, the check of @code{_pw_inited} could be moved out of
@code{_pw_init()} and duplicated in all the other functions. In practice,
-this is not necessary, since most @command{awk} programs are I/O-bound,
+this is not necessary, as most @command{awk} programs are I/O-bound,
and such a change would clutter up the code.
The @command{id} program in @DBREF{Id Program}
@@ -22753,7 +22860,7 @@ the association of name to number must be unique within the file.
we cast it to @code{long} for all cases.)
@item Group Member List
-A comma-separated list of user names. These users are members of the group.
+A comma-separated list of usernames. These users are members of the group.
Modern Unix systems allow users to be members of several groups
simultaneously. If your system does, then there are elements
@code{"group1"} through @code{"group@var{N}"} in @code{PROCINFO}
@@ -22868,7 +22975,7 @@ is being used, and to restore the appropriate field splitting mechanism.
The group information is stored is several associative arrays.
The arrays are indexed by group name (@code{@w{_gr_byname}}), by group ID number
(@code{@w{_gr_bygid}}), and by position in the database (@code{@w{_gr_bycount}}).
-There is an additional array indexed by user name (@code{@w{_gr_groupsbyuser}}),
+There is an additional array indexed by username (@code{@w{_gr_groupsbyuser}}),
which is a space-separated list of groups to which each user belongs.
Unlike the user database, it is possible to have multiple records in the
@@ -22881,7 +22988,7 @@ tvpeople:*:101:david,conan,tom,joan
@end example
For this reason, @code{_gr_init()} looks to see if a group name or
-group ID number is already seen. If it is, then the user names are
+group ID number is already seen. If it is, the usernames are
simply concatenated onto the previous list of users.@footnote{There is actually a
subtle problem with the code just presented. Suppose that
the first time there were no names. This code adds the names with
@@ -22927,7 +23034,7 @@ function getgrgid(gid)
@cindex @code{getgruser()} function (C library)
The @code{getgruser()} function does not have a C counterpart. It takes a
-user name and returns the list of groups that have the user as a member:
+username and returns the list of groups that have the user as a member:
@cindex @code{getgruser()} function, user-defined
@example
@@ -23070,7 +23177,7 @@ The functions presented here fit into the following categories:
@c nested list
@table @asis
@item General problems
-Number to string conversion, assertions, rounding, random number
+Number-to-string conversion, assertions, rounding, random number
generation, converting characters to numbers, joining strings, getting
easily usable time-of-day information, and reading a whole file in
one shot.
@@ -23130,7 +23237,7 @@ ARGIND != Argind @{
@}
END @{
if (ARGIND < ARGC - 1)
- ARGIND = ARGC - 1
+ ARGIND = ARGC - 1
if (ARGIND > Argind)
for (Argind++; Argind <= ARGIND; Argind++)
zerofile(ARGV[Argind], Argind)
@@ -23266,7 +23373,7 @@ The programs are presented in alphabetical order.
@end menu
@node Cut Program
-@subsection Cutting out Fields and Columns
+@subsection Cutting Out Fields and Columns
@cindex @command{cut} utility
@c STARTOFRANGE cut
@@ -23543,7 +23650,7 @@ function set_charlist( field, i, j, f, g, n, m, t,
@c endfile
@end example
-Next is the rule that actually processes the data. If the @option{-s} option
+Next is the rule that processes the data. If the @option{-s} option
is given, then @code{suppress} is true. The first @code{if} statement
makes sure that the input record does have the field separator. If
@command{cut} is processing fields, @code{suppress} is true, and the field
@@ -23575,9 +23682,9 @@ written out between the fields:
@end example
This version of @command{cut} relies on @command{gawk}'s @code{FIELDWIDTHS}
-variable to do the character-based cutting. While it is possible in
+variable to do the character-based cutting. It is possible in
other @command{awk} implementations to use @code{substr()}
-(@pxref{String Functions}),
+(@pxref{String Functions}), but
it is also extremely painful.
The @code{FIELDWIDTHS} variable supplies an elegant solution to the problem
of picking the input line apart by characters.
@@ -23722,7 +23829,7 @@ matched lines in the output:
@c endfile
@end example
-The last two lines are commented out, since they are not needed in
+The last two lines are commented out, as they are not needed in
@command{gawk}. They should be uncommented if you have to use another version
of @command{awk}.
@@ -23732,7 +23839,7 @@ into lowercase if the @option{-i} option is specified.@footnote{It
also introduces a subtle bug;
if a match happens, we output the translated line, not the original.}
The rule is
-commented out since it is not necessary with @command{gawk}:
+commented out as it is not necessary with @command{gawk}:
@example
@c file eg/prog/egrep.awk
@@ -23869,7 +23976,7 @@ function usage()
@c ENDOFRANGE egrep
@node Id Program
-@subsection Printing out User Information
+@subsection Printing Out User Information
@cindex printing, user information
@cindex users, information about, printing
@@ -23984,7 +24091,7 @@ function pr_first_field(str, a)
The test in the @code{for} loop is worth noting.
Any supplementary groups in the @code{PROCINFO} array have the
indices @code{"group1"} through @code{"group@var{N}"} for some
-@var{N}, i.e., the total number of supplementary groups.
+@var{N} (i.e., the total number of supplementary groups).
However, we don't know in advance how many of these groups
there are.
@@ -24024,10 +24131,10 @@ aims to demonstrate.}
By default,
the output files are named @file{xaa}, @file{xab}, and so on. Each file has
-1000 lines in it, with the likely exception of the last file. To change the
+1,000 lines in it, with the likely exception of the last file. To change the
number of lines in each file, supply a number on the command line
-preceded with a minus; e.g., @samp{-500} for files with 500 lines in them
-instead of 1000. To change the name of the output files to something like
+preceded with a minus (e.g., @samp{-500} for files with 500 lines in them
+instead of 1,000). To change the name of the output files to something like
@file{myfileaa}, @file{myfileab}, and so on, supply an additional
argument that specifies the @value{FN} prefix.
@@ -24075,7 +24182,7 @@ BEGIN @{
@}
# test argv in case reading from stdin instead of file
if (i in ARGV)
- i++ # skip data file name
+ i++ # skip datafile name
if (i in ARGV) @{
outfile = ARGV[i]
ARGV[i] = ""
@@ -24169,8 +24276,8 @@ truncating them and starting over.
The @code{BEGIN} rule first makes a copy of all the command-line arguments
into an array named @code{copy}.
-@code{ARGV[0]} is not copied, since it is not needed.
-@code{tee} cannot use @code{ARGV} directly, since @command{awk} attempts to
+@code{ARGV[0]} is not needed, so it is not copied.
+@code{tee} cannot use @code{ARGV} directly, because @command{awk} attempts to
process each @value{FN} in @code{ARGV} as input data.
@cindex flag variables
@@ -24219,7 +24326,7 @@ BEGIN @{
@c endfile
@end example
-The following single rule does all the work. Since there is no pattern, it is
+The following single rule does all the work. Because there is no pattern, it is
executed for each line of input. The body of the rule simply prints the
line into each file on the command line, and then to the standard output:
@@ -24250,7 +24357,7 @@ for (i in copy)
@end example
@noindent
-This is more concise but it is also less efficient. The @samp{if} is
+This is more concise, but it is also less efficient. The @samp{if} is
tested for each record and for each output file. By duplicating the loop
body, the @samp{if} is only tested once for each input record. If there are
@var{N} input records and @var{M} output files, the first method only
@@ -24470,10 +24577,10 @@ The second rule does the work. The variable @code{equal} is one or zero,
depending upon the results of @code{are_equal()}'s comparison. If @command{uniq}
is counting repeated lines, and the lines are equal, then it increments the @code{count} variable.
Otherwise, it prints the line and resets @code{count},
-since the two lines are not equal.
+because the two lines are not equal.
If @command{uniq} is not counting, and if the lines are equal, @code{count} is incremented.
-Nothing is printed, since the point is to remove duplicates.
+Nothing is printed, as the point is to remove duplicates.
Otherwise, if @command{uniq} is counting repeated lines and more than
one line is seen, or if @command{uniq} is counting nonrepeated lines
and only one line is seen, then the line is printed, and @code{count}
@@ -24542,7 +24649,7 @@ Brian Kernighan suggests that
``an alternative approach to state machines is to just read
the input into an array, then use indexing. It's almost always
easier code, and for most inputs where you would use this, just
-as fast.'' Consider how to rewrite the logic to follow this
+as fast.'' Consider how to rewrite the logic to follow this
suggestion.
@end ifset
@@ -24594,7 +24701,7 @@ Count only characters.
@end table
Implementing @command{wc} in @command{awk} is particularly elegant,
-since @command{awk} does a lot of the work for us; it splits lines into
+because @command{awk} does a lot of the work for us; it splits lines into
words (i.e., fields) and counts them, it counts lines (i.e., records),
and it can easily tell us how long a line is.
@@ -24699,7 +24806,7 @@ function endfile(file)
@end example
There is one rule that is executed for each line. It adds the length of
-the record, plus one, to @code{chars}.@footnote{Since @command{gawk}
+the record, plus one, to @code{chars}.@footnote{Because @command{gawk}
understands multibyte locales, this code counts characters, not bytes.}
Adding one plus the record length
is needed because the newline character separating records (the value
@@ -25047,8 +25154,8 @@ often used to map uppercase letters into lowercase for further processing:
@command{tr} requires two lists of characters.@footnote{On some older
systems, including Solaris, the system version of @command{tr} may require
that the lists be written as range expressions enclosed in square brackets
-(@samp{[a-z]}) and quoted, to prevent the shell from attempting a file
-name expansion. This is not a feature.} When processing the input, the
+(@samp{[a-z]}) and quoted, to prevent the shell from attempting a
+@value{FN} expansion. This is not a feature.} When processing the input, the
first character in the first list is replaced with the first character
in the second list, the second character in the first list is replaced
with the second character in the second list, and so on. If there are
@@ -25163,9 +25270,9 @@ BEGIN @{
@c endfile
@end example
-While it is possible to do character transliteration in a user-level
-function, it is not necessarily efficient, and we (the @command{gawk}
-authors) started to consider adding a built-in function. However,
+It is possible to do character transliteration in a user-level
+function, but it is not necessarily efficient, and we (the @command{gawk}
+developers) started to consider adding a built-in function. However,
shortly after writing this program, we learned that Brian Kernighan
had added the @code{toupper()} and @code{tolower()} functions to his
@command{awk} (@pxref{String Functions}). These functions handle the
@@ -25209,7 +25316,7 @@ the @code{line} array and printing the page when 20 labels have been read.
The @code{BEGIN} rule simply sets @code{RS} to the empty string, so that
@command{awk} splits records at blank lines
(@pxref{Records}).
-It sets @code{MAXLINES} to 100, since 100 is the maximum number
+It sets @code{MAXLINES} to 100, because 100 is the maximum number
of lines on the page
@iftex
(@math{20 @cdot 5 = 100}).
@@ -25366,9 +25473,9 @@ useful on real text files:
@item
The @command{awk} language considers upper- and lowercase characters to be
distinct. Therefore, ``bartender'' and ``Bartender'' are not treated
-as the same word. This is undesirable, since in normal text, words
-are capitalized if they begin sentences, and a frequency analyzer should not
-be sensitive to capitalization.
+as the same word. This is undesirable, because words are capitalized
+if they begin sentences in normal text, and a frequency analyzer should
+not be sensitive to capitalization.
@item
Words are detected using the @command{awk} convention that fields are
@@ -25549,7 +25656,7 @@ The nodes
and @ref{Sample Programs},
are the top level nodes for a large number of @command{awk} programs.
@end ifinfo
-If you want to experiment with these programs, it is tedious to have to type
+If you want to experiment with these programs, it is tedious to type
them in by hand. Here we present a program that can extract parts of a
Texinfo input file into separate files.
@@ -25627,7 +25734,7 @@ It also prints some final advice:
@@example
@@c file examples/messages.awk
-END @@@{ print "Always avoid bored archeologists!" @@@}
+END @@@{ print "Always avoid bored archaeologists!" @@@}
@@c end file
@@end example
@dots{}
@@ -25799,7 +25906,7 @@ The @command{sed} utility is a stream editor, a program that reads a
stream of data, makes changes to it, and passes it on.
It is often used to make global changes to a large file or to a stream
of data generated by a pipeline of commands.
-While @command{sed} is a complicated program in its own right, its most common
+Although @command{sed} is a complicated program in its own right, its most common
use is to perform global substitutions in the middle of a pipeline:
@example
@@ -25808,7 +25915,7 @@ use is to perform global substitutions in the middle of a pipeline:
Here, @samp{s/old/new/g} tells @command{sed} to look for the regexp
@samp{old} on each input line and globally replace it with the text
-@samp{new}, i.e., all the occurrences on a line. This is similar to
+@samp{new} (i.e., all the occurrences on a line). This is similar to
@command{awk}'s @code{gsub()} function
(@pxref{String Functions}).
@@ -25892,7 +25999,7 @@ not treated as @value{FN}s
(@pxref{ARGC and ARGV}).
The @code{usage()} function prints an error message and exits.
-Finally, the single rule handles the printing scheme outlined above,
+Finally, the single rule handles the printing scheme outlined earlier,
using @code{print} or @code{printf} as appropriate, depending upon the
value of @code{RT}.
@c ENDOFRANGE awksed
@@ -25936,8 +26043,8 @@ BEGIN @{
The following program, @file{igawk.sh}, provides this service.
It simulates @command{gawk}'s searching of the @env{AWKPATH} variable
-and also allows @dfn{nested} includes; i.e., a file that is included
-with @code{@@include} can contain further @code{@@include} statements.
+and also allows @dfn{nested} includes (i.e., a file that is included
+with @code{@@include} can contain further @code{@@include} statements).
@command{igawk} makes an effort to only include files once, so that nested
includes don't accidentally include a library function twice.
@@ -25967,10 +26074,10 @@ Literal text, provided with @option{-e} or @option{--source}. This
text is just appended directly.
@item
-Source @value{FN}s, provided with @option{-f}. We use a neat trick and append
-@samp{@@include @var{filename}} to the shell variable's contents. Since the file-inclusion
-program works the way @command{gawk} does, this gets the text
-of the file included into the program at the correct point.
+Source @value{FN}s, provided with @option{-f}. We use a neat trick and
+append @samp{@@include @var{filename}} to the shell variable's contents.
+Because the file-inclusion program works the way @command{gawk} does, this
+gets the text of the file included in the program at the correct point.
@end enumerate
@item
@@ -26269,9 +26376,10 @@ EOF
@c endfile
@end example
-The shell construct @samp{@var{command} << @var{marker}} is called a @dfn{here document}.
-Everything in the shell script up to the @var{marker} is fed to @var{command} as input.
-The shell processes the contents of the here document for variable and command substitution
+The shell construct @samp{@var{command} << @var{marker}} is called
+a @dfn{here document}. Everything in the shell script up to the
+@var{marker} is fed to @var{command} as input. The shell processes
+the contents of the here document for variable and command substitution
(and possibly other things as well, depending upon the shell).
The shell construct @samp{$(@dots{})} is called @dfn{command substitution}.
@@ -26286,14 +26394,16 @@ It's done in these steps:
@enumerate
@item
Run @command{gawk} with the @code{@@include}-processing program (the
-value of the @code{expand_prog} shell variable) on standard input.
+value of the @code{expand_prog} shell variable) reading standard input.
@item
-Standard input is the contents of the user's program, from the shell variable @code{program}.
-Its contents are fed to @command{gawk} via a here document.
+Standard input is the contents of the user's program,
+from the shell variable @code{program}.
+Feed its contents to @command{gawk} via a here document.
@item
-The results of this processing are saved in the shell variable @code{processed_program} by using command substitution.
+Save the results of this processing in the shell variable
+@code{processed_program} by using command substitution.
@end enumerate
The last step is to call @command{gawk} with the expanded program,
@@ -26369,7 +26479,7 @@ of @command{awk} programs as Web CGI scripts.}
@c ENDOFRANGE igawk
@node Anagram Program
-@subsection Finding Anagrams From A Dictionary
+@subsection Finding Anagrams from a Dictionary
@cindex anagrams, finding
An interesting programming challenge is to
@@ -26378,17 +26488,17 @@ word list (such as
@file{/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'').
+(e.g., ``babbling'' and ``blabbing'').
-Column 2, Problem C of Jon Bentley's @cite{Programming Pearls}, second
-edition, presents an elegant algorithm. The idea is to give words that
+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
-in sorted order.
+in sorted order:
@c STARTOFRANGE anagram
@cindex @code{anagram.awk} program
@@ -26460,7 +26570,7 @@ function word2key(word, a, i, n, result)
Finally, the @code{END} rule traverses the array
and prints out the anagram lists. It sends the output
-to the system @command{sort} command, since otherwise
+to the system @command{sort} command because otherwise
the anagrams would appear in arbitrary order:
@example
@@ -26488,21 +26598,21 @@ Here is some partial output when the program is run:
@example
$ @kbd{gawk -f anagram.awk /usr/share/dict/words | grep '^b'}
@dots{}
-babbled blabbed
-babbler blabber brabble
-babblers blabbers brabbles
-babbling blabbing
-babbly blabby
-babel bable
-babels beslab
-babery yabber
+babbled blabbed
+babbler blabber brabble
+babblers blabbers brabbles
+babbling blabbing
+babbly blabby
+babel bable
+babels beslab
+babery yabber
@dots{}
@end example
@c ENDOFRANGE anagram
@node Signature Program
-@subsection And Now For Something Completely Different
+@subsection And Now for Something Completely Different
@cindex signature program
@cindex Brini, Davide
@@ -26542,28 +26652,28 @@ Subject: The GNU Awk User's Guide, Section 13.3.11
From: "Chris Johansen" <johansen@main.nc.us>
Message-ID: <op.v0iw6wlv7finx3@asusodin.thrudvang.lan>
-Arnold, you don't know me, but we have a tenuous connection. My wife is
+Arnold, you don't know me, but we have a tenuous connection. My wife is
Barbara A. Field, FAIA, GIT '65 (B. Arch.).
-I have had a couple of paper copies of "Effective Awk Programming" for
-years, and now I'm going through a Kindle version of "The GNU Awk User's
-Guide" again. When I got to section 13.3.11, I reformatted and lightly
+I have had a couple of paper copies of "Effective Awk Programming" for
+years, and now I'm going through a Kindle version of "The GNU Awk User's
+Guide" again. When I got to section 13.3.11, I reformatted and lightly
commented Davide Brin's signature script to understand its workings.
-It occurs to me that this might have pedagogical value as an example
-(although imperfect) of the value of whitespace and comments, and a
-starting point for that discussion. It certainly helped _me_ understand
-what's going on. You are welcome to it, as-is or modified (subject to
+It occurs to me that this might have pedagogical value as an example
+(although imperfect) of the value of whitespace and comments, and a
+starting point for that discussion. It certainly helped _me_ understand
+what's going on. You are welcome to it, as-is or modified (subject to
Davide's constraints, of course, which I think I have met).
-If I were to include it in a future edition, I would put it at some
-distance from section 13.3.11, say, as a note or an appendix, so as not to
+If I were to include it in a future edition, I would put it at some
+distance from section 13.3.11, say, as a note or an appendix, so as not to
be a "spoiler" to the puzzle.
Best regards,
---
+--
Chris Johansen {johansen at main dot nc dot us}
- . . . collapsing the probability wave function, sending ripples of
+ . . . collapsing the probability wave function, sending ripples of
certainty through the space-time continuum.
@@ -26572,7 +26682,7 @@ certainty through the space-time continuum.
# From "13.3.11 And Now For Something Completely Different"
# http://www.gnu.org/software/gawk/manual/html_node/Signature-Program.html#Signature-Program
-# Copyright © 2008 Davide Brini
+# Copyright © 2008 Davide Brini
# Copying and distribution of the code published in this page, with
# or without modification, are permitted in any medium without
@@ -26691,7 +26801,7 @@ Brian Kernighan suggests that
``an alternative approach to state machines is to just read
the input into an array, then use indexing. It's almost always
easier code, and for most inputs where you would use this, just
-as fast.'' Rewrite the logic to follow this
+as fast.'' Rewrite the logic to follow this
suggestion.
@@ -26792,7 +26902,7 @@ the use of the external @command{sort} utility.
@c EXCLUDE END
@ifnotinfo
-@part @value{PART3}Moving Beyond Standard @command{awk} With @command{gawk}
+@part @value{PART3}Moving Beyond Standard @command{awk} with @command{gawk}
@end ifnotinfo
@ifdocbook
@@ -26801,19 +26911,19 @@ It contains the following chapters:
@itemize @value{BULLET}
@item
-@ref{Advanced Features}.
+@ref{Advanced Features}
@item
-@ref{Internationalization}.
+@ref{Internationalization}
@item
-@ref{Debugger}.
+@ref{Debugger}
@item
-@ref{Arbitrary Precision Arithmetic}.
+@ref{Arbitrary Precision Arithmetic}
@item
-@ref{Dynamic Extensions}.
+@ref{Dynamic Extensions}
@end itemize
@end ifdocbook
@@ -26972,7 +27082,7 @@ in a particular order that you, the programmer, choose. @command{gawk}
lets you do this.
@DBREF{Controlling Scanning} describes how you can assign special,
-pre-defined values to @code{PROCINFO["sorted_in"]} in order to
+predefined values to @code{PROCINFO["sorted_in"]} in order to
control the order in which @command{gawk} traverses an array
during a @code{for} loop.
@@ -26996,7 +27106,7 @@ Here, @var{i1} and @var{i2} are the indices, and @var{v1} and @var{v2}
are the corresponding values of the two elements being compared.
Either @var{v1} or @var{v2}, or both, can be arrays if the array being
traversed contains subarrays as values.
-(@xref{Arrays of Arrays}, for more information about subarrays.)
+(@DBXREF{Arrays of Arrays} for more information about subarrays.)
The three possible return values are interpreted as follows:
@table @code
@@ -27039,7 +27149,7 @@ function cmp_str_val(i1, v1, i2, v2)
The third
comparison function makes all numbers, and numeric strings without
-any leading or trailing spaces, come out first during loop traversal:
+any leading or trailing spaces, come out first during loop traversal:
@example
function cmp_num_str_val(i1, v1, i2, v2, n1, n2)
@@ -27047,10 +27157,10 @@ function cmp_num_str_val(i1, v1, i2, v2, n1, n2)
# numbers before string value comparison, ascending order
n1 = v1 + 0
n2 = v2 + 0
- if (n1 == v1)
+ if (n1 == v1)
return (n2 == v2) ? (n1 - n2) : -1
else if (n2 == v2)
- return 1
+ return 1
return (v1 < v2) ? -1 : (v1 != v2)
@}
@end example
@@ -27065,7 +27175,7 @@ BEGIN @{
data[10] = "one"
data[100] = 100
data[20] = "two"
-
+
f[1] = "cmp_num_idx"
f[2] = "cmp_str_val"
f[3] = "cmp_num_str_val"
@@ -27089,14 +27199,14 @@ $ @kbd{gawk -f compdemo.awk}
@print{} data[10] = one
@print{} data[20] = two
@print{} data[100] = 100
-@print{}
+@print{}
@print{} Sort function: cmp_str_val @ii{Sort by element values as strings}
@print{} data[one] = 10
@print{} data[100] = 100 @ii{String 100 is less than string 20}
@print{} data[two] = 20
@print{} data[10] = one
@print{} data[20] = two
-@print{}
+@print{}
@print{} Sort function: cmp_num_str_val @ii{Sort all numeric values before all strings}
@print{} data[one] = 10
@print{} data[two] = 20
@@ -27107,7 +27217,7 @@ $ @kbd{gawk -f compdemo.awk}
Consider sorting the entries of a GNU/Linux system password file
according to login name. The following program sorts records
-by a specific field position and can be used for this purpose:
+by a specific field position and can be used for this purpose:
@example
# passwd-sort.awk --- simple program to sort by field position
@@ -27153,7 +27263,7 @@ $ @kbd{gawk -v POS=1 -F: -f sort.awk /etc/passwd}
The comparison should normally always return the same value when given a
specific pair of array elements as its arguments. If inconsistent
-results are returned then the order is undefined. This behavior can be
+results are returned, then the order is undefined. This behavior can be
exploited to introduce random order into otherwise seemingly
ordered data:
@@ -27165,7 +27275,7 @@ function cmp_randomize(i1, v1, i2, v2)
@}
@end example
-As mentioned above, the order of the indices is arbitrary if two
+As already mentioned, 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
@@ -27206,10 +27316,10 @@ When string comparisons are made during a sort, either for element
values where one or both aren't numbers, or for element indices
handled as strings, the value of @code{IGNORECASE}
(@pxref{Built-in Variables}) controls whether
-the comparisons treat corresponding uppercase and lowercase letters as
+the comparisons treat corresponding upper- and lowercase letters as
equivalent or distinct.
-Another point to keep in mind is that in the case of subarrays
+Another point to keep in mind is that in the case of subarrays,
the element values can themselves be arrays; a production comparison
function should use the @code{isarray()} function
(@pxref{Type Functions}),
@@ -27217,7 +27327,7 @@ to check for this, and choose a defined sorting order for subarrays.
All sorting based on @code{PROCINFO["sorted_in"]}
is disabled in POSIX mode,
-since the @code{PROCINFO} array is not special in that case.
+because the @code{PROCINFO} array is not special in that case.
As a side note, sorting the array indices before traversing
the array has been reported to add 15% to 20% overhead to the
@@ -27238,8 +27348,8 @@ sorted array traversal is not the default.
@cindex @code{asorti()} function (@command{gawk}), arrays@comma{} sorting
@cindex sort function, arrays, sorting
In most @command{awk} implementations, sorting an array requires writing
-a @code{sort()} function. While this can be educational for exploring
-different sorting algorithms, usually that's not the point of the program.
+a @code{sort()} function. This can be educational for exploring
+different sorting algorithms, but usually that's not the point of the program.
@command{gawk} provides the built-in @code{asort()} and @code{asorti()}
functions (@pxref{String Functions}) for sorting arrays. For example:
@@ -27335,8 +27445,8 @@ Because @code{IGNORECASE} affects string comparisons, the value
of @code{IGNORECASE} also affects sorting for both @code{asort()} and @code{asorti()}.
Note also that the locale's sorting order does @emph{not}
come into play; comparisons are based on character values only.@footnote{This
-is true because locale-based comparison occurs only when in POSIX
-compatibility mode, and since @code{asort()} and @code{asorti()} are
+is true because locale-based comparison occurs only when in
+POSIX-compatibility mode, and because @code{asort()} and @code{asorti()} are
@command{gawk} extensions, they are not available in that case.}
@node Two-way I/O
@@ -27412,7 +27522,7 @@ remain more difficult to use than two-way pipes.} @c 8/2014
@cindex @command{csh} utility, @code{|&} operator, comparison with
However, with @command{gawk}, it is possible to
open a @emph{two-way} pipe to another process. The second process is
-termed a @dfn{coprocess}, since it runs in parallel with @command{gawk}.
+termed a @dfn{coprocess}, as it runs in parallel with @command{gawk}.
The two-way connection is created using the @samp{|&} operator
(borrowed from the Korn shell, @command{ksh}):@footnote{This is very
different from the same operator in the C shell and in Bash.}
@@ -27572,7 +27682,7 @@ You can think of this as just a @emph{very long} two-way pipeline to
a coprocess.
The way @command{gawk} decides that you want to use TCP/IP networking is
by recognizing special @value{FN}s that begin with one of @samp{/inet/},
-@samp{/inet4/} or @samp{/inet6/}.
+@samp{/inet4/}, or @samp{/inet6/}.
The full syntax of the special @value{FN} is
@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}}.
@@ -27601,7 +27711,7 @@ or @samp{http}, in which case @command{gawk} attempts to determine
the predefined port number using the C @code{getaddrinfo()} function.
@item remote-host
-The IP address or fully-qualified domain name of the Internet
+The IP address or fully qualified domain name of the Internet
host to which you want to connect.
@item remote-port
@@ -27675,12 +27785,12 @@ gawk --profile=myprog.prof -f myprog.awk data1 data2
@end example
@noindent
-In the above example, @command{gawk} places the profile in
+In the preceding example, @command{gawk} places the profile in
@file{myprog.prof} instead of in @file{awkprof.out}.
-Here is a sample session showing a simple @command{awk} program, its input data, and the
-results from running @command{gawk} with the @option{--profile} option.
-First, the @command{awk} program:
+Here is a sample session showing a simple @command{awk} program,
+its input data, and the results from running @command{gawk} with the
+@option{--profile} option. First, the @command{awk} program:
@example
BEGIN @{ print "First BEGIN rule" @}
@@ -27838,7 +27948,7 @@ the body of an @code{if}, @code{else}, or loop is only a single statement.
@item
Parentheses are used only where needed, as indicated by the structure
of the program and the precedence rules.
-For example, @samp{(3 + 5) * 4} means add three plus five, then multiply
+For example, @samp{(3 + 5) * 4} means add three and five, then multiply
the total by four. However, @samp{3 + 5 * 4} has no parentheses, and
means @samp{3 + (5 * 4)}.
@@ -28097,8 +28207,7 @@ following steps, in this order:
@enumerate
@item
-The programmer goes
-through the source for all of @command{guide}'s components
+The programmer reviews the source for all of @command{guide}'s components
and marks each string that is a candidate for translation.
For example, @code{"`-F': option required"} is a good candidate for translation.
A table with strings of option names is not (e.g., @command{gawk}'s
@@ -28218,8 +28327,8 @@ if necessary. (It is almost never necessary to supply a different category.)
@cindex sorting characters in different languages
@cindex @code{LC_COLLATE} locale category
@item LC_COLLATE
-Text-collation information; i.e., how different characters
-and/or groups of characters sort in a given language.
+Text-collation information (i.e., how different characters
+and/or groups of characters sort in a given language).
@cindex @code{LC_CTYPE} locale category
@item LC_CTYPE
@@ -28438,7 +28547,7 @@ BEGIN @{
@end enumerate
-@xref{I18N Example},
+@DBXREF{I18N Example}
for an example program showing the steps to create
and use translations from @command{awk}.
@@ -28499,7 +28608,7 @@ second argument to @code{dcngettext()}.@footnote{The
You should distribute the generated @file{.pot} file with
your @command{awk} program; translators will eventually use it
to provide you translations that you can also then distribute.
-@xref{I18N Example},
+@DBXREF{I18N Example}
for the full list of steps to go through to create and test
translations for @command{guide}.
@c ENDOFRANGE portobfi
@@ -28627,7 +28736,7 @@ change:
@cindex @code{TEXTDOMAIN} variable, portability and
@item
Assignments to @code{TEXTDOMAIN} won't have any effect,
-since @code{TEXTDOMAIN} is not special in other @command{awk} implementations.
+because @code{TEXTDOMAIN} is not special in other @command{awk} implementations.
@item
Non-GNU versions of @command{awk} treat marked strings
@@ -28675,8 +28784,8 @@ enough arguments are supplied in the function call. Many versions of
underlying C library version of @code{sprintf()}, but only one format and
argument at a time. What happens if a positional specification is
used is anybody's guess.
-However, since the positional specifications are primarily for use in
-@emph{translated} format strings, and since non-GNU @command{awk}s never
+However, because the positional specifications are primarily for use in
+@emph{translated} format strings, and because non-GNU @command{awk}s never
retrieve the translated string, this should not be a problem in practice.
@end itemize
@c ENDOFRANGE inap
@@ -28739,7 +28848,7 @@ called ``Hippy.'' Ah, well.}
@example
@group
-$ cp guide.pot guide-mellow.po
+$ @kbd{cp guide.pot guide-mellow.po}
@var{Add translations to} guide-mellow.po @dots{}
@end group
@end example
@@ -28765,7 +28874,7 @@ msgstr "Like, the scoop is"
The next step is to make the directory to hold the binary message object
file and then to create the @file{guide.mo} file.
We pretend that our file is to be used in the @code{en_US.UTF-8} locale,
-since we have to use a locale name known to the C @command{gettext} routines.
+because we have to use a locale name known to the C @command{gettext} routines.
The directory layout shown here is standard for GNU @command{gettext} on
GNU/Linux systems. Other versions of @command{gettext} may use a different
layout:
@@ -28802,7 +28911,7 @@ $ @kbd{gawk -f guide.awk}
@print{} Pardon me, Zaphod who?
@end example
-If the three replacement functions for @code{dcgettext()}, @code{dcngettext()}
+If the three replacement functions for @code{dcgettext()}, @code{dcngettext()},
and @code{bindtextdomain()}
(@pxref{I18N Portability})
are in a file named @file{libintl.awk},
@@ -28904,7 +29013,7 @@ how to use @command{gawk} for debugging your program is easy.
@end menu
@node Debugging
-@section Introduction to The @command{gawk} Debugger
+@section Introduction to the @command{gawk} Debugger
This @value{SECTION} introduces debugging in general and begins
the discussion of debugging in @command{gawk}.
@@ -28922,8 +29031,8 @@ the discussion of debugging in @command{gawk}.
ahead to the next section on the specific features of the @command{gawk}
debugger.)
-Of course, a debugging program cannot remove bugs for you, since it has
-no way of knowing what you or your users consider a ``bug'' and what is a
+Of course, a debugging program cannot remove bugs for you, because it has
+no way of knowing what you or your users consider a ``bug'' versus a
``feature.'' (Sometimes, we humans have a hard time with this ourselves.)
In that case, what can you expect from such a tool? The answer to that
depends on the language being debugged, but in general, you can expect at
@@ -28944,7 +29053,7 @@ having to change your source files.
@item
The chance to see the values of data in the program at any point in
execution, and also to change that data on the fly, to see how that
-affects what happens afterwards. (This often includes the ability
+affects what happens afterward. (This often includes the ability
to look at internal data structures besides the variables you actually
defined in your code.)
@@ -28964,11 +29073,11 @@ functional program that you or someone else wrote).
Before diving in to the details, we need to introduce several
important concepts that apply to just about all debuggers.
The following list defines terms used throughout the rest of
-this @value{CHAPTER}.
+this @value{CHAPTER}:
@table @dfn
@cindex stack frame
-@item Stack Frame
+@item Stack frame
Programs generally call functions during the course of their execution.
One function can call another, or a function can call itself (recursion).
You can view the chain of called functions (main program calls A, which
@@ -29003,7 +29112,7 @@ as many breakpoints as you like.
A watchpoint is similar to a breakpoint. The difference is that
breakpoints are oriented around the code: stop when a certain point in the
code is reached. A watchpoint, however, specifies that program execution
-should stop when a @emph{data value} is changed. This is useful, since
+should stop when a @emph{data value} is changed. This is useful, as
sometimes it happens that a variable receives an erroneous value, and it's
hard to track down where this happens just by looking at the code.
By using a watchpoint, you can stop whenever a variable is assigned to,
@@ -29017,13 +29126,13 @@ Debugging an @command{awk} program has some specific aspects that are
not shared with other programming languages.
First of all, the fact that @command{awk} programs usually take input
-line-by-line from a file or files and operate on those lines using specific
+line by line from a file or files and operate on those lines using specific
rules makes it especially useful to organize viewing the execution of
the program in terms of these rules. As we will see, each @command{awk}
rule is treated almost like a function call, with its own specific block
of instructions.
-In addition, since @command{awk} is by design a very concise language,
+In addition, because @command{awk} is by design a very concise language,
it is easy to lose sight of everything that is going on ``inside''
each line of @command{awk} code. The debugger provides the opportunity
to look at the individual primitive instructions carried out
@@ -29150,7 +29259,7 @@ gawk> @kbd{bt}
@end example
This tells us that @code{are_equal()} was called by the main program at
-line 88 of @file{uniq.awk}. (This is not a big surprise, since this
+line 88 of @file{uniq.awk}. (This is not a big surprise, because this
is the only call to @code{are_equal()} in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -29167,7 +29276,7 @@ gawk> @kbd{p n}
@end example
@noindent
-In this case, @code{n} is an uninitialized local variable, since the
+In this case, @code{n} is an uninitialized local variable, because the
function was called without arguments (@pxref{Function Calls}).
A more useful variable to display might be the current record:
@@ -29178,8 +29287,8 @@ gawk> @kbd{p $0}
@end example
@noindent
-This might be a bit puzzling at first since this is the second line of
-our test input above. Let's look at @code{NR}:
+This might be a bit puzzling at first, as this is the second line of
+our test input. Let's look at @code{NR}:
@example
gawk> @kbd{p NR}
@@ -29219,7 +29328,7 @@ gawk> @kbd{n}
This tells us that @command{gawk} is now ready to execute line 66, which
decides whether to give the lines the special ``field skipping'' treatment
indicated by the @option{-1} command-line option. (Notice that we skipped
-from where we were before at line 63 to here, since the condition in line 63
+from where we were before at line 63 to here, because the condition in line 63
@samp{if (fcount == 0 && charcount == 0)} was false.)
Continuing to step, we now get to the splitting of the current and
@@ -29249,7 +29358,7 @@ gawk> @kbd{p n m alast aline}
This is kind of disappointing, though. All we found out is that there
are five elements in @code{alast}; @code{m} and @code{aline} don't have
-values since we are at line 68 but haven't executed it yet.
+values because we are at line 68 but haven't executed it yet.
This information is useful enough (we now know that
none of the words were accidentally left out), but what if we want to see
inside the array?
@@ -29358,8 +29467,9 @@ show the abbreviation on a second description line.
A debugger command name may also be truncated if that partial
name is unambiguous. The debugger has the built-in capability to
automatically repeat the previous command just by hitting @key{Enter}.
-This works for the commands @code{list}, @code{next}, @code{nexti}, @code{step}, @code{stepi}
-and @code{continue} executed without any argument.
+This works for the commands @code{list}, @code{next}, @code{nexti},
+@code{step}, @code{stepi}, and @code{continue} executed without any
+argument.
@menu
* Breakpoint Control:: Control of Breakpoints.
@@ -29374,9 +29484,9 @@ and @code{continue} executed without any argument.
@node Breakpoint Control
@subsection Control of Breakpoints
-As we saw above, the first thing you probably want to do in a debugging
-session is to get your breakpoints set up, since otherwise your program
-will just run as if it was not under the debugger. The commands for
+As we saw earlier, the first thing you probably want to do in a debugging
+session is to get your breakpoints set up, because your program
+will otherwise just run as if it was not under the debugger. The commands for
controlling breakpoints are:
@table @asis
@@ -29447,8 +29557,8 @@ that the debugger evaluates
whenever the breakpoint or watchpoint is reached. If the condition is true, then
the debugger stops execution and prompts for a command. Otherwise,
the debugger continues executing the program. If the condition expression is
-not specified, any existing condition is removed; i.e., the breakpoint or
-watchpoint is made unconditional.
+not specified, any existing condition is removed (i.e., the breakpoint or
+watchpoint is made unconditional).
@cindex debugger commands, @code{d} (@code{delete})
@cindex debugger commands, @code{delete}
@@ -29589,7 +29699,7 @@ Execute one (or @var{count}) instruction(s), stepping over function calls.
@item @code{return} [@var{value}]
Cancel execution of a function call. If @var{value} (either a string or a
number) is specified, it is used as the function's return value. If used in a
-frame other than the innermost one (the currently executing function, i.e.,
+frame other than the innermost one (the currently executing function; i.e.,
frame number 0), discard all inner frames in addition to the selected one,
and the caller of that frame becomes the innermost frame.
@@ -29655,7 +29765,7 @@ gawk> @kbd{display x}
@end example
@noindent
-displays the assigned item number, the variable name and its current value.
+This displays the assigned item number, the variable name, and its current value.
If the display variable refers to a function parameter, it is silently
deleted from the list as soon as the execution reaches a context where
no such variable of the given name exists.
@@ -29723,7 +29833,7 @@ or field.
String values must be enclosed between double quotes (@code{"}@dots{}@code{"}).
You can also set special @command{awk} variables, such as @code{FS},
-@code{NF}, @code{NR}, etc.
+@code{NF}, @code{NR}, and son on.
@cindex debugger commands, @code{w} (@code{watch})
@cindex debugger commands, @code{watch}
@@ -29786,7 +29896,7 @@ Print a backtrace of all function calls (stack frames), or innermost @var{count}
frames if @var{count} > 0. Print the outermost @var{count} frames if
@var{count} < 0. The backtrace displays the name and arguments to each
function, the source @value{FN}, and the line number.
-The alias @code{where} for @code{backtrace} is provided for long-time
+The alias @code{where} for @code{backtrace} is provided for longtime
GDB users who may be used to that command.
@cindex debugger commands, @code{down}
@@ -29815,7 +29925,7 @@ Then select and print the frame.
@end table
@node Debugger Info
-@subsection Obtaining Information about the Program and the Debugger State
+@subsection Obtaining Information About the Program and the Debugger State
Besides looking at the values of variables, there is often a need to get
other sorts of information about the state of your program and of the
@@ -29983,51 +30093,51 @@ partial dump of Davide Brini's obfuscated code
@smallexample
gawk> @kbd{dump}
@print{} # BEGIN
-@print{}
-@print{} [ 1:0xfcd340] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
-@print{} [ 1:0xfcc240] Op_push_i : "~" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc2a0] Op_push_i : "~" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc280] Op_match :
-@print{} [ 1:0xfcc1e0] Op_store_var : O
-@print{} [ 1:0xfcc2e0] Op_push_i : "==" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc340] Op_push_i : "==" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc320] Op_equal :
-@print{} [ 1:0xfcc200] Op_store_var : o
-@print{} [ 1:0xfcc380] Op_push : o
-@print{} [ 1:0xfcc360] Op_plus_i : 0 [MALLOC|NUMCUR|NUMBER]
-@print{} [ 1:0xfcc220] Op_push_lhs : o [do_reference = true]
-@print{} [ 1:0xfcc300] Op_assign_plus :
-@print{} [ :0xfcc2c0] Op_pop :
-@print{} [ 1:0xfcc400] Op_push : O
-@print{} [ 1:0xfcc420] Op_push_i : "" [MALLOC|STRING|STRCUR]
-@print{} [ :0xfcc4a0] Op_no_op :
-@print{} [ 1:0xfcc480] Op_push : O
-@print{} [ :0xfcc4c0] Op_concat : [expr_count = 3] [concat_flag = 0]
-@print{} [ 1:0xfcc3c0] Op_store_var : x
-@print{} [ 1:0xfcc440] Op_push_lhs : X [do_reference = true]
-@print{} [ 1:0xfcc3a0] Op_postincrement :
-@print{} [ 1:0xfcc4e0] Op_push : x
-@print{} [ 1:0xfcc540] Op_push : o
-@print{} [ 1:0xfcc500] Op_plus :
-@print{} [ 1:0xfcc580] Op_push : o
-@print{} [ 1:0xfcc560] Op_plus :
-@print{} [ 1:0xfcc460] Op_leq :
-@print{} [ :0xfcc5c0] Op_jmp_false : [target_jmp = 0xfcc5e0]
-@print{} [ 1:0xfcc600] Op_push_i : "%c" [MALLOC|STRING|STRCUR]
-@print{} [ :0xfcc660] Op_no_op :
-@print{} [ 1:0xfcc520] Op_assign_concat : c
-@print{} [ :0xfcc620] Op_jmp : [target_jmp = 0xfcc440]
-@print{}
-@dots{}
-@print{}
+@print{}
+@print{} [ 1:0xfcd340] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
+@print{} [ 1:0xfcc240] Op_push_i : "~" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc2a0] Op_push_i : "~" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc280] Op_match :
+@print{} [ 1:0xfcc1e0] Op_store_var : O
+@print{} [ 1:0xfcc2e0] Op_push_i : "==" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc340] Op_push_i : "==" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc320] Op_equal :
+@print{} [ 1:0xfcc200] Op_store_var : o
+@print{} [ 1:0xfcc380] Op_push : o
+@print{} [ 1:0xfcc360] Op_plus_i : 0 [MALLOC|NUMCUR|NUMBER]
+@print{} [ 1:0xfcc220] Op_push_lhs : o [do_reference = true]
+@print{} [ 1:0xfcc300] Op_assign_plus :
+@print{} [ :0xfcc2c0] Op_pop :
+@print{} [ 1:0xfcc400] Op_push : O
+@print{} [ 1:0xfcc420] Op_push_i : "" [MALLOC|STRING|STRCUR]
+@print{} [ :0xfcc4a0] Op_no_op :
+@print{} [ 1:0xfcc480] Op_push : O
+@print{} [ :0xfcc4c0] Op_concat : [expr_count = 3] [concat_flag = 0]
+@print{} [ 1:0xfcc3c0] Op_store_var : x
+@print{} [ 1:0xfcc440] Op_push_lhs : X [do_reference = true]
+@print{} [ 1:0xfcc3a0] Op_postincrement :
+@print{} [ 1:0xfcc4e0] Op_push : x
+@print{} [ 1:0xfcc540] Op_push : o
+@print{} [ 1:0xfcc500] Op_plus :
+@print{} [ 1:0xfcc580] Op_push : o
+@print{} [ 1:0xfcc560] Op_plus :
+@print{} [ 1:0xfcc460] Op_leq :
+@print{} [ :0xfcc5c0] Op_jmp_false : [target_jmp = 0xfcc5e0]
+@print{} [ 1:0xfcc600] Op_push_i : "%c" [MALLOC|STRING|STRCUR]
+@print{} [ :0xfcc660] Op_no_op :
+@print{} [ 1:0xfcc520] Op_assign_concat : c
+@print{} [ :0xfcc620] Op_jmp : [target_jmp = 0xfcc440]
+@print{}
+@dots{}
+@print{}
@print{} [ 2:0xfcc5a0] Op_K_printf : [expr_count = 17] [redir_type = ""]
-@print{} [ :0xfcc140] Op_no_op :
-@print{} [ :0xfcc1c0] Op_atexit :
-@print{} [ :0xfcc640] Op_stop :
-@print{} [ :0xfcc180] Op_no_op :
-@print{} [ :0xfcd150] Op_after_beginfile :
-@print{} [ :0xfcc160] Op_no_op :
-@print{} [ :0xfcc1a0] Op_after_endfile :
+@print{} [ :0xfcc140] Op_no_op :
+@print{} [ :0xfcc1c0] Op_atexit :
+@print{} [ :0xfcc640] Op_stop :
+@print{} [ :0xfcc180] Op_no_op :
+@print{} [ :0xfcd150] Op_after_beginfile :
+@print{} [ :0xfcc160] Op_no_op :
+@print{} [ :0xfcc1a0] Op_after_endfile :
gawk>
@end smallexample
@@ -30084,7 +30194,7 @@ function @var{function}. This command may change the current source file.
@itemx @code{q}
Exit the debugger. Debugging is great fun, but sometimes we all have
to tend to other obligations in life, and sometimes we find the bug,
-and are free to go on to the next one! As we saw above, if you are
+and are free to go on to the next one! As we saw earlier, if you are
running a program, the debugger warns you if you accidentally type
@samp{q} or @samp{quit}, to make sure you really want to quit.
@@ -30161,7 +30271,7 @@ If you perused the dump of opcodes in @ref{Miscellaneous Debugger Commands}
(or if you are already familiar with @command{gawk} internals),
you will realize that much of the internal manipulation of data
in @command{gawk}, as in many interpreters, is done on a stack.
-@code{Op_push}, @code{Op_pop}, etc., are the ``bread and butter'' of
+@code{Op_push}, @code{Op_pop}, and the like, are the ``bread and butter'' of
most @command{gawk} code.
Unfortunately, as of now, the @command{gawk}
@@ -30175,8 +30285,8 @@ change back to obscure, perhaps more optimal code later.
@item
There is no way to look ``inside'' the process of compiling
regular expressions to see if you got it right. As an @command{awk}
-programmer, you are expected to know what @code{/[^[:alnum:][:blank:]]/}
-means.
+programmer, you are expected to know the meaning of
+@code{/[^[:alnum:][:blank:]]/}.
@item
The @command{gawk} debugger is designed to be used by running a program (with all its
@@ -30228,7 +30338,7 @@ and editing.
@end itemize
@node Arbitrary Precision Arithmetic
-@chapter Arithmetic and Arbitrary Precision Arithmetic with @command{gawk}
+@chapter Arithmetic and Arbitrary-Precision Arithmetic with @command{gawk}
@cindex arbitrary precision
@cindex multiple precision
@cindex infinite precision
@@ -30238,9 +30348,9 @@ This @value{CHAPTER} introduces some basic concepts relating to
how computers do arithmetic and defines some important terms.
It then proceeds to describe floating-point arithmetic,
which is what @command{awk} uses for all its computations, including a
-discussion of arbitrary precision floating point arithmetic, which is
+discussion of arbitrary-precision floating-point arithmetic, which is
a feature available only in @command{gawk}. It continues on to present
-arbitrary precision integers, and concludes with a description of some
+arbitrary-precision integers, and concludes with a description of some
points where @command{gawk} and the POSIX standard are not quite in
agreement.
@@ -30303,51 +30413,51 @@ The disadvantage is that their range is limited.
@cindex integers, unsigned
In computers, integer values come in two flavors: @dfn{signed} and
@dfn{unsigned}. Signed values may be negative or positive, whereas
-unsigned values are always positive (that is, greater than or equal
+unsigned values are always positive (i.e., greater than or equal
to zero).
In computer systems, integer arithmetic is exact, but the possible
range of values is limited. Integer arithmetic is generally faster than
-floating point arithmetic.
+floating-point arithmetic.
-@item Floating point arithmetic
+@item Floating-point arithmetic
Floating-point numbers represent what were called in school ``real''
-numbers; i.e., those that have a fractional part, such as 3.1415927.
+numbers (i.e., those that have a fractional part, such as 3.1415927).
The advantage to floating-point numbers is that they can represent a
much larger range of values than can integers. The disadvantage is that
there are numbers that they cannot represent exactly.
-Modern systems support floating point arithmetic in hardware, with a
+Modern systems support floating-point arithmetic in hardware, with a
limited range of values. There are software libraries that allow
-the use of arbitrary precision floating point calculations.
+the use of arbitrary-precision floating-point calculations.
-POSIX @command{awk} uses @dfn{double precision} floating-point numbers, which
-can hold more digits than @dfn{single precision} floating-point numbers.
-@command{gawk} has facilities for performing arbitrary precision floating
-point arithmetic, which we describe in more detail shortly.
+POSIX @command{awk} uses @dfn{double-precision} floating-point numbers, which
+can hold more digits than @dfn{single-precision} floating-point numbers.
+@command{gawk} has facilities for performing arbitrary-precision
+floating-point arithmetic, which we describe in more detail shortly.
@end table
-Computers work with integer and floating point values of different
-ranges. Integer values are usually either 32 or 64 bits in size. Single
-precision floating point values occupy 32 bits, whereas double precision
-floating point values occupy 64 bits. Floating point values are always
+Computers work with integer and floating-point values of different
+ranges. Integer values are usually either 32 or 64 bits in size.
+Single-precision floating-point values occupy 32 bits, whereas double-precision
+floating-point values occupy 64 bits. Floating-point values are always
signed. The possible ranges of values are shown in @ref{table-numeric-ranges}.
@float Table,table-numeric-ranges
-@caption{Value Ranges for Different Numeric Representations}
+@caption{Value ranges for different numeric representations}
@multitable @columnfractions .34 .33 .33
@headitem Numeric representation @tab Minimum value @tab Maximum value
@item 32-bit signed integer @tab @minus{}2,147,483,648 @tab 2,147,483,647
@item 32-bit unsigned integer @tab 0 @tab 4,294,967,295
@item 64-bit signed integer @tab @minus{}9,223,372,036,854,775,808 @tab 9,223,372,036,854,775,807
@item 64-bit unsigned integer @tab 0 @tab 18,446,744,073,709,551,615
-@item Single precision floating point (approximate) @tab @code{1.175494e-38} @tab @code{3.402823e+38}
-@item Double precision floating point (approximate) @tab @code{2.225074e-308} @tab @code{1.797693e+308}
+@item Single-precision floating point (approximate) @tab @code{1.175494e-38} @tab @code{3.402823e+38}
+@item Double-precision floating point (approximate) @tab @code{2.225074e-308} @tab @code{1.797693e+308}
@end multitable
@end float
@node Math Definitions
-@section Other Stuff To Know
+@section Other Stuff to Know
The rest of this @value{CHAPTER} uses a number of terms. Here are some
informal definitions that should help you work your way through the material
@@ -30424,7 +30534,7 @@ How numbers are rounded up or down when necessary.
More details are provided later.
@item Significand
-A floating point value consists the significand multiplied by 10
+A floating-point value consists the significand multiplied by 10
to the power of the exponent. For example, in @code{1.2345e67},
the significand is @code{1.2345}.
@@ -30442,19 +30552,19 @@ on some of those terms.
On modern systems, floating-point hardware uses the representation and
operations defined by the IEEE 754 standard.
Three of the standard IEEE 754 types are 32-bit single precision,
-64-bit double precision and 128-bit quadruple precision.
+64-bit double precision, and 128-bit quadruple precision.
The standard also specifies extended precision formats
to allow greater precisions and larger exponent ranges.
-(@command{awk} uses only the 64-bit double precision format.)
+(@command{awk} uses only the 64-bit double-precision format.)
@ref{table-ieee-formats} lists the precision and exponent
field values for the basic IEEE 754 binary formats:
@float Table,table-ieee-formats
-@caption{Basic IEEE Format Values}
+@caption{Basic IEEE format values}
@multitable @columnfractions .20 .20 .20 .20 .20
@headitem Name @tab Total bits @tab Precision @tab Minimum exponent @tab Maximum exponent
-@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
+@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
@item Double @tab 64 @tab 53 @tab @minus{}1022 @tab +1023
@item Quadruple @tab 128 @tab 113 @tab @minus{}16382 @tab +16383
@end multitable
@@ -30466,14 +30576,14 @@ one extra bit of significand.
@end quotation
@node MPFR features
-@section Arbitrary Precision Arithmetic Features In @command{gawk}
+@section Arbitrary-Precision Arithmetic Features in @command{gawk}
-By default, @command{gawk} uses the double precision floating-point values
+By default, @command{gawk} uses the double-precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do so, @command{gawk} uses the @uref{http://www.mpfr.org
-GNU MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for arbitrary
-precision arithmetic on numbers. You can see if MPFR support is available
-like so:
+compiled to do so, @command{gawk} uses the @uref{http://www.mpfr.org,
+GNU MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for
+arbitrary-precision arithmetic on numbers. You can see if MPFR support
+is available like so:
@example
$ @kbd{gawk --version}
@@ -30501,11 +30611,11 @@ Two predefined variables, @code{PREC} and @code{ROUNDMODE},
provide control over the working precision and the rounding mode.
The precision and the rounding mode are set globally for every operation
to follow.
-@xref{Setting precision}, and @ref{Setting the rounding mode},
+@DBXREF{Setting precision} and @DBREF{Setting the rounding mode}
for more information.
@node FP Math Caution
-@section Floating Point Arithmetic: Caveat Emptor!
+@section Floating-Point Arithmetic: Caveat Emptor!
@quotation
@i{Math class is tough!}
@@ -30538,17 +30648,17 @@ rely just on what we tell you.
@end menu
@node Inexactness of computations
-@subsection Floating Point Arithmetic Is Not Exact
+@subsection Floating-Point Arithmetic Is Not Exact
Binary floating-point representations and arithmetic are inexact.
Simple values like 0.1 cannot be precisely represented using
binary floating-point numbers, and the limited precision of
floating-point numbers means that slight changes in
the order of operations or the precision of intermediate storage
-can change the result. To make matters worse, with arbitrary precision
-floating-point, you can set the precision before starting a computation,
-but then you cannot be sure of the number of significant decimal places
-in the final result.
+can change the result. To make matters worse, with arbitrary-precision
+floating-point arithmetic, you can set the precision before starting a
+computation, but then you cannot be sure of the number of significant
+decimal places in the final result.
@menu
* Inexact representation:: Numbers are not exactly represented.
@@ -30570,7 +30680,7 @@ y = 0.425
Unlike the number in @code{y}, the number stored in @code{x}
is exactly representable
-in binary since it can be written as a finite sum of one or
+in binary because it can be written as a finite sum of one or
more fractions whose denominators are all powers of two.
When @command{gawk} reads a floating-point number from
program source, it automatically rounds that number to whatever
@@ -30596,7 +30706,7 @@ Because the underlying representation can be a little bit off from the exact val
comparing floating-point values to see if they are exactly equal is generally a bad idea.
Here is an example where it does not work like you would expect:
-@example
+@example
$ @kbd{gawk 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
@print{} 0
@end example
@@ -30605,7 +30715,7 @@ The general wisdom when comparing floating-point values is to see if
they are within some small range of each other (called a @dfn{delta},
or @dfn{tolerance}).
You have to decide how small a delta is important to you. Code to do
-this looks something like this:
+this looks something like the following:
@example
delta = 0.00001 # for example
@@ -30625,7 +30735,7 @@ else
The loss of accuracy during a single computation with floating-point
numbers usually isn't enough to worry about. However, if you compute a
-value which is the result of a sequence of floating point operations,
+value which is the result of a sequence of floating-point operations,
the error can accumulate and greatly affect the computation itself.
Here is an attempt to compute the value of @value{PI} using one of its
many series representations:
@@ -30671,9 +30781,9 @@ $ @kbd{gawk 'BEGIN @{}
@end example
@node Getting Accuracy
-@subsection Getting The Accuracy You Need
+@subsection Getting the Accuracy You Need
-Can arbitrary precision arithmetic give exact results? There are
+Can arbitrary-precision arithmetic give exact results? There are
no easy answers. The standard rules of algebra often do not apply
when using floating-point arithmetic.
Among other things, the distributive and associative laws
@@ -30682,12 +30792,12 @@ for your computation. Rounding error, cumulative precision loss
and underflow are often troublesome.
When @command{gawk} tests the expressions @samp{0.1 + 12.2} and
-@samp{12.3} for equality using the machine double precision arithmetic,
+@samp{12.3} for equality using the machine double-precision arithmetic,
it decides that they are not equal! (@xref{Comparing FP Values}.)
You can get the result you want by increasing the precision; 56 bits in
this case does the job:
-@example
+@example
$ @kbd{gawk -M -v PREC=56 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
@print{} 1
@end example
@@ -30696,7 +30806,7 @@ If adding more bits is good, perhaps adding even more bits of
precision is better?
Here is what happens if we use an even larger value of @code{PREC}:
-@example
+@example
$ @kbd{gawk -M -v PREC=201 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
@print{} 0
@end example
@@ -30705,15 +30815,15 @@ This is not a bug in @command{gawk} or in the MPFR library.
It is easy to forget that the finite number of bits used to store the value
is often just an approximation after proper rounding.
The test for equality succeeds if and only if @emph{all} bits in the two operands
-are exactly the same. Since this is not necessarily true after floating-point
+are exactly the same. Because this is not necessarily true after floating-point
computations with a particular precision and effective rounding mode,
a straight test for equality may not work. Instead, compare the
two numbers to see if they are within the desirable delta of each other.
In applications where 15 or fewer decimal places suffice,
-hardware double precision arithmetic can be adequate, and is usually much faster.
+hardware double-precision arithmetic can be adequate, and is usually much faster.
But you need to keep in mind that every floating-point operation
-can suffer a new rounding error with catastrophic consequences as illustrated
+can suffer a new rounding error with catastrophic consequences, as illustrated
by our earlier attempt to compute the value of @value{PI}.
Extra precision can greatly enhance the stability and the accuracy
of your computation in such cases.
@@ -30737,9 +30847,9 @@ an arbitrarily large value for @code{PREC}. Reformulation of
the problem at hand is often the correct approach in such situations.
@node Try To Round
-@subsection Try A Few Extra Bits of Precision and Rounding
+@subsection Try a Few Extra Bits of Precision and Rounding
-Instead of arbitrary precision floating-point arithmetic,
+Instead of arbitrary-precision floating-point arithmetic,
often all you need is an adjustment of your logic
or a different order for the operations in your calculation.
The stability and the accuracy of the computation of @value{PI}
@@ -30751,7 +30861,7 @@ simple algebraic transformation:
@end example
@noindent
-After making this, change the program converges to
+After making this change, the program converges to
@value{PI} in under 30 iterations:
@example
@@ -30767,7 +30877,7 @@ $ @kbd{gawk -f pi2.awk}
@end example
@node Setting precision
-@subsection Setting The Precision
+@subsection Setting the Precision
@command{gawk} uses a global working precision; it does not keep track of
the precision or accuracy of individual numbers. Performing an arithmetic
@@ -30779,14 +30889,14 @@ shown in @ref{table-predefined-precision-strings},
to emulate an IEEE 754 binary format.
@float Table,table-predefined-precision-strings
-@caption{Predefined Precision Strings For @code{PREC}}
+@caption{Predefined precision strings for @code{PREC}}
@multitable {@code{"double"}} {12345678901234567890123456789012345}
@headitem @code{PREC} @tab IEEE 754 Binary Format
-@item @code{"half"} @tab 16-bit half-precision.
-@item @code{"single"} @tab Basic 32-bit single precision.
-@item @code{"double"} @tab Basic 64-bit double precision.
-@item @code{"quad"} @tab Basic 128-bit quadruple precision.
-@item @code{"oct"} @tab 256-bit octuple precision.
+@item @code{"half"} @tab 16-bit half-precision
+@item @code{"single"} @tab Basic 32-bit single precision
+@item @code{"double"} @tab Basic 64-bit double precision
+@item @code{"quad"} @tab Basic 128-bit quadruple precision
+@item @code{"oct"} @tab 256-bit octuple precision
@end multitable
@end float
@@ -30817,7 +30927,7 @@ differences among various ways to print a floating-point constant:
@example
$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 0.1) @}'}
-@print{} 0.1000000000000000055511151
+@print{} 0.1000000000000000055511151
$ @kbd{gawk -M -v PREC=113 'BEGIN @{ printf("%0.25f\n", 0.1) @}'}
@print{} 0.1000000000000000000000000
$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", "0.1") @}'}
@@ -30827,7 +30937,7 @@ $ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 1/10) @}'}
@end example
@node Setting the rounding mode
-@subsection Setting The Rounding Mode
+@subsection Setting the Rounding Mode
The @code{ROUNDMODE} variable provides
program level control over the rounding mode.
@@ -30835,7 +30945,7 @@ The correspondence between @code{ROUNDMODE} and the IEEE
rounding modes is shown in @ref{table-gawk-rounding-modes}.
@float Table,table-gawk-rounding-modes
-@caption{@command{gawk} Rounding Modes}
+@caption{@command{gawk} rounding modes}
@multitable @columnfractions .45 .30 .25
@headitem Rounding Mode @tab IEEE Name @tab @code{ROUNDMODE}
@item Round to nearest, ties to even @tab @code{roundTiesToEven} @tab @code{"N"} or @code{"n"}
@@ -30850,7 +30960,7 @@ rounding modes is shown in @ref{table-gawk-rounding-modes}.
selects the IEEE 754 rounding mode @code{roundTiesToEven}.
In @ref{table-gawk-rounding-modes}, the value @code{"A"} selects
@code{roundTiesToAway}. This is only available if your version of the
-MPFR library supports it; otherwise setting @code{ROUNDMODE} to @code{"A"}
+MPFR library supports it; otherwise, setting @code{ROUNDMODE} to @code{"A"}
has no effect.
The default mode @code{roundTiesToEven} is the most preferred,
@@ -30921,14 +31031,14 @@ accumulation of round-off error, look for a significant difference in
output when you change the rounding mode to be sure.
@node Arbitrary Precision Integers
-@section Arbitrary Precision Integer Arithmetic with @command{gawk}
+@section Arbitrary-Precision Integer Arithmetic with @command{gawk}
@cindex integers, arbitrary precision
@cindex arbitrary precision integers
When given the @option{-M} option,
-@command{gawk} performs all integer arithmetic using GMP arbitrary
-precision integers. Any number that looks like an integer in a source
-or @value{DF} is stored as an arbitrary precision integer. The size
+@command{gawk} performs all integer arithmetic using GMP arbitrary-precision
+integers. Any number that looks like an integer in a source
+or @value{DF} is stored as an arbitrary-precision integer. The size
of the integer is limited only by the available memory. For example,
the following computes
@iftex
@@ -30943,7 +31053,7 @@ the following computes
5<superscript>4<superscript>3<superscript>2</superscript></superscript></superscript>, @c
@end docbook
the result of which is beyond the
-limits of ordinary hardware double precision floating point values:
+limits of ordinary hardware double-precision floating-point values:
@example
$ @kbd{gawk -M 'BEGIN @{}
@@ -30955,7 +31065,7 @@ $ @kbd{gawk -M 'BEGIN @{}
@print{} 62060698786608744707 ... 92256259918212890625
@end example
-If instead you were to compute the same value using arbitrary precision
+If instead you were to compute the same value using arbitrary-precision
floating-point values, the precision needed for correct output (using
the formula
@iftex
@@ -31000,10 +31110,10 @@ floating-point results exactly. You can either increase the precision
@samp{2.0} with an integer, to perform all computations using integer
arithmetic to get the correct output.
-Sometimes @command{gawk} must implicitly convert an arbitrary precision
-integer into an arbitrary precision floating-point value. This is
+Sometimes @command{gawk} must implicitly convert an arbitrary-precision
+integer into an arbitrary-precision floating-point value. This is
primarily because the MPFR library does not always provide the relevant
-interface to process arbitrary precision integers or mixed-mode numbers
+interface to process arbitrary-precision integers or mixed-mode numbers
as needed by an operation or function. In such a case, the precision is
set to the minimum value necessary for exact conversion, and the working
precision is not used for this purpose. If this is not what you need or
@@ -31021,7 +31131,7 @@ to begin with:
gawk -M 'BEGIN @{ n = 13.0; print n % 2.0 @}'
@end example
-Note that for the particular example above, it is likely best
+Note that for this particular example, it is likely best
to just use the following:
@example
@@ -31043,13 +31153,13 @@ should support additional features. These features are:
@itemize @value{BULLET}
@item
-Interpretation of floating point data values specified in hexadecimal
+Interpretation of floating-point data values specified in hexadecimal
notation (e.g., @code{0xDEADBEEF}). (Note: data values, @emph{not}
source code constants.)
@item
-Support for the special IEEE 754 floating point values ``Not A Number''
-(NaN), positive Infinity (``inf'') and negative Infinity (``@minus{}inf'').
+Support for the special IEEE 754 floating-point values ``Not A Number''
+(NaN), positive Infinity (``inf''), and negative Infinity (``@minus{}inf'').
In particular, the format for these values is as specified by the ISO 1999
C standard, which ignores case and can allow implementation-dependent additional
characters after the @samp{nan} and allow either @samp{inf} or @samp{infinity}.
@@ -31060,8 +31170,8 @@ practice:
@itemize @value{BULLET}
@item
-The @command{gawk} maintainer feels that supporting hexadecimal floating
-point values, in particular, is ugly, and was never intended by the
+The @command{gawk} maintainer feels that supporting hexadecimal
+floating-point values, in particular, is ugly, and was never intended by the
original designers to be part of the language.
@item
@@ -31075,10 +31185,10 @@ interpretation of the standard, which requires a certain amount of
intended by the standard developers. In other words, ``we see how you
got where you are, but we don't think that that's where you want to be.''
-Recognizing the above issues, but attempting to provide compatibility
+Recognizing these issues, but attempting to provide compatibility
with the earlier versions of the standard,
the 2008 POSIX standard added explicit wording to allow, but not require,
-that @command{awk} support hexadecimal floating point values and
+that @command{awk} support hexadecimal floating-point values and
special values for ``Not A Number'' and infinity.
Although the @command{gawk} maintainer continues to feel that
@@ -31135,12 +31245,12 @@ Thus @samp{+nan} and @samp{+NaN} are the same.
@itemize @value{BULLET}
@item
Most computer arithmetic is done using either integers or floating-point
-values. Standard @command{awk} uses double precision
+values. Standard @command{awk} uses double-precision
floating-point values.
@item
-In the early 1990's, Barbie mistakenly said ``Math class is tough!''
-While math isn't tough, floating-point arithmetic isn't the same
+In the early 1990s, Barbie mistakenly said ``Math class is tough!''
+Although math isn't tough, floating-point arithmetic isn't the same
as pencil and paper math, and care must be taken:
@c nested list
@@ -31173,7 +31283,7 @@ arithmetic. Use @code{PREC} to set the precision in bits, and
@item
With @option{-M}, @command{gawk} performs
-arbitrary precision integer arithmetic using the GMP library.
+arbitrary-precision integer arithmetic using the GMP library.
This is faster and more space efficient than using MPFR for
the same calculations.
@@ -31186,7 +31296,7 @@ It pays to be aware of them.
Overall, there is no need to be unduly suspicious about the results from
floating-point arithmetic. The lesson to remember is that floating-point
arithmetic is always more complex than arithmetic using pencil and
-paper. In order to take advantage of the power of computer floating-point,
+paper. In order to take advantage of the power of computer floating point,
you need to know its limitations and work within them. For most casual
use of floating-point arithmetic, you will often get the expected result
if you simply round the display of your final results to the correct number
@@ -31250,8 +31360,8 @@ C library routines that could be of use. As with most software,
``the sky is the limit;'' if you can imagine something that you might
want to do and can write in C or C++, you can write an extension to do it!
-Extensions are written in C or C++, using the @dfn{Application Programming
-Interface} (API) defined for this purpose by the @command{gawk}
+Extensions are written in C or C++, using the @dfn{application programming
+interface} (API) defined for this purpose by the @command{gawk}
developers. The rest of this @value{CHAPTER} explains
the facilities that the API provides and how to use
them, and presents a small example extension. In addition, it documents
@@ -31288,7 +31398,7 @@ int plugin_is_GPL_compatible;
@end example
@node Extension Mechanism Outline
-@section At A High Level How It Works
+@section How It Works at a High Level
Communication between
@command{gawk} and an extension is two-way. First, when an extension
@@ -31303,22 +31413,22 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-load-extension"/>}.
@ifnotdocbook
@float Figure,figure-load-extension
-@caption{Loading The Extension}
+@caption{Loading the extension}
@c FIXME: One day, it should not be necessary to have two cases,
@c but rather just the one without the "txt" final argument.
@c This applies to the other figures as well.
@ifinfo
-@center @image{api-figure1, , , Loading The Extension, txt}
+@center @image{api-figure1, , , Loading the extension, txt}
@end ifinfo
@ifnotinfo
-@center @image{api-figure1, , , Loading The Extension}
+@center @image{api-figure1, , , Loading the extension}
@end ifnotinfo
@end float
@end ifnotdocbook
@docbook
<figure id="figure-load-extension" float="0">
-<title>Loading The Extension</title>
+<title>Loading the extension</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure1.png" format="PNG"/></imageobject>
</mediaobject>
@@ -31338,19 +31448,19 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-register-new-function
@ifnotdocbook
@float Figure,figure-register-new-function
-@caption{Registering A New Function}
+@caption{Registering a new function}
@ifinfo
-@center @image{api-figure2, , , Registering A New Function, txt}
+@center @image{api-figure2, , , Registering a new Function, txt}
@end ifinfo
@ifnotinfo
-@center @image{api-figure2, , , Registering A New Function}
+@center @image{api-figure2, , , Registering a new Function}
@end ifnotinfo
@end float
@end ifnotdocbook
@docbook
<figure id="figure-register-new-function" float="0">
-<title>Registering A New Function</title>
+<title>Registering a new function</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure2.png" format="PNG"/></imageobject>
</mediaobject>
@@ -31371,7 +31481,7 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-call-new-function"/>}
@ifnotdocbook
@float Figure,figure-call-new-function
-@caption{Calling The New Function}
+@caption{Calling the new function}
@ifinfo
@center @image{api-figure3, , , Calling the new function, txt}
@end ifinfo
@@ -31383,7 +31493,7 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-call-new-function"/>}
@docbook
<figure id="figure-call-new-function" float="0">
-<title>Calling The New Function</title>
+<title>Calling the new function</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure3.png" format="PNG"/></imageobject>
</mediaobject>
@@ -31419,10 +31529,9 @@ The API also provides major and minor version numbers, so that an
extension can check if the @command{gawk} it is loaded with supports the
facilities it was compiled with. (Version mismatches ``shouldn't''
happen, but we all know how @emph{that} goes.)
-@xref{Extension Versioning}, for details.
+@DBXREF{Extension Versioning} for details.
@end itemize
-
@node Extension API Description
@section API Description
@cindex extension API
@@ -31464,20 +31573,23 @@ Allocating, reallocating, and releasing memory.
@item
Registration functions. You may register:
+
+@c nested list
@itemize @value{MINUS}
@item
-extension functions,
+Extension functions
@item
-exit callbacks,
+Exit callbacks
@item
-a version string,
+A version string
@item
-input parsers,
+Input parsers
@item
-output wrappers,
+Output wrappers
@item
-and two-way processors.
+Two-way processors
@end itemize
+
All of these are discussed in detail, later in this @value{CHAPTER}.
@item
@@ -31524,7 +31636,7 @@ Some points about using the API:
@itemize @value{BULLET}
@item
-The following types and/or macros and/or functions are referenced
+The following types, macros, and/or functions are referenced
in @file{gawkapi.h}. For correct use, you must therefore include the
corresponding standard header file @emph{before} including @file{gawkapi.h}:
@@ -31538,7 +31650,7 @@ corresponding standard header file @emph{before} including @file{gawkapi.h}:
@item @code{memset()} @tab @code{<string.h>}
@item @code{size_t} @tab @code{<sys/types.h>}
@item @code{struct stat} @tab @code{<sys/stat.h>}
-@end multitable
+@end multitable
Due to portability concerns, especially to systems that are not
fully standards-compliant, it is your responsibility
@@ -31570,7 +31682,7 @@ and is managed by @command{gawk} from then on.
The API defines several simple @code{struct}s that map values as seen
from @command{awk}. A value can be a @code{double}, a string, or an
array (as in multidimensional arrays, or when creating a new array).
-String values maintain both pointer and length since embedded @sc{nul}
+String values maintain both pointer and length, because embedded @sc{nul}
characters are allowed.
@quotation NOTE
@@ -31595,14 +31707,14 @@ so that the extension can, e.g., print an error message
@c The table there should be presented here
@end itemize
-While you may call the API functions by using the function pointers
-directly, the interface is not so pretty. To make extension code look
+You may call the API functions by using the function pointers
+directly, but the interface is not so pretty. To make extension code look
more like regular code, the @file{gawkapi.h} header file defines several
macros that you should use in your code. This @value{SECTION} presents
the macros as if they were functions.
@node General Data Types
-@subsection General Purpose Data Types
+@subsection General-Purpose Data Types
@cindex Robbins, Arnold
@cindex Ramey, Chet
@@ -31617,9 +31729,10 @@ can accommodate both love and hate.}
@author Chet Ramey
@end quotation
-The extension API defines a number of simple types and structures for general
-purpose use. Additional, more specialized, data structures are introduced
-in subsequent @value{SECTION}s, together with the functions that use them.
+The extension API defines a number of simple types and structures for
+general-purpose use. Additional, more specialized, data structures are
+introduced in subsequent @value{SECTION}s, together with the functions
+that use them.
@table @code
@item typedef void *awk_ext_id_t;
@@ -31646,8 +31759,9 @@ A simple boolean type.
This represents a mutable string. @command{gawk}
owns the memory pointed to if it supplied
the value. Otherwise, it takes ownership of the memory pointed to.
-@strong{Such memory must come from calling one of the
-@code{gawk_malloc()}, @code{gawk_calloc()}, or @code{gawk_realloc()} functions!}
+@emph{Such memory must come from calling one of the
+@code{gawk_malloc()}, @code{gawk_calloc()}, or
+@code{gawk_realloc()} functions!}
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -31673,7 +31787,7 @@ It is used in the following @code{struct}.
@itemx @ @ @ @ @ @ @ @ awk_value_cookie_t@ vc;
@itemx @ @ @ @ @} u;
@itemx @} awk_value_t;
-An ``@command{awk} value.''
+An ``@command{awk} value.''
The @code{val_type} member indicates what kind of value the
@code{union} holds, and each member is of the appropriate type.
@@ -31686,13 +31800,14 @@ These macros make accessing the fields of the @code{awk_value_t} more
readable.
@item typedef void *awk_scalar_t;
-Scalars can be represented as an opaque type. These values are obtained from
-@command{gawk} and then passed back into it. This is discussed in a general fashion below,
-and in more detail in @ref{Symbol table by cookie}.
+Scalars can be represented as an opaque type. These values are obtained
+from @command{gawk} and then passed back into it. This is discussed
+in a general fashion in the text following this list, and in more detail in
+@ref{Symbol table by cookie}.
@item typedef void *awk_value_cookie_t;
A ``value cookie'' is an opaque type representing a cached value.
-This is also discussed in a general fashion below,
+This is also discussed in a general fashion in the text following this list,
and in more detail in @ref{Cached values}.
@end table
@@ -31702,7 +31817,7 @@ Scalar values in @command{awk} are either numbers or strings. The
indicates what is in the @code{union}.
Representing numbers is easy---the API uses a C @code{double}. Strings
-require more work. Since @command{gawk} allows embedded @sc{nul} bytes
+require more work. Because @command{gawk} allows embedded @sc{nul} bytes
in string values, a string must be represented as a pair containing a
data-pointer and length. This is the @code{awk_string_t} type.
@@ -31715,13 +31830,13 @@ itself be an array. Discussion of arrays is delayed until
The various macros listed earlier make it easier to use the elements
of the @code{union} as if they were fields in a @code{struct}; this
is a common coding practice in C. Such code is easier to write and to
-read, however it remains @emph{your} responsibility to make sure that
+read, but it remains @emph{your} responsibility to make sure that
the @code{val_type} member correctly reflects the type of the value in
the @code{awk_value_t}.
Conceptually, the first three members of the @code{union} (number, string,
and array) are all that is needed for working with @command{awk} values.
-However, since the API provides routines for accessing and changing
+However, because the API provides routines for accessing and changing
the value of global scalar variables only by using the variable's name,
there is a performance penalty: @command{gawk} must find the variable
each time it is accessed and changed. This turns out to be a real issue,
@@ -31761,7 +31876,7 @@ The API provides a number of @dfn{memory allocation} functions for
allocating memory that can be passed to @command{gawk}, as well as a number of
convenience macros.
This @value{SUBSECTION} presents them all as function prototypes, in
-the way that extension code would use them.
+the way that extension code would use them:
@table @code
@item void *gawk_malloc(size_t size);
@@ -31806,7 +31921,8 @@ The arguments to this macro are as follows:
The pointer variable to point at the allocated storage.
@item type
-The type of the pointer variable, used to create a cast for the call to @code{gawk_malloc()}.
+The type of the pointer variable. This is used to create a cast for
+the call to @code{gawk_malloc()}.
@item size
The total number of bytes to be allocated.
@@ -31841,7 +31957,7 @@ The arguments are the same as for the @code{emalloc()} macro.
The API provides a number of @dfn{constructor} functions for creating
string and numeric values, as well as a number of convenience macros.
This @value{SUBSECTION} presents them all as function prototypes, in
-the way that extension code would use them.
+the way that extension code would use them:
@table @code
@item static inline awk_value_t *
@@ -31920,8 +32036,8 @@ This is a pointer to the C function that provides the extension's
functionality.
The function must fill in @code{*result} with either a number
or a string. @command{gawk} takes ownership of any string memory.
-As mentioned earlier, string memory @strong{must} come from one of @code{gawk_malloc()},
-@code{gawk_calloc()} or @code{gawk_realloc()}.
+As mentioned earlier, string memory @strong{must} come from one of
+@code{gawk_malloc()}, @code{gawk_calloc()}, or @code{gawk_realloc()}.
The @code{num_actual_args} argument tells the C function how many
actual parameters were passed from the calling @command{awk} code.
@@ -31956,7 +32072,7 @@ Such functions are useful if you have general ``cleanup'' tasks
that should be performed in your extension (such as closing database
connections or other resource deallocations).
You can register such
-a function with @command{gawk} using the following function.
+a function with @command{gawk} using the following function:
@table @code
@item void awk_atexit(void (*funcp)(void *data, int exit_status),
@@ -31977,8 +32093,9 @@ the function pointed to by @code{funcp}.
@end table
@end table
-Exit callback functions are called in Last-In-First-Out (LIFO) order---that is, in
-the reverse order in which they are registered with @command{gawk}.
+Exit callback functions are called in last-in-first-out (LIFO)
+order---that is, in the reverse order in which they are registered with
+@command{gawk}.
@node Extension Version String
@subsubsection Registering An Extension Version String
@@ -31989,7 +32106,7 @@ version of your extension, with @command{gawk}, as follows:
@table @code
@item void register_ext_version(const char *version);
Register the string pointed to by @code{version} with @command{gawk}.
-@command{gawk} does @emph{not} copy the @code{version} string, so
+Note that @command{gawk} does @emph{not} copy the @code{version} string, so
it should not be changed.
@end table
@@ -32071,7 +32188,7 @@ appropriately.
@item
When your extension is loaded, register your input parser with
@command{gawk} using the @code{register_input_parser()} API function
-(described below).
+(described next).
@end enumerate
An @code{awk_input_buf_t} looks like this:
@@ -32101,7 +32218,7 @@ The name of the file.
@item int fd;
A file descriptor for the file. If @command{gawk} was able to
-open the file, then @code{fd} will @emph{not} be equal to
+open the file, then @code{fd} will @emph{not} be equal to
@code{INVALID_HANDLE}. Otherwise, it will.
@item struct stat sbuf;
@@ -32115,15 +32232,15 @@ The decision can be made based upon @command{gawk} state (the value
of a variable defined previously by the extension and set by
@command{awk} code), the name of the
file, whether or not the file descriptor is valid, the information
-in the @code{struct stat}, or any combination of the above.
+in the @code{struct stat}, or any combination of these factors.
Once @code{@var{XXX}_can_take_file()} has returned true, and
@command{gawk} has decided to use your input parser, it calls
@code{@var{XXX}_take_control_of()}. That function then fills one of
either the @code{get_record} field or the @code{read_func} field in
the @code{awk_input_buf_t}. It must also ensure that @code{fd} is @emph{not}
-set to @code{INVALID_HANDLE}. All of the fields that may be filled by
-@code{@var{XXX}_take_control_of()} are as follows:
+set to @code{INVALID_HANDLE}. The following list describes the fields that
+may be filled by @code{@var{XXX}_take_control_of()}:
@table @code
@item void *opaque;
@@ -32138,13 +32255,13 @@ is not required to use this pointer.
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ size_t *rt_len);
This function pointer should point to a function that creates the input
records. Said function is the core of the input parser. Its behavior
-is described below.
+is described in the text following this list.
@item ssize_t (*read_func)();
This function pointer should point to function that has the
same behavior as the standard POSIX @code{read()} system call.
It is an alternative to the @code{get_record} pointer. Its behavior
-is also described below.
+is also described in the text following this list.
@item void (*close_func)(struct awk_input *iobuf);
This function pointer should point to a function that does
@@ -32282,7 +32399,7 @@ values, etc.) within @command{gawk}.
The function pointed to by this field is called when @command{gawk}
decides to let the output wrapper take control of the file. It should
fill in appropriate members of the @code{awk_output_buf_t} structure,
-as described below, and return true if successful, false otherwise.
+as described next, and return true if successful, false otherwise.
@item awk_const struct output_wrapper *awk_const next;
This is for use by @command{gawk};
@@ -32425,9 +32542,9 @@ Register the two-way processor pointed to by @code{two_way_processor} with
@cindex messages from extensions
You can print different kinds of warning messages from your
-extension, as described below. Note that for these functions,
+extension, as described here. Note that for these functions,
you must pass in the extension id received from @command{gawk}
-when the extension was loaded.@footnote{Because the API uses only ISO C 90
+when the extension was loaded:@footnote{Because the API uses only ISO C 90
features, it cannot make use of the ISO C 99 variadic macro feature to hide
that parameter. More's the pity.}
@@ -32484,7 +32601,7 @@ value type, as appropriate. This behavior is summarized in
@ref{table-value-types-returned}.
@float Table,table-value-types-returned
-@caption{API Value Types Returned}
+@caption{API value types returned}
@docbook
<informaltable>
<tgroup cols="6">
@@ -32496,7 +32613,7 @@ value type, as appropriate. This behavior is summarized in
<colspec colwidth="16.6*" colname="c6"/>
<spanspec spanname="hspan" namest="c3" nameend="c6" align="center"/>
<thead>
- <row><entry></entry><entry spanname="hspan"><para>Type of Actual Value:</para></entry></row>
+ <row><entry></entry><entry spanname="hspan"><para>Type of Actual Value</para></entry></row>
<row>
<entry></entry>
<entry></entry>
@@ -32532,7 +32649,7 @@ value type, as appropriate. This behavior is summarized in
<entry><para>false</para></entry>
</row>
<row>
- <entry><para><emphasis role="bold">Requested:</emphasis></para></entry>
+ <entry><para><emphasis role="bold">Requested</emphasis></para></entry>
<entry><para><emphasis role="bold">Scalar</emphasis></para></entry>
<entry><para>Scalar</para></entry>
<entry><para>Scalar</para></entry>
@@ -32563,7 +32680,7 @@ value type, as appropriate. This behavior is summarized in
@ifnotplaintext
@ifnotdocbook
@multitable @columnfractions .50 .50
-@headitem @tab Type of Actual Value:
+@headitem @tab Type of Actual Value
@end multitable
@c 10/2014: Thanks to Karl Berry for this bit to reduce the space:
@tex
@@ -32574,7 +32691,7 @@ value type, as appropriate. This behavior is summarized in
@item @tab @b{String} @tab String @tab String @tab false @tab false
@item @tab @b{Number} @tab Number if can be converted, else false @tab Number @tab false @tab false
@item @b{Type} @tab @b{Array} @tab false @tab false @tab Array @tab false
-@item @b{Requested:} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
+@item @b{Requested} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
@item @tab @b{Undefined} @tab String @tab Number @tab Array @tab Undefined
@item @tab @b{Value Cookie} @tab false @tab false @tab false @tab false
@end multitable
@@ -32628,7 +32745,7 @@ indicates the type of value expected.
@item awk_bool_t set_argument(size_t count, awk_array_t array);
Convert a parameter that was undefined into an array; this provides
call-by-reference for arrays. Return false if @code{count} is too big,
-or if the argument's type is not undefined. @xref{Array Manipulation},
+or if the argument's type is not undefined. @DBXREF{Array Manipulation}
for more information on creating arrays.
@end table
@@ -32683,7 +32800,7 @@ cannot change any of those variables.
@quotation CAUTION
It is possible for the lookup of @code{PROCINFO} to fail. This happens if
the @command{awk} program being run does not reference @code{PROCINFO};
-in this case @command{gawk} doesn't bother to create the array and
+in this case, @command{gawk} doesn't bother to create the array and
populate it.
@end quotation
@@ -32693,9 +32810,9 @@ populate it.
A @dfn{scalar cookie} is an opaque handle that provides access
to a global variable or array. It is an optimization that
avoids looking up variables in @command{gawk}'s symbol table every time
-access is needed. This was discussed earlier, in @ref{General Data Types}.
+access is needed. This was discussed earlier in @ref{General Data Types}.
-The following functions let you work with scalar cookies.
+The following functions let you work with scalar cookies:
@table @code
@item awk_bool_t sym_lookup_scalar(awk_scalar_t cookie,
@@ -32740,18 +32857,21 @@ do_magic(int nargs, awk_value_t *result)
@noindent
This code looks (and is) simple and straightforward. So what's the problem?
-Consider what happens if @command{awk}-level code associated with your
-extension calls the @code{magic()} function (implemented in C by @code{do_magic()}),
-once per record, while processing hundreds of thousands or millions of records.
-The @code{MAGIC_VAR} variable is looked up in the symbol table once or twice per function call!
+Well, consider what happens if @command{awk}-level code associated
+with your extension calls the @code{magic()} function (implemented in
+C by @code{do_magic()}), once per record, while processing hundreds
+of thousands or millions of records. The @code{MAGIC_VAR} variable is
+looked up in the symbol table once or twice per function call!
-The symbol table lookup is really pure overhead; it is considerably more efficient
-to get a cookie that represents the variable, and use that to get the variable's
-value and update it as needed.@footnote{The difference is measurable and quite real. Trust us.}
+The symbol table lookup is really pure overhead; it is considerably
+more efficient to get a cookie that represents the variable, and use
+that to get the variable's value and update it as needed.@footnote{The
+difference is measurable and quite real. Trust us.}
-Thus, the way to use cookies is as follows. First, install your extension's variable
-in @command{gawk}'s symbol table using @code{sym_update()}, as usual. Then get a
-scalar cookie for the variable using @code{sym_lookup()}:
+Thus, the way to use cookies is as follows. First, install
+your extension's variable in @command{gawk}'s symbol table using
+@code{sym_update()}, as usual. Then get a scalar cookie for the variable
+using @code{sym_lookup()}:
@example
static awk_scalar_t magic_var_cookie; /* cookie for MAGIC_VAR */
@@ -32814,7 +32934,7 @@ or @code{sym_update_scalar()}, as you like.
However, you can understand the point of cached values if you remember that
@emph{every} string value's storage @emph{must} come from @code{gawk_malloc()},
-@code{gawk_calloc()} or @code{gawk_realloc()}.
+@code{gawk_calloc()}, or @code{gawk_realloc()}.
If you have 20 variables, all of which have the same string value, you
must create 20 identical copies of the string.@footnote{Numeric values
are clearly less problematic, requiring only a C @code{double} to store.}
@@ -32825,11 +32945,11 @@ is what the routines in this section let you do. The functions are as follows:
@table @code
@item awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);
-Create a cached string or numeric value from @code{value} for efficient later
-assignment.
-Only values of type @code{AWK_NUMBER} and @code{AWK_STRING} are allowed. Any other type
-is rejected. While @code{AWK_UNDEFINED} could be allowed, doing so would
-result in inferior performance.
+Create a cached string or numeric value from @code{value} for
+efficient later assignment. Only values of type @code{AWK_NUMBER}
+and @code{AWK_STRING} are allowed. Any other type is rejected.
+@code{AWK_UNDEFINED} could be allowed, but doing so would result in
+inferior performance.
@item awk_bool_t release_value(awk_value_cookie_t vc);
Release the memory associated with a value cookie obtained
@@ -32850,7 +32970,7 @@ my_extension_init()
size_t long_string_len;
/* code from earlier */
- @dots{}
+ @dots{}
/* @dots{} fill in long_string and long_string_len @dots{} */
make_malloced_string(long_string, long_string_len, & value);
create_value(& value, & answer_cookie); /* create cookie */
@@ -32880,7 +33000,7 @@ do_magic(int nargs, awk_value_t *result)
@end example
@noindent
-Using value cookies in this way saves considerable storage, since all of
+Using value cookies in this way saves considerable storage, as all of
@code{VAR1} through @code{VAR100} share the same value.
You might be wondering, ``Is this sharing problematic?
@@ -32902,7 +33022,7 @@ you should release any cached values that you created, using
@subsection Array Manipulation
@cindex array manipulation in extensions
-The primary data structure@footnote{Okay, the only data structure.} in @command{awk}
+The primary data structure@footnote{OK, the only data structure.} in @command{awk}
is the associative array (@pxref{Arrays}).
Extensions need to be able to manipulate @command{awk} arrays.
The API provides a number of data structures for working with arrays,
@@ -32923,7 +33043,7 @@ both work with and create true arrays of arrays (@pxref{General Data Types}).
@node Array Data Types
@subsubsection Array Data Types
-The data types associated with arrays are listed below.
+The data types associated with arrays are as follows:
@table @code
@item typedef void *awk_array_t;
@@ -33042,7 +33162,7 @@ The following functions relate to arrays as a whole:
@table @code
@item awk_array_t create_array(void);
Create a new array to which elements may be added.
-@xref{Creating Arrays}, for a discussion of how to
+@DBXREF{Creating Arrays} for a discussion of how to
create a new array and add elements to it.
@item awk_bool_t clear_array(awk_array_t a_cookie);
@@ -33077,7 +33197,7 @@ The function returns true upon success, false otherwise.
@node Flattening Arrays
@subsubsection Working With All The Elements of an Array
-To @dfn{flatten} an array is create a structure that
+To @dfn{flatten} an array is to create a structure that
represents the full array in a fashion that makes it easy
for C code to traverse the entire array. Test code
in @file{extension/testext.c} does this, and also serves
@@ -33245,7 +33365,7 @@ code) once you have called @code{release_flattened_array()}:
@}
@end example
-Finally, since everything was successful, the function sets the
+Finally, because everything was successful, the function sets the
return value to success, and returns:
@example
@@ -33280,7 +33400,7 @@ code can access them and manipulate them.
There are two important points about creating arrays from extension code:
-@enumerate 1
+@itemize @value{BULLET}
@item
You must install a new array into @command{gawk}'s symbol
table immediately upon creating it. Once you have done so,
@@ -33322,7 +33442,7 @@ new_array = val.array_cookie; /* YOU MUST DO THIS */
If installing an array as a subarray, you must also retrieve the value
of the array cookie after the call to @code{set_element()}.
-@end enumerate
+@end itemize
The following C code is a simple test extension to create an array
with two regular elements and with a subarray. The leading @code{#include}
@@ -33441,7 +33561,7 @@ dl_load_func(func_table, testarray, "")
@end ignore
@end example
-Here is sample script that loads the extension
+Here is a sample script that loads the extension
and then dumps the array:
@example
@@ -33471,7 +33591,7 @@ $ @kbd{AWKLIBPATH=$PWD ./gawk -f subarray.awk}
@end example
@noindent
-(@xref{Finding Extensions}, for more information on the
+(@DBXREF{Finding Extensions} for more information on the
@env{AWKLIBPATH} environment variable.)
@node Extension API Variables
@@ -33583,8 +33703,8 @@ The others should not change during execution.
As mentioned earlier (@pxref{Extension Mechanism Outline}), the function
definitions as presented are really macros. To use these macros, your
extension must provide a small amount of boilerplate code (variables and
-functions) towards the top of your source file, using pre-defined names
-as described below. The boilerplate needed is also provided in comments
+functions) toward the top of your source file, using predefined names
+as described here. The boilerplate needed is also provided in comments
in the @file{gawkapi.h} header file:
@example
@@ -33672,7 +33792,7 @@ This macro expands to a @code{dl_load()} function that performs
all the necessary initializations.
@end table
-The point of the all the variables and arrays is to let the
+The point of all the variables and arrays is to let the
@code{dl_load()} function (from the @code{dl_load_func()}
macro) do all the standard work. It does the following:
@@ -33707,7 +33827,7 @@ Compiled extensions have to be installed in a directory where
built in the default fashion, the directory in which to find
extensions is @file{/usr/local/lib/gawk}. You can also specify a search
path with a list of directories to search for compiled extensions.
-@xref{AWKLIBPATH Variable}, for more information.
+@DBXREF{AWKLIBPATH Variable} for more information.
@node Extension Example
@section Example: Some File Functions
@@ -33715,7 +33835,7 @@ path with a list of directories to search for compiled extensions.
@quotation
@i{No matter where you go, there you are.}
-@author Buckaroo Bonzai
+@author Buckaroo Banzai
@end quotation
@c It's enough to show chdir and stat, no need for fts
@@ -33888,9 +34008,9 @@ in the @command{gawk} distribution for the complete version.}
The file includes a number of standard header files, and then includes
the @file{gawkapi.h} header file which provides the API definitions.
-Those are followed by the necessary variable declarations
+Those are followed by the necessary variable declarations
to make use of the API macros and boilerplate code
-(@pxref{Extension API Boilerplate}).
+(@pxref{Extension API Boilerplate}):
@example
#ifdef HAVE_CONFIG_H
@@ -33931,7 +34051,7 @@ that implements it is called @code{do_foo()}. The function should have
two arguments: the first is an @code{int} usually called @code{nargs},
that represents the number of actual arguments for the function.
The second is a pointer to an @code{awk_value_t}, usually named
-@code{result}.
+@code{result}:
@example
/* do_chdir --- provide dynamically loaded chdir() function for gawk */
@@ -33951,13 +34071,13 @@ do_chdir(int nargs, awk_value_t *result)
@end example
The @code{newdir}
-variable represents the new directory to change to, retrieved
+variable represents the new directory to change to, which is retrieved
with @code{get_argument()}. Note that the first argument is
numbered zero.
If the argument is retrieved successfully, the function calls the
@code{chdir()} system call. If the @code{chdir()} fails, @code{ERRNO}
-is updated.
+is updated:
@example
if (get_argument(0, AWK_STRING, & newdir)) @{
@@ -34158,7 +34278,7 @@ of @code{stat()}) to get the file information, in case the file is a
symbolic link. However, if there were three arguments, @code{statfunc}
is set point to @code{stat()}, instead.
-Here is the @code{do_stat()} function. It starts with
+Here is the @code{do_stat()} function, which starts with
variable declarations and argument checking:
@ignore
@@ -34273,7 +34393,7 @@ dl_load_func(func_table, filefuncs, "")
And that's it!
@node Using Internal File Ops
-@subsection Integrating The Extensions
+@subsection Integrating the Extensions
@cindex @command{gawk}, interpreter@comma{} adding code to
Now that the code is written, it must be possible to add it at
@@ -34282,9 +34402,9 @@ code must be compiled. Assuming that the functions are in
a file named @file{filefuncs.c}, and @var{idir} is the location
of the @file{gawkapi.h} header file,
the following steps@footnote{In practice, you would probably want to
-use the GNU Autotools---Automake, Autoconf, Libtool, and @command{gettext}---to
+use the GNU Autotools (Automake, Autoconf, Libtool, and @command{gettext}) to
configure and build your libraries. Instructions for doing so are beyond
-the scope of this @value{DOCUMENT}. @xref{gawkextlib}, for Internet links to
+the scope of this @value{DOCUMENT}. @DBXREF{gawkextlib} for Internet links to
the tools.} create a GNU/Linux shared library:
@example
@@ -34292,7 +34412,7 @@ $ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -I@var{idir} filefuncs.c}
$ @kbd{gcc -o filefuncs.so -shared filefuncs.o}
@end example
-Once the library exists, it is loaded by using the @code{@@load} keyword.
+Once the library exists, it is loaded by using the @code{@@load} keyword:
@example
# file testff.awk
@@ -34356,13 +34476,14 @@ $ @kbd{AWKLIBPATH=$PWD gawk -f testff.awk}
@end example
@node Extension Samples
-@section The Sample Extensions In The @command{gawk} Distribution
+@section The Sample Extensions in the @command{gawk} Distribution
@cindex extensions distributed with @command{gawk}
This @value{SECTION} provides brief overviews of the sample extensions
that come in the @command{gawk} distribution. Some of them are intended
-for production use, such the @code{filefuncs}, @code{readdir} and @code{inplace} extensions.
-Others mainly provide example code that shows how to use the extension API.
+for production use (e.g., the @code{filefuncs}, @code{readdir} and
+@code{inplace} extensions). Others mainly provide example code that
+shows how to use the extension API.
@menu
* Extension Sample File Functions:: The file functions sample.
@@ -34383,9 +34504,9 @@ Others mainly provide example code that shows how to use the extension API.
@end menu
@node Extension Sample File Functions
-@subsection File Related Functions
+@subsection File-Related Functions
-The @code{filefuncs} extension provides three different functions, as follows:
+The @code{filefuncs} extension provides three different functions, as follows.
The usage is:
@table @asis
@@ -34396,7 +34517,7 @@ This is how you load the extension.
@item @code{result = chdir("/some/directory")}
The @code{chdir()} function is a direct hook to the @code{chdir()}
system call to change the current directory. It returns zero
-upon success or less than zero upon error. In the latter case it updates
+upon success or less than zero upon error. In the latter case, it updates
@code{ERRNO}.
@cindex @code{stat()} extension function
@@ -34404,7 +34525,7 @@ upon success or less than zero upon error. In the latter case it updates
The @code{stat()} function provides a hook into the
@code{stat()} system call.
It returns zero upon success or less than zero upon error.
-In the latter case it updates @code{ERRNO}.
+In the latter case, it updates @code{ERRNO}.
By default, it uses the @code{lstat()} system call. However, if passed
a third argument, it uses @code{stat()} instead.
@@ -34451,8 +34572,8 @@ Not all systems support all file types. @tab All
@item @code{flags = or(FTS_PHYSICAL, ...)}
@itemx @code{result = fts(pathlist, flags, filedata)}
Walk the file trees provided in @code{pathlist} and fill in the
-@code{filedata} array as described below. @code{flags} is the bitwise
-OR of several predefined values, also described below.
+@code{filedata} array as described next. @code{flags} is the bitwise
+OR of several predefined values, also described in a moment.
Return zero if there were no errors, otherwise return @minus{}1.
@end table
@@ -34500,7 +34621,7 @@ whether or not @code{FTS_LOGICAL} is set.
By default, the C library @code{fts()} routines do not return entries for
@file{.} (dot) and @file{..} (dot-dot). This option causes entries for
dot-dot to also be included. (The extension always includes an entry
-for dot, see below.)
+for dot; more on this in a moment.)
@item FTS_XDEV
During a traversal, do not cross onto a different mounted filesystem.
@@ -34510,7 +34631,7 @@ During a traversal, do not cross onto a different mounted filesystem.
The @code{filedata} array is first cleared. Then, @code{fts()} creates
an element in @code{filedata} for every element in @code{pathlist}.
The index is the name of the directory or file given in @code{pathlist}.
-The element for this index is itself an array. There are two cases.
+The element for this index is itself an array. There are two cases:
@c nested table
@table @emph
@@ -34536,8 +34657,8 @@ contain an element named @code{"error"}, which is a string describing the error.
@item The path is a directory
In this case, the array contains one element for each entry in the
-directory. If an entry is a file, that element is as for files, just
-described. If the entry is a directory, that element is (recursively),
+directory. If an entry is a file, that element is the same as for files, just
+described. If the entry is a directory, that element is (recursively)
an array describing the subdirectory. If @code{FTS_SEEDOT} was provided
in the flags, then there will also be an element named @code{".."}. This
element will be an array containing the data as provided by @code{stat()}.
@@ -34556,8 +34677,8 @@ The @code{fts()} extension does not exactly mimic the
interface of the C library @code{fts()} routines, choosing instead to
provide an interface that is based on associative arrays, which is
more comfortable to use from an @command{awk} program. This includes the
-lack of a comparison function, since @command{gawk} already provides
-powerful array sorting facilities. While an @code{fts_read()}-like
+lack of a comparison function, because @command{gawk} already provides
+powerful array sorting facilities. Although an @code{fts_read()}-like
interface could have been provided, this felt less natural than simply
creating a multidimensional array to represent the file hierarchy and
its information.
@@ -34567,7 +34688,7 @@ See @file{test/fts.awk} in the @command{gawk} distribution for an example
use of the @code{fts()} extension function.
@node Extension Sample Fnmatch
-@subsection Interface To @code{fnmatch()}
+@subsection Interface to @code{fnmatch()}
This extension provides an interface to the C library
@code{fnmatch()} function. The usage is:
@@ -34580,10 +34701,10 @@ This is how you load the extension.
@item result = fnmatch(pattern, string, flags)
The return value is zero on success, @code{FNM_NOMATCH}
if the string did not match the pattern, or
-a different non-zero value if an error occurred.
+a different nonzero value if an error occurred.
@end table
-Besides the @code{fnmatch()} function, the @code{fnmatch} extension
+In addition to the @code{fnmatch()} function, the @code{fnmatch} extension
adds one constant (@code{FNM_NOMATCH}), and an array of flag values
named @code{FNM}.
@@ -34601,7 +34722,7 @@ Either zero, or the bitwise OR of one or more of the
flags in the @code{FNM} array.
@end table
-The flags are follows:
+The flags are as follows:
@multitable @columnfractions .25 .75
@headitem Array element @tab Corresponding flag defined by @code{fnmatch()}
@@ -34624,9 +34745,9 @@ if (fnmatch("*.a", "foo.c", flags) == FNM_NOMATCH)
@end example
@node Extension Sample Fork
-@subsection Interface To @code{fork()}, @code{wait()} and @code{waitpid()}
+@subsection Interface to @code{fork()}, @code{wait()}, and @code{waitpid()}
-The @code{fork} extension adds three functions, as follows.
+The @code{fork} extension adds three functions, as follows:
@table @code
@item @@load "fork"
@@ -34724,7 +34845,7 @@ $ @kbd{gawk -i inplace -v INPLACE_SUFFIX=.bak '@{ gsub(/foo/, "bar") @}}
@subsection Character and Numeric values: @code{ord()} and @code{chr()}
The @code{ordchr} extension adds two functions, named
-@code{ord()} and @code{chr()}, as follows.
+@code{ord()} and @code{chr()}, as follows:
@table @code
@item @@load "ordchr"
@@ -34772,7 +34893,7 @@ indicating the type of the file. The letters and their corresponding file
types are shown in @ref{table-readdir-file-types}.
@float Table,table-readdir-file-types
-@caption{File Types Returned By The @code{readdir} Extension}
+@caption{File types returned by the @code{readdir} extension}
@multitable @columnfractions .1 .9
@headitem Letter @tab File Type
@item @code{b} @tab Block device
@@ -34809,7 +34930,7 @@ BEGIN @{ FS = "/" @}
@subsection Reversing Output
The @code{revoutput} extension adds a simple output wrapper that reverses
-the characters in each output line. It's main purpose is to show how to
+the characters in each output line. Its main purpose is to show how to
write an output wrapper, although it may be mildly amusing for the unwary.
Here is an example:
@@ -34831,7 +34952,7 @@ The output from this program is:
The @code{revtwoway} extension adds a simple two-way processor that
reverses the characters in each line sent to it for reading back by
-the @command{awk} program. It's main purpose is to show how to write
+the @command{awk} program. Its main purpose is to show how to write
a two-way processor, although it may also be mildly amusing.
The following example shows how to use it:
@@ -34858,7 +34979,7 @@ is:
@samp{cinap t'nod}.
@node Extension Sample Read write array
-@subsection Dumping and Restoring An Array
+@subsection Dumping and Restoring an Array
The @code{rwarray} extension adds two functions,
named @code{writea()} and @code{reada()}, as follows:
@@ -34884,7 +35005,7 @@ Here too, the return value is one on success and zero upon failure.
The array created by @code{reada()} is identical to that written by
@code{writea()} in the sense that the contents are the same. However,
-due to implementation issues, the array traversal order of the recreated
+due to implementation issues, the array traversal order of the re-created
array is likely to be different from that of the original array. As array
traversal order in @command{awk} is by default undefined, this is (technically)
not a problem. If you need to guarantee a particular traversal
@@ -34892,7 +35013,7 @@ order, use the array sorting features in @command{gawk} to do so
(@pxref{Array Sorting}).
The file contains binary data. All integral values are written in network
-byte order. However, double precision floating-point values are written
+byte order. However, double-precision floating-point values are written
as native binary data. Thus, arrays containing only string data can
theoretically be dumped on systems with one byte order and restored on
systems with a different one, but this has not been tried.
@@ -34908,7 +35029,7 @@ ret = reada("arraydump.bin", array)
@end example
@node Extension Sample Readfile
-@subsection Reading An Entire File
+@subsection Reading an Entire File
The @code{readfile} extension adds a single function
named @code{readfile()}, and an input parser:
@@ -34955,7 +35076,7 @@ This is how you load the extension.
@cindex @code{gettimeofday()} extension function
@item the_time = gettimeofday()
Return the time in seconds that has elapsed since 1970-01-01 UTC as a
-floating point value. If the time is unavailable on this platform, return
+floating-point value. If the time is unavailable on this platform, return
@minus{}1 and set @code{ERRNO}. The returned time should have sub-second
precision, but the actual precision may vary based on the platform.
If the standard C @code{gettimeofday()} system call is available on this
@@ -34998,22 +35119,22 @@ As of this writing, there are five extensions:
@itemize @value{BULLET}
@item
-GD graphics library extension.
+GD graphics library extension
@item
-PDF extension.
+PDF extension
@item
-PostgreSQL extension.
+PostgreSQL extension
@item
-MPFR library extension.
-This provides access to a number of MPFR functions which @command{gawk}'s
-native MPFR support does not.
+MPFR library extension
+(this provides access to a number of MPFR functions which @command{gawk}'s
+native MPFR support does not)
@item
XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
-XML parsing library.
+XML parsing library
@end itemize
@cindex @command{git} utility
@@ -35064,9 +35185,9 @@ to install both @command{gawk} and @code{gawkextlib}, depending upon
how your system works.
If you write an extension that you wish to share with other
-@command{gawk} users, please consider doing so through the
+@command{gawk} users, consider doing so through the
@code{gawkextlib} project.
-See the project's web site for more information.
+See the project's website for more information.
@node Extension summary
@section Summary
@@ -35074,7 +35195,7 @@ See the project's web site for more information.
@itemize @value{BULLET}
@item
You can write extensions (sometimes called plug-ins) for @command{gawk}
-in C or C++ using the Application Programming Interface (API) defined
+in C or C++ using the application programming interface (API) defined
by the @command{gawk} developers.
@item
@@ -35105,44 +35226,44 @@ API function pointers are provided for the following kinds of operations:
@itemize @value{BULLET}
@item
-Allocating, reallocating, and releasing memory.
+Allocating, reallocating, and releasing memory
@item
-Registration functions. You may register
+Registration functions (you may register
extension functions,
exit callbacks,
a version string,
input parsers,
output wrappers,
-and two-way processors.
+and two-way processors)
@item
-Printing fatal, warning, and ``lint'' warning messages.
+Printing fatal, warning, and ``lint'' warning messages
@item
-Updating @code{ERRNO}, or unsetting it.
+Updating @code{ERRNO}, or unsetting it
@item
Accessing parameters, including converting an undefined parameter into
-an array.
+an array
@item
-Symbol table access: retrieving a global variable, creating one,
-or changing one.
+Symbol table access (retrieving a global variable, creating one,
+or changing one)
@item
Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and
-can be a big performance win.
+can be a big performance win
@item
-Manipulating arrays:
-retrieving, adding, deleting, and modifying elements;
+Manipulating arrays
+(retrieving, adding, deleting, and modifying elements;
getting the count of elements in an array;
creating a new array;
clearing an array;
and
-flattening an array for easy C style looping over all its indices and elements.
+flattening an array for easy C style looping over all its indices and elements)
@end itemize
@item
@@ -35221,34 +35342,34 @@ and the Glossary:
@end ifclear
@ifset FOR_PRINT
-Part IV contains two appendices and the license that
+Part IV contains three appendices, the last of which is the license that
covers the @command{gawk} source code:
@end ifset
@itemize @value{BULLET}
@item
-@ref{Language History}.
+@ref{Language History}
@item
-@ref{Installation}.
+@ref{Installation}
@ifclear FOR_PRINT
@item
-@ref{Notes}.
+@ref{Notes}
@item
-@ref{Basic Concepts}.
+@ref{Basic Concepts}
@item
-@ref{Glossary}.
+@ref{Glossary}
@end ifclear
@item
-@ref{Copying}.
+@ref{Copying}
@ifclear FOR_PRINT
@item
-@ref{GNU Free Documentation License}.
+@ref{GNU Free Documentation License}
@end ifclear
@end itemize
@end ifdocbook
@@ -35257,7 +35378,7 @@ covers the @command{gawk} source code:
@appendix The Evolution of the @command{awk} Language
This @value{DOCUMENT} describes the GNU implementation of @command{awk},
-which follows the POSIX specification. Many long-time @command{awk}
+which follows the POSIX specification. Many longtime @command{awk}
users learned @command{awk} programming with the original @command{awk}
implementation in Version 7 Unix. (This implementation was the basis for
@command{awk} in Berkeley Unix, through 4.3-Reno. Subsequent versions
@@ -35492,7 +35613,7 @@ The ability to delete all of an array at once with @samp{delete @var{array}}
@end itemize
-@xref{Common Extensions}, for a list of common extensions
+@DBXREF{Common Extensions} for a list of common extensions
not permitted by the POSIX standard.
The 2008 POSIX standard can be found online at
@@ -35512,7 +35633,7 @@ has made his version available via his home page
(@pxref{Other Versions}).
This @value{SECTION} describes common extensions that
-originally appeared in his version of @command{awk}.
+originally appeared in his version of @command{awk}:
@itemize @value{BULLET}
@item
@@ -35538,7 +35659,7 @@ or array elements through it.
@end ignore
@end itemize
-@xref{Common Extensions}, for a full list of the extensions
+@DBXREF{Common Extensions} for a full list of the extensions
available in his @command{awk}.
@node POSIX/GNU
@@ -35594,7 +35715,7 @@ The @file{/dev/stdin}, @file{/dev/stdout}, @file{/dev/stderr} and
@item
The @file{/inet}, @file{/inet4}, and @samp{/inet6} special files for
TCP/IP networking using @samp{|&} to specify which version of the
-IP protocol to use.
+IP protocol to use
(@pxref{TCP/IP Networking}).
@end itemize
@@ -35642,7 +35763,7 @@ New keywords:
@itemize @value{MINUS}
@item
-The @code{BEGINFILE} and @code{ENDFILE} special patterns.
+The @code{BEGINFILE} and @code{ENDFILE} special patterns
(@pxref{BEGINFILE/ENDFILE}).
@item
@@ -35679,7 +35800,7 @@ making translations easier
@item
The @code{split()} function's additional optional fourth
-argument which is an array to hold the text of the field separators.
+argument which is an array to hold the text of the field separators
(@pxref{String Functions}).
@end itemize
@@ -36442,7 +36563,7 @@ load @command{awk} library files.
@item
The @option{-l} and @option{--load} options load compiled dynamic extensions.
-@item
+@item
The @option{-M} and @option{--bignum} options enable MPFR.
@item
@@ -36481,7 +36602,7 @@ The dynamic extension interface was completely redone
@cindex extensions, @command{mawk}
The following table summarizes the common extensions supported
by @command{gawk}, Brian Kernighan's @command{awk}, and @command{mawk},
-the three most widely-used freely available versions of @command{awk}
+the three most widely used freely available versions of @command{awk}
(@pxref{Other Versions}).
@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk} {Now standard}
@@ -36499,7 +36620,7 @@ the three most widely-used freely available versions of @command{awk}
@item @code{func} keyword @tab X @tab @tab X @tab
@item @code{BINMODE} variable @tab @tab X @tab X @tab
@item @code{RS} as regexp @tab @tab X @tab X @tab
-@item Time related functions @tab @tab X @tab X @tab
+@item Time-related functions @tab @tab X @tab X @tab
@end multitable
@node Ranges and Locales
@@ -36515,7 +36636,7 @@ the first character in the range and the last character in the range,
inclusive. Ordering was based on the numeric value of each character
in the machine's native character set. Thus, on ASCII-based systems,
@samp{[a-z]} matched all the lowercase letters, and only the lowercase
-letters, since the numeric values for the letters from @samp{a} through
+letters, as the numeric values for the letters from @samp{a} through
@samp{z} were contiguous. (On an EBCDIC system, the range @samp{[a-z]}
includes additional, non-alphabetic characters as well.)
@@ -36526,8 +36647,8 @@ that @samp{[A-Z]} was the ``correct'' way to match uppercase letters.
And indeed, this was true.@footnote{And Life was good.}
The 1992 POSIX standard introduced the idea of locales (@pxref{Locales}).
-Since many locales include other letters besides the plain twenty-six
-letters of the American English alphabet, the POSIX standard added
+Because many locales include other letters besides the plain 26
+letters of the English alphabet, the POSIX standard added
character classes (@pxref{Bracket Expressions}) as a way to match
different kinds of characters besides the traditional ones in the ASCII
character set.
@@ -36544,7 +36665,7 @@ In other words, these locales sort characters in dictionary order,
and @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
instead it might be equivalent to @samp{[ABCXYabcdxyz]}, for example.
-This point needs to be emphasized: Much literature teaches that you should
+This point needs to be emphasized: much literature teaches that you should
use @samp{[a-z]} to match a lowercase character. But on systems with
non-ASCII locales, this also matches all of the uppercase characters
except @samp{A} or @samp{Z}! This was a continuous cause of confusion, even well
@@ -36560,7 +36681,7 @@ $ @kbd{echo something1234abc | gawk-3.1.8 '@{ sub("[A-Z]*$", ""); print @}'}
@end example
@noindent
-This output is unexpected, since the @samp{bc} at the end of
+This output is unexpected, as the @samp{bc} at the end of
@samp{something1234abc} should not normally match @samp{[A-Z]*}.
This result is due to the locale setting (and thus you may not see
it on your system).
@@ -36582,7 +36703,7 @@ like ``why does @samp{[A-Z]} match lowercase letters?!?''
@cindex Berry, Karl
This situation existed for close to 10 years, if not more, and
the @command{gawk} maintainer grew weary of trying to explain that
-@command{gawk} was being nicely standards-compliant, and that the issue
+@command{gawk} was being nicely standards compliant, and that the issue
was in the user's locale. During the development of @value{PVERSION} 4.0,
he modified @command{gawk} to always treat ranges in the original,
pre-POSIX fashion, unless @option{--posix} was used (@pxref{Options}).@footnote{And
@@ -36795,7 +36916,7 @@ Michael Benzinger contributed the initial code for @code{switch} statements.
@cindex McPhee, Patrick
Patrick T.J.@: McPhee contributed the code for dynamic loading in Windows32
environments.
-(This is no longer supported)
+(This is no longer supported.)
@item
@cindex Wallin, Anders
@@ -36819,7 +36940,7 @@ into a byte-code interpreter, including the debugger.
The addition of true arrays of arrays.
@item
-The additional modifications for support of arbitrary precision arithmetic.
+The additional modifications for support of arbitrary-precision arithmetic.
@item
The initial text of
@@ -36875,7 +36996,7 @@ helping David Trueman, and as the primary maintainer since around 1994.
@itemize @value{BULLET}
@item
The @command{awk} language has evolved over time. The first release
-was with V7 Unix circa 1978. In 1987 for System V Release 3.1,
+was with V7 Unix circa 1978. In 1987, for System V Release 3.1,
major additions, including user-defined functions, were made to the language.
Additional changes were made for System V Release 4, in 1989.
Since then, further minor changes happen under the auspices of the
@@ -36917,8 +37038,8 @@ This appendix provides instructions for installing @command{gawk} on the
various platforms that are supported by the developers. The primary
developer supports GNU/Linux (and Unix), whereas the other ports are
contributed.
-@xref{Bugs},
-for the electronic mail addresses of the people who maintain
+@DBXREF{Bugs}
+for the email addresses of the people who maintain
the respective ports.
@menu
@@ -36972,7 +37093,7 @@ wget http://ftp.gnu.org/gnu/gawk/gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz
The GNU software archive is mirrored around the world.
The up-to-date list of mirror sites is available from
-@uref{http://www.gnu.org/order/ftp.html, the main FSF web site}.
+@uref{http://www.gnu.org/order/ftp.html, the main FSF website}.
Try to use one of the mirrors; they
will be less busy, and you can usually find one closer to your site.
@@ -36983,7 +37104,7 @@ different compression programs: @command{gzip}, @command{bzip2},
and @command{xz}. For simplicity, the rest of these instructions assume
you are using the one compressed with the GNU Zip program, @code{gzip}.
-Once you have the distribution (for example,
+Once you have the distribution (e.g.,
@file{gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz}),
use @code{gzip} to expand the
file and then use @code{tar} to extract it. You can use the following
@@ -37076,7 +37197,7 @@ as a list of things that the POSIX standard should describe but does not.
@item doc/awkforai.txt
Pointers to the original draft of
a short article describing why @command{gawk} is a good language for
-Artificial Intelligence (AI) programming.
+artificial intelligence (AI) programming.
@item doc/bc_notes
A brief description of @command{gawk}'s ``byte code'' internals.
@@ -37182,7 +37303,7 @@ source file for this @value{DOCUMENT}. It also contains a @file{Makefile.in} fil
The library functions from
@ref{Library Functions},
and the @command{igawk} program from
-@ref{Igawk Program},
+@DBREF{Igawk Program}
are included as ready-to-use files in the @command{gawk} distribution.
They are installed as part of the installation process.
The rest of the programs in this @value{DOCUMENT} are available in appropriate
@@ -37201,11 +37322,11 @@ Files needed for building @command{gawk} under MS-Windows
@ifclear FOR_PRINT
and OS/2
@end ifclear
-(@pxref{PC Installation}, for details).
+(@DBPXREF{PC Installation} for details).
@item vms/*
Files needed for building @command{gawk} under Vax/VMS and OpenVMS
-(@pxref{VMS Installation}, for details).
+(@DBPXREF{VMS Installation} for details).
@item test/*
A test suite for
@@ -37217,7 +37338,7 @@ be confident of a successful port.
@c ENDOFRANGE gawdis
@node Unix Installation
-@appendixsec Compiling and Installing @command{gawk} on Unix-like Systems
+@appendixsec Compiling and Installing @command{gawk} on Unix-Like Systems
Usually, you can compile and install @command{gawk} by typing only two
commands. However, if you use an unusual system, you may need
@@ -37230,7 +37351,7 @@ to configure @command{gawk} for your system yourself.
@end menu
@node Quick Installation
-@appendixsubsec Compiling @command{gawk} for Unix-like Systems
+@appendixsubsec Compiling @command{gawk} for Unix-Like Systems
The normal installation steps should work on all modern commercial
Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin
@@ -37247,7 +37368,7 @@ described fully in
@cite{Autoconf---Generating Automatic Configuration Scripts},
which can be found online at
@uref{http://www.gnu.org/software/autoconf/manual/index.html,
-the Free Software Foundation's web site}.)
+the Free Software Foundation's website}.)
@end ifnotinfo
@ifinfo
(The Autoconf software is described fully starting with
@@ -37294,7 +37415,7 @@ run @samp{make check}. All of the tests should succeed.
If these steps do not work, or if any of the tests fail,
check the files in the @file{README_d} directory to see if you've
found a known problem. If the failure is not described there,
-please send in a bug report (@pxref{Bugs}).
+send in a bug report (@pxref{Bugs}).
Of course, once you've built @command{gawk}, it is likely that you will
wish to install it. To do so, you need to run the command @samp{make
@@ -37358,7 +37479,7 @@ function for deficient systems.
@end table
Use the command @samp{./configure --help} to see the full list of
-options that @command{configure} supplies.
+options supplied by @command{configure}.
@node Configuration Philosophy
@appendixsubsec The Configuration Process
@@ -37392,19 +37513,19 @@ facts about your operating system. For example, there may not be an
@cindex @code{custom.h} file
It is possible for your C compiler to lie to @command{configure}. It may
do so by not exiting with an error when a library function is not
-available. To get around this, edit the file @file{custom.h}.
+available. To get around this, edit the @file{custom.h} file.
Use an @samp{#ifdef} that is appropriate for your system, and either
@code{#define} any constants that @command{configure} should have defined but
didn't, or @code{#undef} any constants that @command{configure} defined and
-should not have. @file{custom.h} is automatically included by
-@file{config.h}.
+should not have. The @file{custom.h} file is automatically included by
+the @file{config.h} file.
It is also possible that the @command{configure} program generated by
Autoconf will not work on your system in some other fashion.
-If you do have a problem, the file @file{configure.ac} is the input for
+If you do have a problem, the @file{configure.ac} file is the input for
Autoconf. You may be able to change this file and generate a
new version of @command{configure} that works on your system
-(@pxref{Bugs},
+(@DBPXREF{Bugs}
for information on how to report problems in configuring @command{gawk}).
The same mechanism may be used to send in updates to @file{configure.ac}
and/or @file{custom.h}.
@@ -37444,7 +37565,7 @@ The limitations of MS-DOS (and MS-DOS shells under the other operating
systems) has meant that various ``DOS extenders'' are often used with
programs such as @command{gawk}. The varying capabilities of Microsoft
Windows 3.1 and Windows32 can add to the confusion. For an overview
-of the considerations, please refer to @file{README_d/README.pc} in
+of the considerations, refer to @file{README_d/README.pc} in
the distribution.
@menu
@@ -37607,7 +37728,7 @@ Ancient OS/2 ports of GNU @command{make} are not able to handle
the Makefiles of this package. If you encounter any problems with
@command{make}, try GNU Make 3.79.1 or later versions. You should
find the latest version on
-@uref{ftp://hobbes.nmsu.edu/pub/os2/}.@footnote{As of May, 2014,
+@uref{ftp://hobbes.nmsu.edu/pub/os2/}.@footnote{As of November 2014,
this site is still there, but the author could not find a package
for GNU Make.}
@end quotation
@@ -37817,7 +37938,7 @@ need to use the @code{BINMODE} variable.
This can cause problems with other Unix-like components that have
been ported to MS-Windows that expect @command{gawk} to do automatic
-translation of @code{"\r\n"}, since it won't.
+translation of @code{"\r\n"}, because it won't.
@node VMS Installation
@appendixsubsec Compiling and Installing @command{gawk} on Vax/VMS and OpenVMS
@@ -37881,14 +38002,14 @@ The most recent builds used HP C V7.3 on Alpha VMS 8.3 and both
Alpha and IA64 VMS 8.4 used HP C 7.3.@footnote{The IA64 architecture
is also known as ``Itanium.''}
-@xref{VMS GNV}, for information on building
+@DBXREF{VMS GNV} for information on building
@command{gawk} as a PCSI kit that is compatible with the GNV product.
@node VMS Dynamic Extensions
@appendixsubsubsec Compiling @command{gawk} Dynamic Extensions on VMS
The extensions that have been ported to VMS can be built using one of
-the following commands.
+the following commands:
@example
$ @kbd{MMS/DESCRIPTION=[.vms]descrip.mms extensions}
@@ -37905,7 +38026,7 @@ $ @kbd{MMK/DESCRIPTION=[.vms]descrip.mms extensions}
or a logical name to find the dynamic extensions.
Dynamic extensions need to be compiled with the same compiler options for
-floating point, pointer size, and symbol name handling as were used
+floating-point, pointer size, and symbol name handling as were used
to compile @command{gawk} itself.
Alpha and Itanium should use IEEE floating point. The pointer size is 32 bits,
and the symbol name handling should be exact case with CRC shortening for
@@ -38035,7 +38156,7 @@ Note that uppercase and mixed-case text must be quoted.
The VMS port of @command{gawk} includes a @code{DCL}-style interface in addition
to the original shell-style interface (see the help entry for details).
One side effect of dual command-line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
+single parameter (as in the quoted string program), the command
becomes ambiguous. To work around this, the normally optional @option{--}
flag is required to force Unix-style parsing rather than @code{DCL} parsing. If any
other dash-type options (or multiple parameters such as @value{DF}s to
@@ -38155,10 +38276,10 @@ recommend compiling and using the current version.
@node Bugs
@appendixsec Reporting Problems and Bugs
-@cindex archeologists
+@cindex archaeologists
@quotation
-@i{There is nothing more dangerous than a bored archeologist.}
-@author The Hitchhiker's Guide to the Galaxy
+@i{There is nothing more dangerous than a bored archaeologist.}
+@author Douglas Adams, @cite{The Hitchhiker's Guide to the Galaxy}
@end quotation
@c the radio show, not the book. :-)
@@ -38167,10 +38288,10 @@ recommend compiling and using the current version.
@c STARTOFRANGE tblgawb
@cindex troubleshooting, @command{gawk}, bug reports
If you have problems with @command{gawk} or think that you have found a bug,
-please report it to the developers; we cannot promise to do anything
+report it to the developers; we cannot promise to do anything
but we might well want to fix it.
-Before reporting a bug, please make sure you have really found a genuine bug.
+Before reporting a bug, make sure you have really found a genuine bug.
Carefully reread the documentation and see if it says you can do
what you're trying to do. If it's not clear whether you should be able
to do something or not, report that too; it's a bug in the documentation!
@@ -38183,7 +38304,7 @@ the compiler you used to compile @command{gawk}, and the exact results
@command{gawk} gave you. Also say what you expected to occur; this helps
us decide whether the problem is really in the documentation.
-Please include the version number of @command{gawk} you are using.
+Make sure to include the version number of @command{gawk} you are using.
You can get this information with the command @samp{gawk --version}.
@cindex @code{bug-gawk@@gnu.org} bug reporting address
@@ -38195,7 +38316,7 @@ Once you have a precise problem description, send email to
The @command{gawk} maintainers subscribe to this address and
thus they will receive your bug report.
Although you can send mail to the maintainers directly,
-the bug reporting address is preferred since the
+the bug reporting address is preferred because the
email list is archived at the GNU Project.
@emph{All email must be in English. This is the only language
understood in common by all the maintainers.}
@@ -38204,19 +38325,19 @@ understood in common by all the maintainers.}
@quotation CAUTION
Do @emph{not} try to report bugs in @command{gawk} by
posting to the Usenet/Internet newsgroup @code{comp.lang.awk}.
-While the @command{gawk} developers do occasionally read this newsgroup,
-there is no guarantee that we will see your posting. The steps described
-above are the only official recognized way for reporting bugs.
+The @command{gawk} developers do occasionally read this newsgroup,
+but there is no guarantee that we will see your posting. The steps described
+here are the only officially recognized way for reporting bugs.
Really.
@end quotation
@quotation NOTE
Many distributions of GNU/Linux and the various BSD-based operating systems
have their own bug reporting systems. If you report a bug using your distribution's
-bug reporting system, @emph{please} also send a copy to
+bug reporting system, you should also send a copy to
@EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org}.
-This is for two reasons. First, while some distributions forward
+This is for two reasons. First, although some distributions forward
bug reports ``upstream'' to the GNU mailing list, many don't, so there is a good
chance that the @command{gawk} maintainers won't even see the bug report! Second,
mail to the GNU list is archived, and having everything at the GNU project
@@ -38227,8 +38348,8 @@ Non-bug suggestions are always welcome as well. If you have questions
about things that are unclear in the documentation or are just obscure
features, ask on the bug list; we will try to help you out if we can.
-If you find bugs in one of the non-Unix ports of @command{gawk}, please
-send an electronic mail message to the bug list, with a copy to the
+If you find bugs in one of the non-Unix ports of @command{gawk},
+send an email to the bug list, with a copy to the
person who maintains that port. They are named in the following list,
as well as in the @file{README} file in the @command{gawk} distribution.
Information in the @file{README} file should be considered authoritative
@@ -38259,7 +38380,7 @@ The people maintaining the various @command{gawk} ports are:
@item z/OS (OS/390) @tab Dave Pitts, @EMAIL{dpitts@@cozx.com,dpitts at cozx dot com}.
@end multitable
-If your bug is also reproducible under Unix, please send a copy of your
+If your bug is also reproducible under Unix, send a copy of your
report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well.
@c ENDOFRANGE dbugg
@c ENDOFRANGE tblgawb
@@ -38303,7 +38424,7 @@ This @value{SECTION} briefly describes where to get them:
Brian Kernighan, one of the original designers of Unix @command{awk},
has made his implementation of
@command{awk} freely available.
-You can retrieve this version via the World Wide Web from
+You can retrieve this version via
@uref{http://www.cs.princeton.edu/~bwk, his home page}.
It is available in several archive formats:
@@ -38326,7 +38447,7 @@ git clone git://github.com/onetrueawk/awk bwkawk
@end example
@noindent
-The above command creates a copy of the @uref{http://www.git-scm.com, Git}
+This command creates a copy of the @uref{http://www.git-scm.com, Git}
repository in a directory named @file{bwkawk}. If you leave that argument
off the @command{git} command line, the repository copy is created in a
directory named @file{awk}.
@@ -38334,9 +38455,13 @@ directory named @file{awk}.
This version requires an ISO C (1990 standard) compiler; the C compiler
from GCC (the GNU Compiler Collection) works quite nicely.
-@xref{Common Extensions},
+@DBXREF{Common Extensions}
for a list of extensions in this @command{awk} that are not in POSIX @command{awk}.
+As a side note, Dan Bornstein has created a Git repository tracking
+all the versions of BWK @command{awk} that he could find. It's
+available at @uref{git://github.com/onetrueawk/awk}.
+
@cindex Brennan, Michael
@cindex @command{mawk} utility
@cindex source code, @command{mawk}
@@ -38366,7 +38491,7 @@ Once you have it,
is similar to @command{gawk}'s
(@pxref{Unix Installation}).
-@xref{Common Extensions},
+@DBXREF{Common Extensions}
for a list of extensions in @command{mawk} that are not in POSIX @command{awk}.
@cindex Sumner, Andrew
@@ -38428,8 +38553,8 @@ has not been done, at least to our knowledge.
@cindex Illumos
@cindex Illumos, POSIX-compliant @command{awk}
@cindex source code, Illumos @command{awk}
-The source code used to be available from the OpenSolaris web site.
-However, that project was ended and the web site shut down. Fortunately, the
+The source code used to be available from the OpenSolaris website.
+However, that project was ended and the website shut down. Fortunately, the
@uref{http://wiki.illumos.org/display/illumos/illumos+Home, Illumos project}
makes this implementation available. You can view the files one at a time from
@uref{https://github.com/joyent/illumos-joyent/blob/master/usr/src/cmd/awk_xpg4}.
@@ -38448,7 +38573,7 @@ from POSIX @command{awk}. More information is available on the
@cindex libmawk
@cindex source code, libmawk
This is an embeddable @command{awk} interpreter derived from
-@command{mawk}. For more information see
+@command{mawk}. For more information, see
@uref{http://repo.hu/projects/libmawk/}.
@item @code{pawk}
@@ -38462,7 +38587,7 @@ modified version of BWK @command{awk}, described earlier.)
@item @w{QSE Awk}
@cindex QSE Awk
@cindex source code, QSE Awk
-This is an embeddable @command{awk} interpreter. For more information
+This is an embeddable @command{awk} interpreter. For more information,
see @uref{http://code.google.com/p/qse/} and @uref{http://awk.info/?tools/qse}.
@item @command{QTawk}
@@ -38477,9 +38602,10 @@ including the manual and a download link.
The project may also be frozen; no new code changes have been made
since approximately 2008.
-@item Other Versions
-See also the @uref{http://en.wikipedia.org/wiki/Awk_language#Versions_and_implementations,
-Wikipedia article}, for information on additional versions.
+@item Other versions
+See also the ``Versions and implementations'' section of the
+@uref{http://en.wikipedia.org/wiki/Awk_language#Versions_and_implementations,
+Wikipedia article} for information on additional versions.
@end table
@c ENDOFRANGE awkim
@@ -38681,7 +38807,7 @@ This document describes how GNU software should be written. If you haven't
read it, please do so, preferably @emph{before} starting to modify @command{gawk}.
(The @cite{GNU Coding Standards} are available from
the GNU Project's
-@uref{http://www.gnu.org/prep/standards_toc.html, web site}.
+@uref{http://www.gnu.org/prep/standards_toc.html, website}.
Texinfo, Info, and DVI versions are also available.)
@cindex @command{gawk}, coding style in
@@ -40547,7 +40673,7 @@ record or a string.
@end docbook
@c This file is intended to be included within another document,
-@c hence no sectioning command or @node.
+@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/}
@@ -40769,7 +40895,7 @@ terms of section 4, provided that you also meet all of these
conditions:
@enumerate a
-@item
+@item
The work must carry prominent notices stating that you modified it,
and giving a relevant date.
@@ -41219,7 +41345,7 @@ state the exclusion of warranty; and each file should have at least
the ``copyright'' line and a pointer to where the full notice is found.
@smallexample
-@var{one line to give the program's name and a brief idea of what it does.}
+@var{one line to give the program's name and a brief idea of what it does.}
Copyright (C) @var{year} @var{name of author}
This program is free software: you can redistribute it and/or modify
@@ -41242,7 +41368,7 @@ If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
@smallexample
-@var{program} Copyright (C) @var{year} @var{name of author}
+@var{program} Copyright (C) @var{year} @var{name of author}
This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}.
This is free software, and you are welcome to redistribute it
under certain conditions; type @samp{show c} for details.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 6a66f8c4..1ea028d4 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -51,7 +51,7 @@
@set PATCHLEVEL 2
@ifset FOR_PRINT
-@set TITLE Effective AWK Programming
+@set TITLE Effective Awk Programming
@end ifset
@ifclear FOR_PRINT
@set TITLE GAWK: Effective AWK Programming
@@ -170,12 +170,24 @@
@macro DBREF{text}
@ref{\text\}
@end macro
+@macro DBXREF{text}
+@xref{\text\}
+@end macro
+@macro DBPXREF{text}
+@pxref{\text\}
+@end macro
@end ifdocbook
@ifnotdocbook
@macro DBREF{text}
@ref{\text\},
@end macro
+@macro DBXREF{text}
+@xref{\text\},
+@end macro
+@macro DBPXREF{text}
+@pxref{\text\},
+@end macro
@end ifnotdocbook
@ifclear FOR_PRINT
@@ -310,7 +322,7 @@ A copy of the license is included in the section entitled
A copy of the license
may be found on the Internet at
@uref{http://www.gnu.org/software/gawk/manual/html_node/GNU-Free-Documentation-License.html,
-the GNU Project's web site}.
+the GNU Project's website}.
@end ifset
@enumerate a
@@ -378,10 +390,10 @@ ISBN 1-882114-28-0 @*
@sp 9
@center @i{To my parents, for their love, and for the wonderful example they set for me.}
@sp 1
-@center @i{To my wife Miriam, for making me complete.
+@center @i{To my wife, Miriam, for making me complete.
Thank you for building your life together with me.}
@sp 1
-@center @i{To our children Chana, Rivka, Nachum and Malka, for enrichening our lives in innumerable ways.}
+@center @i{To our children, Chana, Rivka, Nachum, and Malka, for enrichening our lives in innumerable ways.}
@sp 1
@w{ }
@page
@@ -1070,7 +1082,7 @@ for enrichening our lives in innumerable ways.
<!-- can't put mawk into command tags. sigh. -->
<affiliation><jobtitle>Author of mawk</jobtitle></affiliation>
</author>
- <date>March, 2001</date>
+ <date>March 2001</date>
</prefaceinfo>
@end docbook
@@ -1082,21 +1094,23 @@ The circumstances started a couple of years
earlier. I was working at a new job and noticed an unplugged
Unix computer sitting in the corner. No one knew how to use it,
and neither did I. However,
-a couple of days later it was running, and
+a couple of days later, it was running, and
I was @code{root} and the one-and-only user.
That day, I began the transition from statistician to Unix programmer.
On one of many trips to the library or bookstore in search of
-books on Unix, I found the gray AWK book, a.k.a.@: Aho, Kernighan and
-Weinberger, @cite{The AWK Programming Language}, Addison-Wesley,
-1988. AWK's simple programming paradigm---find a pattern in the
+books on Unix, I found the gray AWK book, a.k.a.@:
+Alfred V.@: Aho, Brian W.@: Kernighan, and
+Peter J.@: Weinberger's @cite{The AWK Programming Language} (Addison-Wesley,
+1988). @command{awk}'s simple programming paradigm---find a pattern in the
input and then perform an action---often reduced complex or tedious
data manipulations to a few lines of code. I was excited to try my
hand at programming in AWK.
Alas, the @command{awk} on my computer was a limited version of the
-language described in the AWK book. I discovered that my computer
-had ``old @command{awk}'' and the AWK book described ``new @command{awk}.''
+language described in the gray book. I discovered that my computer
+had ``old @command{awk}'' and the book described
+``new @command{awk}.''
I learned that this was typical; the old version refused to step
aside or relinquish its name. If a system had a new @command{awk}, it was
invariably called @command{nawk}, and few systems had it.
@@ -1114,7 +1128,7 @@ My Unix system started out unplugged from the wall; it certainly was not
plugged into a network. So, oblivious to the existence of @command{gawk}
and the Unix community in general, and desiring a new @command{awk}, I wrote
my own, called @command{mawk}.
-Before I was finished I knew about @command{gawk},
+Before I was finished, I knew about @command{gawk},
but it was too late to stop, so I eventually posted
to a @code{comp.sources} newsgroup.
@@ -1123,7 +1137,7 @@ from Arnold introducing
himself. He suggested we share design and algorithms and
attached a draft of the POSIX standard so
that I could update @command{mawk} to support language extensions added
-after publication of the AWK book.
+after publication of @cite{The AWK Programming Language}.
Frankly, if our roles had
been reversed, I would not have been so open and we probably would
@@ -1142,7 +1156,7 @@ standard.
On the other hand, the novice AWK programmer can study
a wealth of practical programs that emphasize
the power of AWK's basic idioms:
-data driven control-flow, pattern matching with regular expressions,
+data-driven control flow, pattern matching with regular expressions,
and associative arrays.
Those looking for something new can try out @command{gawk}'s
interface to network protocols via special @file{/inet} files.
@@ -1203,7 +1217,7 @@ AWK or want to learn how, then read this book.
@display
Michael Brennan
Author of @command{mawk}
-March, 2001
+March 2001
@end display
@end ifnotdocbook
@@ -1221,7 +1235,7 @@ March, 2001
<!-- can't put mawk into command tags. sigh. -->
<affiliation><jobtitle>Author of mawk</jobtitle></affiliation>
</author>
- <date>October, 2014</date>
+ <date>October 2014</date>
</prefaceinfo>
@end docbook
@@ -1255,7 +1269,7 @@ details, and as expected, many examples to help you learn the ins and outs.
@display
Michael Brennan
Author of @command{mawk}
-October, 2014
+October 2014
@end display
@end ifnotdocbook
@@ -1275,9 +1289,9 @@ October, 2014
<firstname>Arnold</firstname>
<surname>Robbins</surname>
<affiliation><jobtitle>Nof Ayalon</jobtitle></affiliation>
- <affiliation><jobtitle>ISRAEL</jobtitle></affiliation>
+ <affiliation><jobtitle>Israel</jobtitle></affiliation>
</author>
- <date>December, 2014</date>
+ <date>December 2014</date>
</prefaceinfo>
@end docbook
@@ -1289,7 +1303,7 @@ The @command{awk} utility interprets a special-purpose programming
language that makes it easy to handle simple data-reformatting jobs.
The GNU implementation of @command{awk} is called @command{gawk}; if you
-invoke it with the proper options or environment variables
+invoke it with the proper options or environment variables,
it is fully compatible with
the POSIX@footnote{The 2008 POSIX standard is accessible online at
@w{@url{http://www.opengroup.org/onlinepubs/9699919799/}.}}
@@ -1396,7 +1410,7 @@ has been removed.}
@unnumberedsec History of @command{awk} and @command{gawk}
@cindex recipe for a programming language
@cindex programming language, recipe for
-@sidebar Recipe For A Programming Language
+@sidebar Recipe for a Programming Language
@multitable {2 parts} {1 part @code{egrep}} {1 part @code{snobol}}
@item @tab 1 part @code{egrep} @tab 1 part @code{snobol}
@@ -1415,7 +1429,7 @@ more parts C. Document very well and release.
@cindex Kernighan, Brian
@cindex @command{awk}, history of
The name @command{awk} comes from the initials of its designers: Alfred V.@:
-Aho, Peter J.@: Weinberger and Brian W.@: Kernighan. The original version of
+Aho, Peter J.@: Weinberger, and Brian W.@: Kernighan. The original version of
@command{awk} was written in 1977 at AT&T Bell Laboratories.
In 1985, a new version made the programming
language more powerful, introducing user-defined functions, multiple input
@@ -1441,7 +1455,7 @@ Circa 1994, I became the primary maintainer.
Current development focuses on bug fixes,
performance improvements, standards compliance and, occasionally, new features.
-In May of 1997, J@"urgen Kahrs felt the need for network access
+In May 1997, J@"urgen Kahrs felt the need for network access
from @command{awk}, and with a little help from me, set about adding
features to do this for @command{gawk}. At that time, he also
wrote the bulk of
@@ -1454,7 +1468,7 @@ John Haque rewrote the @command{gawk} internals, in the process providing
an @command{awk}-level debugger. This version became available as
@command{gawk} @value{PVERSION} 4.0, in 2011.
-@xref{Contributors},
+@DBXREF{Contributors}
for a full list of those who made important contributions to @command{gawk}.
@node Names
@@ -1464,7 +1478,7 @@ for a full list of those who made important contributions to @command{gawk}.
The @command{awk} language has evolved over the years. Full details are
provided in @ref{Language History}.
The language described in this @value{DOCUMENT}
-is often referred to as ``new @command{awk}''.
+is often referred to as ``new @command{awk}.''
By analogy, the original version of @command{awk} is
referred to as ``old @command{awk}.''
@@ -1543,12 +1557,15 @@ Most of the time, the examples use complete @command{awk} programs.
Some of the more advanced sections show only the part of the @command{awk}
program that illustrates the concept being described.
-While this @value{DOCUMENT} is aimed principally at people who have not been
+Although this @value{DOCUMENT} is aimed principally at people who have not been
exposed
to @command{awk}, there is a lot of information here that even the @command{awk}
expert should find useful. In particular, the description of POSIX
@command{awk} and the example programs in
-@ref{Library Functions}, and in
+@ref{Library Functions}, and
+@ifnotdocbook
+in
+@end ifnotdocbook
@ref{Sample Programs},
should be of interest.
@@ -1556,22 +1573,30 @@ This @value{DOCUMENT} is split into several parts, as follows:
@c FULLXREF ON
+@itemize @value{BULLET}
+@item
Part I describes the @command{awk} language and @command{gawk} program in detail.
It starts with the basics, and continues through all of the features of @command{awk}.
It contains the following chapters:
+@c nested
+@itemize @value{MINUS}
+@item
@ref{Getting Started},
provides the essentials you need to know to begin using @command{awk}.
+@item
@ref{Invoking Gawk},
describes how to run @command{gawk}, the meaning of its
command-line options, and how it finds @command{awk}
program source files.
+@item
@ref{Regexp},
introduces regular expressions in general, and in particular the flavors
supported by POSIX @command{awk} and @command{gawk}.
+@item
@ref{Reading Files},
describes how @command{awk} reads your data.
It introduces the concepts of records and fields, as well
@@ -1579,46 +1604,62 @@ as the @code{getline} command.
I/O redirection is first described here.
Network I/O is also briefly introduced here.
+@item
@ref{Printing},
describes how @command{awk} programs can produce output with
@code{print} and @code{printf}.
+@item
@ref{Expressions},
describes expressions, which are the basic building blocks
for getting most things done in a program.
+@item
@ref{Patterns and Actions},
describes how to write patterns for matching records, actions for
doing something when a record is matched, and the predefined variables
@command{awk} and @command{gawk} use.
+@item
@ref{Arrays},
covers @command{awk}'s one-and-only data structure: associative arrays.
Deleting array elements and whole arrays is also described, as well as
sorting arrays in @command{gawk}. It also describes how @command{gawk}
provides arrays of arrays.
+@item
@ref{Functions},
describes the built-in functions @command{awk} and @command{gawk} provide,
as well as how to define your own functions. It also discusses how
@command{gawk} lets you call functions indirectly.
+@end itemize
+@item
Part II shows how to use @command{awk} and @command{gawk} for problem solving.
There is lots of code here for you to read and learn from.
It contains the following chapters:
+@c nested
+@itemize @value{MINUS}
+@item
@ref{Library Functions}, which provides a number of functions meant to
be used from main @command{awk} programs.
+@item
@ref{Sample Programs},
which provides many sample @command{awk} programs.
+@end itemize
Reading these two chapters allows you to see @command{awk}
solving real problems.
+@item
Part III focuses on features specific to @command{gawk}.
It contains the following chapters:
+@c nested
+@itemize @value{MINUS}
+@item
@ref{Advanced Features},
describes a number of advanced features.
Of particular note
@@ -1627,18 +1668,24 @@ have two-way communications with another process,
perform TCP/IP networking, and
profile your @command{awk} programs.
+@item
@ref{Internationalization},
describes special features for translating program
messages into different languages at runtime.
+@item
@ref{Debugger}, describes the @command{gawk} debugger.
+@item
@ref{Arbitrary Precision Arithmetic},
describes advanced arithmetic facilities.
+@item
@ref{Dynamic Extensions}, describes how to add new variables and
functions to @command{gawk} by writing extensions in C or C++.
+@end itemize
+@item
@ifclear FOR_PRINT
Part IV provides the appendices, the Glossary, and two licenses that cover
the @command{gawk} source code and this @value{DOCUMENT}, respectively.
@@ -1649,11 +1696,14 @@ Part IV provides the following appendices,
including the GNU General Public License:
@end ifset
+@itemize @value{MINUS}
+@item
@ref{Language History},
describes how the @command{awk} language has evolved since
its first release to present. It also describes how @command{gawk}
has acquired features over time.
+@item
@ref{Installation},
describes how to get @command{gawk}, how to compile it
on POSIX-compatible systems,
@@ -1661,17 +1711,22 @@ and how to compile and use it on different
non-POSIX systems. It also describes how to report bugs
in @command{gawk} and where to get other freely
available @command{awk} implementations.
+@end itemize
@ifset FOR_PRINT
-
+@itemize @value{MINUS}
+@item
@ref{Copying},
presents the license that covers the @command{gawk} source code.
+@end itemize
The version of this @value{DOCUMENT} distributed with @command{gawk}
contains additional appendices and other end material.
To save space, we have omitted them from the
printed edition. You may find them online, as follows:
+@itemize @value{BULLET}
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/Notes.html,
The appendix on implementation notes}
describes how to disable @command{gawk}'s extensions, how to contribute
@@ -1679,44 +1734,54 @@ new code to @command{gawk}, where to find information on some possible
future directions for @command{gawk} development, and the design decisions
behind the extension API.
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/Basic-Concepts.html,
The appendix on basic concepts}
provides some very cursory background material for those who
are completely unfamiliar with computer programming.
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/Glossary.html,
The Glossary}
-defines most, if not all, the significant terms used
+defines most, if not all of, the significant terms used
throughout the @value{DOCUMENT}. If you find terms that you aren't familiar with,
try looking them up here.
+@item
@uref{http://www.gnu.org/software/gawk/manual/html_node/GNU-Free-Documentation-License.html,
The GNU FDL}
is the license that covers this @value{DOCUMENT}.
+@end itemize
Some of the chapters have exercise sections; these have also been
omitted from the print edition but are available online.
@end ifset
@ifclear FOR_PRINT
+@itemize @value{MINUS}
+@item
@ref{Notes},
describes how to disable @command{gawk}'s extensions, as
well as how to contribute new code to @command{gawk},
and some possible future directions for @command{gawk} development.
+@item
@ref{Basic Concepts},
provides some very cursory background material for those who
are completely unfamiliar with computer programming.
-The @ref{Glossary}, defines most, if not all, the significant terms used
+The @ref{Glossary}, defines most, if not all of, the significant terms used
throughout the @value{DOCUMENT}. If you find terms that you aren't familiar with,
try looking them up here.
+@item
@ref{Copying}, and
@ref{GNU Free Documentation License},
present the licenses that cover the @command{gawk} source code
and this @value{DOCUMENT}, respectively.
+@end itemize
@end ifclear
+@end itemize
@c FULLXREF OFF
@@ -1779,7 +1844,7 @@ pressing the @kbd{d} key and finally releasing both keys.
For the sake of brevity, throughout this @value{DOCUMENT}, we refer to
Brian Kernighan's version of @command{awk} as ``BWK @command{awk}.''
-(@xref{Other Versions}, for information on his and other versions.)
+(@DBXREF{Other Versions} for information on his and other versions.)
@ifset FOR_PRINT
@quotation NOTE
@@ -1795,7 +1860,7 @@ Cautionary or warning notes look like this.
@unnumberedsubsec Dark Corners
@cindex Kernighan, Brian
@quotation
-@i{Dark corners are basically fractal --- no matter how much
+@i{Dark corners are basically fractal---no matter how much
you illuminate, there's always a smaller but darker one.}
@author Brian Kernighan
@end quotation
@@ -1865,7 +1930,7 @@ The GPL applies to the C language source code for @command{gawk}.
To find out more about the FSF and the GNU Project online,
see @uref{http://www.gnu.org, the GNU Project's home page}.
This @value{DOCUMENT} may also be read from
-@uref{http://www.gnu.org/software/gawk/manual/, their web site}.
+@uref{http://www.gnu.org/software/gawk/manual/, GNU's website}.
@ifclear FOR_PRINT
A shell, an editor (Emacs), highly portable optimizing C, C++, and
@@ -1902,10 +1967,10 @@ License in @ref{GNU Free Documentation License}.)
@cindex Close, Diane
The @value{DOCUMENT} itself has gone through multiple previous editions.
Paul Rubin wrote the very first draft of @cite{The GAWK Manual};
-it was around 40 pages in size.
+it was around 40 pages long.
Diane Close and Richard Stallman improved it, yielding a
version that was
-around 90 pages long and barely described the original, ``old''
+around 90 pages and barely described the original, ``old''
version of @command{awk}.
I started working with that version in the fall of 1988.
@@ -1938,17 +2003,17 @@ and the major new additions are @ref{Arbitrary Precision Arithmetic},
and @ref{Dynamic Extensions}.
This @value{DOCUMENT} will undoubtedly continue to evolve. If you
-find an error in this @value{DOCUMENT}, please report it! @xref{Bugs},
+find an error in this @value{DOCUMENT}, please report it! @DBXREF{Bugs}
for information on submitting problem reports electronically.
@ifset FOR_PRINT
@c fakenode --- for prepinfo
@unnumberedsec How to Stay Current
-It may be you have a version of @command{gawk} which is newer than the
+You may have a newer version of @command{gawk} than the
one described here. To find out what has changed,
you should first look at the @file{NEWS} file in the @command{gawk}
-distribution, which provides a high level summary of what changed in
+distribution, which provides a high-level summary of what changed in
each release.
You can then look at the @uref{http://www.gnu.org/software/gawk/manual/,
@@ -1973,13 +2038,13 @@ contributed code: the archive did not grow and the domain went unused
for several years.
Late in 2008, a volunteer took on the task of setting up
-an @command{awk}-related web site---@uref{http://awk.info}---and did a very
+an @command{awk}-related website---@uref{http://awk.info}---and did a very
nice job.
If you have written an interesting @command{awk} program, or have written
a @command{gawk} extension that you would like to share with the rest
of the world, please see @uref{http://awk.info/?contribute} for how to
-contribute it to the web site.
+contribute it to the website.
@ignore
As of this writing, this website is in search of a maintainer; please
@@ -2126,12 +2191,13 @@ portable program it is today. It has been and continues to be a pleasure
working with this team of fine people.
Notable code and documentation contributions were made by
-a number of people. @xref{Contributors}, for the full list.
+a number of people. @DBXREF{Contributors} for the full list.
@ifset FOR_PRINT
@cindex Oram, Andy
Thanks to Andy Oram, of O'Reilly Media, for initiating
the fourth edition and for his support during the work.
+Thanks to Jasmine Kwityn for her copy-editing work.
@end ifset
Thanks to Michael Brennan for the Foreword.
@@ -2145,7 +2211,7 @@ the Texinfo markup language sane.
@cindex Kernighan, Brian
@cindex Brennan, Michael
@cindex Day, Robert P.J.@:
-Robert P.J.@: Day, Michael Brennan and Brian Kernighan kindly acted as
+Robert P.J.@: Day, Michael Brennan, and Brian Kernighan kindly acted as
reviewers for the 2015 edition of this @value{DOCUMENT}. Their feedback
helped improve the final work.
@@ -2157,7 +2223,7 @@ or its documentation without his help.
Brian is in a class by himself as a programmer and technical
author. I have to thank him (yet again) for his ongoing friendship
-and the role model he has been for me for close to 30 years!
+and for being a role model to me for close to 30 years!
Having him as a reviewer is an exciting privilege. It has also
been extremely humbling@enddots{}
@@ -2178,8 +2244,8 @@ take advantage of those opportunities.
@noindent
Arnold Robbins @*
Nof Ayalon @*
-ISRAEL @*
-December, 2014
+Israel @*
+December 2014
@end iftex
@ifnotinfo
@@ -2196,31 +2262,31 @@ following chapters:
@itemize @value{BULLET}
@item
-@ref{Getting Started}.
+@ref{Getting Started}
@item
-@ref{Invoking Gawk}.
+@ref{Invoking Gawk}
@item
-@ref{Regexp}.
+@ref{Regexp}
@item
-@ref{Reading Files}.
+@ref{Reading Files}
@item
-@ref{Printing}.
+@ref{Printing}
@item
-@ref{Expressions}.
+@ref{Expressions}
@item
-@ref{Patterns and Actions}.
+@ref{Patterns and Actions}
@item
-@ref{Arrays}.
+@ref{Arrays}
@item
-@ref{Functions}.
+@ref{Functions}
@end itemize
@end ifdocbook
@@ -2235,17 +2301,17 @@ following chapters:
The basic function of @command{awk} is to search files for lines (or other
units of text) that contain certain patterns. When a line matches one
of the patterns, @command{awk} performs specified actions on that line.
-@command{awk} keeps processing input lines in this way until it reaches
+@command{awk} continues to process input lines in this way until it reaches
the end of the input files.
@cindex @command{awk}, uses for
@cindex programming languages@comma{} data-driven vs.@: procedural
@cindex @command{awk} programs
Programs in @command{awk} are different from programs in most other languages,
-because @command{awk} programs are @dfn{data-driven}; that is, you describe
-the data you want to work with and then what to do when you find it.
+because @command{awk} programs are @dfn{data driven} (i.e., you describe
+the data you want to work with and then what to do when you find it).
Most other languages are @dfn{procedural}; you have to describe, in great
-detail, every step the program is to take. When working with procedural
+detail, every step the program should take. When working with procedural
languages, it is usually much
harder to clearly describe the data your program will process.
For this reason, @command{awk} programs are often refreshingly easy to
@@ -2255,9 +2321,9 @@ read and write.
@cindex rule, definition of
When you run @command{awk}, you specify an @command{awk} @dfn{program} that
tells @command{awk} what to do. The program consists of a series of
-@dfn{rules}. (It may also contain @dfn{function definitions},
-an advanced feature that we will ignore for now.
-@xref{User-defined}.) Each rule specifies one
+@dfn{rules} (it may also contain @dfn{function definitions},
+an advanced feature that we will ignore for now;
+@pxref{User-defined}). Each rule specifies one
pattern to search for and one action to perform
upon finding the pattern.
@@ -2357,10 +2423,11 @@ programs from shell scripts, because it avoids the need for a separate
file for the @command{awk} program. A self-contained shell script is more
reliable because there are no other files to misplace.
+Later in this chapter,
+@ifdocbook
+the section
+@end ifdocbook
@ref{Very Simple},
-@ifnotinfo
-later in this @value{CHAPTER},
-@end ifnotinfo
presents several short,
self-contained programs.
@@ -2419,7 +2486,7 @@ startup file.
This next simple @command{awk} program
emulates the @command{cat} utility; it copies whatever you type on the
-keyboard to its standard output (why this works is explained shortly).
+keyboard to its standard output (why this works is explained shortly):
@example
$ @kbd{awk '@{ print @}'}
@@ -2504,7 +2571,7 @@ affect the execution of the @command{awk} program but it does make
Once you have learned @command{awk}, you may want to write self-contained
@command{awk} scripts, using the @samp{#!} script mechanism. You can do
this on many systems.@footnote{The @samp{#!} mechanism works on
-GNU/Linux systems, BSD-based systems and commercial Unix systems.}
+GNU/Linux systems, BSD-based systems, and commercial Unix systems.}
For example, you could update the file @file{advice} to look like this:
@example
@@ -2543,7 +2610,7 @@ according to the instructions in your program. (This is different
from a @dfn{compiled} language such as C, where your program is first
compiled into machine code that is executed directly by your system's
processor.) The @command{awk} utility is thus termed an @dfn{interpreter}.
-Many modern languages are interperted.
+Many modern languages are interpreted.
The line beginning with @samp{#!} lists the full @value{FN} of an
interpreter to run and a single optional initial command-line argument
@@ -2589,14 +2656,14 @@ can explain what the program does and how it works. Nearly all
programming languages have provisions for comments, as programs are
typically hard to understand without them.
-In the @command{awk} language, a comment starts with the sharp sign
+In the @command{awk} language, a comment starts with the number sign
character (@samp{#}) and continues to the end of the line.
The @samp{#} does not have to be the first character on the line. The
-@command{awk} language ignores the rest of a line following a sharp sign.
+@command{awk} language ignores the rest of a line following a number sign.
For example, we could have put the following into @file{advice}:
@example
-# This program prints a nice friendly message. It helps
+# This program prints a nice, friendly message. It helps
# keep novice users from being afraid of the computer.
BEGIN @{ print "Don't Panic!" @}
@end example
@@ -2612,7 +2679,8 @@ when reading it at a later time.
@quotation CAUTION
As mentioned in
@ref{One-shot},
-you can enclose small to medium programs in single quotes, in order to keep
+you can enclose short to medium-sized programs in single quotes,
+in order to keep
your shell scripts self-contained. When doing so, @emph{don't} put
an apostrophe (i.e., a single quote) into a comment (or anywhere else
in your program). The shell interprets the quote as the closing
@@ -2641,7 +2709,7 @@ $ @kbd{awk '@{ print "hello" @} # let's be cute'}
@cindex @code{\} (backslash)
@cindex backslash (@code{\})
Putting a backslash before the single quote in @samp{let's} wouldn't help,
-since backslashes are not special inside single quotes.
+because backslashes are not special inside single quotes.
The next @value{SUBSECTION} describes the shell's quoting rules.
@end quotation
@@ -2653,7 +2721,7 @@ The next @value{SUBSECTION} describes the shell's quoting rules.
* DOS Quoting:: Quoting in Windows Batch Files.
@end menu
-For short to medium length @command{awk} programs, it is most convenient
+For short to medium-length @command{awk} programs, it is most convenient
to enter the program on the @command{awk} command line.
This is best done by enclosing the entire program in single quotes.
This is true whether you are entering the program interactively at
@@ -2677,8 +2745,8 @@ or empty, string.
The null string is character data that has no value.
In other words, it is empty. It is written in @command{awk} programs
like this: @code{""}. In the shell, it can be written using single
-or double quotes: @code{""} or @code{''}. While the null string has
-no characters in it, it does exist. Consider this command:
+or double quotes: @code{""} or @code{''}. Although the null string has
+no characters in it, it does exist. For example, consider this command:
@example
$ @kbd{echo ""}
@@ -2688,8 +2756,7 @@ $ @kbd{echo ""}
Here, the @command{echo} utility receives a single argument, even
though that argument has no characters in it. In the rest of this
@value{DOCUMENT}, we use the terms @dfn{null string} and @dfn{empty string}
-interchangeably. Now, on to the quoting rules.
-
+interchangeably. Now, on to the quoting rules:
@itemize @value{BULLET}
@item
@@ -2712,7 +2779,7 @@ The shell does no interpretation of the quoted text, passing it on verbatim
to the command.
It is @emph{impossible} to embed a single quote inside single-quoted text.
Refer back to
-@ref{Comments},
+@DBREF{Comments}
for an example of what happens if you try.
@item
@@ -2722,7 +2789,7 @@ Double quotes protect most things between the opening and closing quotes.
The shell does at least variable and command substitution on the quoted text.
Different shells may do additional kinds of processing on double-quoted text.
-Since certain characters within double-quoted text are processed by the shell,
+Because certain characters within double-quoted text are processed by the shell,
they must be @dfn{escaped} within the text. Of note are the characters
@samp{$}, @samp{`}, @samp{\}, and @samp{"}, all of which must be preceded by
a backslash within double-quoted text if they are to be passed on literally
@@ -2784,7 +2851,7 @@ $ @kbd{awk 'BEGIN @{ print "Here is a single quote <'"'"'>" @}'}
@noindent
This program consists of three concatenated quoted strings. The first and the
-third are single-quoted, the second is double-quoted.
+third are single quoted, the second is double quoted.
This can be ``simplified'' to:
@@ -2829,7 +2896,7 @@ escapes mean.
A fourth option is to use command-line variable assignment, like this:
@example
-$ awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}'
+$ @kbd{awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}'}
@print{} Here is a single quote <'>
@end example
@@ -2900,7 +2967,7 @@ information about monthly shipments. In both files,
each line is considered to be one @dfn{record}.
In @file{mail-list}, each record contains the name of a person,
-his/her phone number, his/her email-address, and a code for their relationship
+his/her phone number, his/her email address, and a code for his/her relationship
with the author of the list.
The columns are aligned using spaces.
An @samp{A} in the last column
@@ -3021,8 +3088,8 @@ empty action that does nothing (i.e., no lines are printed).
Many practical @command{awk} programs are just a line or two. Following is a
collection of useful, short programs to get you started. Some of these
programs contain constructs that haven't been covered yet. (The description
-of the program will give you a good idea of what is going on, but please
-read the rest of the @value{DOCUMENT} to become an @command{awk} expert!)
+of the program will give you a good idea of what is going on, but you'll
+need to read the rest of the @value{DOCUMENT} to become an @command{awk} expert!)
Most of the examples use a @value{DF} named @file{data}. This is just a
placeholder; if you use these programs yourself, substitute
your own @value{FN}s for @file{data}.
@@ -3063,7 +3130,7 @@ expand data | awk '@{ if (x < length($0)) x = length($0) @}
@end example
This example differs slightly from the previous one:
-The input is processed by the @command{expand} utility to change TABs
+the input is processed by the @command{expand} utility to change TABs
into spaces, so the widths compared are actually the right-margin columns,
as opposed to the number of input characters on each line.
@@ -3317,7 +3384,7 @@ lines in the middle of a regular expression or a string.
with the C shell.} It works for @command{awk} programs in files and
for one-shot programs, @emph{provided} you are using a POSIX-compliant
shell, such as the Unix Bourne shell or Bash. But the C shell behaves
-differently! There, you must use two backslashes in a row, followed by
+differently! There you must use two backslashes in a row, followed by
a newline. Note also that when using the C shell, @emph{every} newline
in your @command{awk} program must be escaped with a backslash. To illustrate:
@@ -3358,9 +3425,9 @@ starts a comment, it ignores @emph{everything} on the rest of the
line. For example:
@example
-$ gawk 'BEGIN @{ print "dont panic" # a friendly \
-> BEGIN rule
-> @}'
+$ @kbd{gawk 'BEGIN @{ print "dont panic" # a friendly \}
+> @kbd{ BEGIN rule}
+> @kbd{@}'}
@error{} gawk: cmd. line:2: BEGIN rule
@error{} gawk: cmd. line:2: ^ syntax error
@end example
@@ -3410,7 +3477,7 @@ and array sorting.
As we develop our presentation of the @command{awk} language, we introduce
most of the variables and many of the functions. They are described
-systematically in @ref{Built-in Variables}, and in
+systematically in @DBREF{Built-in Variables} and in
@ref{Built-in}.
@node When
@@ -3444,8 +3511,8 @@ eight-bit microprocessors,
@end ifset
and a microcode assembler for a special-purpose Prolog
computer.
-While the original @command{awk}'s capabilities were strained by tasks
-of such complexity, modern versions are more capable.
+The original @command{awk}'s capabilities were strained by tasks
+of such complexity, but modern versions are more capable.
@cindex @command{awk} programs, complex
If you find yourself writing @command{awk} scripts of more than, say,
@@ -3500,7 +3567,7 @@ a comma, open brace, question mark, colon,
This @value{CHAPTER} covers how to run @command{awk}, both POSIX-standard
and @command{gawk}-specific command-line options, and what
@command{awk} and
-@command{gawk} do with non-option arguments.
+@command{gawk} do with nonoption arguments.
It then proceeds to cover how @command{gawk} searches for source files,
reading standard input along with other files, @command{gawk}'s
environment variables, @command{gawk}'s exit status, using include files,
@@ -3544,7 +3611,7 @@ enclosed in [@dots{}] in these templates are optional:
@cindex GNU long options
@cindex long options
@cindex options, long
-Besides traditional one-letter POSIX-style options, @command{gawk} also
+In addition to traditional one-letter POSIX-style options, @command{gawk} also
supports GNU long options.
@cindex dark corner, invoking @command{awk}
@@ -3607,7 +3674,7 @@ Set the @code{FS} variable to @var{fs}
@cindex @option{--file} option
@cindex @command{awk} programs, location of
Read @command{awk} program source from @var{source-file}
-instead of in the first non-option argument.
+instead of in the first nonoption argument.
This option may be given multiple times; the @command{awk}
program consists of the concatenation of the contents of
each specified @var{source-file}.
@@ -3867,7 +3934,7 @@ care to search for all occurrences of each inappropriate construct. As
@itemx @option{--bignum}
@cindex @option{-M} option
@cindex @option{--bignum} option
-Force arbitrary precision arithmetic on numbers. This option has no effect
+Force arbitrary-precision arithmetic on numbers. This option has no effect
if @command{gawk} is not compiled to use the GNU MPFR and MP libraries
(@pxref{Arbitrary Precision Arithmetic}).
@@ -3883,10 +3950,8 @@ values in input data
(@pxref{Nondecimal Data}).
@quotation CAUTION
-This option can severely break old programs.
-Use with care.
-
-This option may disappear in a future version of @command{gawk}.
+This option can severely break old programs. Use with care. Also note
+that this option may disappear in a future version of @command{gawk}.
@end quotation
@item @option{-N}
@@ -3920,7 +3985,7 @@ pretty-print the program and not run it.
@cindex @option{--optimize} option
@cindex @option{-O} option
Enable some optimizations on the internal representation of the program.
-At the moment this includes just simple constant folding.
+At the moment, this includes just simple constant folding.
@item @option{-p}[@var{file}]
@itemx @option{--profile}[@code{=}@var{file}]
@@ -3997,8 +4062,8 @@ Allow interval expressions
(@pxref{Regexp Operators})
in regexps.
This is now @command{gawk}'s default behavior.
-Nevertheless, this option remains both for backward compatibility,
-and for use in combination with @option{--traditional}.
+Nevertheless, this option remains (both for backward compatibility
+and for use in combination with @option{--traditional}).
@item @option{-S}
@itemx @option{--sandbox}
@@ -4051,7 +4116,7 @@ If it is, @command{awk} reads its program source from all of the named files, as
if they had been concatenated together into one big file. This is
useful for creating libraries of @command{awk} functions. These functions
can be written once and then retrieved from a standard place, instead
-of having to be included into each individual program.
+of having to be included in each individual program.
The @option{-i} option is similar in this regard.
(As mentioned in
@ref{Definition Syntax},
@@ -4062,7 +4127,7 @@ if the program is entered at the keyboard,
by specifying @samp{-f /dev/tty}. After typing your program,
type @kbd{Ctrl-d} (the end-of-file character) to terminate it.
(You may also use @samp{-f -} to read program source from the standard
-input but then you will not be able to also use the standard input as a
+input, but then you will not be able to also use the standard input as a
source of data.)
Because it is clumsy using the standard @command{awk} mechanisms to mix
@@ -4075,7 +4140,7 @@ options may also be used multiple times on the command line.
@cindex @option{-e} option
If no @option{-f} or @option{-e} option is specified, then @command{gawk}
-uses the first non-option command-line argument as the text of the
+uses the first nonoption command-line argument as the text of the
program source code.
@cindex @env{POSIXLY_CORRECT} environment variable
@@ -4142,7 +4207,7 @@ All the command-line arguments are made available to your @command{awk} program
and the program text (if present) are omitted from @code{ARGV}.
All other arguments, including variable assignments, are
included. As each element of @code{ARGV} is processed, @command{gawk}
-sets the variable @code{ARGIND} to the index in @code{ARGV} of the
+sets @code{ARGIND} to the index in @code{ARGV} of the
current element.
@c FIXME: One day, move the ARGC and ARGV node closer to here.
@@ -4319,7 +4384,7 @@ value of @env{AWKPATH}.
@code{ENVIRON["AWKPATH"]}. This provides access to the actual search
path value from within an @command{awk} program.
-While you can change @code{ENVIRON["AWKPATH"]} within your @command{awk}
+Although you can change @code{ENVIRON["AWKPATH"]} within your @command{awk}
program, this has no effect on the running program's behavior. This makes
sense: the @env{AWKPATH} environment variable is used to find the program
source files. Once your program is running, all the files have been
@@ -4355,7 +4420,7 @@ path value from within an @command{awk} program.
A number of other environment variables affect @command{gawk}'s
behavior, but they are more specialized. Those in the following
-list are meant to be used by regular users.
+list are meant to be used by regular users:
@table @env
@item GAWK_MSEC_SLEEP
@@ -4375,7 +4440,7 @@ retry a two-way TCP/IP (socket) connection before giving up.
@xref{TCP/IP Networking}.
@item POSIXLY_CORRECT
-Causes @command{gawk} to switch to POSIX compatibility
+Causes @command{gawk} to switch to POSIX-compatibility
mode, disabling all traditional and GNU extensions.
@xref{Options}.
@end table
@@ -4407,11 +4472,11 @@ for debugging problems on filesystems on non-POSIX operating systems
where I/O is performed in records, not in blocks.
@item GAWK_MSG_SRC
-If this variable exists, @command{gawk} includes the file
-name and line number within the @command{gawk} source code
+If this variable exists, @command{gawk} includes the @value{FN}
+and line number within the @command{gawk} source code
from which warning and/or fatal messages
are generated. Its purpose is to help isolate the source of a
-message, since there are multiple places which produce the
+message, as there are multiple places which produce the
same warning or error message.
@item GAWK_NO_DFA
@@ -4423,8 +4488,8 @@ supposed to be differences, but occasionally theory and practice don't
coordinate with each other.)
@item GAWK_NO_PP_RUN
-If this variable exists, then when invoked with the @option{--pretty-print}
-option, @command{gawk} skips running the program.
+When @command{gawk} is invoked with the @option{--pretty-print} option,
+it will not run the program if this environment variable exists.
@quotation CAUTION
This variable will not survive into the next major release.
@@ -4463,11 +4528,11 @@ If an error occurs, @command{gawk} exits with the value of
the C constant @code{EXIT_FAILURE}. This is usually one.
If @command{gawk} exits because of a fatal error, the exit
-status is 2. On non-POSIX systems, this value may be mapped
+status is two. On non-POSIX systems, this value may be mapped
to @code{EXIT_FAILURE}.
@node Include Files
-@section Including Other Files Into Your Program
+@section Including Other Files into Your Program
@c Panos Papadopoulos <panos1962@gmail.com> contributed the original
@c text for this section.
@@ -4516,9 +4581,9 @@ $ @kbd{gawk -f test2}
@print{} This is script test2.
@end example
-@code{gawk} runs the @file{test2} script which includes @file{test1}
+@code{gawk} runs the @file{test2} script, which includes @file{test1}
using the @code{@@include}
-keyword. So, to include external @command{awk} source files you just
+keyword. So, to include external @command{awk} source files, you just
use @code{@@include} followed by the name of the file to be included,
enclosed in double quotes.
@@ -4555,26 +4620,26 @@ The @value{FN} can, of course, be a pathname. For example:
@end example
@noindent
-or:
+and:
@example
@@include "/usr/awklib/network"
@end example
@noindent
-are valid. The @env{AWKPATH} environment variable can be of great
+are both valid. The @env{AWKPATH} environment variable can be of great
value when using @code{@@include}. The same rules for the use
of the @env{AWKPATH} variable in command-line file searches
(@pxref{AWKPATH Variable}) apply to
@code{@@include} also.
This is very helpful in constructing @command{gawk} function libraries.
-If you have a large script with useful, general purpose @command{awk}
+If you have a large script with useful, general-purpose @command{awk}
functions, you can break it down into library files and put those files
in a special directory. You can then include those ``libraries,'' using
either the full pathnames of the files, or by setting the @env{AWKPATH}
environment variable accordingly and then using @code{@@include} with
-just the file part of the full pathname. Of course you can have more
+just the file part of the full pathname. Of course, you can have more
than one directory to keep library files; the more complex the working
environment is, the more directories you may need to organize the files
to be included.
@@ -4592,7 +4657,7 @@ searched first for source files, before searching in @env{AWKPATH},
and this also applies to files named with @code{@@include}.
@node Loading Shared Libraries
-@section Loading Dynamic Extensions Into Your Program
+@section Loading Dynamic Extensions into Your Program
This @value{SECTION} describes a feature that is specific to @command{gawk}.
@@ -4602,7 +4667,7 @@ This @value{SECTION} describes a feature that is specific to @command{gawk}.
The @code{@@load} keyword can be used to read external @command{awk} extensions
(stored as system shared libraries).
This allows you to link in compiled code that may offer superior
-performance and/or give you access to extended capabilities not supported
+performance and/or give you access to extended capabilities not supported
by the @command{awk} language. The @env{AWKLIBPATH} variable is used to
search for the extension. Using @code{@@load} is completely equivalent
to using the @option{-l} command-line option.
@@ -4610,7 +4675,7 @@ to using the @option{-l} command-line option.
If the extension is not initially found in @env{AWKLIBPATH}, another
search is conducted after appending the platform's default shared library
suffix to the @value{FN}. For example, on GNU/Linux systems, the suffix
-@samp{.so} is used.
+@samp{.so} is used:
@example
$ @kbd{gawk '@@load "ordchr"; BEGIN @{print chr(65)@}'}
@@ -4745,13 +4810,13 @@ The three standard options for all versions of @command{awk} are
and many others, as well as corresponding GNU-style long options.
@item
-Non-option command-line arguments are usually treated as @value{FN}s,
+Nonoption command-line arguments are usually treated as @value{FN}s,
unless they have the form @samp{@var{var}=@var{value}}, in which case
they are taken as variable assignments to be performed at that point
in processing the input.
@item
-All non-option command-line arguments, excluding the program text,
+All nonoption command-line arguments, excluding the program text,
are placed in the @code{ARGV} array. Adjusting @code{ARGC} and @code{ARGV}
affects how @command{awk} processes input.
@@ -4800,7 +4865,7 @@ belongs to that set.
The simplest regular expression is a sequence of letters, numbers, or
both. Such a regexp matches any string that contains that sequence.
Thus, the regexp @samp{foo} matches any string containing @samp{foo}.
-Therefore, the pattern @code{/foo/} matches any input record containing
+Thus, the pattern @code{/foo/} matches any input record containing
the three adjacent characters @samp{foo} @emph{anywhere} in the record. Other
kinds of regexps let you specify more complicated classes of strings.
@@ -4863,17 +4928,16 @@ and @samp{!~} perform regular expression comparisons. Expressions
using these operators can be used as patterns, or in @code{if},
@code{while}, @code{for}, and @code{do} statements.
(@xref{Statements}.)
-For example:
+For example, the following is true if the expression @var{exp} (taken
+as a string) matches @var{regexp}:
@example
@var{exp} ~ /@var{regexp}/
@end example
@noindent
-is true if the expression @var{exp} (taken as a string)
-matches @var{regexp}. The following example matches, or selects,
-all input records with the uppercase letter @samp{J} somewhere in the
-first field:
+This example matches, or selects, all input records with the uppercase
+letter @samp{J} somewhere in the first field:
@example
$ @kbd{awk '$1 ~ /J/' inventory-shipped}
@@ -4943,9 +5007,9 @@ string or regexp. Thus, the string whose contents are the two characters
@samp{"} and @samp{\} must be written @code{"\"\\"}.
Other escape sequences represent unprintable characters
-such as TAB or newline. While there is nothing to stop you from entering most
+such as TAB or newline. There is nothing to stop you from entering most
unprintable characters directly in a string constant or regexp constant,
-they may look ugly.
+but they may look ugly.
The following list presents
all the escape sequences used in @command{awk} and
@@ -5018,7 +5082,7 @@ undefined results. (The @samp{\x} escape sequence is not allowed in
POSIX @command{awk}.)
@quotation CAUTION
-The next major relase of @command{gawk} will change, such
+The next major release of @command{gawk} will change, such
that a maximum of two hexadecimal digits following the
@samp{\x} will be used.
@end quotation
@@ -5030,7 +5094,7 @@ A literal slash (necessary for regexp constants only).
This sequence is used when you want to write a regexp
constant that contains a slash
(such as @code{/.*:\/home\/[[:alnum:]]+:.*/}; the @samp{[[:alnum:]]}
-notation is discussed shortly, in @ref{Bracket Expressions}).
+notation is discussed in @ref{Bracket Expressions}).
Because the regexp is delimited by
slashes, you need to escape any slash that is part of the pattern,
in order to tell @command{awk} to keep processing the rest of the regexp.
@@ -5053,7 +5117,7 @@ with a backslash have special meaning in regexps.
In a regexp, a backslash before any character that is not in the previous list
and not listed in
-@ref{GNU Regexp Operators},
+@DBREF{GNU Regexp Operators}
means that the next character should be taken literally, even if it would
normally be a regexp operator. For example, @code{/a\+b/} matches the three
characters @samp{a+b}.
@@ -5064,25 +5128,7 @@ characters @samp{a+b}.
For complete portability, do not use a backslash before any character not
shown in the previous list and that is not an operator.
-To summarize:
-
-@itemize @value{BULLET}
-@item
-The escape sequences in the list above are always processed first,
-for both string constants and regexp constants. This happens very early,
-as soon as @command{awk} reads your program.
-
-@item
-@command{gawk} processes both regexp constants and dynamic regexps
-(@pxref{Computed Regexps}),
-for the special operators listed in
-@ref{GNU Regexp Operators}.
-
-@item
-A backslash before any other character means to treat that character
-literally.
-@end itemize
-
+@c 11/2014: Moved so as to not stack sidebars
@sidebar Backslash Before Regular Characters
@cindex portability, backslash in escape sequences
@cindex POSIX @command{awk}, backslashes in string constants
@@ -5118,6 +5164,25 @@ In such implementations, typing @code{"a\qc"} is the same as typing
@end table
@end sidebar
+To summarize:
+
+@itemize @value{BULLET}
+@item
+The escape sequences in the preceding list are always processed first,
+for both string constants and regexp constants. This happens very early,
+as soon as @command{awk} reads your program.
+
+@item
+@command{gawk} processes both regexp constants and dynamic regexps
+(@pxref{Computed Regexps}),
+for the special operators listed in
+@ref{GNU Regexp Operators}.
+
+@item
+A backslash before any other character means to treat that character
+literally.
+@end itemize
+
@sidebar Escape Sequences for Metacharacters
@cindex metacharacters, escape sequences for
@@ -5165,7 +5230,7 @@ sequences and that are not listed in the following stand for themselves:
@cindex backslash (@code{\}), regexp operator
@cindex @code{\} (backslash), regexp operator
@item @code{\}
-This is used to suppress the special meaning of a character when
+This suppresses the special meaning of a character when
matching. For example, @samp{\$}
matches the character @samp{$}.
@@ -5174,8 +5239,9 @@ matches the character @samp{$}.
@cindex @code{^} (caret), regexp operator
@cindex caret (@code{^}), regexp operator
@item @code{^}
-This matches the beginning of a string. For example, @samp{^@@chapter}
-matches @samp{@@chapter} at the beginning of a string and can be used
+This matches the beginning of a string. @samp{^@@chapter}
+matches @samp{@@chapter} at the beginning of a string,
+for example, and can be used
to identify chapter beginnings in Texinfo source files.
The @samp{^} is known as an @dfn{anchor}, because it anchors the pattern to
match only at the beginning of the string.
@@ -5281,7 +5347,7 @@ There are two subtle points to understand about how @samp{*} works.
First, the @samp{*} applies only to the single preceding regular expression
component (e.g., in @samp{ph*}, it applies just to the @samp{h}).
To cause @samp{*} to apply to a larger sub-expression, use parentheses:
-@samp{(ph)*} matches @samp{ph}, @samp{phph}, @samp{phphph} and so on.
+@samp{(ph)*} matches @samp{ph}, @samp{phph}, @samp{phphph}, and so on.
Second, @samp{*} finds as many repetitions as possible. If the text
to be matched is @samp{phhhhhhhhhhhhhhooey}, @samp{ph*} matches all of
@@ -5381,7 +5447,7 @@ expressions are not available in regular expressions.
@cindex range expressions (regexps)
@cindex character lists in regular expression
-As mentioned earlier, a bracket expression matches any character amongst
+As mentioned earlier, a bracket expression matches any character among
those listed between the opening and closing square brackets.
Within a bracket expression, a @dfn{range expression} consists of two
@@ -5439,23 +5505,23 @@ a keyword denoting the class, and @samp{:]}.
POSIX standard.
@float Table,table-char-classes
-@caption{POSIX Character Classes}
+@caption{POSIX character classes}
@multitable @columnfractions .15 .85
@headitem Class @tab Meaning
-@item @code{[:alnum:]} @tab Alphanumeric characters.
-@item @code{[:alpha:]} @tab Alphabetic characters.
-@item @code{[:blank:]} @tab Space and TAB characters.
-@item @code{[:cntrl:]} @tab Control characters.
-@item @code{[:digit:]} @tab Numeric characters.
-@item @code{[:graph:]} @tab Characters that are both printable and visible.
-(A space is printable but not visible, whereas an @samp{a} is both.)
-@item @code{[:lower:]} @tab Lowercase alphabetic characters.
-@item @code{[:print:]} @tab Printable characters (characters that are not control characters).
-@item @code{[:punct:]} @tab Punctuation characters (characters that are not letters, digits,
-control characters, or space characters).
-@item @code{[:space:]} @tab Space characters (such as space, TAB, and formfeed, to name a few).
-@item @code{[:upper:]} @tab Uppercase alphabetic characters.
-@item @code{[:xdigit:]} @tab Characters that are hexadecimal digits.
+@item @code{[:alnum:]} @tab Alphanumeric characters
+@item @code{[:alpha:]} @tab Alphabetic characters
+@item @code{[:blank:]} @tab Space and TAB characters
+@item @code{[:cntrl:]} @tab Control characters
+@item @code{[:digit:]} @tab Numeric characters
+@item @code{[:graph:]} @tab Characters that are both printable and visible
+(a space is printable but not visible, whereas an @samp{a} is both)
+@item @code{[:lower:]} @tab Lowercase alphabetic characters
+@item @code{[:print:]} @tab Printable characters (characters that are not control characters)
+@item @code{[:punct:]} @tab Punctuation characters (characters that are not letters, digits
+control characters, or space characters)
+@item @code{[:space:]} @tab Space characters (such as space, TAB, and formfeed, to name a few)
+@item @code{[:upper:]} @tab Uppercase alphabetic characters
+@item @code{[:xdigit:]} @tab Characters that are hexadecimal digits
@end multitable
@end float
@@ -5470,7 +5536,7 @@ and numeric characters in your character set.
@c Thanks to
@c Date: Tue, 01 Jul 2014 07:39:51 +0200
@c From: Hermann Peifer <peifer@gmx.eu>
-Some utilities that match regular expressions provide a non-standard
+Some utilities that match regular expressions provide a nonstandard
@code{[:ascii:]} character class; @command{awk} does not. However, you
can simulate such a construct using @code{[\x00-\x7F]}. This matches
all values numerically between zero and 127, which is the defined
@@ -5656,7 +5722,7 @@ $ @kbd{awk '$0 ~ "[ \t\n]"'}
@error{} ]...
@error{} source line number 1
@error{} context is
-@error{} $0 ~ "[ >>> \t\n]" <<<
+@error{} $0 ~ "[ >>> \t\n]" <<<
@end example
@cindex newlines, in regexp constants
@@ -5766,9 +5832,9 @@ word-constituent characters. For example,
@cindex regular expressions, operators, for buffers
@cindex operators, string-matching, for buffers
There are two other operators that work on buffers. In Emacs, a
-@dfn{buffer} is, naturally, an Emacs buffer. For other programs,
-@command{gawk}'s regexp library routines consider the entire
-string to match as the buffer.
+@dfn{buffer} is, naturally, an Emacs buffer.
+Other GNU programs, including @command{gawk},
+consider the entire string to match as the buffer.
The operators are:
@table @code
@@ -5829,16 +5895,16 @@ in @ref{Regexp Operators}.
@end ifnottex
@item @code{--posix}
-Only POSIX regexps are supported; the GNU operators are not special
+Match only POSIX regexps; the GNU operators are not special
(e.g., @samp{\w} matches a literal @samp{w}). Interval expressions
are allowed.
@cindex Brian Kernighan's @command{awk}
@item @code{--traditional}
-Traditional Unix @command{awk} regexps are matched. The GNU operators
+Match traditional Unix @command{awk} regexps. The GNU operators
are not special, and interval expressions are not available.
-The POSIX character classes (@samp{[[:alnum:]]}, etc.) are supported,
-as BWK @command{awk} supports them.
+Because BWK @command{awk} supports them,
+the POSIX character classes (@samp{[[:alnum:]]}, etc.) are available.
Characters described by octal and hexadecimal escape sequences are
treated literally, even if they represent regexp metacharacters.
@@ -5898,7 +5964,7 @@ When @code{IGNORECASE} is not zero, @emph{all} regexp and string
operations ignore case.
Changing the value of @code{IGNORECASE} dynamically controls the
-case-sensitivity of the program as it runs. Case is significant by
+case sensitivity of the program as it runs. Case is significant by
default because @code{IGNORECASE} (like most variables) is initialized
to zero:
@@ -5911,7 +5977,7 @@ if (x ~ /ab/) @dots{} # now it will succeed
@end example
In general, you cannot use @code{IGNORECASE} to make certain rules
-case-insensitive and other rules case-sensitive, because there is no
+case insensitive and other rules case sensitive, as there is no
straightforward way
to set @code{IGNORECASE} just for the pattern of
a particular rule.@footnote{Experienced C and C++ programmers will note
@@ -5922,13 +5988,13 @@ and
However, this is somewhat obscure and we don't recommend it.}
To do this, use either bracket expressions or @code{tolower()}. However, one
thing you can do with @code{IGNORECASE} only is dynamically turn
-case-sensitivity on or off for all the rules at once.
+case sensitivity on or off for all the rules at once.
@code{IGNORECASE} can be set on the command line or in a @code{BEGIN} rule
(@pxref{Other Arguments}; also
@pxref{Using BEGIN/END}).
Setting @code{IGNORECASE} from the command line is a way to make
-a program case-insensitive without having to edit it.
+a program case insensitive without having to edit it.
@c @cindex ISO 8859-1
@c @cindex ISO Latin-1
@@ -5965,12 +6031,12 @@ in conditional expressions, or as part of matching expressions
using the @samp{~} and @samp{!~} operators.
@item
-Escape sequences let you represent non-printable characters and
+Escape sequences let you represent nonprintable characters and
also let you represent regexp metacharacters as literal characters
to be matched.
@item
-Regexp operators provide grouping, alternation and repetition.
+Regexp operators provide grouping, alternation, and repetition.
@item
Bracket expressions give you a shorthand for specifying sets
@@ -5985,8 +6051,8 @@ the match, such as for text substitution and when the record separator
is a regexp.
@item
-Matching expressions may use dynamic regexps, that is, string values
-treated as regular expressions.
+Matching expressions may use dynamic regexps (i.e., string values
+treated as regular expressions).
@item
@command{gawk}'s @code{IGNORECASE} variable lets you control the
@@ -6060,7 +6126,7 @@ used with it do not have to be named on the @command{awk} command line
@command{awk} divides the input for your program into records and fields.
It keeps track of the number of records that have been read so far from
the current input file. This value is stored in a predefined variable
-called @code{FNR} which is reset to zero every time a new file is started.
+called @code{FNR}, which is reset to zero every time a new file is started.
Another predefined variable, @code{NR}, records the total number of input
records read so far from all @value{DF}s. It starts at zero, but is
never automatically reset to zero.
@@ -6071,7 +6137,7 @@ never automatically reset to zero.
@end menu
@node awk split records
-@subsection Record Splitting With Standard @command{awk}
+@subsection Record Splitting with Standard @command{awk}
@cindex separators, for records
@cindex record separators
@@ -6088,7 +6154,7 @@ the value of @code{RS} can be changed in the @command{awk} program
with the assignment operator, @samp{=}
(@pxref{Assignment Ops}).
The new record-separator character should be enclosed in quotation marks,
-which indicate a string constant. Often the right time to do this is
+which indicate a string constant. Often, the right time to do this is
at the beginning of execution, before any input is processed,
so that the very first record is read with the proper separator.
To do this, use the special @code{BEGIN} pattern
@@ -6102,7 +6168,7 @@ awk 'BEGIN @{ RS = "u" @}
@noindent
changes the value of @code{RS} to @samp{u}, before reading any input.
-This is a string whose first character is the letter ``u;'' as a result, records
+This is a string whose first character is the letter ``u''; as a result, records
are separated by the letter ``u.'' Then the input file is read, and the second
rule in the @command{awk} program (the action with no pattern) prints each
record. Because each @code{print} statement adds a newline at the end of
@@ -6150,7 +6216,7 @@ $ @kbd{awk 'BEGIN @{ RS = "u" @}}
@print{} m@@ny
@print{} .ed
@print{} R
-@print{}
+@print{}
@end example
@noindent
@@ -6196,7 +6262,7 @@ being fully POSIX-compliant (@pxref{Options}).
Then, the following (extreme) pipeline prints a surprising @samp{1}:
@example
-$ echo | gawk --posix 'BEGIN @{ RS = "a" @} ; @{ print NF @}'
+$ @kbd{echo | gawk --posix 'BEGIN @{ RS = "a" @} ; @{ print NF @}'}
@print{} 1
@end example
@@ -6218,7 +6284,7 @@ The empty string @code{""} (a string without any characters)
has a special meaning
as the value of @code{RS}. It means that records are separated
by one or more blank lines and nothing else.
-@xref{Multiple Line}, for more details.
+@DBXREF{Multiple Line} for more details.
If you change the value of @code{RS} in the middle of an @command{awk} run,
the new value is used to delimit subsequent records, but the record
@@ -6238,7 +6304,7 @@ sets the variable @code{RT} to the text in the input that matched
@code{RS}.
@node gawk split records
-@subsection Record Splitting With @command{gawk}
+@subsection Record Splitting with @command{gawk}
@cindex common extensions, @code{RS} as a regexp
@cindex extensions, common@comma{} @code{RS} as a regexp
@@ -6282,11 +6348,11 @@ $ @kbd{echo record 1 AAAA record 2 BBBB record 3 |}
The square brackets delineate the contents of @code{RT}, letting you
see the leading and trailing whitespace. The final value of
@code{RT} is a newline.
-@xref{Simple Sed}, for a more useful example
+@DBXREF{Simple Sed} for a more useful example
of @code{RS} as a regexp and @code{RT}.
If you set @code{RS} to a regular expression that allows optional
-trailing text, such as @samp{RS = "abc(XYZ)?"} it is possible, due
+trailing text, such as @samp{RS = "abc(XYZ)?"}, it is possible, due
to implementation constraints, that @command{gawk} may match the leading
part of the regular expression, but not the trailing part, particularly
if the input text that could match the trailing part is fairly long.
@@ -6349,9 +6415,9 @@ character as a record separator. However, this is a special case:
@cindex records, treating files as
@cindex treating files, as single records
-@xref{Readfile Function}, for an interesting way to read
-whole files. If you are using @command{gawk}, see @ref{Extension Sample
-Readfile}, for another option.
+@DBXREF{Readfile Function} for an interesting way to read
+whole files. If you are using @command{gawk}, see @DBREF{Extension Sample
+Readfile} for another option.
@end sidebar
@c ENDOFRANGE inspl
@c ENDOFRANGE recspl
@@ -6373,9 +6439,9 @@ called @dfn{fields}. By default, fields are separated by @dfn{whitespace},
like words in a line.
Whitespace in @command{awk} means any string of one or more spaces,
TABs, or newlines;@footnote{In POSIX @command{awk}, newlines are not
-considered whitespace for separating fields.} other characters, such as
-formfeed, vertical tab, etc., that are
-considered whitespace by other languages, are @emph{not} considered
+considered whitespace for separating fields.} other characters
+that are considered whitespace by other languages
+(such as formfeed, vertical tab, etc.) are @emph{not} considered
whitespace by @command{awk}.
The purpose of fields is to make it more convenient for you to refer to
@@ -6392,7 +6458,7 @@ to refer to a field in an @command{awk} program,
followed by the number of the field you want. Thus, @code{$1}
refers to the first field, @code{$2} to the second, and so on.
(Unlike the Unix shells, the field numbers are not limited to single digits.
-@code{$127} is the one hundred twenty-seventh field in the record.)
+@code{$127} is the 127th field in the record.)
For example, suppose the following is a line of input:
@example
@@ -6462,7 +6528,7 @@ awk '@{ print $NR @}'
@noindent
Recall that @code{NR} is the number of records read so far: one in the
-first record, two in the second, etc. So this example prints the first
+first record, two in the second, and so on. So this example prints the first
field of the first record, the second field of the second record, and so
on. For the twentieth record, field number 20 is printed; most likely,
the record has fewer than 20 fields, so this prints a blank line.
@@ -6479,7 +6545,7 @@ The parentheses are used so that the multiplication is done before the
@samp{$} operation; they are necessary whenever there is a binary
operator@footnote{A @dfn{binary operator}, such as @samp{*} for
multiplication, is one that takes two operands. The distinction
-is required, since @command{awk} also has unary (one-operand)
+is required, because @command{awk} also has unary (one-operand)
and ternary (three-operand) operators.}
in the field-number expression. This example, then, prints the
type of relationship (the fourth field) for every line of the file
@@ -6553,7 +6619,7 @@ $ @kbd{awk '@{ $2 = $2 - 10; print $0 @}' inventory-shipped}
@dots{}
@end example
-It is also possible to also assign contents to fields that are out
+It is also possible to assign contents to fields that are out
of range. For example:
@example
@@ -6604,9 +6670,9 @@ else
@noindent
should print @samp{everything is normal}, because @code{NF+1} is certain
-to be out of range. (@xref{If Statement},
+to be out of range. (@DBXREF{If Statement}
for more information about @command{awk}'s @code{if-else} statements.
-@xref{Typing and Comparison},
+@DBXREF{Typing and Comparison}
for more information about the @samp{!=} operator.)
It is important to note that making an assignment to an existing field
@@ -6646,8 +6712,8 @@ after the new value of @code{NF} and recomputes @code{$0}.
Here is an example:
@example
-$ echo a b c d e f | awk '@{ print "NF =", NF;
-> NF = 3; print $0 @}'
+$ @kbd{echo a b c d e f | awk '@{ print "NF =", NF;}
+> @kbd{ NF = 3; print $0 @}'}
@print{} NF = 6
@print{} a b c
@end example
@@ -6691,7 +6757,7 @@ in a record simply by setting @code{FS} and @code{OFS}, and then
expecting a plain @samp{print} or @samp{print $0} to print the
modified record.
-But this does not work, since nothing was done to change the record
+But this does not work, because nothing was done to change the record
itself. Instead, you must force the record to be rebuilt, typically
with a statement such as @samp{$1 = $1}, as described earlier.
@end sidebar
@@ -6743,7 +6809,7 @@ the Unix Bourne shell, @command{sh}, or Bash).
@cindex @code{FS} variable, changing value of
The value of @code{FS} can be changed in the @command{awk} program with the
assignment operator, @samp{=} (@pxref{Assignment Ops}).
-Often the right time to do this is at the beginning of execution
+Often, the right time to do this is at the beginning of execution
before any input has been processed, so that the very first record
is read with the proper separator. To do this, use the special
@code{BEGIN} pattern
@@ -6899,7 +6965,7 @@ statement prints the new @code{$0}.
@cindex dark corner, @code{^}, in @code{FS}
There is an additional subtlety to be aware of when using regular expressions
for field splitting.
-It is not well-specified in the POSIX standard, or anywhere else, what @samp{^}
+It is not well specified in the POSIX standard, or anywhere else, what @samp{^}
means when splitting fields. Does the @samp{^} match only at the beginning of
the entire record? Or is each field separator a new string? It turns out that
different @command{awk} versions answer this question differently, and you
@@ -7065,11 +7131,11 @@ awk -F: '$5 == ""' /etc/passwd
@end example
@node Full Line Fields
-@subsection Making The Full Line Be A Single Field
+@subsection Making the Full Line Be a Single Field
Occasionally, it's useful to treat the whole input line as a
single field. This can be done easily and portably simply by
-setting @code{FS} to @code{"\n"} (a newline).@footnote{Thanks to
+setting @code{FS} to @code{"\n"} (a newline):@footnote{Thanks to
Andrew Schorr for this tip.}
@example
@@ -7079,42 +7145,6 @@ awk -F'\n' '@var{program}' @var{files @dots{}}
@noindent
When you do this, @code{$1} is the same as @code{$0}.
-@node Field Splitting Summary
-@subsection Field-Splitting Summary
-
-It is important to remember that when you assign a string constant
-as the value of @code{FS}, it undergoes normal @command{awk} string
-processing. For example, with Unix @command{awk} and @command{gawk},
-the assignment @samp{FS = "\.."} assigns the character string @code{".."}
-to @code{FS} (the backslash is stripped). This creates a regexp meaning
-``fields are separated by occurrences of any two characters.''
-If instead you want fields to be separated by a literal period followed
-by any single character, use @samp{FS = "\\.."}.
-
-The following list summarizes how fields are split, based on the value
-of @code{FS} (@samp{==} means ``is equal to''):
-
-@table @code
-@item FS == " "
-Fields are separated by runs of whitespace. Leading and trailing
-whitespace are ignored. This is the default.
-
-@item FS == @var{any other single character}
-Fields are separated by each occurrence of the character. Multiple
-successive occurrences delimit empty fields, as do leading and
-trailing occurrences.
-The character can even be a regexp metacharacter; it does not need
-to be escaped.
-
-@item FS == @var{regexp}
-Fields are separated by occurrences of characters that match @var{regexp}.
-Leading and trailing matches of @var{regexp} delimit empty fields.
-
-@item FS == ""
-Each individual character in the record becomes a separate field.
-(This is a common extension; it is not specified by the POSIX standard.)
-@end table
-
@sidebar Changing @code{FS} Does Not Affect the Fields
@cindex POSIX @command{awk}, field separators and
@@ -7160,6 +7190,42 @@ root:nSijPlPhZZwgE:0:0:Root:/:
@end example
@end sidebar
+@node Field Splitting Summary
+@subsection Field-Splitting Summary
+
+It is important to remember that when you assign a string constant
+as the value of @code{FS}, it undergoes normal @command{awk} string
+processing. For example, with Unix @command{awk} and @command{gawk},
+the assignment @samp{FS = "\.."} assigns the character string @code{".."}
+to @code{FS} (the backslash is stripped). This creates a regexp meaning
+``fields are separated by occurrences of any two characters.''
+If instead you want fields to be separated by a literal period followed
+by any single character, use @samp{FS = "\\.."}.
+
+The following list summarizes how fields are split, based on the value
+of @code{FS} (@samp{==} means ``is equal to''):
+
+@table @code
+@item FS == " "
+Fields are separated by runs of whitespace. Leading and trailing
+whitespace are ignored. This is the default.
+
+@item FS == @var{any other single character}
+Fields are separated by each occurrence of the character. Multiple
+successive occurrences delimit empty fields, as do leading and
+trailing occurrences.
+The character can even be a regexp metacharacter; it does not need
+to be escaped.
+
+@item FS == @var{regexp}
+Fields are separated by occurrences of characters that match @var{regexp}.
+Leading and trailing matches of @var{regexp} delimit empty fields.
+
+@item FS == ""
+Each individual character in the record becomes a separate field.
+(This is a common extension; it is not specified by the POSIX standard.)
+@end table
+
@sidebar @code{FS} and @code{IGNORECASE}
The @code{IGNORECASE} variable
@@ -7178,7 +7244,7 @@ print $1
@noindent
The output is @samp{aCa}. If you really want to split fields on an
alphabetic character while ignoring case, use a regexp that will
-do it for you. E.g., @samp{FS = "[c]"}. In this case, @code{IGNORECASE}
+do it for you (e.g., @samp{FS = "[c]"}). In this case, @code{IGNORECASE}
will take effect.
@end sidebar
@@ -7188,20 +7254,20 @@ will take effect.
@node Constant Size
@section Reading Fixed-Width Data
-@quotation NOTE
+@cindex data, fixed-width
+@cindex fixed-width data
+@cindex advanced features, fixed-width data
+
+@c O'Reilly doesn't like it as a note the first thing in the section.
This @value{SECTION} discusses an advanced
feature of @command{gawk}. If you are a novice @command{awk} user,
you might want to skip it on the first reading.
-@end quotation
-@cindex data, fixed-width
-@cindex fixed-width data
-@cindex advanced features, fixed-width data
-@command{gawk} provides a facility for dealing with
-fixed-width fields with no distinctive field separator. For example,
-data of this nature arises in the input for old Fortran programs where
-numbers are run together, or in the output of programs that did not
-anticipate the use of their output as input for other programs.
+@command{gawk} provides a facility for dealing with fixed-width fields
+with no distinctive field separator. For example, data of this nature
+arises in the input for old Fortran programs where numbers are run
+together, or in the output of programs that did not anticipate the use
+of their output as input for other programs.
An example of the latter is a table where all the columns are lined up by
the use of a variable number of spaces and @emph{empty fields are just
@@ -7240,15 +7306,10 @@ dave ttyq4 26Jun9115days 46 46 wnewmail
@end group
@end example
-The following program takes the above input, converts the idle time to
+The following program takes this input, converts the idle time to
number of seconds, and prints out the first two fields and the calculated
idle time:
-@quotation NOTE
-This program uses a number of @command{awk} features that
-haven't been introduced yet.
-@end quotation
-
@example
BEGIN @{ FIELDWIDTHS = "9 6 10 6 7 7 35" @}
NR > 2 @{
@@ -7267,6 +7328,11 @@ NR > 2 @{
@}
@end example
+@quotation NOTE
+The preceding program uses a number of @command{awk} features that
+haven't been introduced yet.
+@end quotation
+
Running the program on the data produces the following results:
@example
@@ -7312,17 +7378,16 @@ else
This information is useful when writing a function
that needs to temporarily change @code{FS} or @code{FIELDWIDTHS},
read some records, and then restore the original settings
-(@pxref{Passwd Functions},
+(@DBPXREF{Passwd Functions}
for an example of such a function).
@node Splitting By Content
-@section Defining Fields By Content
+@section Defining Fields by Content
-@quotation NOTE
+@c O'Reilly doesn't like it as a note the first thing in the section.
This @value{SECTION} discusses an advanced
feature of @command{gawk}. If you are a novice @command{awk} user,
you might want to skip it on the first reading.
-@end quotation
@cindex advanced features, specifying field content
Normally, when using @code{FS}, @command{gawk} defines the fields as the
@@ -7333,12 +7398,12 @@ However, there are times when you really want to define the fields by
what they are, and not by what they are not.
The most notorious such case
-is so-called @dfn{comma separated value} (CSV) data. Many spreadsheet programs,
+is so-called @dfn{comma-separated values} (CSV) data. Many spreadsheet programs,
for example, can export their data into text files, where each record is
terminated with a newline, and fields are separated by commas. If only
commas separated the data, there wouldn't be an issue. The problem comes when
-one of the fields contains an @emph{embedded} comma. While there is no
-formal standard specification for CSV data@footnote{At least, we don't know of one.},
+one of the fields contains an @emph{embedded} comma. Although there is no
+formal standard specification for CSV data,@footnote{At least, we don't know of one.}
in such cases, most programs embed the field in double quotes. So we might
have data like this:
@@ -7354,7 +7419,7 @@ The @code{FPAT} variable offers a solution for cases like this.
The value of @code{FPAT} should be a string that provides a regular expression.
This regular expression describes the contents of each field.
-In the case of CSV data as presented above, each field is either ``anything that
+In the case of CSV data as presented here, each field is either ``anything that
is not a comma,'' or ``a double quote, anything that is not a double quote, and a
closing double quote.'' If written as a regular expression constant
(@pxref{Regexp}),
@@ -7419,10 +7484,10 @@ will be @code{"FPAT"} if content-based field splitting is being used.
@quotation NOTE
Some programs export CSV data that contains embedded newlines between
the double quotes. @command{gawk} provides no way to deal with this.
-Since there is no formal specification for CSV data, there isn't much
+Because no formal specification for CSV data exists, there isn't much
more to be done;
the @code{FPAT} mechanism provides an elegant solution for the majority
-of cases, and the @command{gawk} developers are satisfied with that.
+of cases, and the @command{gawk} developers are satisfied with that.
@end quotation
As written, the regexp used for @code{FPAT} requires that each field
@@ -7576,7 +7641,7 @@ $ @kbd{awk -f addrs.awk addresses}
@dots{}
@end example
-@xref{Labels Program}, for a more realistic program that deals with
+@DBXREF{Labels Program} for a more realistic program dealing with
address lists. The following list summarizes how records are split,
based on the value of
@ifinfo
@@ -7671,7 +7736,7 @@ represents a shell command.
@quotation NOTE
When @option{--sandbox} is specified (@pxref{Options}),
-reading lines from files, pipes and coprocesses is disabled.
+reading lines from files, pipes, and coprocesses is disabled.
@end quotation
@menu
@@ -7814,7 +7879,7 @@ free
@end example
The @code{getline} command used in this way sets only the variables
-@code{NR}, @code{FNR} and @code{RT} (and of course, @var{var}).
+@code{NR}, @code{FNR}, and @code{RT} (and of course, @var{var}).
The record is not
split into fields, so the values of the fields (including @code{$0}) and
the value of @code{NF} do not change.
@@ -7868,7 +7933,7 @@ you want your program to be portable to all @command{awk} implementations.
Use @samp{getline @var{var} < @var{file}} to read input
from the file
-@var{file}, and put it in the variable @var{var}. As above, @var{file}
+@var{file}, and put it in the variable @var{var}. As earlier, @var{file}
is a string-valued expression that specifies the file from which to read.
In this version of @code{getline}, none of the predefined variables are
@@ -7904,7 +7969,7 @@ One deficiency of this program is that it does not process nested
@code{@@include} statements
(i.e., @code{@@include} statements in included files)
the way a true macro preprocessor would.
-@xref{Igawk Program}, for a program
+@DBXREF{Igawk Program} for a program
that does handle nested @code{@@include} statements.
@node Getline/Pipe
@@ -8203,7 +8268,7 @@ and whether the variant is standard or a @command{gawk} extension.
Note: for each variant, @command{gawk} sets the @code{RT} predefined variable.
@float Table,table-getline-variants
-@caption{@code{getline} Variants and What They Set}
+@caption{@code{getline} variants and what they set}
@multitable @columnfractions .33 .38 .27
@headitem Variant @tab Effect @tab @command{awk} / @command{gawk}
@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, @code{NR}, and @code{RT} @tab @command{awk}
@@ -8221,7 +8286,7 @@ Note: for each variant, @command{gawk} sets the @code{RT} predefined variable.
@c ENDOFRANGE infir
@node Read Timeout
-@section Reading Input With A Timeout
+@section Reading Input with a Timeout
@cindex timeout, reading input
@cindex differences in @command{awk} and @command{gawk}, read timeouts
@@ -8229,7 +8294,7 @@ This @value{SECTION} describes a feature that is specific to @command{gawk}.
You may specify a timeout in milliseconds for reading input from the keyboard,
a pipe, or two-way communication, including TCP/IP sockets. This can be done
-on a per input, command or connection basis, by setting a special element
+on a per input, command, or connection basis, by setting a special element
in the @code{PROCINFO} array (@pxref{Auto-set}):
@example
@@ -8303,11 +8368,11 @@ You should not assume that the read operation will block
exactly after the tenth record has been printed. It is possible that
@command{gawk} will read and buffer more than one record's
worth of data the first time. Because of this, changing the value
-of timeout like in the above example is not very useful.
+of timeout like in the preceding example is not very useful.
@end quotation
-If the @code{PROCINFO} element is not present and the environment
-variable @env{GAWK_READ_TIMEOUT} exists,
+If the @code{PROCINFO} element is not present and the
+@env{GAWK_READ_TIMEOUT} environment variable exists,
@command{gawk} uses its value to initialize the timeout value.
The exclusive use of the environment variable to specify timeout
has the disadvantage of not being able to control it
@@ -8328,7 +8393,7 @@ or the attempt to open a FIFO special file for reading can block
indefinitely until some other process opens it for writing.
@node Command-line directories
-@section Directories On The Command Line
+@section Directories on the Command Line
@cindex differences in @command{awk} and @command{gawk}, command-line directories
@cindex directories, command-line
@cindex command line, directories on
@@ -8343,14 +8408,14 @@ command line, but otherwise ignores it. This makes it easier to use
shell wildcards with your @command{awk} program:
@example
-$ @kbd{gawk -f whizprog.awk *} @ii{Directories could kill this progam}
+$ @kbd{gawk -f whizprog.awk *} @ii{Directories could kill this program}
@end example
If either of the @option{--posix}
or @option{--traditional} options is given, then @command{gawk} reverts
to treating a directory on the command line as a fatal error.
-@xref{Extension Sample Readdir}, for a way to treat directories
+@DBXREF{Extension Sample Readdir} for a way to treat directories
as usable data from an @command{awk} program.
@node Input Summary
@@ -8377,7 +8442,7 @@ The possibilities are as follows:
@item
After splitting the input into records, @command{awk} further splits
-the record into individual fields, named @code{$1}, @code{$2} and so
+the record into individual fields, named @code{$1}, @code{$2}, and so
on. @code{$0} is the whole record, and @code{NF} indicates how many
fields there are. The default way to split fields is between whitespace
characters.
@@ -8391,7 +8456,7 @@ greater than @code{NF} creates the field and rebuilds the record, using
thing. Decrementing @code{NF} throws away fields and rebuilds the record.
@item
-Field splitting is more complicated than record splitting.
+Field splitting is more complicated than record splitting:
@multitable @columnfractions .40 .45 .15
@headitem Field separator value @tab Fields are split @dots{} @tab @command{awk} / @command{gawk}
@@ -8464,7 +8529,7 @@ The @code{print} statement is not limited when
computing @emph{which} values to print. However, with two exceptions,
you cannot specify @emph{how} to print them---how many
columns, whether to use exponential notation or not, and so on.
-(For the exceptions, @pxref{Output Separators}, and
+(For the exceptions, @DBPXREF{Output Separators} and
@ref{OFMT}.)
For printing with specifications, you need the @code{printf} statement
(@pxref{Printf}).
@@ -8661,14 +8726,14 @@ separated by single spaces. However, this doesn't need to be the case;
a single space is simply the default. Any string of
characters may be used as the @dfn{output field separator} by setting the
predefined variable @code{OFS}. The initial value of this variable
-is the string @w{@code{" "}}---that is, a single space.
+is the string @w{@code{" "}} (i.e., a single space).
-The output from an entire @code{print} statement is called an
-@dfn{output record}. Each @code{print} statement outputs one output
-record, and then outputs a string called the @dfn{output record separator}
-(or @code{ORS}). The initial
-value of @code{ORS} is the string @code{"\n"}; i.e., a newline
-character. Thus, each @code{print} statement normally makes a separate line.
+The output from an entire @code{print} statement is called an @dfn{output
+record}. Each @code{print} statement outputs one output record, and
+then outputs a string called the @dfn{output record separator} (or
+@code{ORS}). The initial value of @code{ORS} is the string @code{"\n"}
+(i.e., a newline character). Thus, each @code{print} statement normally
+makes a separate line.
@cindex output, records
@cindex output record separator, See @code{ORS} variable
@@ -8691,27 +8756,27 @@ newline:
$ @kbd{awk 'BEGIN @{ OFS = ";"; ORS = "\n\n" @}}
> @kbd{@{ print $1, $2 @}' mail-list}
@print{} Amelia;555-5553
-@print{}
+@print{}
@print{} Anthony;555-3412
-@print{}
+@print{}
@print{} Becky;555-7685
-@print{}
+@print{}
@print{} Bill;555-1675
-@print{}
+@print{}
@print{} Broderick;555-0542
-@print{}
+@print{}
@print{} Camilla;555-2912
-@print{}
+@print{}
@print{} Fabius;555-1234
-@print{}
+@print{}
@print{} Julie;555-6699
-@print{}
+@print{}
@print{} Martin;555-6480
-@print{}
+@print{}
@print{} Samuel;555-3430
-@print{}
+@print{}
@print{} Jean-Paul;555-2127
-@print{}
+@print{}
@end example
If the value of @code{ORS} does not contain a newline, the program's output
@@ -8792,7 +8857,7 @@ printf @var{format}, @var{item1}, @var{item2}, @dots{}
@end example
@noindent
-As print @code{print}, the entire list of arguments may optionally be
+As for @code{print}, the entire list of arguments may optionally be
enclosed in parentheses. Here too, the parentheses are necessary if any
of the item expressions use the @samp{>} relational operator; otherwise,
it can be confused with an output redirection (@pxref{Redirection}).
@@ -8900,7 +8965,7 @@ which follow the decimal point.
(The @samp{4.3} represents two modifiers,
discussed in the next @value{SUBSECTION}.)
-On systems supporting IEEE 754 floating point format, values
+On systems supporting IEEE 754 floating-point format, values
representing negative
infinity are formatted as
@samp{-inf} or @samp{-infinity},
@@ -8931,7 +8996,7 @@ Print a string.
@item @code{%u}
Print an unsigned decimal integer.
(This format is of marginal use, because all numbers in @command{awk}
-are floating-point; it is provided primarily for compatibility with C.)
+are floating point; it is provided primarily for compatibility with C.)
@item @code{%x}, @code{%X}
Print an unsigned hexadecimal integer;
@@ -9024,7 +9089,7 @@ says to always supply a sign for numeric conversions, even if the data
to format is positive. The @samp{+} overrides the space modifier.
@item #
-Use an ``alternate form'' for certain control letters.
+Use an ``alternative form'' for certain control letters.
For @code{%o}, supply a leading zero.
For @code{%x} and @code{%X}, supply a leading @code{0x} or @samp{0X} for
a nonzero result.
@@ -9041,7 +9106,7 @@ value to print.
@item '
A single quote or apostrophe character is a POSIX extension to ISO C.
-It indicates that the integer part of a floating point value, or the
+It indicates that the integer part of a floating-point value, or the
entire part of an integer decimal value, should have a thousands-separator
character in it. This only works in locales that support such characters.
For example:
@@ -9122,7 +9187,7 @@ prints @samp{foob}.
@end table
The C library @code{printf}'s dynamic @var{width} and @var{prec}
-capability (for example, @code{"%*.*s"}) is supported. Instead of
+capability (e.g., @code{"%*.*s"}) is supported. Instead of
supplying explicit @var{width} and/or @var{prec} values in the format
string, they are passed in the argument list. For example:
@@ -9222,7 +9287,7 @@ awk 'BEGIN @{ print "Name Number"
@{ printf "%-10s %s\n", $1, $2 @}' mail-list
@end example
-The above example mixes @code{print} and @code{printf} statements in
+The preceding example mixes @code{print} and @code{printf} statements in
the same program. Using just @code{printf} statements can produce the
same results:
@@ -9369,7 +9434,7 @@ close(report)
The @code{close()} function is called here because it's a good idea to close
the pipe as soon as all the intended output has been sent to it.
-@xref{Close Files And Pipes},
+@DBXREF{Close Files And Pipes}
for more information.
This example also illustrates the use of a variable to represent
@@ -9393,9 +9458,9 @@ but subsidiary to, the @command{awk} program.
This feature is a @command{gawk} extension, and is not available in
POSIX @command{awk}.
-@xref{Getline/Coprocess},
+@DBXREF{Getline/Coprocess}
for a brief discussion.
-@xref{Two-way I/O},
+@DBXREF{Two-way I/O}
for a more complete discussion.
@end table
@@ -9419,7 +9484,7 @@ print "Avoid improbability generators" >> "guide.txt"
@noindent
This is indeed how redirections must be used from the shell. But in
@command{awk}, it isn't necessary. In this kind of case, a program should
-use @samp{>} for all the @code{print} statements, since the output file
+use @samp{>} for all the @code{print} statements, because the output file
is only opened once. (It happens that if you mix @samp{>} and @samp{>>}
that output is produced in the expected order. However, mixing the operators
for the same file is definitely poor style, and is confusing to readers
@@ -9468,7 +9533,7 @@ The program builds up a list of command lines,
using the @command{mv} utility to rename the files.
It then sends the list to the shell for execution.
-@xref{Shell Quoting}, for a function that can help in generating
+@DBXREF{Shell Quoting} for a function that can help in generating
command lines to be fed to the shell.
@end sidebar
@c ENDOFRANGE outre
@@ -9533,7 +9598,7 @@ that happens, writing to the screen is not correct. In fact, if
terminal at all.
Then opening @file{/dev/tty} fails.
-@command{gawk}, BWK @command{awk} and @command{mawk} provide
+@command{gawk}, BWK @command{awk}, and @command{mawk} provide
special @value{FN}s for accessing the three standard streams.
If the @value{FN} matches one of these special names when @command{gawk}
(or one of the others) redirects input or output, then it directly uses
@@ -9576,7 +9641,7 @@ It is a common error to omit the quotes, which leads
to confusing results.
@command{gawk} does not treat these @value{FN}s as special when
-in POSIX compatibility mode. However, since BWK @command{awk}
+in POSIX-compatibility mode. However, because BWK @command{awk}
supports them, @command{gawk} does support them even when
invoked with the @option{--traditional} option (@pxref{Options}).
@@ -9585,7 +9650,7 @@ invoked with the @option{--traditional} option (@pxref{Options}).
@c STARTOFRANGE gfn
@cindex @command{gawk}, file names in
-Besides access to standard input, stanard output, and standard error,
+Besides access to standard input, standard output, and standard error,
@command{gawk} provides access to any open file descriptor.
Additionally, there are special @value{FN}s reserved for
TCP/IP networking.
@@ -9634,7 +9699,7 @@ This is done using a special @value{FN} of the form:
@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}}
@end example
-The @var{net-type} is one of @samp{inet}, @samp{inet4} or @samp{inet6}.
+The @var{net-type} is one of @samp{inet}, @samp{inet4}, or @samp{inet6}.
The @var{protocol} is one of @samp{tcp} or @samp{udp},
and the other fields represent the other essential pieces of information
for making a networking connection.
@@ -9823,7 +9888,7 @@ is not closed and released until @code{close()} is called or
@command{awk} exits.
@code{close()} silently does nothing if given an argument that
-does not represent a file, pipe or coprocess that was opened with
+does not represent a file, pipe, or coprocess that was opened with
a redirection. In such a case, it returns a negative value,
indicating an error. In addition, @command{gawk} sets @code{ERRNO}
to a string indicating the error.
@@ -9857,9 +9922,10 @@ which describes it in more detail and gives an example.
@cindex Unix @command{awk}, @code{close()} function and
In many older versions of Unix @command{awk}, the @code{close()} function
-is actually a statement. It is a syntax error to try and use the return
-value from @code{close()}:
+is actually a statement.
@value{DARKCORNER}
+It is a syntax error to try and use the return
+value from @code{close()}:
@example
command = "@dots{}"
@@ -9922,11 +9988,11 @@ Output from both @code{print} and @code{printf} may be redirected to
files, pipes, and coprocesses.
@item
-@command{gawk} provides special file names for access to standard input,
-output and error, and for network communications.
+@command{gawk} provides special @value{FN}s for access to standard input,
+output, and error, and for network communications.
@item
-Use @code{close()} to close open file, pipe and coprocess redirections.
+Use @code{close()} to close open file, pipe, and coprocess redirections.
For coprocesses, it is possible to close only one direction of the
communications.
@@ -9994,7 +10060,7 @@ combinations of these with various operators.
@end menu
@node Values
-@section Constants, Variables and Conversions
+@section Constants, Variables, and Conversions
Expressions are built up from values and the operations performed
upon them. This @value{SECTION} describes the elementary objects
@@ -10020,7 +10086,7 @@ string, and regular expression.
Each is used in the appropriate context when you need a data
value that isn't going to change. Numeric constants can
-have different forms, but are stored identically internally.
+have different forms, but are internally stored in an identical manner.
@menu
* Scalar Constants:: Numeric and string constants.
@@ -10036,7 +10102,7 @@ have different forms, but are stored identically internally.
A @dfn{numeric constant} stands for a number. This number can be an
integer, a decimal fraction, or a number in scientific (exponential)
notation.@footnote{The internal representation of all numbers,
-including integers, uses double precision floating-point numbers.
+including integers, uses double-precision floating-point numbers.
On most modern systems, these are in IEEE 754 standard format.
@xref{Arbitrary Precision Arithmetic}, for much more information.}
Here are some examples of numeric constants that all
@@ -10050,7 +10116,7 @@ have the same value:
@cindex string constants
A string constant consists of a sequence of characters enclosed in
-double-quotation marks. For example:
+double quotation marks. For example:
@example
"parrot"
@@ -10072,13 +10138,13 @@ implementations may have difficulty with some character codes.
@cindex numbers, octal
@cindex numbers, hexadecimal
-In @command{awk}, all numbers are in decimal; i.e., base 10. Many other
+In @command{awk}, all numbers are in decimal (i.e., base 10). Many other
programming languages allow you to specify numbers in other bases, often
octal (base 8) and hexadecimal (base 16).
-In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc.
+In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on.
Just as @samp{11}, in decimal, is 1 times 10 plus 1, so
@samp{11}, in octal, is 1 times 8, plus 1. This equals 9 in decimal.
-In hexadecimal, there are 16 digits. Since the everyday decimal
+In hexadecimal, there are 16 digits. Because the everyday decimal
number system only has ten digits (@samp{0}--@samp{9}), the letters
@samp{a} through @samp{f} are used to represent the rest.
(Case in the letters is usually irrelevant; hexadecimal @samp{a} and @samp{A}
@@ -10130,11 +10196,12 @@ you can use the @code{strtonum()} function
to convert the data into a number.
Most of the time, you will want to use octal or hexadecimal constants
when working with the built-in bit manipulation functions;
-see @ref{Bitwise Functions},
+see @DBREF{Bitwise Functions}
for more information.
-Unlike some early C implementations, @samp{8} and @samp{9} are not valid
-in octal constants; e.g., @command{gawk} treats @samp{018} as decimal 18:
+Unlike some early C implementations, @samp{8} and @samp{9} are not
+valid in octal constants. For example, @command{gawk} treats @samp{018}
+as decimal 18:
@example
$ @kbd{gawk 'BEGIN @{ print "021 is", 021 ; print 018 @}'}
@@ -10191,7 +10258,7 @@ matched.
However, regexp constants (such as @code{/foo/}) may be used like simple expressions.
When a
regexp constant appears by itself, it has the same meaning as if it appeared
-in a pattern, i.e., @samp{($0 ~ /foo/)}
+in a pattern (i.e., @samp{($0 ~ /foo/)}).
@value{DARKCORNER}
@xref{Expression Patterns}.
This means that the following two code segments:
@@ -10288,7 +10355,7 @@ either @code{sub()} or @code{gsub()}. However, what really happens is that
the @code{pat} parameter is either one or zero, depending upon whether
or not @code{$0} matches @code{/hi/}.
@command{gawk} issues a warning when it sees a regexp constant used as
-a parameter to a user-defined function, since passing a truth value in
+a parameter to a user-defined function, because passing a truth value in
this way is probably not what was intended.
@c ENDOFRANGE rec
@@ -10328,7 +10395,7 @@ variable's current value. Variables are given new values with
@dfn{decrement operators}.
@xref{Assignment Ops}.
In addition, the @code{sub()} and @code{gsub()} functions can
-change a variable's value, and the @code{match()}, @code{split()}
+change a variable's value, and the @code{match()}, @code{split()},
and @code{patsplit()} functions can change the contents of their
array parameters. @xref{String Functions}.
@@ -10336,7 +10403,7 @@ array parameters. @xref{String Functions}.
@cindex variables, initializing
A few variables have special built-in meanings, such as @code{FS} (the
field separator), and @code{NF} (the number of fields in the current input
-record). @xref{Built-in Variables}, for a list of the predefined variables.
+record). @DBXREF{Built-in Variables} for a list of the predefined variables.
These predefined variables can be used and assigned just like all other
variables, but their values are also used or changed automatically by
@command{awk}. All predefined variables' names are entirely uppercase.
@@ -10377,7 +10444,7 @@ as in the following:
the variable is set at the very beginning, even before the
@code{BEGIN} rules execute. The @option{-v} option and its assignment
must precede all the @value{FN} arguments, as well as the program text.
-(@xref{Options}, for more information about
+(@DBXREF{Options} for more information about
the @option{-v} option.)
Otherwise, the variable assignment is performed at a time determined by
its position among the input file arguments---after the processing of the
@@ -10417,7 +10484,7 @@ sequences
@node Conversion
@subsection Conversion of Strings and Numbers
-Number to string and string to number conversion are generally
+Number-to-string and string-to-number conversion are generally
straightforward. There can be subtleties to be aware of;
this @value{SECTION} discusses this important facet of @command{awk}.
@@ -10428,7 +10495,7 @@ this @value{SECTION} discusses this important facet of @command{awk}.
@end menu
@node Strings And Numbers
-@subsubsection How @command{awk} Converts Between Strings And Numbers
+@subsubsection How @command{awk} Converts Between Strings and Numbers
@cindex converting, strings to numbers
@cindex strings, converting
@@ -10459,7 +10526,7 @@ string, concatenate that number with the empty string, @code{""}.
To force a string to be converted to a number, add zero to that string.
A string is converted to a number by interpreting any numeric prefix
of the string as numerals:
-@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1000, and @code{"25fix"}
+@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1,000, and @code{"25fix"}
has a numeric value of 25.
Strings that can't be interpreted as valid numbers convert to zero.
@@ -10499,7 +10566,7 @@ b = a ""
@code{b} has the value @code{"12"}, not @code{"12.00"}.
@value{DARKCORNER}
-@sidebar Pre-POSIX @command{awk} Used @code{OFMT} For String Conversion
+@sidebar Pre-POSIX @command{awk} Used @code{OFMT} for String Conversion
@cindex POSIX @command{awk}, @code{OFMT} variable and
@cindex @code{OFMT} variable
@cindex portability, new @command{awk} vs.@: old @command{awk}
@@ -10511,7 +10578,7 @@ specifies the output format to use when printing numbers with @code{print}.
conversion from the semantics of printing. Both @code{CONVFMT} and
@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority
of cases, old @command{awk} programs do not change their behavior.
-@xref{Print}, for more information on the @code{print} statement.
+@DBXREF{Print} for more information on the @code{print} statement.
@end sidebar
@node Locale influences conversions
@@ -10533,7 +10600,7 @@ The POSIX standard says that @command{awk} always uses the period as the decimal
point when reading the @command{awk} program source code, and for
command-line variable assignments (@pxref{Other Arguments}). However,
when interpreting input data, for @code{print} and @code{printf} output,
-and for number to string conversion, the local decimal point character
+and for number-to-string conversion, the local decimal point character
is used. @value{DARKCORNER} In all cases, numbers in source code and
in input data cannot have a thousands separator. Here are some examples
indicating the difference in behavior, on a GNU/Linux system:
@@ -10558,7 +10625,7 @@ as the full number including the fractional part, 4.321.
Some earlier versions of @command{gawk} fully complied with this aspect
of the standard. However, many users in non-English locales complained
-about this behavior, since their data used a period as the decimal
+about this behavior, because their data used a period as the decimal
point, so the default behavior was restored to use a period as the
decimal point character. You can use the @option{--use-lc-numeric}
option (@pxref{Options}) to force @command{gawk} to use the locale's
@@ -10571,7 +10638,7 @@ point character is used and when a period is used. Some of these
features have not been described yet.
@float Table,table-locale-affects
-@caption{Locale Decimal Point versus A Period}
+@caption{Locale decimal point versus a period}
@multitable @columnfractions .15 .20 .45
@headitem Feature @tab Default @tab @option{--posix} or @option{--use-lc-numeric}
@item @code{%'g} @tab Use locale @tab Use locale
@@ -10581,13 +10648,13 @@ features have not been described yet.
@end multitable
@end float
-Finally, modern day formal standards and IEEE standard floating point
+Finally, modern day formal standards and IEEE standard floating-point
representation can have an unusual but important effect on the way
@command{gawk} converts some special string values to numbers. The details
are presented in @ref{POSIX Floating Point Problems}.
@node All Operators
-@section Operators: Doing Something With Values
+@section Operators: Doing Something with Values
This @value{SECTION} introduces the @dfn{operators} which make use
of the values provided by constants and variables.
@@ -10666,7 +10733,7 @@ Multiplication.
Division; because all numbers in @command{awk} are floating-point
numbers, the result is @emph{not} rounded to an integer---@samp{3 / 4} has
the value 0.75. (It is a common mistake, especially for C programmers,
-to forget that @emph{all} numbers in @command{awk} are floating-point,
+to forget that @emph{all} numbers in @command{awk} are floating point,
and that division of integer-looking constants produces a real number,
not an integer.)
@@ -10751,7 +10818,7 @@ $ @kbd{awk '@{ print "Field number one:" $1 @}' mail-list}
@cindex troubleshooting, string concatenation
Because string concatenation does not have an explicit operator, it is
-often necessary to insure that it happens at the right time by using
+often necessary to ensure that it happens at the right time by using
parentheses to enclose the items to concatenate. For example,
you might expect that the
following code fragment concatenates @code{file} and @code{name}:
@@ -11013,7 +11080,14 @@ The indices of @code{bar} are practically guaranteed to be different, because
@code{rand()} returns different values each time it is called.
(Arrays and the @code{rand()} function haven't been covered yet.
@xref{Arrays},
-and see @ref{Numeric Functions}, for more information).
+and
+@ifnotdocbook
+@DBPXREF{Numeric Functions}
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Numeric Functions}
+@end ifdocbook
+for more information).
This example illustrates an important fact about assignment
operators: the lefthand expression is only evaluated @emph{once}.
@@ -11046,20 +11120,20 @@ to a number.
@cindex @code{*} (asterisk), @code{**=} operator
@cindex asterisk (@code{*}), @code{**=} operator
@float Table,table-assign-ops
-@caption{Arithmetic Assignment Operators}
+@caption{Arithmetic assignment operators}
@multitable @columnfractions .30 .70
@headitem Operator @tab Effect
-@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue}.
-@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue}.
-@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient}.
-@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor}.
-@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus}.
+@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue}
+@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue}
+@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient}
+@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor}
+@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus}
@cindex common extensions, @code{**=} operator
@cindex extensions, common@comma{} @code{**=} operator
@cindex @command{awk} language, POSIX version
@cindex POSIX @command{awk}
@item @var{lvalue} @code{^=} @var{power} @tab
-@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power}. @value{COMMONEXT}
+@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power} @value{COMMONEXT}
@end multitable
@end float
@@ -11090,7 +11164,7 @@ This is most notable in some commercial @command{awk} versions.
For example:
@example
-$ awk /==/ /dev/null
+$ @kbd{awk /==/ /dev/null}
@error{} awk: syntax error at source line 1
@error{} context is
@error{} >>> /= <<<
@@ -11142,7 +11216,7 @@ but with the side effect of incrementing it.
The post-increment @samp{foo++} is nearly the same as writing @samp{(foo
+= 1) - 1}. It is not perfectly equivalent because all numbers in
-@command{awk} are floating-point---in floating-point, @samp{foo + 1 - 1} does
+@command{awk} are floating point---in floating point, @samp{foo + 1 - 1} does
not necessarily equal @code{foo}. But the difference is minute as
long as you stick to numbers that are fairly small (less than
@iftex
@@ -11247,8 +11321,8 @@ You should avoid such things in your own programs.
@node Truth Values and Conditions
@section Truth Values and Conditions
-In certain contexts, expression values also serve as ``truth values;'' i.e.,
-they determine what should happen next as the program runs. This
+In certain contexts, expression values also serve as ``truth values''; (i.e.,
+they determine what should happen next as the program runs). This
@value{SECTION} describes how @command{awk} defines ``true'' and ``false''
and how values are compared.
@@ -11304,7 +11378,7 @@ the string constant @code{"0"} is actually true, because it is non-null.
@subsection Variable Typing and Comparison Expressions
@quotation
@i{The Guide is definitive. Reality is frequently inaccurate.}
-@author The Hitchhiker's Guide to the Galaxy
+@author Douglas Adams, @cite{The Hitchhiker's Guide to the Galaxy}
@end quotation
@c STARTOFRANGE comex
@@ -11332,7 +11406,7 @@ compares variables.
@end menu
@node Variable Typing
-@subsubsection String Type Versus Numeric Type
+@subsubsection String Type versus Numeric Type
@cindex numeric, strings
@cindex strings, numeric
@@ -11358,7 +11432,7 @@ attribute.
@item
Fields, @code{getline} input, @code{FILENAME}, @code{ARGV} elements,
@code{ENVIRON} elements, and the elements of an array created by
-@code{match()}, @code{split()} and @code{patsplit()} that are numeric
+@code{match()}, @code{split()}, and @code{patsplit()} that are numeric
strings have the @var{strnum} attribute. Otherwise, they have
the @var{string} attribute. Uninitialized variables also have the
@var{strnum} attribute.
@@ -11559,18 +11633,18 @@ operators}, which are a superset of those in C.
@cindex exclamation point (@code{!}), @code{!~} operator
@cindex @code{in} operator
@float Table,table-relational-ops
-@caption{Relational Operators}
+@caption{Relational operators}
@multitable @columnfractions .25 .75
@headitem Expression @tab Result
-@item @var{x} @code{<} @var{y} @tab True if @var{x} is less than @var{y}.
-@item @var{x} @code{<=} @var{y} @tab True if @var{x} is less than or equal to @var{y}.
-@item @var{x} @code{>} @var{y} @tab True if @var{x} is greater than @var{y}.
-@item @var{x} @code{>=} @var{y} @tab True if @var{x} is greater than or equal to @var{y}.
-@item @var{x} @code{==} @var{y} @tab True if @var{x} is equal to @var{y}.
-@item @var{x} @code{!=} @var{y} @tab True if @var{x} is not equal to @var{y}.
-@item @var{x} @code{~} @var{y} @tab True if the string @var{x} matches the regexp denoted by @var{y}.
-@item @var{x} @code{!~} @var{y} @tab True if the string @var{x} does not match the regexp denoted by @var{y}.
-@item @var{subscript} @code{in} @var{array} @tab True if the array @var{array} has an element with the subscript @var{subscript}.
+@item @var{x} @code{<} @var{y} @tab True if @var{x} is less than @var{y}
+@item @var{x} @code{<=} @var{y} @tab True if @var{x} is less than or equal to @var{y}
+@item @var{x} @code{>} @var{y} @tab True if @var{x} is greater than @var{y}
+@item @var{x} @code{>=} @var{y} @tab True if @var{x} is greater than or equal to @var{y}
+@item @var{x} @code{==} @var{y} @tab True if @var{x} is equal to @var{y}
+@item @var{x} @code{!=} @var{y} @tab True if @var{x} is not equal to @var{y}
+@item @var{x} @code{~} @var{y} @tab True if the string @var{x} matches the regexp denoted by @var{y}
+@item @var{x} @code{!~} @var{y} @tab True if the string @var{x} does not match the regexp denoted by @var{y}
+@item @var{subscript} @code{in} @var{array} @tab True if the array @var{array} has an element with the subscript @var{subscript}
@end multitable
@end float
@@ -11608,24 +11682,24 @@ The following list of expressions illustrates the kinds of comparisons
@table @code
@item 1.5 <= 2.0
-numeric comparison (true)
+Numeric comparison (true)
@item "abc" >= "xyz"
-string comparison (false)
+String comparison (false)
@item 1.5 != " +2"
-string comparison (true)
+String comparison (true)
@item "1e2" < "3"
-string comparison (true)
+String comparison (true)
@item a = 2; b = "2"
@itemx a == b
-string comparison (true)
+String comparison (true)
@item a = 2; b = " +2"
@itemx a == b
-string comparison (false)
+String comparison (false)
@end table
In this example:
@@ -11678,7 +11752,7 @@ dynamic regexp (@pxref{Regexp Usage}; also
@cindex @command{awk}, regexp constants and
@cindex regexp constants
A constant regular
-expression in slashes by itself is also an expression. The regexp
+expression in slashes by itself is also an expression.
@code{/@var{regexp}/} is an abbreviation for the following comparison expression:
@example
@@ -11692,7 +11766,7 @@ One special place where @code{/foo/} is @emph{not} an abbreviation for
where this is discussed in more detail.
@node POSIX String Comparison
-@subsubsection String Comparison With POSIX Rules
+@subsubsection String Comparison with POSIX Rules
The POSIX standard says that string comparison is performed based
on the locale's @dfn{collating order}. This is the order in which
@@ -11948,13 +12022,13 @@ example, the function @code{sqrt()} computes the square root of a number.
@cindex functions, built-in
A fixed set of functions are @dfn{built-in}, which means they are
available in every @command{awk} program. The @code{sqrt()} function is one
-of these. @xref{Built-in}, for a list of built-in
+of these. @DBXREF{Built-in} for a list of built-in
functions and their descriptions. In addition, you can define
functions for use in your program.
-@xref{User-defined},
+@DBXREF{User-defined}
for instructions on how to do this.
Finally, @command{gawk} lets you write functions in C or C++
-that may be called from your program: see @ref{Dynamic Extensions}.
+that may be called from your program (@pxref{Dynamic Extensions}).
@cindex arguments, in function calls
The way to use a function is with a @dfn{function call} expression,
@@ -11973,7 +12047,7 @@ rand() @ii{no arguments}
@cindex troubleshooting, function call syntax
@quotation CAUTION
-Do not put any space between the function name and the open-parenthesis!
+Do not put any space between the function name and the opening parenthesis!
A user-defined function name looks just like the name of a
variable---a space would make the expression look like concatenation of
a variable with an expression inside parentheses.
@@ -11994,7 +12068,7 @@ Some of the built-in functions have one or
more optional arguments.
If those arguments are not supplied, the functions
use a reasonable default value.
-@xref{Built-in}, for full details. If arguments
+@DBXREF{Built-in} for full details. If arguments
are omitted in calls to user-defined functions, then those arguments are
treated as local variables. Such local variables act like the
empty string if referenced where a string value is required,
@@ -12149,7 +12223,7 @@ Multiplication, division, remainder.
@item @code{+ -}
Addition, subtraction.
-@item String Concatenation
+@item String concatenation
There is no special symbol for concatenation.
The operands are simply written side by side
(@pxref{Concatenation}).
@@ -12188,7 +12262,7 @@ statements belong to the statement level, not to expressions. The
redirection does not produce an expression that could be the operand of
another operator. As a result, it does not make sense to use a
redirection operator near another operator of lower precedence without
-parentheses. Such combinations (for example, @samp{print foo > a ? b : c}),
+parentheses. Such combinations (e.g., @samp{print foo > a ? b : c}),
result in syntax errors.
The correct way to write this statement is @samp{print foo > (a ? b : c)}.
@@ -12246,7 +12320,7 @@ For maximum portability, do not use them.
@c ENDOFRANGE oppr
@node Locales
-@section Where You Are Makes A Difference
+@section Where You Are Makes a Difference
@cindex locale, definition of
Modern systems support the notion of @dfn{locales}: a way to tell the
@@ -12266,7 +12340,7 @@ character}, to find the record terminator.
Locales can affect how dates and times are formatted (@pxref{Time
Functions}). For example, a common way to abbreviate the date September
-4, 2015 in the United States is ``9/4/15.'' In many countries in
+4, 2015, in the United States is ``9/4/15.'' In many countries in
Europe, however, it is abbreviated ``4.9.15.'' Thus, the @code{%x}
specification in a @code{"US"} locale might produce @samp{9/4/15},
while in a @code{"EUROPE"} locale, it might produce @samp{4.9.15}.
@@ -12285,13 +12359,13 @@ in @ref{Conversion}.
@itemize @value{BULLET}
@item
Expressions are the basic elements of computation in programs. They are
-built from constants, variables, function calls and combinations of the
+built from constants, variables, function calls, and combinations of the
various kinds of values with operators.
@item
@command{awk} supplies three kinds of constants: numeric, string, and
regexp. @command{gawk} lets you specify numeric constants in octal
-and hexadecimal (bases 8 and 16) in addition to decimal (base 10).
+and hexadecimal (bases 8 and 16) as well as decimal (base 10).
In certain contexts, a standalone regexp constant such as @code{/foo/}
has the same meaning as @samp{$0 ~ /foo/}.
@@ -12333,8 +12407,8 @@ or numeric).
Function calls return a value which may be used as part of a larger
expression. Expressions used to pass parameter values are fully
evaluated before the function is called. @command{awk} provides
-built-in and user-defined functions; this is described later on in this
-@value{DOCUMENT}.
+built-in and user-defined functions; this is described in
+@ref{Functions}.
@item
Operator precedence specifies the order in which operations are performed,
@@ -12547,7 +12621,7 @@ The subexpressions of a Boolean operator in a pattern can be constant regular
expressions, comparisons, or any other @command{awk} expressions. Range
patterns are not expressions, so they cannot appear inside Boolean
patterns. Likewise, the special patterns @code{BEGIN}, @code{END},
-@code{BEGINFILE} and @code{ENDFILE},
+@code{BEGINFILE}, and @code{ENDFILE},
which never match any input record, are not expressions and cannot
appear inside Boolean patterns.
@@ -12658,7 +12732,7 @@ They supply startup and cleanup actions for @command{awk} programs.
@code{BEGIN} and @code{END} rules must have actions; there is no default
action for these rules because there is no current record when they run.
@code{BEGIN} and @code{END} rules are often referred to as
-``@code{BEGIN} and @code{END} blocks'' by long-time @command{awk}
+``@code{BEGIN} and @code{END} blocks'' by longtime @command{awk}
programmers.
@menu
@@ -12689,7 +12763,7 @@ $ @kbd{awk '}
This program finds the number of records in the input file @file{mail-list}
that contain the string @samp{li}. The @code{BEGIN} rule prints a title
for the report. There is no need to use the @code{BEGIN} rule to
-initialize the counter @code{n} to zero, since @command{awk} does this
+initialize the counter @code{n} to zero, as @command{awk} does this
automatically (@pxref{Variables}).
The second rule increments the variable @code{n} every time a
record containing the pattern @samp{li} is read. The @code{END} rule
@@ -12717,7 +12791,7 @@ The order in which library functions are named on the command line
controls the order in which their @code{BEGIN} and @code{END} rules are
executed. Therefore, you have to be careful when writing such rules in
library files so that the order in which they are executed doesn't matter.
-@xref{Options}, for more information on
+@DBXREF{Options} for more information on
using library functions.
@xref{Library Functions},
for a number of useful library functions.
@@ -12766,11 +12840,11 @@ of Unix @command{awk} do not.
The third point follows from the first two. The meaning of @samp{print}
inside a @code{BEGIN} or @code{END} rule is the same as always:
@samp{print $0}. If @code{$0} is the null string, then this prints an
-empty record. Many long time @command{awk} programmers use an unadorned
+empty record. Many longtime @command{awk} programmers use an unadorned
@samp{print} in @code{BEGIN} and @code{END} rules, to mean @samp{@w{print ""}},
relying on @code{$0} being null. Although one might generally get away with
this in @code{BEGIN} rules, it is a very bad idea in @code{END} rules,
-at least in @command{gawk}. It is also poor style, since if an empty
+at least in @command{gawk}. It is also poor style, because if an empty
line is needed in the output, the program should print one explicitly.
@cindex @code{next} statement, @code{BEGIN}/@code{END} patterns and
@@ -12780,9 +12854,14 @@ line is needed in the output, the program should print one explicitly.
Finally, the @code{next} and @code{nextfile} statements are not allowed
in a @code{BEGIN} rule, because the implicit
read-a-record-and-match-against-the-rules loop has not started yet. Similarly, those statements
-are not valid in an @code{END} rule, since all the input has been read.
-(@xref{Next Statement}, and see
-@ref{Nextfile Statement}.)
+are not valid in an @code{END} rule, because all the input has been read.
+(@DBXREF{Next Statement} and
+@ifnotdocbook
+@DBPXREF{Nextfile Statement}.)
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Nextfile Statement}.)
+@end ifdocbook
@c ENDOFRANGE beg
@c ENDOFRANGE end
@@ -12935,9 +13014,9 @@ awk "/$pattern/ "'@{ nmatches++ @}
@noindent
The @command{awk} program consists of two pieces of quoted text
that are concatenated together to form the program.
-The first part is double-quoted, which allows substitution of
+The first part is double quoted, which allows substitution of
the @code{pattern} shell variable inside the quotes.
-The second part is single-quoted.
+The second part is single quoted.
Variable substitution via quoting works, but can be potentially
messy. It requires a good understanding of the shell's quoting rules
@@ -12966,7 +13045,7 @@ The assignment @samp{-v pat="$pattern"} still requires double quotes,
in case there is whitespace in the value of @code{$pattern}.
The @command{awk} variable @code{pat} could be named @code{pattern}
too, but that would be more confusing. Using a variable also
-provides more flexibility, since the variable can be used anywhere inside
+provides more flexibility, as the variable can be used anywhere inside
the program---for printing, as an array subscript, or for any other
use---without requiring the quoting tricks at every point in the program.
@@ -13039,7 +13118,7 @@ is used in order to put several statements together in the body of an
Use the @code{getline} command
(@pxref{Getline}).
Also supplied in @command{awk} are the @code{next}
-statement (@pxref{Next Statement}),
+statement (@pxref{Next Statement})
and the @code{nextfile} statement
(@pxref{Nextfile Statement}).
@@ -13127,7 +13206,7 @@ else
print "x is odd"
@end example
-In this example, if the expression @samp{x % 2 == 0} is true (that is,
+In this example, if the expression @samp{x % 2 == 0} is true (i.e.,
if the value of @code{x} is evenly divisible by two), then the first
@code{print} statement is executed; otherwise, the second @code{print}
statement is executed.
@@ -13206,7 +13285,7 @@ field is printed. Then the @samp{i++} increments the value of @code{i}
and the loop repeats. The loop terminates when @code{i} reaches four.
A newline is not required between the condition and the
-body; however using one makes the program clearer unless the body is a
+body; however, using one makes the program clearer unless the body is a
compound statement or else is very simple. The newline after the open-brace
that begins the compound statement is not required either, but the
program is harder to read without it.
@@ -13253,7 +13332,7 @@ The following is an example of a @code{do} statement:
@noindent
This program prints each input record 10 times. However, it isn't a very
-realistic example, since in this case an ordinary @code{while} would do
+realistic example, because in this case an ordinary @code{while} would do
just as well. This situation reflects actual experience; only
occasionally is there a real use for a @code{do} statement.
@@ -13350,7 +13429,7 @@ very common in loops. It can be easier to think of this counting as part
of looping rather than as something to do inside the loop.
@cindex @code{in} operator
-There is an alternate version of the @code{for} loop, for iterating over
+There is an alternative version of the @code{for} loop, for iterating over
all the indices of an array:
@example
@@ -13359,7 +13438,7 @@ for (i in array)
@end example
@noindent
-@xref{Scanning an Array},
+@DBXREF{Scanning an Array}
for more information on this version of the @code{for} loop.
@node Switch Statement
@@ -13379,7 +13458,7 @@ are checked for a match in the order they are defined. If no suitable
Each @code{case} contains a single constant, be it numeric, string, or
regexp. The @code{switch} expression is evaluated, and then each
-@code{case}'s constant is compared against the result in turn. The type of constant
+@code{case}'s constant is compared against the result in turn. The type of constant
determines the comparison: numeric or string do the usual comparisons.
A regexp constant does a regular expression match against the string
value of the original expression. The general form of the @code{switch}
@@ -13426,9 +13505,9 @@ while ((c = getopt(ARGC, ARGV, "aksx")) != -1) @{
@}
@end example
-Note that if none of the statements specified above halt execution
+Note that if none of the statements specified here halt execution
of a matched @code{case} statement, execution falls through to the
-next @code{case} until execution halts. In the above example, the
+next @code{case} until execution halts. In this example, the
@code{case} for @code{"?"} falls through to the @code{default}
case, which is to call a function named @code{usage()}.
(The @code{getopt()} function being called here is
@@ -13555,7 +13634,7 @@ BEGIN @{
@end example
@noindent
-This program loops forever once @code{x} reaches 5, since
+This program loops forever once @code{x} reaches 5, because
the increment (@samp{x++}) is never reached.
@c @cindex @code{continue}, outside of loops
@@ -13616,7 +13695,7 @@ Because of the @code{next} statement,
the program's subsequent rules won't see the bad record. The error
message is redirected to the standard error output stream, as error
messages should be.
-For more detail see
+For more detail, see
@ref{Special Files}.
If the @code{next} statement causes the end of the input to be reached,
@@ -13682,7 +13761,7 @@ rule to skip over a file that would otherwise cause @command{gawk}
to exit with a fatal error. In this case, @code{ENDFILE} rules are not
executed. @xref{BEGINFILE/ENDFILE}.
-While one might think that @samp{close(FILENAME)} would accomplish
+Although it might seem that @samp{close(FILENAME)} would accomplish
the same as @code{nextfile}, this isn't true. @code{close()} is
reserved for closing files, pipes, and coprocesses that are
opened with redirections. It is not related to the main processing that
@@ -13690,7 +13769,7 @@ opened with redirections. It is not related to the main processing that
@quotation NOTE
For many years, @code{nextfile} was a
-common extension. In September, 2012, it was accepted for
+common extension. In September 2012, it was accepted for
inclusion into the POSIX standard.
See @uref{http://austingroupbugs.net/view.php?id=607, the Austin Group website}.
@end quotation
@@ -13739,7 +13818,7 @@ In such a case,
if you don't want the @code{END} rule to do its job, set a variable
to nonzero before the @code{exit} statement and check that variable in
the @code{END} rule.
-@xref{Assert Function},
+@DBXREF{Assert Function}
for an example that does this.
@cindex dark corner, @code{exit} statement
@@ -13750,7 +13829,7 @@ In the case where an argument
is supplied to a first @code{exit} statement, and then @code{exit} is
called a second time from an @code{END} rule with no argument,
@command{awk} uses the previously supplied exit value. @value{DARKCORNER}
-@xref{Exit Status}, for more information.
+@DBXREF{Exit Status} for more information.
@cindex programming conventions, @code{exit} statement
For example, suppose an error condition occurs that is difficult or
@@ -13810,7 +13889,7 @@ their areas of activity.
@end menu
@node User-modified
-@subsection Built-in Variables That Control @command{awk}
+@subsection Built-In Variables That Control @command{awk}
@c STARTOFRANGE bvaru
@cindex predefined variables, user-modifiable
@c STARTOFRANGE nmbv
@@ -13867,7 +13946,7 @@ A space-separated list of columns that tells @command{gawk}
how to split input with fixed columnar boundaries.
Assigning a value to @code{FIELDWIDTHS}
overrides the use of @code{FS} and @code{FPAT} for field splitting.
-@xref{Constant Size}, for more information.
+@DBXREF{Constant Size} for more information.
@cindex @command{gawk}, @code{FPAT} variable in
@cindex @code{FPAT} variable
@@ -13879,7 +13958,7 @@ A regular expression (as a string) that tells @command{gawk}
to create the fields based on text that matches the regular expression.
Assigning a value to @code{FPAT}
overrides the use of @code{FS} and @code{FIELDWIDTHS} for field splitting.
-@xref{Splitting By Content}, for more information.
+@DBXREF{Splitting By Content} for more information.
@cindex @code{FS} variable
@cindex separators, field
@@ -13989,12 +14068,12 @@ character. (@xref{Output Separators}.)
@cindex @code{PREC} variable
@item PREC #
-The working precision of arbitrary precision floating-point numbers,
+The working precision of arbitrary-precision floating-point numbers,
53 bits by default (@pxref{Setting precision}).
@cindex @code{ROUNDMODE} variable
@item ROUNDMODE #
-The rounding mode to use for arbitrary precision arithmetic on
+The rounding mode to use for arbitrary-precision arithmetic on
numbers, by default @code{"N"} (@samp{roundTiesToEven} in
the IEEE 754 standard; @pxref{Setting the rounding mode}).
@@ -14036,7 +14115,7 @@ really accesses @code{foo["A\034B"]}
Used for internationalization of programs at the
@command{awk} level. It sets the default text domain for specially
marked string constants in the source text, as well as for the
-@code{dcgettext()}, @code{dcngettext()} and @code{bindtextdomain()} functions
+@code{dcgettext()}, @code{dcngettext()}, and @code{bindtextdomain()} functions
(@pxref{Internationalization}).
The default value of @code{TEXTDOMAIN} is @code{"messages"}.
@end table
@@ -14046,7 +14125,7 @@ The default value of @code{TEXTDOMAIN} is @code{"messages"}.
@c ENDOFRANGE nmbv
@node Auto-set
-@subsection Built-in Variables That Convey Information
+@subsection Built-In Variables That Convey Information
@c STARTOFRANGE bvconi
@cindex predefined variables, conveying information
@@ -14059,7 +14138,7 @@ information to your program.
The variables that are specific to @command{gawk} are marked with a pound
sign (@samp{#}). These variables are @command{gawk} extensions. In other
@command{awk} implementations or if @command{gawk} is in compatibility
-mode (@pxref{Options}), they are not special.
+mode (@pxref{Options}), they are not special:
@c @asis for docbook
@table @asis
@@ -14100,7 +14179,7 @@ method of accessing command-line arguments.
The value of @code{ARGV[0]} can vary from system to system.
Also, you should note that the program text is @emph{not} included in
@code{ARGV}, nor are any of @command{awk}'s command-line options.
-@xref{ARGC and ARGV}, for information
+@DBXREF{ARGC and ARGV} for information
about how @command{awk} uses these variables.
@value{DARKCORNER}
@@ -14138,8 +14217,13 @@ Some operating systems may not have environment variables.
On such systems, the @code{ENVIRON} array is empty (except for
@w{@code{ENVIRON["AWKPATH"]}} and
@w{@code{ENVIRON["AWKLIBPATH"]}};
-@pxref{AWKPATH Variable}, and
+@DBPXREF{AWKPATH Variable} and
+@ifdocbook
+@DBREF{AWKLIBPATH Variable}).
+@end ifdocbook
+@ifnotdocbook
@pxref{AWKLIBPATH Variable}).
+@end ifnotdocbook
@cindex @command{gawk}, @code{ERRNO} variable in
@cindex @code{ERRNO} variable
@@ -14168,7 +14252,7 @@ The name of the current input file. When no @value{DF}s are listed
on the command line, @command{awk} reads from the standard input and
@code{FILENAME} is set to @code{"-"}. @code{FILENAME} changes each
time a new file is read (@pxref{Reading Files}). Inside a @code{BEGIN}
-rule, the value of @code{FILENAME} is @code{""}, since there are no input
+rule, the value of @code{FILENAME} is @code{""}, because there are no input
files being processed yet.@footnote{Some early implementations of Unix
@command{awk} initialized @code{FILENAME} to @code{"-"}, even if there
were @value{DF}s to be processed. This behavior was incorrect and should
@@ -14200,7 +14284,7 @@ current record. @xref{Changing Fields}.
@cindex differences in @command{awk} and @command{gawk}, @code{FUNCTAB} variable
@item @code{FUNCTAB #}
An array whose indices and corresponding values are the names of all
-the built-in, user-defined and extension functions in the program.
+the built-in, user-defined, and extension functions in the program.
@quotation NOTE
Attempting to use the @code{delete} statement with the @code{FUNCTAB}
@@ -14294,7 +14378,7 @@ The parent process ID of the current process.
If this element exists in @code{PROCINFO}, its value controls the
order in which array indices will be processed by
@samp{for (@var{indx} in @var{array})} loops.
-Since this is an advanced feature, we defer the
+This is an advanced feature, so we defer the
full description until later; see
@ref{Scanning an Array}.
@@ -14314,10 +14398,10 @@ The version of @command{gawk}.
The following additional elements in the array
are available to provide information about the MPFR and GMP libraries
-if your version of @command{gawk} supports arbitrary precision arithmetic
-(@pxref{Arbitrary Precision Arithmetic}):
+if your version of @command{gawk} supports arbitrary-precision arithmetic
+(@pxref{Arbitrary Precision Arithmetic}):
-@table @code
+@table @code
@cindex version of GNU MPFR library
@item PROCINFO["mpfr_version"]
The version of the GNU MPFR library.
@@ -14365,7 +14449,7 @@ The @code{PROCINFO} array has the following additional uses:
@item
It may be used to provide a timeout when reading from any
open input file, pipe, or coprocess.
-@xref{Read Timeout}, for more information.
+@DBXREF{Read Timeout} for more information.
@item
It may be used to cause coprocesses to communicate over pseudo-ttys
@@ -14564,8 +14648,14 @@ use the @code{delete} statement to remove elements from
All of these actions are typically done in the @code{BEGIN} rule,
before actual processing of the input begins.
-@xref{Split Program}, and see
-@ref{Tee Program}, for examples
+@DBXREF{Split Program} and
+@ifnotdocbook
+@DBPXREF{Tee Program}
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Tee Program}
+@end ifdocbook
+for examples
of each way of removing elements from @code{ARGV}.
To actually get options into an @command{awk} program,
@@ -14577,7 +14667,7 @@ awk -f myprog.awk -- -v -q file1 file2 @dots{}
@end example
The following fragment processes @code{ARGV} in order to examine, and
-then remove, the above command-line options:
+then remove, the previously mentioned command-line options:
@example
BEGIN @{
@@ -14613,14 +14703,21 @@ gawk -f myprog.awk -q -v file1 file2 @dots{}
@noindent
Because @option{-q} is not a valid @command{gawk} option, it and the
following @option{-v} are passed on to the @command{awk} program.
-(@xref{Getopt Function}, for an @command{awk} library function that
+(@DBXREF{Getopt Function} for an @command{awk} library function that
parses command-line options.)
When designing your program, you should choose options that don't
-conflict with @command{gawk}'s, since it will process any options
+conflict with @command{gawk}'s, because it will process any options
that it accepts before passing the rest of the command line on to
your program. Using @samp{#!} with the @option{-E} option may help
-(@pxref{Executable Scripts}, and @pxref{Options}).
+(@DBXREF{Executable Scripts}
+and
+@ifnotdocbook
+@DBPXREF{Options}).
+@end ifnotdocbook
+@ifdocbook
+@DBREF{Options}).
+@end ifdocbook
@node Pattern Action Summary
@section Summary
@@ -14786,7 +14883,7 @@ as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}:
@ifnotdocbook
@float Figure,figure-array-elements
-@caption{A Contiguous Array}
+@caption{A contiguous array}
@ifinfo
@center @image{array-elements, , , Basic Program Stages, txt}
@end ifinfo
@@ -14798,7 +14895,7 @@ as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}:
@docbook
<figure id="figure-array-elements" float="0">
-<title>A Contiguous Array</title>
+<title>A contiguous array</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="array-elements.png" format="PNG"/></imageobject>
</mediaobject>
@@ -14817,7 +14914,7 @@ position with zero elements before it.
@cindex associative arrays
@cindex arrays, associative
Arrays in @command{awk} are different---they are @dfn{associative}. This means
-that each array is a collection of pairs: an index and its corresponding
+that each array is a collection of pairs---an index and its corresponding
array element value:
@ifnotdocbook
@@ -14998,7 +15095,7 @@ numbers and strings as indices.
There are some subtleties to how numbers work when used as
array subscripts; this is discussed in more detail in
@ref{Numeric Array Subscripts}.)
-Here, the number @code{1} isn't double-quoted, since @command{awk}
+Here, the number @code{1} isn't double quoted, because @command{awk}
automatically converts it to a string.
@cindex @command{gawk}, @code{IGNORECASE} variable in
@@ -15083,7 +15180,7 @@ This expression tests whether the particular index @var{indx} exists,
without the side effect of creating that element if it is not present.
The expression has the value one (true) if @code{@var{array}[@var{indx}]}
exists and zero (false) if it does not exist.
-(We use @var{indx} here, since @samp{index} is the name of a built-in
+(We use @var{indx} here, because @samp{index} is the name of a built-in
function.)
For example, this statement tests whether the array @code{frequencies}
contains the index @samp{2}:
@@ -15226,7 +15323,7 @@ the word as index. The second rule scans the elements of @code{used} to
find all the distinct words that appear in the input. It prints each
word that is more than 10 characters long and also prints the number of
such words.
-@xref{String Functions},
+@DBXREF{String Functions}
for more information on the built-in function @code{length()}.
@example
@@ -15249,7 +15346,7 @@ END @{
@end example
@noindent
-@xref{Word Sorting},
+@DBXREF{Word Sorting}
for a more detailed example of this type.
@cindex arrays, elements, order of access by @code{in} operator
@@ -15304,7 +15401,7 @@ $ @kbd{nawk -f loopcheck.awk}
@end example
@node Controlling Scanning
-@subsection Using Predefined Array Scanning Orders With @command{gawk}
+@subsection Using Predefined Array Scanning Orders with @command{gawk}
This @value{SUBSECTION} describes a feature that is specific to @command{gawk}.
@@ -15329,7 +15426,7 @@ We describe this now.
@item
Set @code{PROCINFO["sorted_in"]} to the name of a user-defined function
to use for comparison of array elements. This advanced feature
-is described later, in @ref{Array Sorting}.
+is described later in @ref{Array Sorting}.
@end itemize
@cindex @code{PROCINFO}, values of @code{sorted_in}
@@ -15347,7 +15444,7 @@ the index is @code{"10"} rather than numeric 10.)
@item "@@ind_num_asc"
Order by indices in ascending order but force them to be treated as numbers in the process.
-Any index with a non-numeric value will end up positioned as if it were zero.
+Any index with a non-numeric value will end up positioned as if it were zero.
@item "@@val_type_asc"
Order by element values in ascending order (rather than by indices).
@@ -15359,11 +15456,11 @@ which in turn come before all subarrays.
@pxref{Arrays of Arrays}.)
@item "@@val_str_asc"
-Order by element values in ascending order (rather than by indices). Scalar values are
+Order by element values in ascending order (rather than by indices). Scalar values are
compared as strings. Subarrays, if present, come out last.
@item "@@val_num_asc"
-Order by element values in ascending order (rather than by indices). Scalar values are
+Order by element values in ascending order (rather than by indices). Scalar values are
compared as numbers. Subarrays, if present, come out last.
When numeric values are equal, the string values are used to provide
an ordering: this guarantees consistent results across different
@@ -15424,11 +15521,11 @@ $ @kbd{gawk '}
When sorting an array by element values, if a value happens to be
a subarray then it is considered to be greater than any string or
numeric value, regardless of what the subarray itself contains,
-and all subarrays are treated as being equal to each other. Their
+and all subarrays are treated as being equal to each other. Their
order relative to each other is determined by their index strings.
Here are some additional things to bear in mind about sorted
-array traversal.
+array traversal:
@itemize @value{BULLET}
@item
@@ -15448,7 +15545,7 @@ if (save_sorted)
@end example
@item
-As mentioned, the default array traversal order is represented by
+As already mentioned, the default array traversal order is represented by
@code{"@@unsorted"}. You can also get the default behavior by assigning
the null string to @code{PROCINFO["sorted_in"]} or by just deleting the
@code{"sorted_in"} element from the @code{PROCINFO} array with
@@ -15493,7 +15590,7 @@ The program then changes
the value of @code{CONVFMT}. The test @samp{(xyz in data)} generates a new
string value from @code{xyz}---this time @code{"12.15"}---because the value of
@code{CONVFMT} only allows two significant digits. This test fails,
-since @code{"12.15"} is different from @code{"12.153"}.
+because @code{"12.15"} is different from @code{"12.153"}.
@cindex converting integer array subscripts
@cindex integer array indices
@@ -15511,19 +15608,19 @@ for (i = 1; i <= maxsub; i++)
The ``integer values always convert to strings as integers'' rule
has an additional consequence for array indexing.
Octal and hexadecimal constants
+@ifnotdocbook
(@pxref{Nondecimal-numbers})
+@end ifnotdocbook
+@ifdocbook
+(covered in @ref{Nondecimal-numbers})
+@end ifdocbook
are converted internally into numbers, and their original form
-is forgotten.
-This means, for example, that
-@code{array[17]},
-@code{array[021]},
-and
-@code{array[0x11]}
-all refer to the same element!
+is forgotten. This means, for example, that @code{array[17]},
+@code{array[021]}, and @code{array[0x11]} all refer to the same element!
As with many things in @command{awk}, the majority of the time
things work as you would expect them to. But it is useful to have a precise
-knowledge of the actual rules since they can sometimes have a subtle
+knowledge of the actual rules, as they can sometimes have a subtle
effect on your programs.
@node Uninitialized Subscripts
@@ -15666,7 +15763,7 @@ by a number of other implementations.
@cindex Brian Kernighan's @command{awk}
@quotation NOTE
For many years, using @code{delete} without a subscript was a common
-extension. In September, 2012, it was accepted for inclusion into the
+extension. In September 2012, it was accepted for inclusion into the
POSIX standard. See @uref{http://austingroupbugs.net/view.php?id=544,
the Austin Group website}.
@end quotation
@@ -15708,7 +15805,7 @@ a = 3
@cindex subscripts in arrays, multidimensional
@cindex arrays, multidimensional
-A multidimensional array is an array in which an element is identified
+A @dfn{multidimensional array} is an array in which an element is identified
by a sequence of indices instead of a single index. For example, a
two-dimensional array requires two indices. The usual way (in many
languages, including @command{awk}) to refer to an element of a
@@ -15750,7 +15847,7 @@ stored as @samp{foo["a@@b@@c"]}.
@cindex @code{in} operator, index existence in multidimensional arrays
To test whether a particular index sequence exists in a
multidimensional array, use the same operator (@code{in}) that is
-used for single dimensional arrays. Write the whole sequence of indices
+used for single-dimensional arrays. Write the whole sequence of indices
in parentheses, separated by commas, as the left operand:
@example
@@ -15874,7 +15971,7 @@ This simulates a true two-dimensional array. Each subarray element can
contain another subarray as a value, which in turn can hold other arrays
as well. In this way, you can create arrays of three or more dimensions.
The indices can be any @command{awk} expression, including scalars
-separated by commas (that is, a regular @command{awk} simulated
+separated by commas (i.e., a regular @command{awk} simulated
multidimensional subscript). So the following is valid in
@command{gawk}:
@@ -15892,8 +15989,8 @@ is itself an array and not a scalar:
@example
a[4] = "An element in a jagged array"
@end example
-
-The terms @dfn{dimension}, @dfn{row} and @dfn{column} are
+
+The terms @dfn{dimension}, @dfn{row}, and @dfn{column} are
meaningless when applied
to such an array, but we will use ``dimension'' henceforth to imply the
maximum number of indices needed to refer to an existing element. The
@@ -15949,14 +16046,14 @@ The @samp{for (item in array)} statement (@pxref{Scanning an Array})
can be nested to scan all the
elements of an array of arrays if it is rectangular in structure. In order
to print the contents (scalar values) of a two-dimensional array of arrays
-(i.e., in which each first-level element is itself an
-array, not necessarily of the same length)
+(i.e., in which each first-level element is itself an
+array, not necessarily of the same length)
you could use the following code:
@example
for (i in array)
for (j in array[i])
- print array[i][j]
+ print array[i][j]
@end example
The @code{isarray()} function (@pxref{Type Functions})
@@ -15966,7 +16063,7 @@ lets you test if an array element is itself an array:
for (i in array) @{
if (isarray(array[i]) @{
for (j in array[i]) @{
- print array[i][j]
+ print array[i][j]
@}
@}
else
@@ -15976,7 +16073,7 @@ for (i in array) @{
If the structure of a jagged array of arrays is known in advance,
you can often devise workarounds using control statements. For example,
-the following code prints the elements of our main array @code{a}:
+the following code prints the elements of our main array @code{a}:
@example
for (i in a) @{
@@ -15986,13 +16083,13 @@ for (i in a) @{
print a[i][j][k]
@} else
print a[i][j]
- @}
+ @}
@}
@end example
@noindent
-@xref{Walking Arrays}, for a user-defined function that ``walks'' an
-arbitrarily-dimensioned array of arrays.
+@DBXREF{Walking Arrays} for a user-defined function that ``walks'' an
+arbitrarily dimensioned array of arrays.
Recall that a reference to an uninitialized array element yields a value
of @code{""}, the null string. This has one important implication when you
@@ -16042,8 +16139,9 @@ special predefined values to @code{PROCINFO["sorted_in"]}.
@item
Use @samp{delete @var{array}[@var{indx}]} to delete an individual element.
-You may also use @samp{delete @var{array}} to delete all of the elements
-in the array. This latter feature has been a common extension for many
+To delete all of the elements in an array,
+use @samp{delete @var{array}}.
+This latter feature has been a common extension for many
years and is now standard, but may not be supported by all commercial
versions of @command{awk}.
@@ -16096,7 +16194,7 @@ The second half of this @value{CHAPTER} describes these
@end menu
@node Built-in
-@section Built-in Functions
+@section Built-In Functions
@dfn{Built-in} functions are always available for
your @command{awk} program to call. This @value{SECTION} defines all
@@ -16119,7 +16217,7 @@ but are summarized here for your convenience.
@end menu
@node Calling Built-in
-@subsection Calling Built-in Functions
+@subsection Calling Built-In Functions
To call one of @command{awk}'s built-in functions, write the name of
the function followed
@@ -16129,7 +16227,7 @@ is a call to the function @code{atan2()} and has two arguments.
@cindex programming conventions, functions, calling
@cindex whitespace, functions@comma{} calling
Whitespace is ignored between the built-in function name and the
-open parenthesis, but nonetheless it is good practice to avoid using whitespace
+opening parenthesis, but nonetheless it is good practice to avoid using whitespace
there. User-defined functions do not permit whitespace in this way, and
it is easier to avoid mistakes by following a simple
convention that always works---no whitespace after a function name.
@@ -16209,7 +16307,6 @@ depends on your machine's floating-point representation.
@cindex round to nearest integer
Return the nearest integer to @var{x}, located between @var{x} and zero and
truncated toward zero.
-
For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
is @minus{}3, and @code{int(-3)} is @minus{}3 as well.
@@ -16299,7 +16396,7 @@ for generating random numbers to the value @var{x}.
Each seed value leads to a particular sequence of random
numbers.@footnote{Computer-generated random numbers really are not truly
random. They are technically known as ``pseudorandom.'' This means
-that while the numbers in a sequence appear to be random, you can in
+that although the numbers in a sequence appear to be random, you can in
fact generate the same sequence of random numbers over and over again.}
Thus, if the seed is set to the same value a second time,
the same sequence of random numbers is produced again.
@@ -16349,7 +16446,7 @@ doing index calculations, particularly if you are used to C.
In the following list, optional parameters are enclosed in square brackets@w{ ([ ]).}
Several functions perform string substitution; the full discussion is
provided in the description of the @code{sub()} function, which comes
-towards the end since the list is presented alphabetically.
+toward the end, because the list is presented alphabetically.
Those functions that are specific to @command{gawk} are marked with a
pound sign (@samp{#}). They are not available in compatibility mode
@@ -16375,10 +16472,10 @@ These two functions are similar in behavior, so they are described
together.
@quotation NOTE
-The following description ignores the third argument, @var{how}, since it
+The following description ignores the third argument, @var{how}, as it
requires understanding features that we have not discussed yet. Thus,
the discussion here is a deliberate simplification. (We do provide all
-the details later on: @xref{Array Sorting Functions}, for the full story.)
+the details later on; see @DBREF{Array Sorting Functions} for the full story.)
@end quotation
Both functions return the number of elements in the array @var{source}.
@@ -16625,7 +16722,7 @@ at which that substring begins (one, if it starts at the beginning of
The @var{regexp} argument may be either a regexp constant
(@code{/}@dots{}@code{/}) or a string constant (@code{"}@dots{}@code{"}).
In the latter case, the string is treated as a regexp to be matched.
-@xref{Computed Regexps}, for a
+@DBXREF{Computed Regexps} for a
discussion of the difference between the two forms, and the
implications for writing your program correctly.
@@ -16718,7 +16815,7 @@ $ @kbd{echo foooobazbarrrrr |}
@end example
There may not be subscripts for the start and index for every parenthesized
-subexpression, since they may not all have matched text; thus they
+subexpression, because they may not all have matched text; thus they
should be tested for with the @code{in} operator
(@pxref{Reference to Elements}).
@@ -16765,15 +16862,15 @@ a regexp describing where to split @var{string} (much as @code{FS} can
be a regexp describing where to split input records).
If @var{fieldsep} is omitted, the value of @code{FS} is used.
@code{split()} returns the number of elements created.
-@var{seps} is a @command{gawk} extension with @code{@var{seps}[@var{i}]}
+@var{seps} is a @command{gawk} extension with @code{@var{seps}[@var{i}]}
being the separator string
-between @code{@var{array}[@var{i}]} and @code{@var{array}[@var{i}+1]}.
+between @code{@var{array}[@var{i}]} and @code{@var{array}[@var{i}+1]}.
If @var{fieldsep} is a single
-space then any leading whitespace goes into @code{@var{seps}[0]} and
+space then any leading whitespace goes into @code{@var{seps}[0]} and
any trailing
-whitespace goes into @code{@var{seps}[@var{n}]} where @var{n} is the
-return value of
-@code{split()} (that is, the number of elements in @var{array}).
+whitespace goes into @code{@var{seps}[@var{n}]} where @var{n} is the
+return value of
+@code{split()} (i.e., the number of elements in @var{array}).
The @code{split()} function splits strings into pieces in a
manner similar to the way input lines are split into fields. For example:
@@ -16809,7 +16906,7 @@ As with input field-splitting, when the value of @var{fieldsep} is
the elements of
@var{array} but not in @var{seps}, and the elements
are separated by runs of whitespace.
-Also as with input field-splitting, if @var{fieldsep} is the null string, each
+Also, as with input field-splitting, if @var{fieldsep} is the null string, each
individual character in the string is split into its own array element.
@value{COMMONEXT}
@@ -16823,7 +16920,7 @@ the third argument to be a regexp constant (@code{/abc/}) as well as a
string.
@value{DARKCORNER}
The POSIX standard allows this as well.
-@xref{Computed Regexps}, for a
+@DBXREF{Computed Regexps} for a
discussion of the difference between using a string constant or a regexp constant,
and the implications for writing your program correctly.
@@ -16874,7 +16971,7 @@ Using the @code{strtonum()} function is @emph{not} the same as adding zero
to a string value; the automatic coercion of strings to numbers
works only for decimal data, not for octal or hexadecimal.@footnote{Unless
you use the @option{--non-decimal-data} option, which isn't recommended.
-@xref{Nondecimal Data}, for more information.}
+@DBXREF{Nondecimal Data} for more information.}
Note also that @code{strtonum()} uses the current locale's decimal point
for recognizing numbers (@pxref{Locales}).
@@ -16892,7 +16989,7 @@ Return the number of substitutions made (zero or one).
The @var{regexp} argument may be either a regexp constant
(@code{/}@dots{}@code{/}) or a string constant (@code{"}@dots{}@code{"}).
In the latter case, the string is treated as a regexp to be matched.
-@xref{Computed Regexps}, for a
+@DBXREF{Computed Regexps} for a
discussion of the difference between the two forms, and the
implications for writing your program correctly.
@@ -17078,7 +17175,7 @@ Although this makes a certain amount of sense, it can be surprising.
@node Gory Details
-@subsubsection More About @samp{\} and @samp{&} with @code{sub()}, @code{gsub()}, and @code{gensub()}
+@subsubsection More about @samp{\} and @samp{&} with @code{sub()}, @code{gsub()}, and @code{gensub()}
@cindex escape processing, @code{gsub()}/@code{gensub()}/@code{sub()} functions
@cindex @code{sub()} function, escape processing
@@ -17125,7 +17222,7 @@ through unchanged. This is illustrated in @ref{table-sub-escapes}.
@c Thank to Karl Berry for help with the TeX stuff.
@float Table,table-sub-escapes
-@caption{Historical Escape Sequence Processing for @code{sub()} and @code{gsub()}}
+@caption{Historical escape sequence processing for @code{sub()} and @code{gsub()}}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -17197,7 +17294,7 @@ This is shown in
@ref{table-sub-proposed}.
@float Table,table-sub-proposed
-@caption{GNU @command{awk} Rules For @code{sub()} And Backslash}
+@caption{GNU @command{awk} rules for @code{sub()} and backslash}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -17260,7 +17357,7 @@ by anything else is not special; the @samp{\} is placed straight into the output
These rules are presented in @ref{table-posix-sub}.
@float Table,table-posix-sub
-@caption{POSIX Rules For @code{sub()} And @code{gsub()}}
+@caption{POSIX rules for @code{sub()} and @code{gsub()}}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -17309,12 +17406,12 @@ is seen as @samp{\\} and produces @samp{\} instead of @samp{\\}.
Starting with @value{PVERSION} 3.1.4, @command{gawk} followed the POSIX rules
when @option{--posix} is specified (@pxref{Options}). Otherwise,
-it continued to follow the proposed rules, since
+it continued to follow the proposed rules, as
that had been its behavior for many years.
When @value{PVERSION} 4.0.0 was released, the @command{gawk} maintainer
made the POSIX rules the default, breaking well over a decade's worth
-of backwards compatibility.@footnote{This was rather naive of him, despite
+of backward compatibility.@footnote{This was rather naive of him, despite
there being a note in this section indicating that the next major version
would move to the POSIX rules.} Needless to say, this was a bad idea,
and as of @value{PVERSION} 4.0.1, @command{gawk} resumed its historical
@@ -17329,7 +17426,7 @@ appears in the generated text and the @samp{\} does not,
as shown in @ref{table-gensub-escapes}.
@float Table,table-gensub-escapes
-@caption{Escape Sequence Processing For @code{gensub()}}
+@caption{Escape sequence processing for @code{gensub()}}
@tex
\vbox{\bigskip
% We need more characters for escape and tab ...
@@ -17396,7 +17493,7 @@ Optional parameters are enclosed in square brackets ([ ]):
Close the file @var{filename} for input or output. Alternatively, the
argument may be a shell command that was used for creating a coprocess, or
for redirecting to or from a pipe; then the coprocess or pipe is closed.
-@xref{Close Files And Pipes},
+@DBXREF{Close Files And Pipes}
for more information.
When closing a coprocess, it is occasionally useful to first close
@@ -17420,13 +17517,13 @@ a pipe or coprocess.
@cindex buffers, flushing
@cindex output, buffering
-Many utility programs @dfn{buffer} their output; i.e., they save information
+Many utility programs @dfn{buffer} their output (i.e., they save information
to write to a disk file or the screen in memory until there is enough
-for it to be worthwhile to send the data to the output device.
+for it to be worthwhile to send the data to the output device).
This is often more efficient than writing
every little bit of information as soon as it is ready. However, sometimes
-it is necessary to force a program to @dfn{flush} its buffers; that is,
-write the information to its destination, even if a buffer is not full.
+it is necessary to force a program to @dfn{flush} its buffers (i.e.,
+write the information to its destination, even if a buffer is not full).
This is the purpose of the @code{fflush()} function---@command{gawk} also
buffers its output and the @code{fflush()} function forces
@command{gawk} to flush its buffers.
@@ -17434,11 +17531,11 @@ buffers its output and the @code{fflush()} function forces
@cindex extensions, common@comma{} @code{fflush()} function
@cindex Brian Kernighan's @command{awk}
Brian Kernighan added @code{fflush()} to his @command{awk} in April
-of 1992. For two decades, it was a common extension. In December,
+1992. For two decades, it was a common extension. In December
2012, it was accepted for inclusion into the POSIX standard.
See @uref{http://austingroupbugs.net/view.php?id=634, the Austin Group website}.
-POSIX standardizes @code{fflush()} as follows: If there
+POSIX standardizes @code{fflush()} as follows: if there
is no argument, or if the argument is the null string (@w{@code{""}}),
then @command{awk} flushes the buffers for @emph{all} open output files
and pipes.
@@ -17470,6 +17567,49 @@ a file or pipe that was opened for reading (such as with @code{getline}),
or if @var{filename} is not an open file, pipe, or coprocess.
In such a case, @code{fflush()} returns @minus{}1, as well.
+@sidebar Interactive Versus Noninteractive Buffering
+@cindex buffering, interactive vs.@: noninteractive
+
+As a side point, buffering issues can be even more confusing, depending
+upon whether your program is @dfn{interactive} (i.e., communicating
+with a user sitting at a keyboard).@footnote{A program is interactive
+if the standard output is connected to a terminal device. On modern
+systems, this means your keyboard and screen.}
+
+@c Thanks to Walter.Mecky@dresdnerbank.de for this example, and for
+@c motivating me to write this section.
+Interactive programs generally @dfn{line buffer} their output (i.e., they
+write out every line). Noninteractive programs wait until they have
+a full buffer, which may be many lines of output.
+Here is an example of the difference:
+
+@example
+$ @kbd{awk '@{ print $1 + $2 @}'}
+@kbd{1 1}
+@print{} 2
+@kbd{2 3}
+@print{} 5
+@kbd{Ctrl-d}
+@end example
+
+@noindent
+Each line of output is printed immediately. Compare that behavior
+with this example:
+
+@example
+$ @kbd{awk '@{ print $1 + $2 @}' | cat}
+@kbd{1 1}
+@kbd{2 3}
+@kbd{Ctrl-d}
+@print{} 2
+@print{} 5
+@end example
+
+@noindent
+Here, no output is printed until after the @kbd{Ctrl-d} is typed, because
+it is all buffered and sent down the pipe to @command{cat} in one shot.
+@end sidebar
+
@item @code{system(@var{command})}
@cindexawkfunc{system}
@cindex invoke shell command
@@ -17517,49 +17657,6 @@ When @option{--sandbox} is specified, the @code{system()} function is disabled
@end table
-@sidebar Interactive Versus Noninteractive Buffering
-@cindex buffering, interactive vs.@: noninteractive
-
-As a side point, buffering issues can be even more confusing, depending
-upon whether your program is @dfn{interactive}, i.e., communicating
-with a user sitting at a keyboard.@footnote{A program is interactive
-if the standard output is connected to a terminal device. On modern
-systems, this means your keyboard and screen.}
-
-@c Thanks to Walter.Mecky@dresdnerbank.de for this example, and for
-@c motivating me to write this section.
-Interactive programs generally @dfn{line buffer} their output; i.e., they
-write out every line. Noninteractive programs wait until they have
-a full buffer, which may be many lines of output.
-Here is an example of the difference:
-
-@example
-$ @kbd{awk '@{ print $1 + $2 @}'}
-@kbd{1 1}
-@print{} 2
-@kbd{2 3}
-@print{} 5
-@kbd{Ctrl-d}
-@end example
-
-@noindent
-Each line of output is printed immediately. Compare that behavior
-with this example:
-
-@example
-$ @kbd{awk '@{ print $1 + $2 @}' | cat}
-@kbd{1 1}
-@kbd{2 3}
-@kbd{Ctrl-d}
-@print{} 2
-@print{} 5
-@end example
-
-@noindent
-Here, no output is printed until after the @kbd{Ctrl-d} is typed, because
-it is all buffered and sent down the pipe to @command{cat} in one shot.
-@end sidebar
-
@sidebar Controlling Output Buffering with @code{system()}
@cindex buffers, flushing
@cindex buffering, input/output
@@ -17578,7 +17675,7 @@ system("") # flush output
@command{gawk} treats this use of the @code{system()} function as a special
case and is smart enough not to run a shell (or other command
interpreter) with the empty command. Therefore, with @command{gawk}, this
-idiom is not only useful, it is also efficient. While this method should work
+idiom is not only useful, it is also efficient. Although this method should work
with other @command{awk} implementations, it does not necessarily avoid
starting an unnecessary shell. (Other implementations may only
flush the buffer associated with the standard output and not necessarily
@@ -17717,14 +17814,14 @@ Mean Time). Otherwise, the value is formatted for the local time zone.
The @var{timestamp} is in the same format as the value returned by the
@code{systime()} function. If no @var{timestamp} argument is supplied,
@command{gawk} uses the current time of day as the timestamp.
-If no @var{format} argument is supplied, @code{strftime()} uses
+Without a @var{format} argument, @code{strftime()} uses
the value of @code{PROCINFO["strftime"]} as the format string
(@pxref{Built-in Variables}).
The default string value is
@code{@w{"%a %b %e %H:%M:%S %Z %Y"}}. This format string produces
output that is equivalent to that of the @command{date} utility.
You can assign a new value to @code{PROCINFO["strftime"]} to
-change the default format; see below for the various format directives.
+change the default format; see the following list for the various format directives.
@item @code{systime()}
@cindexgawkfunc{systime}
@@ -17801,9 +17898,9 @@ This is the ISO 8601 date format.
@item %g
The year modulo 100 of the ISO 8601 week number, as a decimal number (00--99).
-For example, January 1, 2012 is in week 53 of 2011. Thus, the year
+For example, January 1, 2012, is in week 53 of 2011. Thus, the year
of its ISO 8601 week number is 2011, even though its year is 2012.
-Similarly, December 31, 2012 is in week 1 of 2013. Thus, the year
+Similarly, December 31, 2012, is in week 1 of 2013. Thus, the year
of its ISO week number is 2013, even though its year is 2012.
@item %G
@@ -17899,7 +17996,7 @@ no time zone is determinable.
@item %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH
@itemx %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy
-``Alternate representations'' for the specifications
+``Alternative representations'' for the specifications
that use only the second letter (@code{%c}, @code{%C},
and so on).@footnote{If you don't understand any of this, don't worry about
it; these facilities are meant to make it easier to ``internationalize''
@@ -17912,7 +18009,7 @@ Other internationalization features are described in
A literal @samp{%}.
@end table
-If a conversion specifier is not one of the above, the behavior is
+If a conversion specifier is not one of those just listed, the behavior is
undefined.@footnote{This is because ISO C leaves the
behavior of the C version of @code{strftime()} undefined and @command{gawk}
uses the system's version of @code{strftime()} if it's there.
@@ -17956,7 +18053,7 @@ The date in VMS format (e.g., @samp{20-JUN-1991}).
@end table
@c ENDOFRANGE strf
-Additionally, the alternate representations are recognized but their
+Additionally, the alternative representations are recognized but their
normal representations are used.
@cindex @code{date} utility, POSIX
@@ -17970,7 +18067,7 @@ interprets the current time according to the format specifiers in
the string. For example:
@example
-$ date '+Today is %A, %B %d, %Y.'
+$ @kbd{date '+Today is %A, %B %d, %Y.'}
@print{} Today is Monday, September 22, 2014.
@end example
@@ -18034,8 +18131,10 @@ each successive pair of bits in the operands.
Three common operations are bitwise AND, OR, and XOR.
The operations are described in @ref{table-bitwise-ops}.
+@c 11/2014: Postprocessing turns the docbook informaltable
+@c into a table. Hurray for scripting!
@float Table,table-bitwise-ops
-@caption{Bitwise Operations}
+@caption{Bitwise operations}
@ifnottex
@ifnotdocbook
@display
@@ -18203,7 +18302,7 @@ Return the value of @var{val}, shifted right by @var{count} bits.
Return the bitwise XOR of the arguments. There must be at least two.
@end table
-For all of these functions, first the double precision floating-point value is
+For all of these functions, first the double-precision floating-point value is
converted to the widest C unsigned integer type, then the bitwise operation is
performed. If the result cannot be represented exactly as a C @code{double},
leading nonzero bits are removed one by one until it can be represented
@@ -18302,7 +18401,7 @@ Otherwise, a @code{"0"} is added.
The value is then shifted right by one bit and the loop continues
until there are no more 1 bits.
-If the initial value is zero it returns a simple @code{"0"}.
+If the initial value is zero, it returns a simple @code{"0"}.
Otherwise, at the end, it pads the value with zeros to represent multiples
of 8-bit quantities. This is typical in modern computers.
@@ -18339,8 +18438,8 @@ an array or not. The second is inside the body of a user-defined function
array or not.
@quotation NOTE
-Using @code{isarray()} at the global level to test
-variables makes no sense. Since you are the one writing the program, you
+Using @code{isarray()} at the global level to test
+variables makes no sense. Because you are the one writing the program, you
are supposed to know if your variables are arrays or not. And in fact,
due to the way @command{gawk} works, if you pass the name of a variable
that has not been previously used to @code{isarray()}, @command{gawk}
@@ -18408,7 +18507,7 @@ The default value for @var{category} is @code{"LC_MESSAGES"}.
Complicated @command{awk} programs can often be simplified by defining
your own functions. User-defined functions can be called just like
built-in ones (@pxref{Function Calls}), but it is up to you to define
-them, i.e., to tell @command{awk} what they should do.
+them (i.e., to tell @command{awk} what they should do).
@menu
* Definition Syntax:: How to write definitions and what they mean.
@@ -18547,13 +18646,13 @@ func foo() @{ a = sqrt($1) ; print a @}
@end example
@noindent
-Instead it defines a rule that, for each record, concatenates the value
+Instead, it defines a rule that, for each record, concatenates the value
of the variable @samp{func} with the return value of the function @samp{foo}.
If the resulting string is non-null, the action is executed.
This is probably not what is desired. (@command{awk} accepts this input as
syntactically valid, because functions may be used before they are defined
in @command{awk} programs.@footnote{This program won't actually run,
-since @code{foo()} is undefined.})
+because @code{foo()} is undefined.})
@cindex portability, functions@comma{} defining
To ensure that your @command{awk} programs are portable, always use the
@@ -18624,7 +18723,7 @@ The following is an example of a recursive function. It takes a string
as an input parameter and returns the string in backwards order.
Recursive functions must always have a test that stops the recursion.
In this case, the recursion terminates when the input string is
-already empty.
+already empty:
@c 8/2014: Thanks to Mike Brennan for the improved formulation
@cindex @code{rev()} user-defined function
@@ -18672,7 +18771,7 @@ function ctime(ts, format)
@end example
You might think that @code{ctime()} could use @code{PROCINFO["strftime"]}
-for its format string. That would be a mistake, since @code{ctime()} is
+for its format string. That would be a mistake, because @code{ctime()} is
supposed to return the time formatted in a standard fashion, and user-level
code could have changed @code{PROCINFO["strftime"]}.
@c ENDOFRANGE fdef
@@ -18693,7 +18792,7 @@ the function.
@end menu
@node Calling A Function
-@subsubsection Writing A Function Call
+@subsubsection Writing a Function Call
A function call consists of the function name followed by the arguments
in parentheses. @command{awk} expressions are what you write in the
@@ -18708,7 +18807,7 @@ foo(x y, "lose", 4 * z)
@quotation CAUTION
Whitespace characters (spaces and TABs) are not allowed
-between the function name and the open-parenthesis of the argument list.
+between the function name and the opening parenthesis of the argument list.
If you write whitespace by mistake, @command{awk} might think that you mean
to concatenate a variable with an expression in parentheses. However, it
notices that you used a function name and not a variable name, and reports
@@ -18748,7 +18847,7 @@ function foo(j)
print "foo's i=" i
@}
-BEGIN @{
+BEGIN @{
i = 10
print "top's i=" i
foo(0)
@@ -18771,13 +18870,13 @@ top's i=3
@end example
If you want @code{i} to be local to both @code{foo()} and @code{bar()} do as
-follows (the extra-space before @code{i} is a coding convention to
+follows (the extra space before @code{i} is a coding convention to
indicate that @code{i} is a local variable, not an argument):
@example
function bar( i)
@{
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++)
print "bar's i=" i
@}
@@ -18789,10 +18888,10 @@ function foo(j, i)
print "foo's i=" i
@}
-BEGIN @{
+BEGIN @{
i = 10
print "top's i=" i
- foo(0)
+ foo(0)
print "top's i=" i
@}
@end example
@@ -18851,21 +18950,16 @@ At level 2, index 2 is found in a
@end example
@node Pass By Value/Reference
-@subsubsection Passing Function Arguments By Value Or By Reference
+@subsubsection Passing Function Arguments by Value Or by Reference
In @command{awk}, when you declare a function, there is no way to
declare explicitly whether the arguments are passed @dfn{by value} or
@dfn{by reference}.
-Instead the passing convention is determined at runtime when
+Instead, the passing convention is determined at runtime when
the function is called according to the following rule:
-
-@itemize
-@item
-If the argument is an array variable, then it is passed by reference,
-@item
-Otherwise the argument is passed by value.
-@end itemize
+if the argument is an array variable, then it is passed by reference.
+Otherwise, the argument is passed by value.
@cindex call by value
Passing an argument by value means that when a function is called, it
@@ -18968,7 +19062,13 @@ If @option{--lint} is specified
Some @command{awk} implementations generate a runtime
error if you use either the @code{next} statement
or the @code{nextfile} statement
-(@pxref{Next Statement}, also @pxref{Nextfile Statement})
+(@pxref{Next Statement}, and
+@ifdocbook
+@ref{Nextfile Statement})
+@end ifdocbook
+@ifnotdocbook
+@pxref{Nextfile Statement})
+@end ifnotdocbook
inside a user-defined function.
@command{gawk} does not have this limitation.
@c ENDOFRANGE fudc
@@ -19024,8 +19124,8 @@ function maxelt(vec, i, ret)
@noindent
You call @code{maxelt()} with one argument, which is an array name. The local
variables @code{i} and @code{ret} are not intended to be arguments;
-while there is nothing to stop you from passing more than one argument
-to @code{maxelt()}, the results would be strange. The extra space before
+there is nothing to stop you from passing more than one argument
+to @code{maxelt()} but the results would be strange. The extra space before
@code{i} in the function parameter list indicates that @code{i} and
@code{ret} are local variables.
You should follow this convention when defining functions.
@@ -19162,8 +19262,8 @@ variable as the @emph{name} of the function to call.
@cindex indirect function calls, @code{@@}-notation
@cindex function calls, indirect, @code{@@}-notation for
The syntax is similar to that of a regular function call: an identifier
-immediately followed by a left parenthesis, any arguments, and then
-a closing right parenthesis, with the addition of a leading @samp{@@}
+immediately followed by an opening parenthesis, any arguments, and then
+a closing parenthesis, with the addition of a leading @samp{@@}
character:
@example
@@ -19172,7 +19272,7 @@ result = @@the_func() # calls the sum() function
@end example
Here is a full program that processes the previously shown data,
-using indirect function calls.
+using indirect function calls:
@example
@c file eg/prog/indirectcall.awk
@@ -19213,7 +19313,7 @@ function sum(first, last, ret, i)
These two functions expect to work on fields; thus the parameters
@code{first} and @code{last} indicate where in the fields to start and end.
-Otherwise they perform the expected computations and are not unusual.
+Otherwise they perform the expected computations and are not unusual:
@example
@c file eg/prog/indirectcall.awk
@@ -19258,11 +19358,11 @@ $ @kbd{gawk -f indirectcall.awk class_data1}
@print{} Biology 101:
@print{} sum: <352.8>
@print{} average: <88.2>
-@print{}
+@print{}
@print{} Chemistry 305:
@print{} sum: <356.4>
@print{} average: <89.1>
-@print{}
+@print{}
@print{} English 401:
@print{} sum: <376.1>
@print{} average: <94.025>
@@ -19384,7 +19484,7 @@ function do_sort(first, last, compare, data, i, retval)
retval = data[1]
for (i = 2; i in data; i++)
retval = retval " " data[i]
-
+
return retval
@}
@c endfile
@@ -19430,13 +19530,13 @@ $ @kbd{gawk -f quicksort.awk -f indirectcall.awk class_data2}
@print{} average: <88.2>
@print{} sort: <78.5 87.0 92.4 94.9>
@print{} rsort: <94.9 92.4 87.0 78.5>
-@print{}
+@print{}
@print{} Chemistry 305:
@print{} sum: <356.4>
@print{} average: <89.1>
@print{} sort: <75.2 88.2 94.7 98.3>
@print{} rsort: <98.3 94.7 88.2 75.2>
-@print{}
+@print{}
@print{} English 401:
@print{} sum: <376.1>
@print{} average: <94.025>
@@ -19539,7 +19639,7 @@ functions.
POSIX @command{awk} provides three kinds of built-in functions: numeric,
string, and I/O. @command{gawk} provides functions that sort arrays, work
with values representing time, do bit manipulation, determine variable
-type (array vs.@: scalar), and internationalize and localize programs.
+type (array versus scalar), and internationalize and localize programs.
@command{gawk} also provides several extensions to some of standard
functions, typically in the form of additional arguments.
@@ -19595,7 +19695,7 @@ program. This is equivalent to function pointers in C and C++.
@c ENDOFRANGE funcud
@ifnotinfo
-@part @value{PART2}Problem Solving With @command{awk}
+@part @value{PART2}Problem Solving with @command{awk}
@end ifnotinfo
@ifdocbook
@@ -19605,10 +19705,10 @@ It contains the following chapters:
@itemize @value{BULLET}
@item
-@ref{Library Functions}.
+@ref{Library Functions}
@item
-@ref{Sample Programs}.
+@ref{Sample Programs}
@end itemize
@end ifdocbook
@@ -19669,9 +19769,9 @@ and would like to contribute them to the @command{awk} user community, see
@cindex portability, example programs
The programs in this @value{CHAPTER} and in
@ref{Sample Programs},
-freely use features that are @command{gawk}-specific.
+freely use @command{gawk}-specific features.
Rewriting these programs for different implementations of @command{awk}
-is pretty straightforward.
+is pretty straightforward:
@itemize @value{BULLET}
@item
@@ -19741,7 +19841,7 @@ Library functions often need to have global variables that they can use to
preserve state information between calls to the function---for example,
@code{getopt()}'s variable @code{_opti}
(@pxref{Getopt Function}).
-Such variables are called @dfn{private}, since the only functions that need to
+Such variables are called @dfn{private}, as the only functions that need to
use them are the ones in the library.
When writing a library function, you should try to choose names for your
@@ -19763,10 +19863,10 @@ In addition, several of the library functions use a prefix that helps
indicate what function or set of functions use the variables---for example,
@code{_pw_byname()} in the user database routines
(@pxref{Passwd Functions}).
-This convention is recommended, since it even further decreases the
+This convention is recommended, as it even further decreases the
chance of inadvertent conflict among variable names. Note that this
convention is used equally well for variable names and for private
-function names.@footnote{While all the library routines could have
+function names.@footnote{Although all the library routines could have
been rewritten to use this convention, this was not done, in order to
show how our own @command{awk} programming style has evolved and to
provide some basis for this discussion.}
@@ -19839,7 +19939,7 @@ programming use.
@end menu
@node Strtonum Function
-@subsection Converting Strings To Numbers
+@subsection Converting Strings to Numbers
The @code{strtonum()} function (@pxref{String Functions})
is a @command{gawk} extension. The following function
@@ -19907,7 +20007,7 @@ function mystrtonum(str, ret, n, i, k, c)
# a[6] = "1.e3"
# a[7] = "1.32"
# a[8] = "1.32E2"
-#
+#
# for (i = 1; i in a; i++)
# print a[i], strtonum(a[i]), mystrtonum(a[i])
# @}
@@ -19921,7 +20021,7 @@ string. It sets @code{k} to the index in @code{"1234567"} of the current
octal digit.
The return value will either be the same number as the digit, or zero
if the character is not there, which will be true for a @samp{0}.
-This is safe, since the regexp test in the @code{if} ensures that
+This is safe, because the regexp test in the @code{if} ensures that
only octal values are converted.
Similar logic applies to the code that checks for and converts a
@@ -20268,7 +20368,7 @@ is always 1. This means that on those systems, characters
have numeric values from 128 to 255.
Finally, large mainframe systems use the EBCDIC character set, which
uses all 256 values.
-While there are other character sets in use on some older systems,
+There are other character sets in use on some older systems, but
they are not really worth worrying about:
@example
@@ -20322,7 +20422,7 @@ Good function design is important; this function needs to be general but it
should also have a reasonable default behavior. It is called with an array
as well as the beginning and ending indices of the elements in the array to be
merged. This assumes that the array indices are numeric---a reasonable
-assumption since the array was likely created with @code{split()}
+assumption, as the array was likely created with @code{split()}
(@pxref{String Functions}):
@cindex @code{join()} user-defined function
@@ -20375,7 +20475,7 @@ more difficult than they really need to be.}
The @code{systime()} and @code{strftime()} functions described in
@DBREF{Time Functions}
provide the minimum functionality necessary for dealing with the time of day
-in human readable form. While @code{strftime()} is extensive, the control
+in human-readable form. Although @code{strftime()} is extensive, the control
formats are not necessarily easy to remember or intuitively obvious when
reading a program.
@@ -20466,7 +20566,7 @@ allowed the user to supply an optional timestamp value to use instead
of the current time.
@node Readfile Function
-@subsection Reading A Whole File At Once
+@subsection Reading a Whole File At Once
Often, it is convenient to have the entire contents of a file available
in memory as a single string. A straightforward but naive way to
@@ -20526,7 +20626,7 @@ will never match if the file has contents. @command{gawk} reads data from
the file into @code{tmp} attempting to match @code{RS}. The match fails
after each read, but fails quickly, such that @command{gawk} fills
@code{tmp} with the entire contents of the file.
-(@xref{Records}, for information on @code{RT} and @code{RS}.)
+(@DBXREF{Records} for information on @code{RT} and @code{RS}.)
In the case that @code{file} is empty, the return value is the null
string. Thus calling code may use something like:
@@ -20544,7 +20644,7 @@ test would be @samp{contents == ""}.
also reads an entire file into memory.
@node Shell Quoting
-@subsection Quoting Strings to Pass to The Shell
+@subsection Quoting Strings to Pass to the Shell
@c included by permission
@ignore
@@ -20586,7 +20686,7 @@ chmod -w file.flac
Note the need for shell quoting. The function @code{shell_quote()}
does it. @code{SINGLE} is the one-character string @code{"'"} and
-@code{QSINGLE} is the three-character string @code{"\"'\""}.
+@code{QSINGLE} is the three-character string @code{"\"'\""}:
@example
@c file eg/lib/shellquote.awk
@@ -20646,7 +20746,7 @@ command-line @value{DF}s.
@cindex files, managing, data file boundaries
@cindex files, initialization and cleanup
-The @code{BEGIN} and @code{END} rules are each executed exactly once at
+The @code{BEGIN} and @code{END} rules are each executed exactly once, at
the beginning and end of your @command{awk} program, respectively
(@pxref{BEGIN/END}).
We (the @command{gawk} authors) once had a user who mistakenly thought that the
@@ -20718,7 +20818,7 @@ The following version solves the problem:
@example
@c file eg/lib/ftrans.awk
-# ftrans.awk --- handle data file transitions
+# ftrans.awk --- handle datafile transitions
#
# user supplies beginfile() and endfile() functions
@c endfile
@@ -20746,7 +20846,7 @@ END @{ endfile(_filename_) @}
shows how this library function can be used and
how it simplifies writing the main program.
-@sidebar So Why Does @command{gawk} have @code{BEGINFILE} and @code{ENDFILE}?
+@sidebar So Why Does @command{gawk} Have @code{BEGINFILE} and @code{ENDFILE}?
You are probably wondering, if @code{beginfile()} and @code{endfile()}
functions can do the job, why does @command{gawk} have
@@ -20754,7 +20854,7 @@ functions can do the job, why does @command{gawk} have
Good question. Normally, if @command{awk} cannot open a file, this
causes an immediate fatal error. In this case, there is no way for a
-user-defined function to deal with the problem, since the mechanism for
+user-defined function to deal with the problem, as the mechanism for
calling it relies on the file being open and at the first record. Thus,
the main reason for @code{BEGINFILE} is to give you a ``hook'' to catch
files that cannot be processed. @code{ENDFILE} exists for symmetry,
@@ -20812,8 +20912,8 @@ 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!)
+(This isn't necessary anyway, because @command{gawk} goes to the next
+file as soon as an @code{ENDFILE} rule finishes!)
@node File Checking
@subsection Checking for Readable @value{DDF}s
@@ -20861,19 +20961,19 @@ BEGIN @{
@cindex troubleshooting, @code{getline} function
This works, because the @code{getline} won't be fatal.
Removing the element from @code{ARGV} with @code{delete}
-skips the file (since it's no longer in the list).
+skips the file (because it's no longer in the list).
See also @ref{ARGC and ARGV}.
-The regular expression check purposely does not use character classes
+Because @command{awk} variable names only allow the English letters,
+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
All known @command{awk} implementations silently skip over zero-length files.
-This is a by-product of @command{awk}'s implicit
+This is a by-product of @command{awk}'s implicit
read-a-record-and-match-against-the-rules loop: when @command{awk}
tries to read a record from an empty file, it immediately receives an
end of file indication, closes the file, and proceeds on to the next
@@ -21009,12 +21109,12 @@ are left alone.
@c STARTOFRANGE clibf
@cindex functions, library, C library
@cindex arguments, processing
-Most utilities on POSIX compatible systems take options on
+Most utilities on POSIX-compatible systems take options on
the command line that can be used to change the way a program behaves.
@command{awk} is an example of such a program
(@pxref{Options}).
-Often, options take @dfn{arguments}; i.e., data that the program needs to
-correctly obey the command-line option. For example, @command{awk}'s
+Often, options take @dfn{arguments} (i.e., data that the program needs to
+correctly obey the command-line option). For example, @command{awk}'s
@option{-F} option requires a string to use as the field separator.
The first occurrence on the command line of either @option{--} or a
string that does not begin with @samp{-} ends the options.
@@ -21118,7 +21218,7 @@ necessary for accessing individual characters
(@pxref{String Functions}).@footnote{This
function was written before @command{gawk} acquired the ability to
split strings into single characters using @code{""} as the separator.
-We have left it alone, since using @code{substr()} is more portable.}
+We have left it alone, as using @code{substr()} is more portable.}
The discussion that follows walks through the code a bit at a time:
@@ -21286,9 +21386,9 @@ next element in @code{argv}. If neither condition is true, then only
on the next call to @code{getopt()}.
The @code{BEGIN} rule initializes both @code{Opterr} and @code{Optind} to one.
-@code{Opterr} is set to one, since the default behavior is for @code{getopt()}
+@code{Opterr} is set to one, because the default behavior is for @code{getopt()}
to print a diagnostic message upon seeing an invalid option. @code{Optind}
-is set to one, since there's no reason to look at the program name, which is
+is set to one, because there's no reason to look at the program name, which is
in @code{ARGV[0]}:
@example
@@ -21338,16 +21438,22 @@ etc., as its own options.
@quotation NOTE
After @code{getopt()} is through,
-user level code must clear out all the elements of @code{ARGV} from 1
+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
+as @option{-E} causes @command{gawk} to abandon processing of
further options
-(@pxref{Executable Scripts}, and @pxref{Options}).
+(@DBPXREF{Executable Scripts} and
+@ifnotdocbook
+@pxref{Options}).
+@end ifnotdocbook
+@ifdocbook
+@ref{Options}).
+@end ifdocbook
Several of the sample programs presented in
@ref{Sample Programs},
@@ -21377,7 +21483,7 @@ However, because these are numbers, they do not provide very useful
information to the average user. There needs to be some way to find the
user information associated with the user and group ID numbers. This
@value{SECTION} presents a suite of functions for retrieving information from the
-user database. @xref{Group Functions},
+user database. @DBXREF{Group Functions}
for a similar suite that retrieves information from the group database.
@cindex @code{getpwent()} function (C library)
@@ -21396,7 +21502,7 @@ The ``password'' comes from the original user database file,
encrypted passwords (hence the name).
@cindex @command{pwcat} program
-While an @command{awk} program could simply read @file{/etc/passwd}
+Although an @command{awk} program could simply read @file{/etc/passwd}
directly, this file may not contain complete information about the
system's set of users.@footnote{It is often the case that password
information is stored in a network database.} To be sure you are able to
@@ -21491,12 +21597,12 @@ The user's encrypted password. This may not be available on some systems.
@item User-ID
The user's numeric user ID number.
-(On some systems it's a C @code{long}, and not an @code{int}. Thus
+(On some systems, it's a C @code{long}, and not an @code{int}. Thus
we cast it to @code{long} for all cases.)
@item Group-ID
The user's numeric group ID number.
-(Similar comments about @code{long} vs.@: @code{int} apply here.)
+(Similar comments about @code{long} versus @code{int} apply here.)
@item Full name
The user's full name, and perhaps other information associated with the
@@ -21597,7 +21703,7 @@ 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()}
+The variable @code{_pw_inited} is used for efficiency, as @code{_pw_init()}
needs to be called only once.
@cindex @code{PROCINFO} array, testing the field splitting
@@ -21606,7 +21712,7 @@ 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}.
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
+Doing so is necessary, as 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.
This makes it possible to restore the correct
@@ -21708,7 +21814,7 @@ In turn, calling @code{_pw_init()} is not too expensive, because the
once. If you are worried about squeezing every last cycle out of your
@command{awk} program, the check of @code{_pw_inited} could be moved out of
@code{_pw_init()} and duplicated in all the other functions. In practice,
-this is not necessary, since most @command{awk} programs are I/O-bound,
+this is not necessary, as most @command{awk} programs are I/O-bound,
and such a change would clutter up the code.
The @command{id} program in @DBREF{Id Program}
@@ -21847,7 +21953,7 @@ the association of name to number must be unique within the file.
we cast it to @code{long} for all cases.)
@item Group Member List
-A comma-separated list of user names. These users are members of the group.
+A comma-separated list of usernames. These users are members of the group.
Modern Unix systems allow users to be members of several groups
simultaneously. If your system does, then there are elements
@code{"group1"} through @code{"group@var{N}"} in @code{PROCINFO}
@@ -21962,7 +22068,7 @@ is being used, and to restore the appropriate field splitting mechanism.
The group information is stored is several associative arrays.
The arrays are indexed by group name (@code{@w{_gr_byname}}), by group ID number
(@code{@w{_gr_bygid}}), and by position in the database (@code{@w{_gr_bycount}}).
-There is an additional array indexed by user name (@code{@w{_gr_groupsbyuser}}),
+There is an additional array indexed by username (@code{@w{_gr_groupsbyuser}}),
which is a space-separated list of groups to which each user belongs.
Unlike the user database, it is possible to have multiple records in the
@@ -21975,7 +22081,7 @@ tvpeople:*:101:david,conan,tom,joan
@end example
For this reason, @code{_gr_init()} looks to see if a group name or
-group ID number is already seen. If it is, then the user names are
+group ID number is already seen. If it is, the usernames are
simply concatenated onto the previous list of users.@footnote{There is actually a
subtle problem with the code just presented. Suppose that
the first time there were no names. This code adds the names with
@@ -22021,7 +22127,7 @@ function getgrgid(gid)
@cindex @code{getgruser()} function (C library)
The @code{getgruser()} function does not have a C counterpart. It takes a
-user name and returns the list of groups that have the user as a member:
+username and returns the list of groups that have the user as a member:
@cindex @code{getgruser()} function, user-defined
@example
@@ -22164,7 +22270,7 @@ The functions presented here fit into the following categories:
@c nested list
@table @asis
@item General problems
-Number to string conversion, assertions, rounding, random number
+Number-to-string conversion, assertions, rounding, random number
generation, converting characters to numbers, joining strings, getting
easily usable time-of-day information, and reading a whole file in
one shot.
@@ -22224,7 +22330,7 @@ ARGIND != Argind @{
@}
END @{
if (ARGIND < ARGC - 1)
- ARGIND = ARGC - 1
+ ARGIND = ARGC - 1
if (ARGIND > Argind)
for (Argind++; Argind <= ARGIND; Argind++)
zerofile(ARGV[Argind], Argind)
@@ -22360,7 +22466,7 @@ The programs are presented in alphabetical order.
@end menu
@node Cut Program
-@subsection Cutting out Fields and Columns
+@subsection Cutting Out Fields and Columns
@cindex @command{cut} utility
@c STARTOFRANGE cut
@@ -22637,7 +22743,7 @@ function set_charlist( field, i, j, f, g, n, m, t,
@c endfile
@end example
-Next is the rule that actually processes the data. If the @option{-s} option
+Next is the rule that processes the data. If the @option{-s} option
is given, then @code{suppress} is true. The first @code{if} statement
makes sure that the input record does have the field separator. If
@command{cut} is processing fields, @code{suppress} is true, and the field
@@ -22669,9 +22775,9 @@ written out between the fields:
@end example
This version of @command{cut} relies on @command{gawk}'s @code{FIELDWIDTHS}
-variable to do the character-based cutting. While it is possible in
+variable to do the character-based cutting. It is possible in
other @command{awk} implementations to use @code{substr()}
-(@pxref{String Functions}),
+(@pxref{String Functions}), but
it is also extremely painful.
The @code{FIELDWIDTHS} variable supplies an elegant solution to the problem
of picking the input line apart by characters.
@@ -22816,7 +22922,7 @@ matched lines in the output:
@c endfile
@end example
-The last two lines are commented out, since they are not needed in
+The last two lines are commented out, as they are not needed in
@command{gawk}. They should be uncommented if you have to use another version
of @command{awk}.
@@ -22826,7 +22932,7 @@ into lowercase if the @option{-i} option is specified.@footnote{It
also introduces a subtle bug;
if a match happens, we output the translated line, not the original.}
The rule is
-commented out since it is not necessary with @command{gawk}:
+commented out as it is not necessary with @command{gawk}:
@example
@c file eg/prog/egrep.awk
@@ -22963,7 +23069,7 @@ function usage()
@c ENDOFRANGE egrep
@node Id Program
-@subsection Printing out User Information
+@subsection Printing Out User Information
@cindex printing, user information
@cindex users, information about, printing
@@ -23078,7 +23184,7 @@ function pr_first_field(str, a)
The test in the @code{for} loop is worth noting.
Any supplementary groups in the @code{PROCINFO} array have the
indices @code{"group1"} through @code{"group@var{N}"} for some
-@var{N}, i.e., the total number of supplementary groups.
+@var{N} (i.e., the total number of supplementary groups).
However, we don't know in advance how many of these groups
there are.
@@ -23118,10 +23224,10 @@ aims to demonstrate.}
By default,
the output files are named @file{xaa}, @file{xab}, and so on. Each file has
-1000 lines in it, with the likely exception of the last file. To change the
+1,000 lines in it, with the likely exception of the last file. To change the
number of lines in each file, supply a number on the command line
-preceded with a minus; e.g., @samp{-500} for files with 500 lines in them
-instead of 1000. To change the name of the output files to something like
+preceded with a minus (e.g., @samp{-500} for files with 500 lines in them
+instead of 1,000). To change the name of the output files to something like
@file{myfileaa}, @file{myfileab}, and so on, supply an additional
argument that specifies the @value{FN} prefix.
@@ -23169,7 +23275,7 @@ BEGIN @{
@}
# test argv in case reading from stdin instead of file
if (i in ARGV)
- i++ # skip data file name
+ i++ # skip datafile name
if (i in ARGV) @{
outfile = ARGV[i]
ARGV[i] = ""
@@ -23263,8 +23369,8 @@ truncating them and starting over.
The @code{BEGIN} rule first makes a copy of all the command-line arguments
into an array named @code{copy}.
-@code{ARGV[0]} is not copied, since it is not needed.
-@code{tee} cannot use @code{ARGV} directly, since @command{awk} attempts to
+@code{ARGV[0]} is not needed, so it is not copied.
+@code{tee} cannot use @code{ARGV} directly, because @command{awk} attempts to
process each @value{FN} in @code{ARGV} as input data.
@cindex flag variables
@@ -23313,7 +23419,7 @@ BEGIN @{
@c endfile
@end example
-The following single rule does all the work. Since there is no pattern, it is
+The following single rule does all the work. Because there is no pattern, it is
executed for each line of input. The body of the rule simply prints the
line into each file on the command line, and then to the standard output:
@@ -23344,7 +23450,7 @@ for (i in copy)
@end example
@noindent
-This is more concise but it is also less efficient. The @samp{if} is
+This is more concise, but it is also less efficient. The @samp{if} is
tested for each record and for each output file. By duplicating the loop
body, the @samp{if} is only tested once for each input record. If there are
@var{N} input records and @var{M} output files, the first method only
@@ -23564,10 +23670,10 @@ The second rule does the work. The variable @code{equal} is one or zero,
depending upon the results of @code{are_equal()}'s comparison. If @command{uniq}
is counting repeated lines, and the lines are equal, then it increments the @code{count} variable.
Otherwise, it prints the line and resets @code{count},
-since the two lines are not equal.
+because the two lines are not equal.
If @command{uniq} is not counting, and if the lines are equal, @code{count} is incremented.
-Nothing is printed, since the point is to remove duplicates.
+Nothing is printed, as the point is to remove duplicates.
Otherwise, if @command{uniq} is counting repeated lines and more than
one line is seen, or if @command{uniq} is counting nonrepeated lines
and only one line is seen, then the line is printed, and @code{count}
@@ -23636,7 +23742,7 @@ Brian Kernighan suggests that
``an alternative approach to state machines is to just read
the input into an array, then use indexing. It's almost always
easier code, and for most inputs where you would use this, just
-as fast.'' Consider how to rewrite the logic to follow this
+as fast.'' Consider how to rewrite the logic to follow this
suggestion.
@end ifset
@@ -23688,7 +23794,7 @@ Count only characters.
@end table
Implementing @command{wc} in @command{awk} is particularly elegant,
-since @command{awk} does a lot of the work for us; it splits lines into
+because @command{awk} does a lot of the work for us; it splits lines into
words (i.e., fields) and counts them, it counts lines (i.e., records),
and it can easily tell us how long a line is.
@@ -23793,7 +23899,7 @@ function endfile(file)
@end example
There is one rule that is executed for each line. It adds the length of
-the record, plus one, to @code{chars}.@footnote{Since @command{gawk}
+the record, plus one, to @code{chars}.@footnote{Because @command{gawk}
understands multibyte locales, this code counts characters, not bytes.}
Adding one plus the record length
is needed because the newline character separating records (the value
@@ -24141,8 +24247,8 @@ often used to map uppercase letters into lowercase for further processing:
@command{tr} requires two lists of characters.@footnote{On some older
systems, including Solaris, the system version of @command{tr} may require
that the lists be written as range expressions enclosed in square brackets
-(@samp{[a-z]}) and quoted, to prevent the shell from attempting a file
-name expansion. This is not a feature.} When processing the input, the
+(@samp{[a-z]}) and quoted, to prevent the shell from attempting a
+@value{FN} expansion. This is not a feature.} When processing the input, the
first character in the first list is replaced with the first character
in the second list, the second character in the first list is replaced
with the second character in the second list, and so on. If there are
@@ -24257,9 +24363,9 @@ BEGIN @{
@c endfile
@end example
-While it is possible to do character transliteration in a user-level
-function, it is not necessarily efficient, and we (the @command{gawk}
-authors) started to consider adding a built-in function. However,
+It is possible to do character transliteration in a user-level
+function, but it is not necessarily efficient, and we (the @command{gawk}
+developers) started to consider adding a built-in function. However,
shortly after writing this program, we learned that Brian Kernighan
had added the @code{toupper()} and @code{tolower()} functions to his
@command{awk} (@pxref{String Functions}). These functions handle the
@@ -24303,7 +24409,7 @@ the @code{line} array and printing the page when 20 labels have been read.
The @code{BEGIN} rule simply sets @code{RS} to the empty string, so that
@command{awk} splits records at blank lines
(@pxref{Records}).
-It sets @code{MAXLINES} to 100, since 100 is the maximum number
+It sets @code{MAXLINES} to 100, because 100 is the maximum number
of lines on the page
@iftex
(@math{20 @cdot 5 = 100}).
@@ -24460,9 +24566,9 @@ useful on real text files:
@item
The @command{awk} language considers upper- and lowercase characters to be
distinct. Therefore, ``bartender'' and ``Bartender'' are not treated
-as the same word. This is undesirable, since in normal text, words
-are capitalized if they begin sentences, and a frequency analyzer should not
-be sensitive to capitalization.
+as the same word. This is undesirable, because words are capitalized
+if they begin sentences in normal text, and a frequency analyzer should
+not be sensitive to capitalization.
@item
Words are detected using the @command{awk} convention that fields are
@@ -24643,7 +24749,7 @@ The nodes
and @ref{Sample Programs},
are the top level nodes for a large number of @command{awk} programs.
@end ifinfo
-If you want to experiment with these programs, it is tedious to have to type
+If you want to experiment with these programs, it is tedious to type
them in by hand. Here we present a program that can extract parts of a
Texinfo input file into separate files.
@@ -24721,7 +24827,7 @@ It also prints some final advice:
@@example
@@c file examples/messages.awk
-END @@@{ print "Always avoid bored archeologists!" @@@}
+END @@@{ print "Always avoid bored archaeologists!" @@@}
@@c end file
@@end example
@dots{}
@@ -24893,7 +24999,7 @@ The @command{sed} utility is a stream editor, a program that reads a
stream of data, makes changes to it, and passes it on.
It is often used to make global changes to a large file or to a stream
of data generated by a pipeline of commands.
-While @command{sed} is a complicated program in its own right, its most common
+Although @command{sed} is a complicated program in its own right, its most common
use is to perform global substitutions in the middle of a pipeline:
@example
@@ -24902,7 +25008,7 @@ use is to perform global substitutions in the middle of a pipeline:
Here, @samp{s/old/new/g} tells @command{sed} to look for the regexp
@samp{old} on each input line and globally replace it with the text
-@samp{new}, i.e., all the occurrences on a line. This is similar to
+@samp{new} (i.e., all the occurrences on a line). This is similar to
@command{awk}'s @code{gsub()} function
(@pxref{String Functions}).
@@ -24986,7 +25092,7 @@ not treated as @value{FN}s
(@pxref{ARGC and ARGV}).
The @code{usage()} function prints an error message and exits.
-Finally, the single rule handles the printing scheme outlined above,
+Finally, the single rule handles the printing scheme outlined earlier,
using @code{print} or @code{printf} as appropriate, depending upon the
value of @code{RT}.
@c ENDOFRANGE awksed
@@ -25030,8 +25136,8 @@ BEGIN @{
The following program, @file{igawk.sh}, provides this service.
It simulates @command{gawk}'s searching of the @env{AWKPATH} variable
-and also allows @dfn{nested} includes; i.e., a file that is included
-with @code{@@include} can contain further @code{@@include} statements.
+and also allows @dfn{nested} includes (i.e., a file that is included
+with @code{@@include} can contain further @code{@@include} statements).
@command{igawk} makes an effort to only include files once, so that nested
includes don't accidentally include a library function twice.
@@ -25061,10 +25167,10 @@ Literal text, provided with @option{-e} or @option{--source}. This
text is just appended directly.
@item
-Source @value{FN}s, provided with @option{-f}. We use a neat trick and append
-@samp{@@include @var{filename}} to the shell variable's contents. Since the file-inclusion
-program works the way @command{gawk} does, this gets the text
-of the file included into the program at the correct point.
+Source @value{FN}s, provided with @option{-f}. We use a neat trick and
+append @samp{@@include @var{filename}} to the shell variable's contents.
+Because the file-inclusion program works the way @command{gawk} does, this
+gets the text of the file included in the program at the correct point.
@end enumerate
@item
@@ -25363,9 +25469,10 @@ EOF
@c endfile
@end example
-The shell construct @samp{@var{command} << @var{marker}} is called a @dfn{here document}.
-Everything in the shell script up to the @var{marker} is fed to @var{command} as input.
-The shell processes the contents of the here document for variable and command substitution
+The shell construct @samp{@var{command} << @var{marker}} is called
+a @dfn{here document}. Everything in the shell script up to the
+@var{marker} is fed to @var{command} as input. The shell processes
+the contents of the here document for variable and command substitution
(and possibly other things as well, depending upon the shell).
The shell construct @samp{$(@dots{})} is called @dfn{command substitution}.
@@ -25380,14 +25487,16 @@ It's done in these steps:
@enumerate
@item
Run @command{gawk} with the @code{@@include}-processing program (the
-value of the @code{expand_prog} shell variable) on standard input.
+value of the @code{expand_prog} shell variable) reading standard input.
@item
-Standard input is the contents of the user's program, from the shell variable @code{program}.
-Its contents are fed to @command{gawk} via a here document.
+Standard input is the contents of the user's program,
+from the shell variable @code{program}.
+Feed its contents to @command{gawk} via a here document.
@item
-The results of this processing are saved in the shell variable @code{processed_program} by using command substitution.
+Save the results of this processing in the shell variable
+@code{processed_program} by using command substitution.
@end enumerate
The last step is to call @command{gawk} with the expanded program,
@@ -25463,7 +25572,7 @@ of @command{awk} programs as Web CGI scripts.}
@c ENDOFRANGE igawk
@node Anagram Program
-@subsection Finding Anagrams From A Dictionary
+@subsection Finding Anagrams from a Dictionary
@cindex anagrams, finding
An interesting programming challenge is to
@@ -25472,17 +25581,17 @@ word list (such as
@file{/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'').
+(e.g., ``babbling'' and ``blabbing'').
-Column 2, Problem C of Jon Bentley's @cite{Programming Pearls}, second
-edition, presents an elegant algorithm. The idea is to give words that
+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
-in sorted order.
+in sorted order:
@c STARTOFRANGE anagram
@cindex @code{anagram.awk} program
@@ -25554,7 +25663,7 @@ function word2key(word, a, i, n, result)
Finally, the @code{END} rule traverses the array
and prints out the anagram lists. It sends the output
-to the system @command{sort} command, since otherwise
+to the system @command{sort} command because otherwise
the anagrams would appear in arbitrary order:
@example
@@ -25582,21 +25691,21 @@ Here is some partial output when the program is run:
@example
$ @kbd{gawk -f anagram.awk /usr/share/dict/words | grep '^b'}
@dots{}
-babbled blabbed
-babbler blabber brabble
-babblers blabbers brabbles
-babbling blabbing
-babbly blabby
-babel bable
-babels beslab
-babery yabber
+babbled blabbed
+babbler blabber brabble
+babblers blabbers brabbles
+babbling blabbing
+babbly blabby
+babel bable
+babels beslab
+babery yabber
@dots{}
@end example
@c ENDOFRANGE anagram
@node Signature Program
-@subsection And Now For Something Completely Different
+@subsection And Now for Something Completely Different
@cindex signature program
@cindex Brini, Davide
@@ -25636,28 +25745,28 @@ Subject: The GNU Awk User's Guide, Section 13.3.11
From: "Chris Johansen" <johansen@main.nc.us>
Message-ID: <op.v0iw6wlv7finx3@asusodin.thrudvang.lan>
-Arnold, you don't know me, but we have a tenuous connection. My wife is
+Arnold, you don't know me, but we have a tenuous connection. My wife is
Barbara A. Field, FAIA, GIT '65 (B. Arch.).
-I have had a couple of paper copies of "Effective Awk Programming" for
-years, and now I'm going through a Kindle version of "The GNU Awk User's
-Guide" again. When I got to section 13.3.11, I reformatted and lightly
+I have had a couple of paper copies of "Effective Awk Programming" for
+years, and now I'm going through a Kindle version of "The GNU Awk User's
+Guide" again. When I got to section 13.3.11, I reformatted and lightly
commented Davide Brin's signature script to understand its workings.
-It occurs to me that this might have pedagogical value as an example
-(although imperfect) of the value of whitespace and comments, and a
-starting point for that discussion. It certainly helped _me_ understand
-what's going on. You are welcome to it, as-is or modified (subject to
+It occurs to me that this might have pedagogical value as an example
+(although imperfect) of the value of whitespace and comments, and a
+starting point for that discussion. It certainly helped _me_ understand
+what's going on. You are welcome to it, as-is or modified (subject to
Davide's constraints, of course, which I think I have met).
-If I were to include it in a future edition, I would put it at some
-distance from section 13.3.11, say, as a note or an appendix, so as not to
+If I were to include it in a future edition, I would put it at some
+distance from section 13.3.11, say, as a note or an appendix, so as not to
be a "spoiler" to the puzzle.
Best regards,
---
+--
Chris Johansen {johansen at main dot nc dot us}
- . . . collapsing the probability wave function, sending ripples of
+ . . . collapsing the probability wave function, sending ripples of
certainty through the space-time continuum.
@@ -25666,7 +25775,7 @@ certainty through the space-time continuum.
# From "13.3.11 And Now For Something Completely Different"
# http://www.gnu.org/software/gawk/manual/html_node/Signature-Program.html#Signature-Program
-# Copyright © 2008 Davide Brini
+# Copyright © 2008 Davide Brini
# Copying and distribution of the code published in this page, with
# or without modification, are permitted in any medium without
@@ -25785,7 +25894,7 @@ Brian Kernighan suggests that
``an alternative approach to state machines is to just read
the input into an array, then use indexing. It's almost always
easier code, and for most inputs where you would use this, just
-as fast.'' Rewrite the logic to follow this
+as fast.'' Rewrite the logic to follow this
suggestion.
@@ -25886,7 +25995,7 @@ the use of the external @command{sort} utility.
@c EXCLUDE END
@ifnotinfo
-@part @value{PART3}Moving Beyond Standard @command{awk} With @command{gawk}
+@part @value{PART3}Moving Beyond Standard @command{awk} with @command{gawk}
@end ifnotinfo
@ifdocbook
@@ -25895,19 +26004,19 @@ It contains the following chapters:
@itemize @value{BULLET}
@item
-@ref{Advanced Features}.
+@ref{Advanced Features}
@item
-@ref{Internationalization}.
+@ref{Internationalization}
@item
-@ref{Debugger}.
+@ref{Debugger}
@item
-@ref{Arbitrary Precision Arithmetic}.
+@ref{Arbitrary Precision Arithmetic}
@item
-@ref{Dynamic Extensions}.
+@ref{Dynamic Extensions}
@end itemize
@end ifdocbook
@@ -26066,7 +26175,7 @@ in a particular order that you, the programmer, choose. @command{gawk}
lets you do this.
@DBREF{Controlling Scanning} describes how you can assign special,
-pre-defined values to @code{PROCINFO["sorted_in"]} in order to
+predefined values to @code{PROCINFO["sorted_in"]} in order to
control the order in which @command{gawk} traverses an array
during a @code{for} loop.
@@ -26090,7 +26199,7 @@ Here, @var{i1} and @var{i2} are the indices, and @var{v1} and @var{v2}
are the corresponding values of the two elements being compared.
Either @var{v1} or @var{v2}, or both, can be arrays if the array being
traversed contains subarrays as values.
-(@xref{Arrays of Arrays}, for more information about subarrays.)
+(@DBXREF{Arrays of Arrays} for more information about subarrays.)
The three possible return values are interpreted as follows:
@table @code
@@ -26133,7 +26242,7 @@ function cmp_str_val(i1, v1, i2, v2)
The third
comparison function makes all numbers, and numeric strings without
-any leading or trailing spaces, come out first during loop traversal:
+any leading or trailing spaces, come out first during loop traversal:
@example
function cmp_num_str_val(i1, v1, i2, v2, n1, n2)
@@ -26141,10 +26250,10 @@ function cmp_num_str_val(i1, v1, i2, v2, n1, n2)
# numbers before string value comparison, ascending order
n1 = v1 + 0
n2 = v2 + 0
- if (n1 == v1)
+ if (n1 == v1)
return (n2 == v2) ? (n1 - n2) : -1
else if (n2 == v2)
- return 1
+ return 1
return (v1 < v2) ? -1 : (v1 != v2)
@}
@end example
@@ -26159,7 +26268,7 @@ BEGIN @{
data[10] = "one"
data[100] = 100
data[20] = "two"
-
+
f[1] = "cmp_num_idx"
f[2] = "cmp_str_val"
f[3] = "cmp_num_str_val"
@@ -26183,14 +26292,14 @@ $ @kbd{gawk -f compdemo.awk}
@print{} data[10] = one
@print{} data[20] = two
@print{} data[100] = 100
-@print{}
+@print{}
@print{} Sort function: cmp_str_val @ii{Sort by element values as strings}
@print{} data[one] = 10
@print{} data[100] = 100 @ii{String 100 is less than string 20}
@print{} data[two] = 20
@print{} data[10] = one
@print{} data[20] = two
-@print{}
+@print{}
@print{} Sort function: cmp_num_str_val @ii{Sort all numeric values before all strings}
@print{} data[one] = 10
@print{} data[two] = 20
@@ -26201,7 +26310,7 @@ $ @kbd{gawk -f compdemo.awk}
Consider sorting the entries of a GNU/Linux system password file
according to login name. The following program sorts records
-by a specific field position and can be used for this purpose:
+by a specific field position and can be used for this purpose:
@example
# passwd-sort.awk --- simple program to sort by field position
@@ -26247,7 +26356,7 @@ $ @kbd{gawk -v POS=1 -F: -f sort.awk /etc/passwd}
The comparison should normally always return the same value when given a
specific pair of array elements as its arguments. If inconsistent
-results are returned then the order is undefined. This behavior can be
+results are returned, then the order is undefined. This behavior can be
exploited to introduce random order into otherwise seemingly
ordered data:
@@ -26259,7 +26368,7 @@ function cmp_randomize(i1, v1, i2, v2)
@}
@end example
-As mentioned above, the order of the indices is arbitrary if two
+As already mentioned, 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
@@ -26300,10 +26409,10 @@ When string comparisons are made during a sort, either for element
values where one or both aren't numbers, or for element indices
handled as strings, the value of @code{IGNORECASE}
(@pxref{Built-in Variables}) controls whether
-the comparisons treat corresponding uppercase and lowercase letters as
+the comparisons treat corresponding upper- and lowercase letters as
equivalent or distinct.
-Another point to keep in mind is that in the case of subarrays
+Another point to keep in mind is that in the case of subarrays,
the element values can themselves be arrays; a production comparison
function should use the @code{isarray()} function
(@pxref{Type Functions}),
@@ -26311,7 +26420,7 @@ to check for this, and choose a defined sorting order for subarrays.
All sorting based on @code{PROCINFO["sorted_in"]}
is disabled in POSIX mode,
-since the @code{PROCINFO} array is not special in that case.
+because the @code{PROCINFO} array is not special in that case.
As a side note, sorting the array indices before traversing
the array has been reported to add 15% to 20% overhead to the
@@ -26332,8 +26441,8 @@ sorted array traversal is not the default.
@cindex @code{asorti()} function (@command{gawk}), arrays@comma{} sorting
@cindex sort function, arrays, sorting
In most @command{awk} implementations, sorting an array requires writing
-a @code{sort()} function. While this can be educational for exploring
-different sorting algorithms, usually that's not the point of the program.
+a @code{sort()} function. This can be educational for exploring
+different sorting algorithms, but usually that's not the point of the program.
@command{gawk} provides the built-in @code{asort()} and @code{asorti()}
functions (@pxref{String Functions}) for sorting arrays. For example:
@@ -26429,8 +26538,8 @@ Because @code{IGNORECASE} affects string comparisons, the value
of @code{IGNORECASE} also affects sorting for both @code{asort()} and @code{asorti()}.
Note also that the locale's sorting order does @emph{not}
come into play; comparisons are based on character values only.@footnote{This
-is true because locale-based comparison occurs only when in POSIX
-compatibility mode, and since @code{asort()} and @code{asorti()} are
+is true because locale-based comparison occurs only when in
+POSIX-compatibility mode, and because @code{asort()} and @code{asorti()} are
@command{gawk} extensions, they are not available in that case.}
@node Two-way I/O
@@ -26506,7 +26615,7 @@ remain more difficult to use than two-way pipes.} @c 8/2014
@cindex @command{csh} utility, @code{|&} operator, comparison with
However, with @command{gawk}, it is possible to
open a @emph{two-way} pipe to another process. The second process is
-termed a @dfn{coprocess}, since it runs in parallel with @command{gawk}.
+termed a @dfn{coprocess}, as it runs in parallel with @command{gawk}.
The two-way connection is created using the @samp{|&} operator
(borrowed from the Korn shell, @command{ksh}):@footnote{This is very
different from the same operator in the C shell and in Bash.}
@@ -26666,7 +26775,7 @@ You can think of this as just a @emph{very long} two-way pipeline to
a coprocess.
The way @command{gawk} decides that you want to use TCP/IP networking is
by recognizing special @value{FN}s that begin with one of @samp{/inet/},
-@samp{/inet4/} or @samp{/inet6/}.
+@samp{/inet4/}, or @samp{/inet6/}.
The full syntax of the special @value{FN} is
@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}}.
@@ -26695,7 +26804,7 @@ or @samp{http}, in which case @command{gawk} attempts to determine
the predefined port number using the C @code{getaddrinfo()} function.
@item remote-host
-The IP address or fully-qualified domain name of the Internet
+The IP address or fully qualified domain name of the Internet
host to which you want to connect.
@item remote-port
@@ -26769,12 +26878,12 @@ gawk --profile=myprog.prof -f myprog.awk data1 data2
@end example
@noindent
-In the above example, @command{gawk} places the profile in
+In the preceding example, @command{gawk} places the profile in
@file{myprog.prof} instead of in @file{awkprof.out}.
-Here is a sample session showing a simple @command{awk} program, its input data, and the
-results from running @command{gawk} with the @option{--profile} option.
-First, the @command{awk} program:
+Here is a sample session showing a simple @command{awk} program,
+its input data, and the results from running @command{gawk} with the
+@option{--profile} option. First, the @command{awk} program:
@example
BEGIN @{ print "First BEGIN rule" @}
@@ -26932,7 +27041,7 @@ the body of an @code{if}, @code{else}, or loop is only a single statement.
@item
Parentheses are used only where needed, as indicated by the structure
of the program and the precedence rules.
-For example, @samp{(3 + 5) * 4} means add three plus five, then multiply
+For example, @samp{(3 + 5) * 4} means add three and five, then multiply
the total by four. However, @samp{3 + 5 * 4} has no parentheses, and
means @samp{3 + (5 * 4)}.
@@ -27191,8 +27300,7 @@ following steps, in this order:
@enumerate
@item
-The programmer goes
-through the source for all of @command{guide}'s components
+The programmer reviews the source for all of @command{guide}'s components
and marks each string that is a candidate for translation.
For example, @code{"`-F': option required"} is a good candidate for translation.
A table with strings of option names is not (e.g., @command{gawk}'s
@@ -27312,8 +27420,8 @@ if necessary. (It is almost never necessary to supply a different category.)
@cindex sorting characters in different languages
@cindex @code{LC_COLLATE} locale category
@item LC_COLLATE
-Text-collation information; i.e., how different characters
-and/or groups of characters sort in a given language.
+Text-collation information (i.e., how different characters
+and/or groups of characters sort in a given language).
@cindex @code{LC_CTYPE} locale category
@item LC_CTYPE
@@ -27532,7 +27640,7 @@ BEGIN @{
@end enumerate
-@xref{I18N Example},
+@DBXREF{I18N Example}
for an example program showing the steps to create
and use translations from @command{awk}.
@@ -27593,7 +27701,7 @@ second argument to @code{dcngettext()}.@footnote{The
You should distribute the generated @file{.pot} file with
your @command{awk} program; translators will eventually use it
to provide you translations that you can also then distribute.
-@xref{I18N Example},
+@DBXREF{I18N Example}
for the full list of steps to go through to create and test
translations for @command{guide}.
@c ENDOFRANGE portobfi
@@ -27721,7 +27829,7 @@ change:
@cindex @code{TEXTDOMAIN} variable, portability and
@item
Assignments to @code{TEXTDOMAIN} won't have any effect,
-since @code{TEXTDOMAIN} is not special in other @command{awk} implementations.
+because @code{TEXTDOMAIN} is not special in other @command{awk} implementations.
@item
Non-GNU versions of @command{awk} treat marked strings
@@ -27769,8 +27877,8 @@ enough arguments are supplied in the function call. Many versions of
underlying C library version of @code{sprintf()}, but only one format and
argument at a time. What happens if a positional specification is
used is anybody's guess.
-However, since the positional specifications are primarily for use in
-@emph{translated} format strings, and since non-GNU @command{awk}s never
+However, because the positional specifications are primarily for use in
+@emph{translated} format strings, and because non-GNU @command{awk}s never
retrieve the translated string, this should not be a problem in practice.
@end itemize
@c ENDOFRANGE inap
@@ -27833,7 +27941,7 @@ called ``Hippy.'' Ah, well.}
@example
@group
-$ cp guide.pot guide-mellow.po
+$ @kbd{cp guide.pot guide-mellow.po}
@var{Add translations to} guide-mellow.po @dots{}
@end group
@end example
@@ -27859,7 +27967,7 @@ msgstr "Like, the scoop is"
The next step is to make the directory to hold the binary message object
file and then to create the @file{guide.mo} file.
We pretend that our file is to be used in the @code{en_US.UTF-8} locale,
-since we have to use a locale name known to the C @command{gettext} routines.
+because we have to use a locale name known to the C @command{gettext} routines.
The directory layout shown here is standard for GNU @command{gettext} on
GNU/Linux systems. Other versions of @command{gettext} may use a different
layout:
@@ -27896,7 +28004,7 @@ $ @kbd{gawk -f guide.awk}
@print{} Pardon me, Zaphod who?
@end example
-If the three replacement functions for @code{dcgettext()}, @code{dcngettext()}
+If the three replacement functions for @code{dcgettext()}, @code{dcngettext()},
and @code{bindtextdomain()}
(@pxref{I18N Portability})
are in a file named @file{libintl.awk},
@@ -27998,7 +28106,7 @@ how to use @command{gawk} for debugging your program is easy.
@end menu
@node Debugging
-@section Introduction to The @command{gawk} Debugger
+@section Introduction to the @command{gawk} Debugger
This @value{SECTION} introduces debugging in general and begins
the discussion of debugging in @command{gawk}.
@@ -28016,8 +28124,8 @@ the discussion of debugging in @command{gawk}.
ahead to the next section on the specific features of the @command{gawk}
debugger.)
-Of course, a debugging program cannot remove bugs for you, since it has
-no way of knowing what you or your users consider a ``bug'' and what is a
+Of course, a debugging program cannot remove bugs for you, because it has
+no way of knowing what you or your users consider a ``bug'' versus a
``feature.'' (Sometimes, we humans have a hard time with this ourselves.)
In that case, what can you expect from such a tool? The answer to that
depends on the language being debugged, but in general, you can expect at
@@ -28038,7 +28146,7 @@ having to change your source files.
@item
The chance to see the values of data in the program at any point in
execution, and also to change that data on the fly, to see how that
-affects what happens afterwards. (This often includes the ability
+affects what happens afterward. (This often includes the ability
to look at internal data structures besides the variables you actually
defined in your code.)
@@ -28058,11 +28166,11 @@ functional program that you or someone else wrote).
Before diving in to the details, we need to introduce several
important concepts that apply to just about all debuggers.
The following list defines terms used throughout the rest of
-this @value{CHAPTER}.
+this @value{CHAPTER}:
@table @dfn
@cindex stack frame
-@item Stack Frame
+@item Stack frame
Programs generally call functions during the course of their execution.
One function can call another, or a function can call itself (recursion).
You can view the chain of called functions (main program calls A, which
@@ -28097,7 +28205,7 @@ as many breakpoints as you like.
A watchpoint is similar to a breakpoint. The difference is that
breakpoints are oriented around the code: stop when a certain point in the
code is reached. A watchpoint, however, specifies that program execution
-should stop when a @emph{data value} is changed. This is useful, since
+should stop when a @emph{data value} is changed. This is useful, as
sometimes it happens that a variable receives an erroneous value, and it's
hard to track down where this happens just by looking at the code.
By using a watchpoint, you can stop whenever a variable is assigned to,
@@ -28111,13 +28219,13 @@ Debugging an @command{awk} program has some specific aspects that are
not shared with other programming languages.
First of all, the fact that @command{awk} programs usually take input
-line-by-line from a file or files and operate on those lines using specific
+line by line from a file or files and operate on those lines using specific
rules makes it especially useful to organize viewing the execution of
the program in terms of these rules. As we will see, each @command{awk}
rule is treated almost like a function call, with its own specific block
of instructions.
-In addition, since @command{awk} is by design a very concise language,
+In addition, because @command{awk} is by design a very concise language,
it is easy to lose sight of everything that is going on ``inside''
each line of @command{awk} code. The debugger provides the opportunity
to look at the individual primitive instructions carried out
@@ -28244,7 +28352,7 @@ gawk> @kbd{bt}
@end example
This tells us that @code{are_equal()} was called by the main program at
-line 88 of @file{uniq.awk}. (This is not a big surprise, since this
+line 88 of @file{uniq.awk}. (This is not a big surprise, because this
is the only call to @code{are_equal()} in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -28261,7 +28369,7 @@ gawk> @kbd{p n}
@end example
@noindent
-In this case, @code{n} is an uninitialized local variable, since the
+In this case, @code{n} is an uninitialized local variable, because the
function was called without arguments (@pxref{Function Calls}).
A more useful variable to display might be the current record:
@@ -28272,8 +28380,8 @@ gawk> @kbd{p $0}
@end example
@noindent
-This might be a bit puzzling at first since this is the second line of
-our test input above. Let's look at @code{NR}:
+This might be a bit puzzling at first, as this is the second line of
+our test input. Let's look at @code{NR}:
@example
gawk> @kbd{p NR}
@@ -28313,7 +28421,7 @@ gawk> @kbd{n}
This tells us that @command{gawk} is now ready to execute line 66, which
decides whether to give the lines the special ``field skipping'' treatment
indicated by the @option{-1} command-line option. (Notice that we skipped
-from where we were before at line 63 to here, since the condition in line 63
+from where we were before at line 63 to here, because the condition in line 63
@samp{if (fcount == 0 && charcount == 0)} was false.)
Continuing to step, we now get to the splitting of the current and
@@ -28343,7 +28451,7 @@ gawk> @kbd{p n m alast aline}
This is kind of disappointing, though. All we found out is that there
are five elements in @code{alast}; @code{m} and @code{aline} don't have
-values since we are at line 68 but haven't executed it yet.
+values because we are at line 68 but haven't executed it yet.
This information is useful enough (we now know that
none of the words were accidentally left out), but what if we want to see
inside the array?
@@ -28452,8 +28560,9 @@ show the abbreviation on a second description line.
A debugger command name may also be truncated if that partial
name is unambiguous. The debugger has the built-in capability to
automatically repeat the previous command just by hitting @key{Enter}.
-This works for the commands @code{list}, @code{next}, @code{nexti}, @code{step}, @code{stepi}
-and @code{continue} executed without any argument.
+This works for the commands @code{list}, @code{next}, @code{nexti},
+@code{step}, @code{stepi}, and @code{continue} executed without any
+argument.
@menu
* Breakpoint Control:: Control of Breakpoints.
@@ -28468,9 +28577,9 @@ and @code{continue} executed without any argument.
@node Breakpoint Control
@subsection Control of Breakpoints
-As we saw above, the first thing you probably want to do in a debugging
-session is to get your breakpoints set up, since otherwise your program
-will just run as if it was not under the debugger. The commands for
+As we saw earlier, the first thing you probably want to do in a debugging
+session is to get your breakpoints set up, because your program
+will otherwise just run as if it was not under the debugger. The commands for
controlling breakpoints are:
@table @asis
@@ -28541,8 +28650,8 @@ that the debugger evaluates
whenever the breakpoint or watchpoint is reached. If the condition is true, then
the debugger stops execution and prompts for a command. Otherwise,
the debugger continues executing the program. If the condition expression is
-not specified, any existing condition is removed; i.e., the breakpoint or
-watchpoint is made unconditional.
+not specified, any existing condition is removed (i.e., the breakpoint or
+watchpoint is made unconditional).
@cindex debugger commands, @code{d} (@code{delete})
@cindex debugger commands, @code{delete}
@@ -28683,7 +28792,7 @@ Execute one (or @var{count}) instruction(s), stepping over function calls.
@item @code{return} [@var{value}]
Cancel execution of a function call. If @var{value} (either a string or a
number) is specified, it is used as the function's return value. If used in a
-frame other than the innermost one (the currently executing function, i.e.,
+frame other than the innermost one (the currently executing function; i.e.,
frame number 0), discard all inner frames in addition to the selected one,
and the caller of that frame becomes the innermost frame.
@@ -28749,7 +28858,7 @@ gawk> @kbd{display x}
@end example
@noindent
-displays the assigned item number, the variable name and its current value.
+This displays the assigned item number, the variable name, and its current value.
If the display variable refers to a function parameter, it is silently
deleted from the list as soon as the execution reaches a context where
no such variable of the given name exists.
@@ -28817,7 +28926,7 @@ or field.
String values must be enclosed between double quotes (@code{"}@dots{}@code{"}).
You can also set special @command{awk} variables, such as @code{FS},
-@code{NF}, @code{NR}, etc.
+@code{NF}, @code{NR}, and son on.
@cindex debugger commands, @code{w} (@code{watch})
@cindex debugger commands, @code{watch}
@@ -28880,7 +28989,7 @@ Print a backtrace of all function calls (stack frames), or innermost @var{count}
frames if @var{count} > 0. Print the outermost @var{count} frames if
@var{count} < 0. The backtrace displays the name and arguments to each
function, the source @value{FN}, and the line number.
-The alias @code{where} for @code{backtrace} is provided for long-time
+The alias @code{where} for @code{backtrace} is provided for longtime
GDB users who may be used to that command.
@cindex debugger commands, @code{down}
@@ -28909,7 +29018,7 @@ Then select and print the frame.
@end table
@node Debugger Info
-@subsection Obtaining Information about the Program and the Debugger State
+@subsection Obtaining Information About the Program and the Debugger State
Besides looking at the values of variables, there is often a need to get
other sorts of information about the state of your program and of the
@@ -29077,51 +29186,51 @@ partial dump of Davide Brini's obfuscated code
@smallexample
gawk> @kbd{dump}
@print{} # BEGIN
-@print{}
-@print{} [ 1:0xfcd340] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
-@print{} [ 1:0xfcc240] Op_push_i : "~" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc2a0] Op_push_i : "~" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc280] Op_match :
-@print{} [ 1:0xfcc1e0] Op_store_var : O
-@print{} [ 1:0xfcc2e0] Op_push_i : "==" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc340] Op_push_i : "==" [MALLOC|STRING|STRCUR]
-@print{} [ 1:0xfcc320] Op_equal :
-@print{} [ 1:0xfcc200] Op_store_var : o
-@print{} [ 1:0xfcc380] Op_push : o
-@print{} [ 1:0xfcc360] Op_plus_i : 0 [MALLOC|NUMCUR|NUMBER]
-@print{} [ 1:0xfcc220] Op_push_lhs : o [do_reference = true]
-@print{} [ 1:0xfcc300] Op_assign_plus :
-@print{} [ :0xfcc2c0] Op_pop :
-@print{} [ 1:0xfcc400] Op_push : O
-@print{} [ 1:0xfcc420] Op_push_i : "" [MALLOC|STRING|STRCUR]
-@print{} [ :0xfcc4a0] Op_no_op :
-@print{} [ 1:0xfcc480] Op_push : O
-@print{} [ :0xfcc4c0] Op_concat : [expr_count = 3] [concat_flag = 0]
-@print{} [ 1:0xfcc3c0] Op_store_var : x
-@print{} [ 1:0xfcc440] Op_push_lhs : X [do_reference = true]
-@print{} [ 1:0xfcc3a0] Op_postincrement :
-@print{} [ 1:0xfcc4e0] Op_push : x
-@print{} [ 1:0xfcc540] Op_push : o
-@print{} [ 1:0xfcc500] Op_plus :
-@print{} [ 1:0xfcc580] Op_push : o
-@print{} [ 1:0xfcc560] Op_plus :
-@print{} [ 1:0xfcc460] Op_leq :
-@print{} [ :0xfcc5c0] Op_jmp_false : [target_jmp = 0xfcc5e0]
-@print{} [ 1:0xfcc600] Op_push_i : "%c" [MALLOC|STRING|STRCUR]
-@print{} [ :0xfcc660] Op_no_op :
-@print{} [ 1:0xfcc520] Op_assign_concat : c
-@print{} [ :0xfcc620] Op_jmp : [target_jmp = 0xfcc440]
-@print{}
-@dots{}
-@print{}
+@print{}
+@print{} [ 1:0xfcd340] Op_rule : [in_rule = BEGIN] [source_file = brini.awk]
+@print{} [ 1:0xfcc240] Op_push_i : "~" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc2a0] Op_push_i : "~" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc280] Op_match :
+@print{} [ 1:0xfcc1e0] Op_store_var : O
+@print{} [ 1:0xfcc2e0] Op_push_i : "==" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc340] Op_push_i : "==" [MALLOC|STRING|STRCUR]
+@print{} [ 1:0xfcc320] Op_equal :
+@print{} [ 1:0xfcc200] Op_store_var : o
+@print{} [ 1:0xfcc380] Op_push : o
+@print{} [ 1:0xfcc360] Op_plus_i : 0 [MALLOC|NUMCUR|NUMBER]
+@print{} [ 1:0xfcc220] Op_push_lhs : o [do_reference = true]
+@print{} [ 1:0xfcc300] Op_assign_plus :
+@print{} [ :0xfcc2c0] Op_pop :
+@print{} [ 1:0xfcc400] Op_push : O
+@print{} [ 1:0xfcc420] Op_push_i : "" [MALLOC|STRING|STRCUR]
+@print{} [ :0xfcc4a0] Op_no_op :
+@print{} [ 1:0xfcc480] Op_push : O
+@print{} [ :0xfcc4c0] Op_concat : [expr_count = 3] [concat_flag = 0]
+@print{} [ 1:0xfcc3c0] Op_store_var : x
+@print{} [ 1:0xfcc440] Op_push_lhs : X [do_reference = true]
+@print{} [ 1:0xfcc3a0] Op_postincrement :
+@print{} [ 1:0xfcc4e0] Op_push : x
+@print{} [ 1:0xfcc540] Op_push : o
+@print{} [ 1:0xfcc500] Op_plus :
+@print{} [ 1:0xfcc580] Op_push : o
+@print{} [ 1:0xfcc560] Op_plus :
+@print{} [ 1:0xfcc460] Op_leq :
+@print{} [ :0xfcc5c0] Op_jmp_false : [target_jmp = 0xfcc5e0]
+@print{} [ 1:0xfcc600] Op_push_i : "%c" [MALLOC|STRING|STRCUR]
+@print{} [ :0xfcc660] Op_no_op :
+@print{} [ 1:0xfcc520] Op_assign_concat : c
+@print{} [ :0xfcc620] Op_jmp : [target_jmp = 0xfcc440]
+@print{}
+@dots{}
+@print{}
@print{} [ 2:0xfcc5a0] Op_K_printf : [expr_count = 17] [redir_type = ""]
-@print{} [ :0xfcc140] Op_no_op :
-@print{} [ :0xfcc1c0] Op_atexit :
-@print{} [ :0xfcc640] Op_stop :
-@print{} [ :0xfcc180] Op_no_op :
-@print{} [ :0xfcd150] Op_after_beginfile :
-@print{} [ :0xfcc160] Op_no_op :
-@print{} [ :0xfcc1a0] Op_after_endfile :
+@print{} [ :0xfcc140] Op_no_op :
+@print{} [ :0xfcc1c0] Op_atexit :
+@print{} [ :0xfcc640] Op_stop :
+@print{} [ :0xfcc180] Op_no_op :
+@print{} [ :0xfcd150] Op_after_beginfile :
+@print{} [ :0xfcc160] Op_no_op :
+@print{} [ :0xfcc1a0] Op_after_endfile :
gawk>
@end smallexample
@@ -29178,7 +29287,7 @@ function @var{function}. This command may change the current source file.
@itemx @code{q}
Exit the debugger. Debugging is great fun, but sometimes we all have
to tend to other obligations in life, and sometimes we find the bug,
-and are free to go on to the next one! As we saw above, if you are
+and are free to go on to the next one! As we saw earlier, if you are
running a program, the debugger warns you if you accidentally type
@samp{q} or @samp{quit}, to make sure you really want to quit.
@@ -29255,7 +29364,7 @@ If you perused the dump of opcodes in @ref{Miscellaneous Debugger Commands}
(or if you are already familiar with @command{gawk} internals),
you will realize that much of the internal manipulation of data
in @command{gawk}, as in many interpreters, is done on a stack.
-@code{Op_push}, @code{Op_pop}, etc., are the ``bread and butter'' of
+@code{Op_push}, @code{Op_pop}, and the like, are the ``bread and butter'' of
most @command{gawk} code.
Unfortunately, as of now, the @command{gawk}
@@ -29269,8 +29378,8 @@ change back to obscure, perhaps more optimal code later.
@item
There is no way to look ``inside'' the process of compiling
regular expressions to see if you got it right. As an @command{awk}
-programmer, you are expected to know what @code{/[^[:alnum:][:blank:]]/}
-means.
+programmer, you are expected to know the meaning of
+@code{/[^[:alnum:][:blank:]]/}.
@item
The @command{gawk} debugger is designed to be used by running a program (with all its
@@ -29322,7 +29431,7 @@ and editing.
@end itemize
@node Arbitrary Precision Arithmetic
-@chapter Arithmetic and Arbitrary Precision Arithmetic with @command{gawk}
+@chapter Arithmetic and Arbitrary-Precision Arithmetic with @command{gawk}
@cindex arbitrary precision
@cindex multiple precision
@cindex infinite precision
@@ -29332,9 +29441,9 @@ This @value{CHAPTER} introduces some basic concepts relating to
how computers do arithmetic and defines some important terms.
It then proceeds to describe floating-point arithmetic,
which is what @command{awk} uses for all its computations, including a
-discussion of arbitrary precision floating point arithmetic, which is
+discussion of arbitrary-precision floating-point arithmetic, which is
a feature available only in @command{gawk}. It continues on to present
-arbitrary precision integers, and concludes with a description of some
+arbitrary-precision integers, and concludes with a description of some
points where @command{gawk} and the POSIX standard are not quite in
agreement.
@@ -29397,51 +29506,51 @@ The disadvantage is that their range is limited.
@cindex integers, unsigned
In computers, integer values come in two flavors: @dfn{signed} and
@dfn{unsigned}. Signed values may be negative or positive, whereas
-unsigned values are always positive (that is, greater than or equal
+unsigned values are always positive (i.e., greater than or equal
to zero).
In computer systems, integer arithmetic is exact, but the possible
range of values is limited. Integer arithmetic is generally faster than
-floating point arithmetic.
+floating-point arithmetic.
-@item Floating point arithmetic
+@item Floating-point arithmetic
Floating-point numbers represent what were called in school ``real''
-numbers; i.e., those that have a fractional part, such as 3.1415927.
+numbers (i.e., those that have a fractional part, such as 3.1415927).
The advantage to floating-point numbers is that they can represent a
much larger range of values than can integers. The disadvantage is that
there are numbers that they cannot represent exactly.
-Modern systems support floating point arithmetic in hardware, with a
+Modern systems support floating-point arithmetic in hardware, with a
limited range of values. There are software libraries that allow
-the use of arbitrary precision floating point calculations.
+the use of arbitrary-precision floating-point calculations.
-POSIX @command{awk} uses @dfn{double precision} floating-point numbers, which
-can hold more digits than @dfn{single precision} floating-point numbers.
-@command{gawk} has facilities for performing arbitrary precision floating
-point arithmetic, which we describe in more detail shortly.
+POSIX @command{awk} uses @dfn{double-precision} floating-point numbers, which
+can hold more digits than @dfn{single-precision} floating-point numbers.
+@command{gawk} has facilities for performing arbitrary-precision
+floating-point arithmetic, which we describe in more detail shortly.
@end table
-Computers work with integer and floating point values of different
-ranges. Integer values are usually either 32 or 64 bits in size. Single
-precision floating point values occupy 32 bits, whereas double precision
-floating point values occupy 64 bits. Floating point values are always
+Computers work with integer and floating-point values of different
+ranges. Integer values are usually either 32 or 64 bits in size.
+Single-precision floating-point values occupy 32 bits, whereas double-precision
+floating-point values occupy 64 bits. Floating-point values are always
signed. The possible ranges of values are shown in @ref{table-numeric-ranges}.
@float Table,table-numeric-ranges
-@caption{Value Ranges for Different Numeric Representations}
+@caption{Value ranges for different numeric representations}
@multitable @columnfractions .34 .33 .33
@headitem Numeric representation @tab Minimum value @tab Maximum value
@item 32-bit signed integer @tab @minus{}2,147,483,648 @tab 2,147,483,647
@item 32-bit unsigned integer @tab 0 @tab 4,294,967,295
@item 64-bit signed integer @tab @minus{}9,223,372,036,854,775,808 @tab 9,223,372,036,854,775,807
@item 64-bit unsigned integer @tab 0 @tab 18,446,744,073,709,551,615
-@item Single precision floating point (approximate) @tab @code{1.175494e-38} @tab @code{3.402823e+38}
-@item Double precision floating point (approximate) @tab @code{2.225074e-308} @tab @code{1.797693e+308}
+@item Single-precision floating point (approximate) @tab @code{1.175494e-38} @tab @code{3.402823e+38}
+@item Double-precision floating point (approximate) @tab @code{2.225074e-308} @tab @code{1.797693e+308}
@end multitable
@end float
@node Math Definitions
-@section Other Stuff To Know
+@section Other Stuff to Know
The rest of this @value{CHAPTER} uses a number of terms. Here are some
informal definitions that should help you work your way through the material
@@ -29518,7 +29627,7 @@ How numbers are rounded up or down when necessary.
More details are provided later.
@item Significand
-A floating point value consists the significand multiplied by 10
+A floating-point value consists the significand multiplied by 10
to the power of the exponent. For example, in @code{1.2345e67},
the significand is @code{1.2345}.
@@ -29536,19 +29645,19 @@ on some of those terms.
On modern systems, floating-point hardware uses the representation and
operations defined by the IEEE 754 standard.
Three of the standard IEEE 754 types are 32-bit single precision,
-64-bit double precision and 128-bit quadruple precision.
+64-bit double precision, and 128-bit quadruple precision.
The standard also specifies extended precision formats
to allow greater precisions and larger exponent ranges.
-(@command{awk} uses only the 64-bit double precision format.)
+(@command{awk} uses only the 64-bit double-precision format.)
@ref{table-ieee-formats} lists the precision and exponent
field values for the basic IEEE 754 binary formats:
@float Table,table-ieee-formats
-@caption{Basic IEEE Format Values}
+@caption{Basic IEEE format values}
@multitable @columnfractions .20 .20 .20 .20 .20
@headitem Name @tab Total bits @tab Precision @tab Minimum exponent @tab Maximum exponent
-@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
+@item Single @tab 32 @tab 24 @tab @minus{}126 @tab +127
@item Double @tab 64 @tab 53 @tab @minus{}1022 @tab +1023
@item Quadruple @tab 128 @tab 113 @tab @minus{}16382 @tab +16383
@end multitable
@@ -29560,14 +29669,14 @@ one extra bit of significand.
@end quotation
@node MPFR features
-@section Arbitrary Precision Arithmetic Features In @command{gawk}
+@section Arbitrary-Precision Arithmetic Features in @command{gawk}
-By default, @command{gawk} uses the double precision floating-point values
+By default, @command{gawk} uses the double-precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do so, @command{gawk} uses the @uref{http://www.mpfr.org
-GNU MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for arbitrary
-precision arithmetic on numbers. You can see if MPFR support is available
-like so:
+compiled to do so, @command{gawk} uses the @uref{http://www.mpfr.org,
+GNU MPFR} and @uref{http://gmplib.org, GNU MP} (GMP) libraries for
+arbitrary-precision arithmetic on numbers. You can see if MPFR support
+is available like so:
@example
$ @kbd{gawk --version}
@@ -29595,11 +29704,11 @@ Two predefined variables, @code{PREC} and @code{ROUNDMODE},
provide control over the working precision and the rounding mode.
The precision and the rounding mode are set globally for every operation
to follow.
-@xref{Setting precision}, and @ref{Setting the rounding mode},
+@DBXREF{Setting precision} and @DBREF{Setting the rounding mode}
for more information.
@node FP Math Caution
-@section Floating Point Arithmetic: Caveat Emptor!
+@section Floating-Point Arithmetic: Caveat Emptor!
@quotation
@i{Math class is tough!}
@@ -29632,17 +29741,17 @@ rely just on what we tell you.
@end menu
@node Inexactness of computations
-@subsection Floating Point Arithmetic Is Not Exact
+@subsection Floating-Point Arithmetic Is Not Exact
Binary floating-point representations and arithmetic are inexact.
Simple values like 0.1 cannot be precisely represented using
binary floating-point numbers, and the limited precision of
floating-point numbers means that slight changes in
the order of operations or the precision of intermediate storage
-can change the result. To make matters worse, with arbitrary precision
-floating-point, you can set the precision before starting a computation,
-but then you cannot be sure of the number of significant decimal places
-in the final result.
+can change the result. To make matters worse, with arbitrary-precision
+floating-point arithmetic, you can set the precision before starting a
+computation, but then you cannot be sure of the number of significant
+decimal places in the final result.
@menu
* Inexact representation:: Numbers are not exactly represented.
@@ -29664,7 +29773,7 @@ y = 0.425
Unlike the number in @code{y}, the number stored in @code{x}
is exactly representable
-in binary since it can be written as a finite sum of one or
+in binary because it can be written as a finite sum of one or
more fractions whose denominators are all powers of two.
When @command{gawk} reads a floating-point number from
program source, it automatically rounds that number to whatever
@@ -29690,7 +29799,7 @@ Because the underlying representation can be a little bit off from the exact val
comparing floating-point values to see if they are exactly equal is generally a bad idea.
Here is an example where it does not work like you would expect:
-@example
+@example
$ @kbd{gawk 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
@print{} 0
@end example
@@ -29699,7 +29808,7 @@ The general wisdom when comparing floating-point values is to see if
they are within some small range of each other (called a @dfn{delta},
or @dfn{tolerance}).
You have to decide how small a delta is important to you. Code to do
-this looks something like this:
+this looks something like the following:
@example
delta = 0.00001 # for example
@@ -29719,7 +29828,7 @@ else
The loss of accuracy during a single computation with floating-point
numbers usually isn't enough to worry about. However, if you compute a
-value which is the result of a sequence of floating point operations,
+value which is the result of a sequence of floating-point operations,
the error can accumulate and greatly affect the computation itself.
Here is an attempt to compute the value of @value{PI} using one of its
many series representations:
@@ -29765,9 +29874,9 @@ $ @kbd{gawk 'BEGIN @{}
@end example
@node Getting Accuracy
-@subsection Getting The Accuracy You Need
+@subsection Getting the Accuracy You Need
-Can arbitrary precision arithmetic give exact results? There are
+Can arbitrary-precision arithmetic give exact results? There are
no easy answers. The standard rules of algebra often do not apply
when using floating-point arithmetic.
Among other things, the distributive and associative laws
@@ -29776,12 +29885,12 @@ for your computation. Rounding error, cumulative precision loss
and underflow are often troublesome.
When @command{gawk} tests the expressions @samp{0.1 + 12.2} and
-@samp{12.3} for equality using the machine double precision arithmetic,
+@samp{12.3} for equality using the machine double-precision arithmetic,
it decides that they are not equal! (@xref{Comparing FP Values}.)
You can get the result you want by increasing the precision; 56 bits in
this case does the job:
-@example
+@example
$ @kbd{gawk -M -v PREC=56 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
@print{} 1
@end example
@@ -29790,7 +29899,7 @@ If adding more bits is good, perhaps adding even more bits of
precision is better?
Here is what happens if we use an even larger value of @code{PREC}:
-@example
+@example
$ @kbd{gawk -M -v PREC=201 'BEGIN @{ print (0.1 + 12.2 == 12.3) @}'}
@print{} 0
@end example
@@ -29799,15 +29908,15 @@ This is not a bug in @command{gawk} or in the MPFR library.
It is easy to forget that the finite number of bits used to store the value
is often just an approximation after proper rounding.
The test for equality succeeds if and only if @emph{all} bits in the two operands
-are exactly the same. Since this is not necessarily true after floating-point
+are exactly the same. Because this is not necessarily true after floating-point
computations with a particular precision and effective rounding mode,
a straight test for equality may not work. Instead, compare the
two numbers to see if they are within the desirable delta of each other.
In applications where 15 or fewer decimal places suffice,
-hardware double precision arithmetic can be adequate, and is usually much faster.
+hardware double-precision arithmetic can be adequate, and is usually much faster.
But you need to keep in mind that every floating-point operation
-can suffer a new rounding error with catastrophic consequences as illustrated
+can suffer a new rounding error with catastrophic consequences, as illustrated
by our earlier attempt to compute the value of @value{PI}.
Extra precision can greatly enhance the stability and the accuracy
of your computation in such cases.
@@ -29831,9 +29940,9 @@ an arbitrarily large value for @code{PREC}. Reformulation of
the problem at hand is often the correct approach in such situations.
@node Try To Round
-@subsection Try A Few Extra Bits of Precision and Rounding
+@subsection Try a Few Extra Bits of Precision and Rounding
-Instead of arbitrary precision floating-point arithmetic,
+Instead of arbitrary-precision floating-point arithmetic,
often all you need is an adjustment of your logic
or a different order for the operations in your calculation.
The stability and the accuracy of the computation of @value{PI}
@@ -29845,7 +29954,7 @@ simple algebraic transformation:
@end example
@noindent
-After making this, change the program converges to
+After making this change, the program converges to
@value{PI} in under 30 iterations:
@example
@@ -29861,7 +29970,7 @@ $ @kbd{gawk -f pi2.awk}
@end example
@node Setting precision
-@subsection Setting The Precision
+@subsection Setting the Precision
@command{gawk} uses a global working precision; it does not keep track of
the precision or accuracy of individual numbers. Performing an arithmetic
@@ -29873,14 +29982,14 @@ shown in @ref{table-predefined-precision-strings},
to emulate an IEEE 754 binary format.
@float Table,table-predefined-precision-strings
-@caption{Predefined Precision Strings For @code{PREC}}
+@caption{Predefined precision strings for @code{PREC}}
@multitable {@code{"double"}} {12345678901234567890123456789012345}
@headitem @code{PREC} @tab IEEE 754 Binary Format
-@item @code{"half"} @tab 16-bit half-precision.
-@item @code{"single"} @tab Basic 32-bit single precision.
-@item @code{"double"} @tab Basic 64-bit double precision.
-@item @code{"quad"} @tab Basic 128-bit quadruple precision.
-@item @code{"oct"} @tab 256-bit octuple precision.
+@item @code{"half"} @tab 16-bit half-precision
+@item @code{"single"} @tab Basic 32-bit single precision
+@item @code{"double"} @tab Basic 64-bit double precision
+@item @code{"quad"} @tab Basic 128-bit quadruple precision
+@item @code{"oct"} @tab 256-bit octuple precision
@end multitable
@end float
@@ -29911,7 +30020,7 @@ differences among various ways to print a floating-point constant:
@example
$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 0.1) @}'}
-@print{} 0.1000000000000000055511151
+@print{} 0.1000000000000000055511151
$ @kbd{gawk -M -v PREC=113 'BEGIN @{ printf("%0.25f\n", 0.1) @}'}
@print{} 0.1000000000000000000000000
$ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", "0.1") @}'}
@@ -29921,7 +30030,7 @@ $ @kbd{gawk -M 'BEGIN @{ PREC = 113; printf("%0.25f\n", 1/10) @}'}
@end example
@node Setting the rounding mode
-@subsection Setting The Rounding Mode
+@subsection Setting the Rounding Mode
The @code{ROUNDMODE} variable provides
program level control over the rounding mode.
@@ -29929,7 +30038,7 @@ The correspondence between @code{ROUNDMODE} and the IEEE
rounding modes is shown in @ref{table-gawk-rounding-modes}.
@float Table,table-gawk-rounding-modes
-@caption{@command{gawk} Rounding Modes}
+@caption{@command{gawk} rounding modes}
@multitable @columnfractions .45 .30 .25
@headitem Rounding Mode @tab IEEE Name @tab @code{ROUNDMODE}
@item Round to nearest, ties to even @tab @code{roundTiesToEven} @tab @code{"N"} or @code{"n"}
@@ -29944,7 +30053,7 @@ rounding modes is shown in @ref{table-gawk-rounding-modes}.
selects the IEEE 754 rounding mode @code{roundTiesToEven}.
In @ref{table-gawk-rounding-modes}, the value @code{"A"} selects
@code{roundTiesToAway}. This is only available if your version of the
-MPFR library supports it; otherwise setting @code{ROUNDMODE} to @code{"A"}
+MPFR library supports it; otherwise, setting @code{ROUNDMODE} to @code{"A"}
has no effect.
The default mode @code{roundTiesToEven} is the most preferred,
@@ -30015,14 +30124,14 @@ accumulation of round-off error, look for a significant difference in
output when you change the rounding mode to be sure.
@node Arbitrary Precision Integers
-@section Arbitrary Precision Integer Arithmetic with @command{gawk}
+@section Arbitrary-Precision Integer Arithmetic with @command{gawk}
@cindex integers, arbitrary precision
@cindex arbitrary precision integers
When given the @option{-M} option,
-@command{gawk} performs all integer arithmetic using GMP arbitrary
-precision integers. Any number that looks like an integer in a source
-or @value{DF} is stored as an arbitrary precision integer. The size
+@command{gawk} performs all integer arithmetic using GMP arbitrary-precision
+integers. Any number that looks like an integer in a source
+or @value{DF} is stored as an arbitrary-precision integer. The size
of the integer is limited only by the available memory. For example,
the following computes
@iftex
@@ -30037,7 +30146,7 @@ the following computes
5<superscript>4<superscript>3<superscript>2</superscript></superscript></superscript>, @c
@end docbook
the result of which is beyond the
-limits of ordinary hardware double precision floating point values:
+limits of ordinary hardware double-precision floating-point values:
@example
$ @kbd{gawk -M 'BEGIN @{}
@@ -30049,7 +30158,7 @@ $ @kbd{gawk -M 'BEGIN @{}
@print{} 62060698786608744707 ... 92256259918212890625
@end example
-If instead you were to compute the same value using arbitrary precision
+If instead you were to compute the same value using arbitrary-precision
floating-point values, the precision needed for correct output (using
the formula
@iftex
@@ -30094,10 +30203,10 @@ floating-point results exactly. You can either increase the precision
@samp{2.0} with an integer, to perform all computations using integer
arithmetic to get the correct output.
-Sometimes @command{gawk} must implicitly convert an arbitrary precision
-integer into an arbitrary precision floating-point value. This is
+Sometimes @command{gawk} must implicitly convert an arbitrary-precision
+integer into an arbitrary-precision floating-point value. This is
primarily because the MPFR library does not always provide the relevant
-interface to process arbitrary precision integers or mixed-mode numbers
+interface to process arbitrary-precision integers or mixed-mode numbers
as needed by an operation or function. In such a case, the precision is
set to the minimum value necessary for exact conversion, and the working
precision is not used for this purpose. If this is not what you need or
@@ -30115,7 +30224,7 @@ to begin with:
gawk -M 'BEGIN @{ n = 13.0; print n % 2.0 @}'
@end example
-Note that for the particular example above, it is likely best
+Note that for this particular example, it is likely best
to just use the following:
@example
@@ -30137,13 +30246,13 @@ should support additional features. These features are:
@itemize @value{BULLET}
@item
-Interpretation of floating point data values specified in hexadecimal
+Interpretation of floating-point data values specified in hexadecimal
notation (e.g., @code{0xDEADBEEF}). (Note: data values, @emph{not}
source code constants.)
@item
-Support for the special IEEE 754 floating point values ``Not A Number''
-(NaN), positive Infinity (``inf'') and negative Infinity (``@minus{}inf'').
+Support for the special IEEE 754 floating-point values ``Not A Number''
+(NaN), positive Infinity (``inf''), and negative Infinity (``@minus{}inf'').
In particular, the format for these values is as specified by the ISO 1999
C standard, which ignores case and can allow implementation-dependent additional
characters after the @samp{nan} and allow either @samp{inf} or @samp{infinity}.
@@ -30154,8 +30263,8 @@ practice:
@itemize @value{BULLET}
@item
-The @command{gawk} maintainer feels that supporting hexadecimal floating
-point values, in particular, is ugly, and was never intended by the
+The @command{gawk} maintainer feels that supporting hexadecimal
+floating-point values, in particular, is ugly, and was never intended by the
original designers to be part of the language.
@item
@@ -30169,10 +30278,10 @@ interpretation of the standard, which requires a certain amount of
intended by the standard developers. In other words, ``we see how you
got where you are, but we don't think that that's where you want to be.''
-Recognizing the above issues, but attempting to provide compatibility
+Recognizing these issues, but attempting to provide compatibility
with the earlier versions of the standard,
the 2008 POSIX standard added explicit wording to allow, but not require,
-that @command{awk} support hexadecimal floating point values and
+that @command{awk} support hexadecimal floating-point values and
special values for ``Not A Number'' and infinity.
Although the @command{gawk} maintainer continues to feel that
@@ -30229,12 +30338,12 @@ Thus @samp{+nan} and @samp{+NaN} are the same.
@itemize @value{BULLET}
@item
Most computer arithmetic is done using either integers or floating-point
-values. Standard @command{awk} uses double precision
+values. Standard @command{awk} uses double-precision
floating-point values.
@item
-In the early 1990's, Barbie mistakenly said ``Math class is tough!''
-While math isn't tough, floating-point arithmetic isn't the same
+In the early 1990s, Barbie mistakenly said ``Math class is tough!''
+Although math isn't tough, floating-point arithmetic isn't the same
as pencil and paper math, and care must be taken:
@c nested list
@@ -30267,7 +30376,7 @@ arithmetic. Use @code{PREC} to set the precision in bits, and
@item
With @option{-M}, @command{gawk} performs
-arbitrary precision integer arithmetic using the GMP library.
+arbitrary-precision integer arithmetic using the GMP library.
This is faster and more space efficient than using MPFR for
the same calculations.
@@ -30280,7 +30389,7 @@ It pays to be aware of them.
Overall, there is no need to be unduly suspicious about the results from
floating-point arithmetic. The lesson to remember is that floating-point
arithmetic is always more complex than arithmetic using pencil and
-paper. In order to take advantage of the power of computer floating-point,
+paper. In order to take advantage of the power of computer floating point,
you need to know its limitations and work within them. For most casual
use of floating-point arithmetic, you will often get the expected result
if you simply round the display of your final results to the correct number
@@ -30344,8 +30453,8 @@ C library routines that could be of use. As with most software,
``the sky is the limit;'' if you can imagine something that you might
want to do and can write in C or C++, you can write an extension to do it!
-Extensions are written in C or C++, using the @dfn{Application Programming
-Interface} (API) defined for this purpose by the @command{gawk}
+Extensions are written in C or C++, using the @dfn{application programming
+interface} (API) defined for this purpose by the @command{gawk}
developers. The rest of this @value{CHAPTER} explains
the facilities that the API provides and how to use
them, and presents a small example extension. In addition, it documents
@@ -30382,7 +30491,7 @@ int plugin_is_GPL_compatible;
@end example
@node Extension Mechanism Outline
-@section At A High Level How It Works
+@section How It Works at a High Level
Communication between
@command{gawk} and an extension is two-way. First, when an extension
@@ -30397,22 +30506,22 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-load-extension"/>}.
@ifnotdocbook
@float Figure,figure-load-extension
-@caption{Loading The Extension}
+@caption{Loading the extension}
@c FIXME: One day, it should not be necessary to have two cases,
@c but rather just the one without the "txt" final argument.
@c This applies to the other figures as well.
@ifinfo
-@center @image{api-figure1, , , Loading The Extension, txt}
+@center @image{api-figure1, , , Loading the extension, txt}
@end ifinfo
@ifnotinfo
-@center @image{api-figure1, , , Loading The Extension}
+@center @image{api-figure1, , , Loading the extension}
@end ifnotinfo
@end float
@end ifnotdocbook
@docbook
<figure id="figure-load-extension" float="0">
-<title>Loading The Extension</title>
+<title>Loading the extension</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure1.png" format="PNG"/></imageobject>
</mediaobject>
@@ -30432,19 +30541,19 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-register-new-function
@ifnotdocbook
@float Figure,figure-register-new-function
-@caption{Registering A New Function}
+@caption{Registering a new function}
@ifinfo
-@center @image{api-figure2, , , Registering A New Function, txt}
+@center @image{api-figure2, , , Registering a new Function, txt}
@end ifinfo
@ifnotinfo
-@center @image{api-figure2, , , Registering A New Function}
+@center @image{api-figure2, , , Registering a new Function}
@end ifnotinfo
@end float
@end ifnotdocbook
@docbook
<figure id="figure-register-new-function" float="0">
-<title>Registering A New Function</title>
+<title>Registering a new function</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure2.png" format="PNG"/></imageobject>
</mediaobject>
@@ -30465,7 +30574,7 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-call-new-function"/>}
@ifnotdocbook
@float Figure,figure-call-new-function
-@caption{Calling The New Function}
+@caption{Calling the new function}
@ifinfo
@center @image{api-figure3, , , Calling the new function, txt}
@end ifinfo
@@ -30477,7 +30586,7 @@ This is shown in @inlineraw{docbook, <xref linkend="figure-call-new-function"/>}
@docbook
<figure id="figure-call-new-function" float="0">
-<title>Calling The New Function</title>
+<title>Calling the new function</title>
<mediaobject>
<imageobject role="web"><imagedata fileref="api-figure3.png" format="PNG"/></imageobject>
</mediaobject>
@@ -30513,10 +30622,9 @@ The API also provides major and minor version numbers, so that an
extension can check if the @command{gawk} it is loaded with supports the
facilities it was compiled with. (Version mismatches ``shouldn't''
happen, but we all know how @emph{that} goes.)
-@xref{Extension Versioning}, for details.
+@DBXREF{Extension Versioning} for details.
@end itemize
-
@node Extension API Description
@section API Description
@cindex extension API
@@ -30558,20 +30666,23 @@ Allocating, reallocating, and releasing memory.
@item
Registration functions. You may register:
+
+@c nested list
@itemize @value{MINUS}
@item
-extension functions,
+Extension functions
@item
-exit callbacks,
+Exit callbacks
@item
-a version string,
+A version string
@item
-input parsers,
+Input parsers
@item
-output wrappers,
+Output wrappers
@item
-and two-way processors.
+Two-way processors
@end itemize
+
All of these are discussed in detail, later in this @value{CHAPTER}.
@item
@@ -30618,7 +30729,7 @@ Some points about using the API:
@itemize @value{BULLET}
@item
-The following types and/or macros and/or functions are referenced
+The following types, macros, and/or functions are referenced
in @file{gawkapi.h}. For correct use, you must therefore include the
corresponding standard header file @emph{before} including @file{gawkapi.h}:
@@ -30632,7 +30743,7 @@ corresponding standard header file @emph{before} including @file{gawkapi.h}:
@item @code{memset()} @tab @code{<string.h>}
@item @code{size_t} @tab @code{<sys/types.h>}
@item @code{struct stat} @tab @code{<sys/stat.h>}
-@end multitable
+@end multitable
Due to portability concerns, especially to systems that are not
fully standards-compliant, it is your responsibility
@@ -30664,7 +30775,7 @@ and is managed by @command{gawk} from then on.
The API defines several simple @code{struct}s that map values as seen
from @command{awk}. A value can be a @code{double}, a string, or an
array (as in multidimensional arrays, or when creating a new array).
-String values maintain both pointer and length since embedded @sc{nul}
+String values maintain both pointer and length, because embedded @sc{nul}
characters are allowed.
@quotation NOTE
@@ -30689,14 +30800,14 @@ so that the extension can, e.g., print an error message
@c The table there should be presented here
@end itemize
-While you may call the API functions by using the function pointers
-directly, the interface is not so pretty. To make extension code look
+You may call the API functions by using the function pointers
+directly, but the interface is not so pretty. To make extension code look
more like regular code, the @file{gawkapi.h} header file defines several
macros that you should use in your code. This @value{SECTION} presents
the macros as if they were functions.
@node General Data Types
-@subsection General Purpose Data Types
+@subsection General-Purpose Data Types
@cindex Robbins, Arnold
@cindex Ramey, Chet
@@ -30711,9 +30822,10 @@ can accommodate both love and hate.}
@author Chet Ramey
@end quotation
-The extension API defines a number of simple types and structures for general
-purpose use. Additional, more specialized, data structures are introduced
-in subsequent @value{SECTION}s, together with the functions that use them.
+The extension API defines a number of simple types and structures for
+general-purpose use. Additional, more specialized, data structures are
+introduced in subsequent @value{SECTION}s, together with the functions
+that use them.
@table @code
@item typedef void *awk_ext_id_t;
@@ -30740,8 +30852,9 @@ A simple boolean type.
This represents a mutable string. @command{gawk}
owns the memory pointed to if it supplied
the value. Otherwise, it takes ownership of the memory pointed to.
-@strong{Such memory must come from calling one of the
-@code{gawk_malloc()}, @code{gawk_calloc()}, or @code{gawk_realloc()} functions!}
+@emph{Such memory must come from calling one of the
+@code{gawk_malloc()}, @code{gawk_calloc()}, or
+@code{gawk_realloc()} functions!}
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -30767,7 +30880,7 @@ It is used in the following @code{struct}.
@itemx @ @ @ @ @ @ @ @ awk_value_cookie_t@ vc;
@itemx @ @ @ @ @} u;
@itemx @} awk_value_t;
-An ``@command{awk} value.''
+An ``@command{awk} value.''
The @code{val_type} member indicates what kind of value the
@code{union} holds, and each member is of the appropriate type.
@@ -30780,13 +30893,14 @@ These macros make accessing the fields of the @code{awk_value_t} more
readable.
@item typedef void *awk_scalar_t;
-Scalars can be represented as an opaque type. These values are obtained from
-@command{gawk} and then passed back into it. This is discussed in a general fashion below,
-and in more detail in @ref{Symbol table by cookie}.
+Scalars can be represented as an opaque type. These values are obtained
+from @command{gawk} and then passed back into it. This is discussed
+in a general fashion in the text following this list, and in more detail in
+@ref{Symbol table by cookie}.
@item typedef void *awk_value_cookie_t;
A ``value cookie'' is an opaque type representing a cached value.
-This is also discussed in a general fashion below,
+This is also discussed in a general fashion in the text following this list,
and in more detail in @ref{Cached values}.
@end table
@@ -30796,7 +30910,7 @@ Scalar values in @command{awk} are either numbers or strings. The
indicates what is in the @code{union}.
Representing numbers is easy---the API uses a C @code{double}. Strings
-require more work. Since @command{gawk} allows embedded @sc{nul} bytes
+require more work. Because @command{gawk} allows embedded @sc{nul} bytes
in string values, a string must be represented as a pair containing a
data-pointer and length. This is the @code{awk_string_t} type.
@@ -30809,13 +30923,13 @@ itself be an array. Discussion of arrays is delayed until
The various macros listed earlier make it easier to use the elements
of the @code{union} as if they were fields in a @code{struct}; this
is a common coding practice in C. Such code is easier to write and to
-read, however it remains @emph{your} responsibility to make sure that
+read, but it remains @emph{your} responsibility to make sure that
the @code{val_type} member correctly reflects the type of the value in
the @code{awk_value_t}.
Conceptually, the first three members of the @code{union} (number, string,
and array) are all that is needed for working with @command{awk} values.
-However, since the API provides routines for accessing and changing
+However, because the API provides routines for accessing and changing
the value of global scalar variables only by using the variable's name,
there is a performance penalty: @command{gawk} must find the variable
each time it is accessed and changed. This turns out to be a real issue,
@@ -30855,7 +30969,7 @@ The API provides a number of @dfn{memory allocation} functions for
allocating memory that can be passed to @command{gawk}, as well as a number of
convenience macros.
This @value{SUBSECTION} presents them all as function prototypes, in
-the way that extension code would use them.
+the way that extension code would use them:
@table @code
@item void *gawk_malloc(size_t size);
@@ -30900,7 +31014,8 @@ The arguments to this macro are as follows:
The pointer variable to point at the allocated storage.
@item type
-The type of the pointer variable, used to create a cast for the call to @code{gawk_malloc()}.
+The type of the pointer variable. This is used to create a cast for
+the call to @code{gawk_malloc()}.
@item size
The total number of bytes to be allocated.
@@ -30935,7 +31050,7 @@ The arguments are the same as for the @code{emalloc()} macro.
The API provides a number of @dfn{constructor} functions for creating
string and numeric values, as well as a number of convenience macros.
This @value{SUBSECTION} presents them all as function prototypes, in
-the way that extension code would use them.
+the way that extension code would use them:
@table @code
@item static inline awk_value_t *
@@ -31014,8 +31129,8 @@ This is a pointer to the C function that provides the extension's
functionality.
The function must fill in @code{*result} with either a number
or a string. @command{gawk} takes ownership of any string memory.
-As mentioned earlier, string memory @strong{must} come from one of @code{gawk_malloc()},
-@code{gawk_calloc()} or @code{gawk_realloc()}.
+As mentioned earlier, string memory @strong{must} come from one of
+@code{gawk_malloc()}, @code{gawk_calloc()}, or @code{gawk_realloc()}.
The @code{num_actual_args} argument tells the C function how many
actual parameters were passed from the calling @command{awk} code.
@@ -31050,7 +31165,7 @@ Such functions are useful if you have general ``cleanup'' tasks
that should be performed in your extension (such as closing database
connections or other resource deallocations).
You can register such
-a function with @command{gawk} using the following function.
+a function with @command{gawk} using the following function:
@table @code
@item void awk_atexit(void (*funcp)(void *data, int exit_status),
@@ -31071,8 +31186,9 @@ the function pointed to by @code{funcp}.
@end table
@end table
-Exit callback functions are called in Last-In-First-Out (LIFO) order---that is, in
-the reverse order in which they are registered with @command{gawk}.
+Exit callback functions are called in last-in-first-out (LIFO)
+order---that is, in the reverse order in which they are registered with
+@command{gawk}.
@node Extension Version String
@subsubsection Registering An Extension Version String
@@ -31083,7 +31199,7 @@ version of your extension, with @command{gawk}, as follows:
@table @code
@item void register_ext_version(const char *version);
Register the string pointed to by @code{version} with @command{gawk}.
-@command{gawk} does @emph{not} copy the @code{version} string, so
+Note that @command{gawk} does @emph{not} copy the @code{version} string, so
it should not be changed.
@end table
@@ -31165,7 +31281,7 @@ appropriately.
@item
When your extension is loaded, register your input parser with
@command{gawk} using the @code{register_input_parser()} API function
-(described below).
+(described next).
@end enumerate
An @code{awk_input_buf_t} looks like this:
@@ -31195,7 +31311,7 @@ The name of the file.
@item int fd;
A file descriptor for the file. If @command{gawk} was able to
-open the file, then @code{fd} will @emph{not} be equal to
+open the file, then @code{fd} will @emph{not} be equal to
@code{INVALID_HANDLE}. Otherwise, it will.
@item struct stat sbuf;
@@ -31209,15 +31325,15 @@ The decision can be made based upon @command{gawk} state (the value
of a variable defined previously by the extension and set by
@command{awk} code), the name of the
file, whether or not the file descriptor is valid, the information
-in the @code{struct stat}, or any combination of the above.
+in the @code{struct stat}, or any combination of these factors.
Once @code{@var{XXX}_can_take_file()} has returned true, and
@command{gawk} has decided to use your input parser, it calls
@code{@var{XXX}_take_control_of()}. That function then fills one of
either the @code{get_record} field or the @code{read_func} field in
the @code{awk_input_buf_t}. It must also ensure that @code{fd} is @emph{not}
-set to @code{INVALID_HANDLE}. All of the fields that may be filled by
-@code{@var{XXX}_take_control_of()} are as follows:
+set to @code{INVALID_HANDLE}. The following list describes the fields that
+may be filled by @code{@var{XXX}_take_control_of()}:
@table @code
@item void *opaque;
@@ -31232,13 +31348,13 @@ is not required to use this pointer.
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ size_t *rt_len);
This function pointer should point to a function that creates the input
records. Said function is the core of the input parser. Its behavior
-is described below.
+is described in the text following this list.
@item ssize_t (*read_func)();
This function pointer should point to function that has the
same behavior as the standard POSIX @code{read()} system call.
It is an alternative to the @code{get_record} pointer. Its behavior
-is also described below.
+is also described in the text following this list.
@item void (*close_func)(struct awk_input *iobuf);
This function pointer should point to a function that does
@@ -31376,7 +31492,7 @@ values, etc.) within @command{gawk}.
The function pointed to by this field is called when @command{gawk}
decides to let the output wrapper take control of the file. It should
fill in appropriate members of the @code{awk_output_buf_t} structure,
-as described below, and return true if successful, false otherwise.
+as described next, and return true if successful, false otherwise.
@item awk_const struct output_wrapper *awk_const next;
This is for use by @command{gawk};
@@ -31519,9 +31635,9 @@ Register the two-way processor pointed to by @code{two_way_processor} with
@cindex messages from extensions
You can print different kinds of warning messages from your
-extension, as described below. Note that for these functions,
+extension, as described here. Note that for these functions,
you must pass in the extension id received from @command{gawk}
-when the extension was loaded.@footnote{Because the API uses only ISO C 90
+when the extension was loaded:@footnote{Because the API uses only ISO C 90
features, it cannot make use of the ISO C 99 variadic macro feature to hide
that parameter. More's the pity.}
@@ -31578,7 +31694,7 @@ value type, as appropriate. This behavior is summarized in
@ref{table-value-types-returned}.
@float Table,table-value-types-returned
-@caption{API Value Types Returned}
+@caption{API value types returned}
@docbook
<informaltable>
<tgroup cols="6">
@@ -31590,7 +31706,7 @@ value type, as appropriate. This behavior is summarized in
<colspec colwidth="16.6*" colname="c6"/>
<spanspec spanname="hspan" namest="c3" nameend="c6" align="center"/>
<thead>
- <row><entry></entry><entry spanname="hspan"><para>Type of Actual Value:</para></entry></row>
+ <row><entry></entry><entry spanname="hspan"><para>Type of Actual Value</para></entry></row>
<row>
<entry></entry>
<entry></entry>
@@ -31626,7 +31742,7 @@ value type, as appropriate. This behavior is summarized in
<entry><para>false</para></entry>
</row>
<row>
- <entry><para><emphasis role="bold">Requested:</emphasis></para></entry>
+ <entry><para><emphasis role="bold">Requested</emphasis></para></entry>
<entry><para><emphasis role="bold">Scalar</emphasis></para></entry>
<entry><para>Scalar</para></entry>
<entry><para>Scalar</para></entry>
@@ -31657,7 +31773,7 @@ value type, as appropriate. This behavior is summarized in
@ifnotplaintext
@ifnotdocbook
@multitable @columnfractions .50 .50
-@headitem @tab Type of Actual Value:
+@headitem @tab Type of Actual Value
@end multitable
@c 10/2014: Thanks to Karl Berry for this bit to reduce the space:
@tex
@@ -31668,7 +31784,7 @@ value type, as appropriate. This behavior is summarized in
@item @tab @b{String} @tab String @tab String @tab false @tab false
@item @tab @b{Number} @tab Number if can be converted, else false @tab Number @tab false @tab false
@item @b{Type} @tab @b{Array} @tab false @tab false @tab Array @tab false
-@item @b{Requested:} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
+@item @b{Requested} @tab @b{Scalar} @tab Scalar @tab Scalar @tab false @tab false
@item @tab @b{Undefined} @tab String @tab Number @tab Array @tab Undefined
@item @tab @b{Value Cookie} @tab false @tab false @tab false @tab false
@end multitable
@@ -31722,7 +31838,7 @@ indicates the type of value expected.
@item awk_bool_t set_argument(size_t count, awk_array_t array);
Convert a parameter that was undefined into an array; this provides
call-by-reference for arrays. Return false if @code{count} is too big,
-or if the argument's type is not undefined. @xref{Array Manipulation},
+or if the argument's type is not undefined. @DBXREF{Array Manipulation}
for more information on creating arrays.
@end table
@@ -31777,7 +31893,7 @@ cannot change any of those variables.
@quotation CAUTION
It is possible for the lookup of @code{PROCINFO} to fail. This happens if
the @command{awk} program being run does not reference @code{PROCINFO};
-in this case @command{gawk} doesn't bother to create the array and
+in this case, @command{gawk} doesn't bother to create the array and
populate it.
@end quotation
@@ -31787,9 +31903,9 @@ populate it.
A @dfn{scalar cookie} is an opaque handle that provides access
to a global variable or array. It is an optimization that
avoids looking up variables in @command{gawk}'s symbol table every time
-access is needed. This was discussed earlier, in @ref{General Data Types}.
+access is needed. This was discussed earlier in @ref{General Data Types}.
-The following functions let you work with scalar cookies.
+The following functions let you work with scalar cookies:
@table @code
@item awk_bool_t sym_lookup_scalar(awk_scalar_t cookie,
@@ -31834,18 +31950,21 @@ do_magic(int nargs, awk_value_t *result)
@noindent
This code looks (and is) simple and straightforward. So what's the problem?
-Consider what happens if @command{awk}-level code associated with your
-extension calls the @code{magic()} function (implemented in C by @code{do_magic()}),
-once per record, while processing hundreds of thousands or millions of records.
-The @code{MAGIC_VAR} variable is looked up in the symbol table once or twice per function call!
+Well, consider what happens if @command{awk}-level code associated
+with your extension calls the @code{magic()} function (implemented in
+C by @code{do_magic()}), once per record, while processing hundreds
+of thousands or millions of records. The @code{MAGIC_VAR} variable is
+looked up in the symbol table once or twice per function call!
-The symbol table lookup is really pure overhead; it is considerably more efficient
-to get a cookie that represents the variable, and use that to get the variable's
-value and update it as needed.@footnote{The difference is measurable and quite real. Trust us.}
+The symbol table lookup is really pure overhead; it is considerably
+more efficient to get a cookie that represents the variable, and use
+that to get the variable's value and update it as needed.@footnote{The
+difference is measurable and quite real. Trust us.}
-Thus, the way to use cookies is as follows. First, install your extension's variable
-in @command{gawk}'s symbol table using @code{sym_update()}, as usual. Then get a
-scalar cookie for the variable using @code{sym_lookup()}:
+Thus, the way to use cookies is as follows. First, install
+your extension's variable in @command{gawk}'s symbol table using
+@code{sym_update()}, as usual. Then get a scalar cookie for the variable
+using @code{sym_lookup()}:
@example
static awk_scalar_t magic_var_cookie; /* cookie for MAGIC_VAR */
@@ -31908,7 +32027,7 @@ or @code{sym_update_scalar()}, as you like.
However, you can understand the point of cached values if you remember that
@emph{every} string value's storage @emph{must} come from @code{gawk_malloc()},
-@code{gawk_calloc()} or @code{gawk_realloc()}.
+@code{gawk_calloc()}, or @code{gawk_realloc()}.
If you have 20 variables, all of which have the same string value, you
must create 20 identical copies of the string.@footnote{Numeric values
are clearly less problematic, requiring only a C @code{double} to store.}
@@ -31919,11 +32038,11 @@ is what the routines in this section let you do. The functions are as follows:
@table @code
@item awk_bool_t create_value(awk_value_t *value, awk_value_cookie_t *result);
-Create a cached string or numeric value from @code{value} for efficient later
-assignment.
-Only values of type @code{AWK_NUMBER} and @code{AWK_STRING} are allowed. Any other type
-is rejected. While @code{AWK_UNDEFINED} could be allowed, doing so would
-result in inferior performance.
+Create a cached string or numeric value from @code{value} for
+efficient later assignment. Only values of type @code{AWK_NUMBER}
+and @code{AWK_STRING} are allowed. Any other type is rejected.
+@code{AWK_UNDEFINED} could be allowed, but doing so would result in
+inferior performance.
@item awk_bool_t release_value(awk_value_cookie_t vc);
Release the memory associated with a value cookie obtained
@@ -31944,7 +32063,7 @@ my_extension_init()
size_t long_string_len;
/* code from earlier */
- @dots{}
+ @dots{}
/* @dots{} fill in long_string and long_string_len @dots{} */
make_malloced_string(long_string, long_string_len, & value);
create_value(& value, & answer_cookie); /* create cookie */
@@ -31974,7 +32093,7 @@ do_magic(int nargs, awk_value_t *result)
@end example
@noindent
-Using value cookies in this way saves considerable storage, since all of
+Using value cookies in this way saves considerable storage, as all of
@code{VAR1} through @code{VAR100} share the same value.
You might be wondering, ``Is this sharing problematic?
@@ -31996,7 +32115,7 @@ you should release any cached values that you created, using
@subsection Array Manipulation
@cindex array manipulation in extensions
-The primary data structure@footnote{Okay, the only data structure.} in @command{awk}
+The primary data structure@footnote{OK, the only data structure.} in @command{awk}
is the associative array (@pxref{Arrays}).
Extensions need to be able to manipulate @command{awk} arrays.
The API provides a number of data structures for working with arrays,
@@ -32017,7 +32136,7 @@ both work with and create true arrays of arrays (@pxref{General Data Types}).
@node Array Data Types
@subsubsection Array Data Types
-The data types associated with arrays are listed below.
+The data types associated with arrays are as follows:
@table @code
@item typedef void *awk_array_t;
@@ -32136,7 +32255,7 @@ The following functions relate to arrays as a whole:
@table @code
@item awk_array_t create_array(void);
Create a new array to which elements may be added.
-@xref{Creating Arrays}, for a discussion of how to
+@DBXREF{Creating Arrays} for a discussion of how to
create a new array and add elements to it.
@item awk_bool_t clear_array(awk_array_t a_cookie);
@@ -32171,7 +32290,7 @@ The function returns true upon success, false otherwise.
@node Flattening Arrays
@subsubsection Working With All The Elements of an Array
-To @dfn{flatten} an array is create a structure that
+To @dfn{flatten} an array is to create a structure that
represents the full array in a fashion that makes it easy
for C code to traverse the entire array. Test code
in @file{extension/testext.c} does this, and also serves
@@ -32339,7 +32458,7 @@ code) once you have called @code{release_flattened_array()}:
@}
@end example
-Finally, since everything was successful, the function sets the
+Finally, because everything was successful, the function sets the
return value to success, and returns:
@example
@@ -32374,7 +32493,7 @@ code can access them and manipulate them.
There are two important points about creating arrays from extension code:
-@enumerate 1
+@itemize @value{BULLET}
@item
You must install a new array into @command{gawk}'s symbol
table immediately upon creating it. Once you have done so,
@@ -32416,7 +32535,7 @@ new_array = val.array_cookie; /* YOU MUST DO THIS */
If installing an array as a subarray, you must also retrieve the value
of the array cookie after the call to @code{set_element()}.
-@end enumerate
+@end itemize
The following C code is a simple test extension to create an array
with two regular elements and with a subarray. The leading @code{#include}
@@ -32535,7 +32654,7 @@ dl_load_func(func_table, testarray, "")
@end ignore
@end example
-Here is sample script that loads the extension
+Here is a sample script that loads the extension
and then dumps the array:
@example
@@ -32565,7 +32684,7 @@ $ @kbd{AWKLIBPATH=$PWD ./gawk -f subarray.awk}
@end example
@noindent
-(@xref{Finding Extensions}, for more information on the
+(@DBXREF{Finding Extensions} for more information on the
@env{AWKLIBPATH} environment variable.)
@node Extension API Variables
@@ -32677,8 +32796,8 @@ The others should not change during execution.
As mentioned earlier (@pxref{Extension Mechanism Outline}), the function
definitions as presented are really macros. To use these macros, your
extension must provide a small amount of boilerplate code (variables and
-functions) towards the top of your source file, using pre-defined names
-as described below. The boilerplate needed is also provided in comments
+functions) toward the top of your source file, using predefined names
+as described here. The boilerplate needed is also provided in comments
in the @file{gawkapi.h} header file:
@example
@@ -32766,7 +32885,7 @@ This macro expands to a @code{dl_load()} function that performs
all the necessary initializations.
@end table
-The point of the all the variables and arrays is to let the
+The point of all the variables and arrays is to let the
@code{dl_load()} function (from the @code{dl_load_func()}
macro) do all the standard work. It does the following:
@@ -32801,7 +32920,7 @@ Compiled extensions have to be installed in a directory where
built in the default fashion, the directory in which to find
extensions is @file{/usr/local/lib/gawk}. You can also specify a search
path with a list of directories to search for compiled extensions.
-@xref{AWKLIBPATH Variable}, for more information.
+@DBXREF{AWKLIBPATH Variable} for more information.
@node Extension Example
@section Example: Some File Functions
@@ -32809,7 +32928,7 @@ path with a list of directories to search for compiled extensions.
@quotation
@i{No matter where you go, there you are.}
-@author Buckaroo Bonzai
+@author Buckaroo Banzai
@end quotation
@c It's enough to show chdir and stat, no need for fts
@@ -32982,9 +33101,9 @@ in the @command{gawk} distribution for the complete version.}
The file includes a number of standard header files, and then includes
the @file{gawkapi.h} header file which provides the API definitions.
-Those are followed by the necessary variable declarations
+Those are followed by the necessary variable declarations
to make use of the API macros and boilerplate code
-(@pxref{Extension API Boilerplate}).
+(@pxref{Extension API Boilerplate}):
@example
#ifdef HAVE_CONFIG_H
@@ -33025,7 +33144,7 @@ that implements it is called @code{do_foo()}. The function should have
two arguments: the first is an @code{int} usually called @code{nargs},
that represents the number of actual arguments for the function.
The second is a pointer to an @code{awk_value_t}, usually named
-@code{result}.
+@code{result}:
@example
/* do_chdir --- provide dynamically loaded chdir() function for gawk */
@@ -33045,13 +33164,13 @@ do_chdir(int nargs, awk_value_t *result)
@end example
The @code{newdir}
-variable represents the new directory to change to, retrieved
+variable represents the new directory to change to, which is retrieved
with @code{get_argument()}. Note that the first argument is
numbered zero.
If the argument is retrieved successfully, the function calls the
@code{chdir()} system call. If the @code{chdir()} fails, @code{ERRNO}
-is updated.
+is updated:
@example
if (get_argument(0, AWK_STRING, & newdir)) @{
@@ -33252,7 +33371,7 @@ of @code{stat()}) to get the file information, in case the file is a
symbolic link. However, if there were three arguments, @code{statfunc}
is set point to @code{stat()}, instead.
-Here is the @code{do_stat()} function. It starts with
+Here is the @code{do_stat()} function, which starts with
variable declarations and argument checking:
@ignore
@@ -33367,7 +33486,7 @@ dl_load_func(func_table, filefuncs, "")
And that's it!
@node Using Internal File Ops
-@subsection Integrating The Extensions
+@subsection Integrating the Extensions
@cindex @command{gawk}, interpreter@comma{} adding code to
Now that the code is written, it must be possible to add it at
@@ -33376,9 +33495,9 @@ code must be compiled. Assuming that the functions are in
a file named @file{filefuncs.c}, and @var{idir} is the location
of the @file{gawkapi.h} header file,
the following steps@footnote{In practice, you would probably want to
-use the GNU Autotools---Automake, Autoconf, Libtool, and @command{gettext}---to
+use the GNU Autotools (Automake, Autoconf, Libtool, and @command{gettext}) to
configure and build your libraries. Instructions for doing so are beyond
-the scope of this @value{DOCUMENT}. @xref{gawkextlib}, for Internet links to
+the scope of this @value{DOCUMENT}. @DBXREF{gawkextlib} for Internet links to
the tools.} create a GNU/Linux shared library:
@example
@@ -33386,7 +33505,7 @@ $ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -I@var{idir} filefuncs.c}
$ @kbd{gcc -o filefuncs.so -shared filefuncs.o}
@end example
-Once the library exists, it is loaded by using the @code{@@load} keyword.
+Once the library exists, it is loaded by using the @code{@@load} keyword:
@example
# file testff.awk
@@ -33450,13 +33569,14 @@ $ @kbd{AWKLIBPATH=$PWD gawk -f testff.awk}
@end example
@node Extension Samples
-@section The Sample Extensions In The @command{gawk} Distribution
+@section The Sample Extensions in the @command{gawk} Distribution
@cindex extensions distributed with @command{gawk}
This @value{SECTION} provides brief overviews of the sample extensions
that come in the @command{gawk} distribution. Some of them are intended
-for production use, such the @code{filefuncs}, @code{readdir} and @code{inplace} extensions.
-Others mainly provide example code that shows how to use the extension API.
+for production use (e.g., the @code{filefuncs}, @code{readdir} and
+@code{inplace} extensions). Others mainly provide example code that
+shows how to use the extension API.
@menu
* Extension Sample File Functions:: The file functions sample.
@@ -33477,9 +33597,9 @@ Others mainly provide example code that shows how to use the extension API.
@end menu
@node Extension Sample File Functions
-@subsection File Related Functions
+@subsection File-Related Functions
-The @code{filefuncs} extension provides three different functions, as follows:
+The @code{filefuncs} extension provides three different functions, as follows.
The usage is:
@table @asis
@@ -33490,7 +33610,7 @@ This is how you load the extension.
@item @code{result = chdir("/some/directory")}
The @code{chdir()} function is a direct hook to the @code{chdir()}
system call to change the current directory. It returns zero
-upon success or less than zero upon error. In the latter case it updates
+upon success or less than zero upon error. In the latter case, it updates
@code{ERRNO}.
@cindex @code{stat()} extension function
@@ -33498,7 +33618,7 @@ upon success or less than zero upon error. In the latter case it updates
The @code{stat()} function provides a hook into the
@code{stat()} system call.
It returns zero upon success or less than zero upon error.
-In the latter case it updates @code{ERRNO}.
+In the latter case, it updates @code{ERRNO}.
By default, it uses the @code{lstat()} system call. However, if passed
a third argument, it uses @code{stat()} instead.
@@ -33545,8 +33665,8 @@ Not all systems support all file types. @tab All
@item @code{flags = or(FTS_PHYSICAL, ...)}
@itemx @code{result = fts(pathlist, flags, filedata)}
Walk the file trees provided in @code{pathlist} and fill in the
-@code{filedata} array as described below. @code{flags} is the bitwise
-OR of several predefined values, also described below.
+@code{filedata} array as described next. @code{flags} is the bitwise
+OR of several predefined values, also described in a moment.
Return zero if there were no errors, otherwise return @minus{}1.
@end table
@@ -33594,7 +33714,7 @@ whether or not @code{FTS_LOGICAL} is set.
By default, the C library @code{fts()} routines do not return entries for
@file{.} (dot) and @file{..} (dot-dot). This option causes entries for
dot-dot to also be included. (The extension always includes an entry
-for dot, see below.)
+for dot; more on this in a moment.)
@item FTS_XDEV
During a traversal, do not cross onto a different mounted filesystem.
@@ -33604,7 +33724,7 @@ During a traversal, do not cross onto a different mounted filesystem.
The @code{filedata} array is first cleared. Then, @code{fts()} creates
an element in @code{filedata} for every element in @code{pathlist}.
The index is the name of the directory or file given in @code{pathlist}.
-The element for this index is itself an array. There are two cases.
+The element for this index is itself an array. There are two cases:
@c nested table
@table @emph
@@ -33630,8 +33750,8 @@ contain an element named @code{"error"}, which is a string describing the error.
@item The path is a directory
In this case, the array contains one element for each entry in the
-directory. If an entry is a file, that element is as for files, just
-described. If the entry is a directory, that element is (recursively),
+directory. If an entry is a file, that element is the same as for files, just
+described. If the entry is a directory, that element is (recursively)
an array describing the subdirectory. If @code{FTS_SEEDOT} was provided
in the flags, then there will also be an element named @code{".."}. This
element will be an array containing the data as provided by @code{stat()}.
@@ -33650,8 +33770,8 @@ The @code{fts()} extension does not exactly mimic the
interface of the C library @code{fts()} routines, choosing instead to
provide an interface that is based on associative arrays, which is
more comfortable to use from an @command{awk} program. This includes the
-lack of a comparison function, since @command{gawk} already provides
-powerful array sorting facilities. While an @code{fts_read()}-like
+lack of a comparison function, because @command{gawk} already provides
+powerful array sorting facilities. Although an @code{fts_read()}-like
interface could have been provided, this felt less natural than simply
creating a multidimensional array to represent the file hierarchy and
its information.
@@ -33661,7 +33781,7 @@ See @file{test/fts.awk} in the @command{gawk} distribution for an example
use of the @code{fts()} extension function.
@node Extension Sample Fnmatch
-@subsection Interface To @code{fnmatch()}
+@subsection Interface to @code{fnmatch()}
This extension provides an interface to the C library
@code{fnmatch()} function. The usage is:
@@ -33674,10 +33794,10 @@ This is how you load the extension.
@item result = fnmatch(pattern, string, flags)
The return value is zero on success, @code{FNM_NOMATCH}
if the string did not match the pattern, or
-a different non-zero value if an error occurred.
+a different nonzero value if an error occurred.
@end table
-Besides the @code{fnmatch()} function, the @code{fnmatch} extension
+In addition to the @code{fnmatch()} function, the @code{fnmatch} extension
adds one constant (@code{FNM_NOMATCH}), and an array of flag values
named @code{FNM}.
@@ -33695,7 +33815,7 @@ Either zero, or the bitwise OR of one or more of the
flags in the @code{FNM} array.
@end table
-The flags are follows:
+The flags are as follows:
@multitable @columnfractions .25 .75
@headitem Array element @tab Corresponding flag defined by @code{fnmatch()}
@@ -33718,9 +33838,9 @@ if (fnmatch("*.a", "foo.c", flags) == FNM_NOMATCH)
@end example
@node Extension Sample Fork
-@subsection Interface To @code{fork()}, @code{wait()} and @code{waitpid()}
+@subsection Interface to @code{fork()}, @code{wait()}, and @code{waitpid()}
-The @code{fork} extension adds three functions, as follows.
+The @code{fork} extension adds three functions, as follows:
@table @code
@item @@load "fork"
@@ -33818,7 +33938,7 @@ $ @kbd{gawk -i inplace -v INPLACE_SUFFIX=.bak '@{ gsub(/foo/, "bar") @}}
@subsection Character and Numeric values: @code{ord()} and @code{chr()}
The @code{ordchr} extension adds two functions, named
-@code{ord()} and @code{chr()}, as follows.
+@code{ord()} and @code{chr()}, as follows:
@table @code
@item @@load "ordchr"
@@ -33866,7 +33986,7 @@ indicating the type of the file. The letters and their corresponding file
types are shown in @ref{table-readdir-file-types}.
@float Table,table-readdir-file-types
-@caption{File Types Returned By The @code{readdir} Extension}
+@caption{File types returned by the @code{readdir} extension}
@multitable @columnfractions .1 .9
@headitem Letter @tab File Type
@item @code{b} @tab Block device
@@ -33903,7 +34023,7 @@ BEGIN @{ FS = "/" @}
@subsection Reversing Output
The @code{revoutput} extension adds a simple output wrapper that reverses
-the characters in each output line. It's main purpose is to show how to
+the characters in each output line. Its main purpose is to show how to
write an output wrapper, although it may be mildly amusing for the unwary.
Here is an example:
@@ -33925,7 +34045,7 @@ The output from this program is:
The @code{revtwoway} extension adds a simple two-way processor that
reverses the characters in each line sent to it for reading back by
-the @command{awk} program. It's main purpose is to show how to write
+the @command{awk} program. Its main purpose is to show how to write
a two-way processor, although it may also be mildly amusing.
The following example shows how to use it:
@@ -33952,7 +34072,7 @@ is:
@samp{cinap t'nod}.
@node Extension Sample Read write array
-@subsection Dumping and Restoring An Array
+@subsection Dumping and Restoring an Array
The @code{rwarray} extension adds two functions,
named @code{writea()} and @code{reada()}, as follows:
@@ -33978,7 +34098,7 @@ Here too, the return value is one on success and zero upon failure.
The array created by @code{reada()} is identical to that written by
@code{writea()} in the sense that the contents are the same. However,
-due to implementation issues, the array traversal order of the recreated
+due to implementation issues, the array traversal order of the re-created
array is likely to be different from that of the original array. As array
traversal order in @command{awk} is by default undefined, this is (technically)
not a problem. If you need to guarantee a particular traversal
@@ -33986,7 +34106,7 @@ order, use the array sorting features in @command{gawk} to do so
(@pxref{Array Sorting}).
The file contains binary data. All integral values are written in network
-byte order. However, double precision floating-point values are written
+byte order. However, double-precision floating-point values are written
as native binary data. Thus, arrays containing only string data can
theoretically be dumped on systems with one byte order and restored on
systems with a different one, but this has not been tried.
@@ -34002,7 +34122,7 @@ ret = reada("arraydump.bin", array)
@end example
@node Extension Sample Readfile
-@subsection Reading An Entire File
+@subsection Reading an Entire File
The @code{readfile} extension adds a single function
named @code{readfile()}, and an input parser:
@@ -34049,7 +34169,7 @@ This is how you load the extension.
@cindex @code{gettimeofday()} extension function
@item the_time = gettimeofday()
Return the time in seconds that has elapsed since 1970-01-01 UTC as a
-floating point value. If the time is unavailable on this platform, return
+floating-point value. If the time is unavailable on this platform, return
@minus{}1 and set @code{ERRNO}. The returned time should have sub-second
precision, but the actual precision may vary based on the platform.
If the standard C @code{gettimeofday()} system call is available on this
@@ -34092,22 +34212,22 @@ As of this writing, there are five extensions:
@itemize @value{BULLET}
@item
-GD graphics library extension.
+GD graphics library extension
@item
-PDF extension.
+PDF extension
@item
-PostgreSQL extension.
+PostgreSQL extension
@item
-MPFR library extension.
-This provides access to a number of MPFR functions which @command{gawk}'s
-native MPFR support does not.
+MPFR library extension
+(this provides access to a number of MPFR functions which @command{gawk}'s
+native MPFR support does not)
@item
XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
-XML parsing library.
+XML parsing library
@end itemize
@cindex @command{git} utility
@@ -34158,9 +34278,9 @@ to install both @command{gawk} and @code{gawkextlib}, depending upon
how your system works.
If you write an extension that you wish to share with other
-@command{gawk} users, please consider doing so through the
+@command{gawk} users, consider doing so through the
@code{gawkextlib} project.
-See the project's web site for more information.
+See the project's website for more information.
@node Extension summary
@section Summary
@@ -34168,7 +34288,7 @@ See the project's web site for more information.
@itemize @value{BULLET}
@item
You can write extensions (sometimes called plug-ins) for @command{gawk}
-in C or C++ using the Application Programming Interface (API) defined
+in C or C++ using the application programming interface (API) defined
by the @command{gawk} developers.
@item
@@ -34199,44 +34319,44 @@ API function pointers are provided for the following kinds of operations:
@itemize @value{BULLET}
@item
-Allocating, reallocating, and releasing memory.
+Allocating, reallocating, and releasing memory
@item
-Registration functions. You may register
+Registration functions (you may register
extension functions,
exit callbacks,
a version string,
input parsers,
output wrappers,
-and two-way processors.
+and two-way processors)
@item
-Printing fatal, warning, and ``lint'' warning messages.
+Printing fatal, warning, and ``lint'' warning messages
@item
-Updating @code{ERRNO}, or unsetting it.
+Updating @code{ERRNO}, or unsetting it
@item
Accessing parameters, including converting an undefined parameter into
-an array.
+an array
@item
-Symbol table access: retrieving a global variable, creating one,
-or changing one.
+Symbol table access (retrieving a global variable, creating one,
+or changing one)
@item
Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and
-can be a big performance win.
+can be a big performance win
@item
-Manipulating arrays:
-retrieving, adding, deleting, and modifying elements;
+Manipulating arrays
+(retrieving, adding, deleting, and modifying elements;
getting the count of elements in an array;
creating a new array;
clearing an array;
and
-flattening an array for easy C style looping over all its indices and elements.
+flattening an array for easy C style looping over all its indices and elements)
@end itemize
@item
@@ -34315,34 +34435,34 @@ and the Glossary:
@end ifclear
@ifset FOR_PRINT
-Part IV contains two appendices and the license that
+Part IV contains three appendices, the last of which is the license that
covers the @command{gawk} source code:
@end ifset
@itemize @value{BULLET}
@item
-@ref{Language History}.
+@ref{Language History}
@item
-@ref{Installation}.
+@ref{Installation}
@ifclear FOR_PRINT
@item
-@ref{Notes}.
+@ref{Notes}
@item
-@ref{Basic Concepts}.
+@ref{Basic Concepts}
@item
-@ref{Glossary}.
+@ref{Glossary}
@end ifclear
@item
-@ref{Copying}.
+@ref{Copying}
@ifclear FOR_PRINT
@item
-@ref{GNU Free Documentation License}.
+@ref{GNU Free Documentation License}
@end ifclear
@end itemize
@end ifdocbook
@@ -34351,7 +34471,7 @@ covers the @command{gawk} source code:
@appendix The Evolution of the @command{awk} Language
This @value{DOCUMENT} describes the GNU implementation of @command{awk},
-which follows the POSIX specification. Many long-time @command{awk}
+which follows the POSIX specification. Many longtime @command{awk}
users learned @command{awk} programming with the original @command{awk}
implementation in Version 7 Unix. (This implementation was the basis for
@command{awk} in Berkeley Unix, through 4.3-Reno. Subsequent versions
@@ -34586,7 +34706,7 @@ The ability to delete all of an array at once with @samp{delete @var{array}}
@end itemize
-@xref{Common Extensions}, for a list of common extensions
+@DBXREF{Common Extensions} for a list of common extensions
not permitted by the POSIX standard.
The 2008 POSIX standard can be found online at
@@ -34606,7 +34726,7 @@ has made his version available via his home page
(@pxref{Other Versions}).
This @value{SECTION} describes common extensions that
-originally appeared in his version of @command{awk}.
+originally appeared in his version of @command{awk}:
@itemize @value{BULLET}
@item
@@ -34632,7 +34752,7 @@ or array elements through it.
@end ignore
@end itemize
-@xref{Common Extensions}, for a full list of the extensions
+@DBXREF{Common Extensions} for a full list of the extensions
available in his @command{awk}.
@node POSIX/GNU
@@ -34688,7 +34808,7 @@ The @file{/dev/stdin}, @file{/dev/stdout}, @file{/dev/stderr} and
@item
The @file{/inet}, @file{/inet4}, and @samp{/inet6} special files for
TCP/IP networking using @samp{|&} to specify which version of the
-IP protocol to use.
+IP protocol to use
(@pxref{TCP/IP Networking}).
@end itemize
@@ -34736,7 +34856,7 @@ New keywords:
@itemize @value{MINUS}
@item
-The @code{BEGINFILE} and @code{ENDFILE} special patterns.
+The @code{BEGINFILE} and @code{ENDFILE} special patterns
(@pxref{BEGINFILE/ENDFILE}).
@item
@@ -34773,7 +34893,7 @@ making translations easier
@item
The @code{split()} function's additional optional fourth
-argument which is an array to hold the text of the field separators.
+argument which is an array to hold the text of the field separators
(@pxref{String Functions}).
@end itemize
@@ -35536,7 +35656,7 @@ load @command{awk} library files.
@item
The @option{-l} and @option{--load} options load compiled dynamic extensions.
-@item
+@item
The @option{-M} and @option{--bignum} options enable MPFR.
@item
@@ -35575,7 +35695,7 @@ The dynamic extension interface was completely redone
@cindex extensions, @command{mawk}
The following table summarizes the common extensions supported
by @command{gawk}, Brian Kernighan's @command{awk}, and @command{mawk},
-the three most widely-used freely available versions of @command{awk}
+the three most widely used freely available versions of @command{awk}
(@pxref{Other Versions}).
@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk} {Now standard}
@@ -35593,7 +35713,7 @@ the three most widely-used freely available versions of @command{awk}
@item @code{func} keyword @tab X @tab @tab X @tab
@item @code{BINMODE} variable @tab @tab X @tab X @tab
@item @code{RS} as regexp @tab @tab X @tab X @tab
-@item Time related functions @tab @tab X @tab X @tab
+@item Time-related functions @tab @tab X @tab X @tab
@end multitable
@node Ranges and Locales
@@ -35609,7 +35729,7 @@ the first character in the range and the last character in the range,
inclusive. Ordering was based on the numeric value of each character
in the machine's native character set. Thus, on ASCII-based systems,
@samp{[a-z]} matched all the lowercase letters, and only the lowercase
-letters, since the numeric values for the letters from @samp{a} through
+letters, as the numeric values for the letters from @samp{a} through
@samp{z} were contiguous. (On an EBCDIC system, the range @samp{[a-z]}
includes additional, non-alphabetic characters as well.)
@@ -35620,8 +35740,8 @@ that @samp{[A-Z]} was the ``correct'' way to match uppercase letters.
And indeed, this was true.@footnote{And Life was good.}
The 1992 POSIX standard introduced the idea of locales (@pxref{Locales}).
-Since many locales include other letters besides the plain twenty-six
-letters of the American English alphabet, the POSIX standard added
+Because many locales include other letters besides the plain 26
+letters of the English alphabet, the POSIX standard added
character classes (@pxref{Bracket Expressions}) as a way to match
different kinds of characters besides the traditional ones in the ASCII
character set.
@@ -35638,7 +35758,7 @@ In other words, these locales sort characters in dictionary order,
and @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
instead it might be equivalent to @samp{[ABCXYabcdxyz]}, for example.
-This point needs to be emphasized: Much literature teaches that you should
+This point needs to be emphasized: much literature teaches that you should
use @samp{[a-z]} to match a lowercase character. But on systems with
non-ASCII locales, this also matches all of the uppercase characters
except @samp{A} or @samp{Z}! This was a continuous cause of confusion, even well
@@ -35654,7 +35774,7 @@ $ @kbd{echo something1234abc | gawk-3.1.8 '@{ sub("[A-Z]*$", ""); print @}'}
@end example
@noindent
-This output is unexpected, since the @samp{bc} at the end of
+This output is unexpected, as the @samp{bc} at the end of
@samp{something1234abc} should not normally match @samp{[A-Z]*}.
This result is due to the locale setting (and thus you may not see
it on your system).
@@ -35676,7 +35796,7 @@ like ``why does @samp{[A-Z]} match lowercase letters?!?''
@cindex Berry, Karl
This situation existed for close to 10 years, if not more, and
the @command{gawk} maintainer grew weary of trying to explain that
-@command{gawk} was being nicely standards-compliant, and that the issue
+@command{gawk} was being nicely standards compliant, and that the issue
was in the user's locale. During the development of @value{PVERSION} 4.0,
he modified @command{gawk} to always treat ranges in the original,
pre-POSIX fashion, unless @option{--posix} was used (@pxref{Options}).@footnote{And
@@ -35889,7 +36009,7 @@ Michael Benzinger contributed the initial code for @code{switch} statements.
@cindex McPhee, Patrick
Patrick T.J.@: McPhee contributed the code for dynamic loading in Windows32
environments.
-(This is no longer supported)
+(This is no longer supported.)
@item
@cindex Wallin, Anders
@@ -35913,7 +36033,7 @@ into a byte-code interpreter, including the debugger.
The addition of true arrays of arrays.
@item
-The additional modifications for support of arbitrary precision arithmetic.
+The additional modifications for support of arbitrary-precision arithmetic.
@item
The initial text of
@@ -35969,7 +36089,7 @@ helping David Trueman, and as the primary maintainer since around 1994.
@itemize @value{BULLET}
@item
The @command{awk} language has evolved over time. The first release
-was with V7 Unix circa 1978. In 1987 for System V Release 3.1,
+was with V7 Unix circa 1978. In 1987, for System V Release 3.1,
major additions, including user-defined functions, were made to the language.
Additional changes were made for System V Release 4, in 1989.
Since then, further minor changes happen under the auspices of the
@@ -36011,8 +36131,8 @@ This appendix provides instructions for installing @command{gawk} on the
various platforms that are supported by the developers. The primary
developer supports GNU/Linux (and Unix), whereas the other ports are
contributed.
-@xref{Bugs},
-for the electronic mail addresses of the people who maintain
+@DBXREF{Bugs}
+for the email addresses of the people who maintain
the respective ports.
@menu
@@ -36066,7 +36186,7 @@ wget http://ftp.gnu.org/gnu/gawk/gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz
The GNU software archive is mirrored around the world.
The up-to-date list of mirror sites is available from
-@uref{http://www.gnu.org/order/ftp.html, the main FSF web site}.
+@uref{http://www.gnu.org/order/ftp.html, the main FSF website}.
Try to use one of the mirrors; they
will be less busy, and you can usually find one closer to your site.
@@ -36077,7 +36197,7 @@ different compression programs: @command{gzip}, @command{bzip2},
and @command{xz}. For simplicity, the rest of these instructions assume
you are using the one compressed with the GNU Zip program, @code{gzip}.
-Once you have the distribution (for example,
+Once you have the distribution (e.g.,
@file{gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz}),
use @code{gzip} to expand the
file and then use @code{tar} to extract it. You can use the following
@@ -36170,7 +36290,7 @@ as a list of things that the POSIX standard should describe but does not.
@item doc/awkforai.txt
Pointers to the original draft of
a short article describing why @command{gawk} is a good language for
-Artificial Intelligence (AI) programming.
+artificial intelligence (AI) programming.
@item doc/bc_notes
A brief description of @command{gawk}'s ``byte code'' internals.
@@ -36276,7 +36396,7 @@ source file for this @value{DOCUMENT}. It also contains a @file{Makefile.in} fil
The library functions from
@ref{Library Functions},
and the @command{igawk} program from
-@ref{Igawk Program},
+@DBREF{Igawk Program}
are included as ready-to-use files in the @command{gawk} distribution.
They are installed as part of the installation process.
The rest of the programs in this @value{DOCUMENT} are available in appropriate
@@ -36295,11 +36415,11 @@ Files needed for building @command{gawk} under MS-Windows
@ifclear FOR_PRINT
and OS/2
@end ifclear
-(@pxref{PC Installation}, for details).
+(@DBPXREF{PC Installation} for details).
@item vms/*
Files needed for building @command{gawk} under Vax/VMS and OpenVMS
-(@pxref{VMS Installation}, for details).
+(@DBPXREF{VMS Installation} for details).
@item test/*
A test suite for
@@ -36311,7 +36431,7 @@ be confident of a successful port.
@c ENDOFRANGE gawdis
@node Unix Installation
-@appendixsec Compiling and Installing @command{gawk} on Unix-like Systems
+@appendixsec Compiling and Installing @command{gawk} on Unix-Like Systems
Usually, you can compile and install @command{gawk} by typing only two
commands. However, if you use an unusual system, you may need
@@ -36324,7 +36444,7 @@ to configure @command{gawk} for your system yourself.
@end menu
@node Quick Installation
-@appendixsubsec Compiling @command{gawk} for Unix-like Systems
+@appendixsubsec Compiling @command{gawk} for Unix-Like Systems
The normal installation steps should work on all modern commercial
Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin
@@ -36341,7 +36461,7 @@ described fully in
@cite{Autoconf---Generating Automatic Configuration Scripts},
which can be found online at
@uref{http://www.gnu.org/software/autoconf/manual/index.html,
-the Free Software Foundation's web site}.)
+the Free Software Foundation's website}.)
@end ifnotinfo
@ifinfo
(The Autoconf software is described fully starting with
@@ -36388,7 +36508,7 @@ run @samp{make check}. All of the tests should succeed.
If these steps do not work, or if any of the tests fail,
check the files in the @file{README_d} directory to see if you've
found a known problem. If the failure is not described there,
-please send in a bug report (@pxref{Bugs}).
+send in a bug report (@pxref{Bugs}).
Of course, once you've built @command{gawk}, it is likely that you will
wish to install it. To do so, you need to run the command @samp{make
@@ -36452,7 +36572,7 @@ function for deficient systems.
@end table
Use the command @samp{./configure --help} to see the full list of
-options that @command{configure} supplies.
+options supplied by @command{configure}.
@node Configuration Philosophy
@appendixsubsec The Configuration Process
@@ -36486,19 +36606,19 @@ facts about your operating system. For example, there may not be an
@cindex @code{custom.h} file
It is possible for your C compiler to lie to @command{configure}. It may
do so by not exiting with an error when a library function is not
-available. To get around this, edit the file @file{custom.h}.
+available. To get around this, edit the @file{custom.h} file.
Use an @samp{#ifdef} that is appropriate for your system, and either
@code{#define} any constants that @command{configure} should have defined but
didn't, or @code{#undef} any constants that @command{configure} defined and
-should not have. @file{custom.h} is automatically included by
-@file{config.h}.
+should not have. The @file{custom.h} file is automatically included by
+the @file{config.h} file.
It is also possible that the @command{configure} program generated by
Autoconf will not work on your system in some other fashion.
-If you do have a problem, the file @file{configure.ac} is the input for
+If you do have a problem, the @file{configure.ac} file is the input for
Autoconf. You may be able to change this file and generate a
new version of @command{configure} that works on your system
-(@pxref{Bugs},
+(@DBPXREF{Bugs}
for information on how to report problems in configuring @command{gawk}).
The same mechanism may be used to send in updates to @file{configure.ac}
and/or @file{custom.h}.
@@ -36538,7 +36658,7 @@ The limitations of MS-DOS (and MS-DOS shells under the other operating
systems) has meant that various ``DOS extenders'' are often used with
programs such as @command{gawk}. The varying capabilities of Microsoft
Windows 3.1 and Windows32 can add to the confusion. For an overview
-of the considerations, please refer to @file{README_d/README.pc} in
+of the considerations, refer to @file{README_d/README.pc} in
the distribution.
@menu
@@ -36701,7 +36821,7 @@ Ancient OS/2 ports of GNU @command{make} are not able to handle
the Makefiles of this package. If you encounter any problems with
@command{make}, try GNU Make 3.79.1 or later versions. You should
find the latest version on
-@uref{ftp://hobbes.nmsu.edu/pub/os2/}.@footnote{As of May, 2014,
+@uref{ftp://hobbes.nmsu.edu/pub/os2/}.@footnote{As of November 2014,
this site is still there, but the author could not find a package
for GNU Make.}
@end quotation
@@ -36911,7 +37031,7 @@ need to use the @code{BINMODE} variable.
This can cause problems with other Unix-like components that have
been ported to MS-Windows that expect @command{gawk} to do automatic
-translation of @code{"\r\n"}, since it won't.
+translation of @code{"\r\n"}, because it won't.
@node VMS Installation
@appendixsubsec Compiling and Installing @command{gawk} on Vax/VMS and OpenVMS
@@ -36975,14 +37095,14 @@ The most recent builds used HP C V7.3 on Alpha VMS 8.3 and both
Alpha and IA64 VMS 8.4 used HP C 7.3.@footnote{The IA64 architecture
is also known as ``Itanium.''}
-@xref{VMS GNV}, for information on building
+@DBXREF{VMS GNV} for information on building
@command{gawk} as a PCSI kit that is compatible with the GNV product.
@node VMS Dynamic Extensions
@appendixsubsubsec Compiling @command{gawk} Dynamic Extensions on VMS
The extensions that have been ported to VMS can be built using one of
-the following commands.
+the following commands:
@example
$ @kbd{MMS/DESCRIPTION=[.vms]descrip.mms extensions}
@@ -36999,7 +37119,7 @@ $ @kbd{MMK/DESCRIPTION=[.vms]descrip.mms extensions}
or a logical name to find the dynamic extensions.
Dynamic extensions need to be compiled with the same compiler options for
-floating point, pointer size, and symbol name handling as were used
+floating-point, pointer size, and symbol name handling as were used
to compile @command{gawk} itself.
Alpha and Itanium should use IEEE floating point. The pointer size is 32 bits,
and the symbol name handling should be exact case with CRC shortening for
@@ -37129,7 +37249,7 @@ Note that uppercase and mixed-case text must be quoted.
The VMS port of @command{gawk} includes a @code{DCL}-style interface in addition
to the original shell-style interface (see the help entry for details).
One side effect of dual command-line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
+single parameter (as in the quoted string program), the command
becomes ambiguous. To work around this, the normally optional @option{--}
flag is required to force Unix-style parsing rather than @code{DCL} parsing. If any
other dash-type options (or multiple parameters such as @value{DF}s to
@@ -37249,10 +37369,10 @@ recommend compiling and using the current version.
@node Bugs
@appendixsec Reporting Problems and Bugs
-@cindex archeologists
+@cindex archaeologists
@quotation
-@i{There is nothing more dangerous than a bored archeologist.}
-@author The Hitchhiker's Guide to the Galaxy
+@i{There is nothing more dangerous than a bored archaeologist.}
+@author Douglas Adams, @cite{The Hitchhiker's Guide to the Galaxy}
@end quotation
@c the radio show, not the book. :-)
@@ -37261,10 +37381,10 @@ recommend compiling and using the current version.
@c STARTOFRANGE tblgawb
@cindex troubleshooting, @command{gawk}, bug reports
If you have problems with @command{gawk} or think that you have found a bug,
-please report it to the developers; we cannot promise to do anything
+report it to the developers; we cannot promise to do anything
but we might well want to fix it.
-Before reporting a bug, please make sure you have really found a genuine bug.
+Before reporting a bug, make sure you have really found a genuine bug.
Carefully reread the documentation and see if it says you can do
what you're trying to do. If it's not clear whether you should be able
to do something or not, report that too; it's a bug in the documentation!
@@ -37277,7 +37397,7 @@ the compiler you used to compile @command{gawk}, and the exact results
@command{gawk} gave you. Also say what you expected to occur; this helps
us decide whether the problem is really in the documentation.
-Please include the version number of @command{gawk} you are using.
+Make sure to include the version number of @command{gawk} you are using.
You can get this information with the command @samp{gawk --version}.
@cindex @code{bug-gawk@@gnu.org} bug reporting address
@@ -37289,7 +37409,7 @@ Once you have a precise problem description, send email to
The @command{gawk} maintainers subscribe to this address and
thus they will receive your bug report.
Although you can send mail to the maintainers directly,
-the bug reporting address is preferred since the
+the bug reporting address is preferred because the
email list is archived at the GNU Project.
@emph{All email must be in English. This is the only language
understood in common by all the maintainers.}
@@ -37298,19 +37418,19 @@ understood in common by all the maintainers.}
@quotation CAUTION
Do @emph{not} try to report bugs in @command{gawk} by
posting to the Usenet/Internet newsgroup @code{comp.lang.awk}.
-While the @command{gawk} developers do occasionally read this newsgroup,
-there is no guarantee that we will see your posting. The steps described
-above are the only official recognized way for reporting bugs.
+The @command{gawk} developers do occasionally read this newsgroup,
+but there is no guarantee that we will see your posting. The steps described
+here are the only officially recognized way for reporting bugs.
Really.
@end quotation
@quotation NOTE
Many distributions of GNU/Linux and the various BSD-based operating systems
have their own bug reporting systems. If you report a bug using your distribution's
-bug reporting system, @emph{please} also send a copy to
+bug reporting system, you should also send a copy to
@EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org}.
-This is for two reasons. First, while some distributions forward
+This is for two reasons. First, although some distributions forward
bug reports ``upstream'' to the GNU mailing list, many don't, so there is a good
chance that the @command{gawk} maintainers won't even see the bug report! Second,
mail to the GNU list is archived, and having everything at the GNU project
@@ -37321,8 +37441,8 @@ Non-bug suggestions are always welcome as well. If you have questions
about things that are unclear in the documentation or are just obscure
features, ask on the bug list; we will try to help you out if we can.
-If you find bugs in one of the non-Unix ports of @command{gawk}, please
-send an electronic mail message to the bug list, with a copy to the
+If you find bugs in one of the non-Unix ports of @command{gawk},
+send an email to the bug list, with a copy to the
person who maintains that port. They are named in the following list,
as well as in the @file{README} file in the @command{gawk} distribution.
Information in the @file{README} file should be considered authoritative
@@ -37353,7 +37473,7 @@ The people maintaining the various @command{gawk} ports are:
@item z/OS (OS/390) @tab Dave Pitts, @EMAIL{dpitts@@cozx.com,dpitts at cozx dot com}.
@end multitable
-If your bug is also reproducible under Unix, please send a copy of your
+If your bug is also reproducible under Unix, send a copy of your
report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well.
@c ENDOFRANGE dbugg
@c ENDOFRANGE tblgawb
@@ -37397,7 +37517,7 @@ This @value{SECTION} briefly describes where to get them:
Brian Kernighan, one of the original designers of Unix @command{awk},
has made his implementation of
@command{awk} freely available.
-You can retrieve this version via the World Wide Web from
+You can retrieve this version via
@uref{http://www.cs.princeton.edu/~bwk, his home page}.
It is available in several archive formats:
@@ -37420,7 +37540,7 @@ git clone git://github.com/onetrueawk/awk bwkawk
@end example
@noindent
-The above command creates a copy of the @uref{http://www.git-scm.com, Git}
+This command creates a copy of the @uref{http://www.git-scm.com, Git}
repository in a directory named @file{bwkawk}. If you leave that argument
off the @command{git} command line, the repository copy is created in a
directory named @file{awk}.
@@ -37428,9 +37548,13 @@ directory named @file{awk}.
This version requires an ISO C (1990 standard) compiler; the C compiler
from GCC (the GNU Compiler Collection) works quite nicely.
-@xref{Common Extensions},
+@DBXREF{Common Extensions}
for a list of extensions in this @command{awk} that are not in POSIX @command{awk}.
+As a side note, Dan Bornstein has created a Git repository tracking
+all the versions of BWK @command{awk} that he could find. It's
+available at @uref{git://github.com/onetrueawk/awk}.
+
@cindex Brennan, Michael
@cindex @command{mawk} utility
@cindex source code, @command{mawk}
@@ -37460,7 +37584,7 @@ Once you have it,
is similar to @command{gawk}'s
(@pxref{Unix Installation}).
-@xref{Common Extensions},
+@DBXREF{Common Extensions}
for a list of extensions in @command{mawk} that are not in POSIX @command{awk}.
@cindex Sumner, Andrew
@@ -37522,8 +37646,8 @@ has not been done, at least to our knowledge.
@cindex Illumos
@cindex Illumos, POSIX-compliant @command{awk}
@cindex source code, Illumos @command{awk}
-The source code used to be available from the OpenSolaris web site.
-However, that project was ended and the web site shut down. Fortunately, the
+The source code used to be available from the OpenSolaris website.
+However, that project was ended and the website shut down. Fortunately, the
@uref{http://wiki.illumos.org/display/illumos/illumos+Home, Illumos project}
makes this implementation available. You can view the files one at a time from
@uref{https://github.com/joyent/illumos-joyent/blob/master/usr/src/cmd/awk_xpg4}.
@@ -37542,7 +37666,7 @@ from POSIX @command{awk}. More information is available on the
@cindex libmawk
@cindex source code, libmawk
This is an embeddable @command{awk} interpreter derived from
-@command{mawk}. For more information see
+@command{mawk}. For more information, see
@uref{http://repo.hu/projects/libmawk/}.
@item @code{pawk}
@@ -37556,7 +37680,7 @@ modified version of BWK @command{awk}, described earlier.)
@item @w{QSE Awk}
@cindex QSE Awk
@cindex source code, QSE Awk
-This is an embeddable @command{awk} interpreter. For more information
+This is an embeddable @command{awk} interpreter. For more information,
see @uref{http://code.google.com/p/qse/} and @uref{http://awk.info/?tools/qse}.
@item @command{QTawk}
@@ -37571,9 +37695,10 @@ including the manual and a download link.
The project may also be frozen; no new code changes have been made
since approximately 2008.
-@item Other Versions
-See also the @uref{http://en.wikipedia.org/wiki/Awk_language#Versions_and_implementations,
-Wikipedia article}, for information on additional versions.
+@item Other versions
+See also the ``Versions and implementations'' section of the
+@uref{http://en.wikipedia.org/wiki/Awk_language#Versions_and_implementations,
+Wikipedia article} for information on additional versions.
@end table
@c ENDOFRANGE awkim
@@ -37775,7 +37900,7 @@ This document describes how GNU software should be written. If you haven't
read it, please do so, preferably @emph{before} starting to modify @command{gawk}.
(The @cite{GNU Coding Standards} are available from
the GNU Project's
-@uref{http://www.gnu.org/prep/standards_toc.html, web site}.
+@uref{http://www.gnu.org/prep/standards_toc.html, website}.
Texinfo, Info, and DVI versions are also available.)
@cindex @command{gawk}, coding style in
@@ -39641,7 +39766,7 @@ record or a string.
@end docbook
@c This file is intended to be included within another document,
-@c hence no sectioning command or @node.
+@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/}
@@ -39863,7 +39988,7 @@ terms of section 4, provided that you also meet all of these
conditions:
@enumerate a
-@item
+@item
The work must carry prominent notices stating that you modified it,
and giving a relevant date.
@@ -40313,7 +40438,7 @@ state the exclusion of warranty; and each file should have at least
the ``copyright'' line and a pointer to where the full notice is found.
@smallexample
-@var{one line to give the program's name and a brief idea of what it does.}
+@var{one line to give the program's name and a brief idea of what it does.}
Copyright (C) @var{year} @var{name of author}
This program is free software: you can redistribute it and/or modify
@@ -40336,7 +40461,7 @@ If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
@smallexample
-@var{program} Copyright (C) @var{year} @var{name of author}
+@var{program} Copyright (C) @var{year} @var{name of author}
This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}.
This is free software, and you are welcome to redistribute it
under certain conditions; type @samp{show c} for details.