diff options
Diffstat (limited to 'doc/gawk.info')
-rw-r--r-- | doc/gawk.info | 4123 |
1 files changed, 2065 insertions, 2058 deletions
diff --git a/doc/gawk.info b/doc/gawk.info index 5863ea0f..7f684a92 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -691,24 +691,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. @@ -719,14 +719,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 @@ -740,9 +741,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 @@ -765,7 +766,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 @@ -799,7 +800,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 @@ -815,12 +816,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: @@ -893,7 +894,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 @@ -905,7 +906,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 @@ -925,7 +926,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 @@ -947,7 +948,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 @@ -1002,110 +1003,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 ---------- @@ -1150,7 +1161,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 @@ -1186,7 +1197,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 @@ -1203,9 +1214,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 @@ -1252,12 +1263,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 @@ -1337,7 +1348,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. @@ -1348,8 +1359,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... @@ -1370,22 +1381,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. @@ -1474,7 +1485,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 @@ -1516,7 +1528,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 @@ -1608,7 +1620,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 @@ -1636,8 +1648,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 @@ -1651,13 +1663,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!" } @@ -1666,15 +1678,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' > @@ -1690,8 +1702,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 @@ -1703,7 +1715,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 @@ -1723,15 +1735,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 @@ -1752,7 +1764,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 @@ -1791,7 +1803,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: @@ -1866,7 +1878,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 @@ -1962,13 +1974,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: @@ -1990,7 +2002,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. @@ -2184,10 +2196,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 \\ @@ -2292,8 +2304,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 @@ -2341,10 +2353,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 @@ -2378,8 +2390,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: @@ -2415,7 +2427,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. @@ -2594,7 +2606,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::). @@ -2604,9 +2616,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' @@ -2627,7 +2638,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] @@ -2670,8 +2682,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' @@ -2707,7 +2719,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.) @@ -2715,7 +2727,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 @@ -2726,7 +2738,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'. @@ -2775,8 +2787,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 @@ -2923,11 +2935,11 @@ to manipulate the `AWKPATH' variable. `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 ---------- @@ -2973,7 +2985,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 @@ -2990,7 +3002,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 @@ -3021,8 +3033,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 @@ -3063,13 +3075,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'. @@ -3104,9 +3116,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 @@ -3132,22 +3144,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. @@ -3166,7 +3178,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'. @@ -3181,7 +3193,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 @@ -3238,12 +3250,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. @@ -3282,7 +3294,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. @@ -3323,13 +3335,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 @@ -3383,9 +3395,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 @@ -3440,7 +3452,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. @@ -3466,19 +3478,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 @@ -3497,6 +3496,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 @@ -3529,15 +3541,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 @@ -3610,7 +3622,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. @@ -3694,7 +3706,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 @@ -3734,24 +3746,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 @@ -3759,7 +3771,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 @@ -3952,9 +3964,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). @@ -3982,15 +3994,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. @@ -4030,10 +4041,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 @@ -4041,17 +4051,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 @@ -4088,11 +4098,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. @@ -4104,8 +4114,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 @@ -4164,7 +4174,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. @@ -4177,7 +4187,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 @@ -4189,7 +4199,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 @@ -4199,7 +4209,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 @@ -4305,7 +4315,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 @@ -4345,7 +4355,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' @@ -4413,8 +4423,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 @@ -4425,9 +4435,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. @@ -4486,11 +4496,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 @@ -4520,7 +4530,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. @@ -4566,8 +4576,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 @@ -4668,7 +4678,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. @@ -4708,7 +4718,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 @@ -4820,7 +4830,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' @@ -4945,21 +4955,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 @@ -4998,32 +5037,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 @@ -5038,23 +5051,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 @@ -5090,13 +5097,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 @@ -5113,6 +5117,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 @@ -5156,12 +5163,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, @@ -5169,13 +5175,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 @@ -5184,7 +5190,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 @@ -5238,8 +5244,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. @@ -5365,7 +5371,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.") @@ -5430,7 +5436,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: @@ -5547,7 +5553,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. @@ -5591,8 +5597,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 @@ -5858,19 +5864,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 @@ -5929,13 +5935,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 @@ -5957,7 +5963,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 @@ -5968,7 +5974,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 @@ -6002,8 +6008,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 @@ -6014,7 +6020,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' @@ -6231,14 +6237,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 @@ -6337,10 +6344,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 @@ -6423,7 +6430,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 @@ -6449,7 +6456,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' @@ -6520,7 +6527,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', @@ -6534,7 +6541,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: @@ -6599,10 +6606,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 @@ -6680,8 +6687,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", "----", "------" } @@ -6822,7 +6830,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 @@ -6894,7 +6902,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 @@ -6919,10 +6927,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 ---------- @@ -6934,7 +6942,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. @@ -6981,7 +6989,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 @@ -7123,9 +7131,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. @@ -7146,8 +7155,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 @@ -7200,9 +7209,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. @@ -7262,8 +7271,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 @@ -7289,7 +7298,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: @@ -7313,7 +7322,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" @@ -7326,7 +7335,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. @@ -7336,17 +7345,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 @@ -7384,7 +7393,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 @@ -7427,8 +7436,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" @@ -7492,8 +7501,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 @@ -7533,7 +7542,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 @@ -7605,7 +7614,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'. @@ -7618,7 +7627,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, @@ -7641,7 +7650,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 @@ -7670,7 +7679,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 @@ -7707,7 +7716,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: @@ -7729,7 +7738,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 @@ -7748,9 +7757,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::. @@ -7758,7 +7767,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 @@ -7820,9 +7829,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 @@ -7884,7 +7893,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': @@ -8059,7 +8068,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_. @@ -8077,16 +8086,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. @@ -8135,7 +8144,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). @@ -8199,8 +8208,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. @@ -8251,8 +8260,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 @@ -8268,7 +8277,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 @@ -8285,7 +8294,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. @@ -8366,19 +8375,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 @@ -8408,24 +8417,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: @@ -8457,8 +8466,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/ @@ -8469,7 +8478,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 @@ -8656,7 +8665,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 @@ -8671,7 +8680,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 @@ -8796,7 +8805,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::). @@ -8811,9 +8820,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. @@ -8839,7 +8848,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 @@ -8859,7 +8868,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'. @@ -8879,12 +8888,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/'. @@ -8919,8 +8928,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 @@ -9089,7 +9097,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 @@ -9175,8 +9183,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: @@ -9203,7 +9210,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. @@ -9271,20 +9278,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 @@ -9383,9 +9390,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 @@ -9407,10 +9414,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 @@ -9462,7 +9469,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 @@ -9530,7 +9537,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 @@ -9589,7 +9596,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. @@ -9627,8 +9634,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. @@ -9707,7 +9714,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) @@ -9774,12 +9781,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 @@ -9880,7 +9887,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 @@ -9926,7 +9933,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, @@ -9979,14 +9986,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). @@ -10083,7 +10090,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 @@ -10204,11 +10211,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::). @@ -10235,7 +10242,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"'. @@ -10246,7 +10253,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 @@ -10256,7 +10263,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 @@ -10346,9 +10353,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 @@ -10368,7 +10376,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 @@ -10444,8 +10452,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"]' @@ -10461,7 +10469,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"]' @@ -10653,7 +10661,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'. @@ -10664,7 +10672,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++) { @@ -10696,10 +10704,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 @@ -10851,14 +10859,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 @@ -10898,7 +10906,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. @@ -10961,8 +10969,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) @@ -11138,7 +11146,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'. @@ -11159,7 +11167,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: @@ -11248,7 +11256,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 @@ -11264,12 +11272,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::. @@ -11310,8 +11318,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 @@ -11330,7 +11338,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. @@ -11433,7 +11441,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). @@ -11470,7 +11478,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 @@ -11505,7 +11513,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) @@ -11606,8 +11614,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" @@ -11620,7 +11628,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 @@ -11696,7 +11704,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 @@ -11737,11 +11745,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 @@ -11785,7 +11793,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 @@ -11810,7 +11818,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 @@ -11818,7 +11826,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. @@ -11890,10 +11898,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, @@ -11984,7 +11990,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. @@ -12015,7 +12021,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 @@ -12033,10 +12040,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 @@ -12275,7 +12282,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::). @@ -12314,8 +12321,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: @@ -12339,7 +12346,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.) @@ -12548,7 +12555,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. @@ -12591,7 +12598,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 @@ -12621,7 +12628,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 @@ -12648,20 +12655,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 @@ -12680,7 +12686,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 @@ -12724,23 +12730,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. @@ -12765,6 +12771,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. @@ -12798,37 +12836,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 @@ -12842,8 +12849,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.) @@ -12934,14 +12941,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 @@ -13005,9 +13012,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. @@ -13101,15 +13108,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 @@ -13129,8 +13136,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 @@ -13218,7 +13225,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. @@ -13255,7 +13262,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 @@ -13313,7 +13320,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. @@ -13349,11 +13356,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 @@ -13399,8 +13406,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: @@ -13513,7 +13520,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 @@ -13525,7 +13532,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 @@ -13579,7 +13586,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) { @@ -13615,9 +13622,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 ---------- @@ -13642,7 +13649,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 @@ -13655,10 +13662,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. @@ -13711,7 +13718,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) @@ -13784,20 +13791,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 @@ -13874,7 +13878,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. @@ -13923,11 +13927,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 @@ -14041,15 +14046,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 @@ -14077,7 +14082,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 { @@ -14354,7 +14359,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. @@ -14444,8 +14449,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 @@ -14503,8 +14508,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 @@ -14521,7 +14526,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) @@ -14562,9 +14567,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 @@ -14598,7 +14603,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' @@ -14665,8 +14670,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 @@ -14895,8 +14900,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) @@ -14954,7 +14959,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 @@ -14994,7 +14999,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. @@ -15071,7 +15076,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 @@ -15134,7 +15139,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 @@ -15162,7 +15167,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 @@ -15206,7 +15211,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 @@ -15266,7 +15271,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 @@ -15282,7 +15287,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 @@ -15290,7 +15295,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 @@ -15334,8 +15339,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 @@ -15363,12 +15368,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 ---------- @@ -15476,11 +15481,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. @@ -15705,10 +15710,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 @@ -15748,14 +15753,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. @@ -15764,7 +15769,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 @@ -15789,7 +15794,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 @@ -15834,13 +15839,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 @@ -15918,14 +15923,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. @@ -15996,8 +16001,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. @@ -16067,7 +16072,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 @@ -16158,7 +16163,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 @@ -16170,7 +16175,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' @@ -16198,7 +16203,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) { @@ -16310,7 +16315,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. @@ -16439,7 +16444,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 @@ -16656,10 +16661,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, @@ -16684,8 +16689,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. @@ -16796,14 +16801,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) @@ -16915,7 +16920,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, @@ -16999,7 +17004,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 @@ -17028,11 +17033,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 @@ -17065,7 +17070,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] = "" @@ -17137,8 +17142,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 @@ -17170,7 +17175,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: @@ -17194,11 +17199,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: @@ -17376,13 +17382,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: @@ -17454,10 +17460,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 @@ -17564,7 +17570,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. @@ -17878,14 +17884,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 @@ -17922,7 +17929,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 @@ -18046,9 +18053,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 @@ -18171,9 +18178,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 @@ -18230,7 +18237,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 ... @@ -18366,15 +18373,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 @@ -18435,7 +18442,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'. @@ -18473,10 +18480,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 @@ -18497,8 +18504,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 @@ -18758,13 +18765,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 @@ -18821,23 +18828,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. @@ -18874,8 +18881,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" @@ -18910,7 +18917,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 @@ -19191,7 +19198,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 @@ -19348,7 +19355,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: @@ -19358,7 +19365,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 @@ -19392,16 +19399,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 @@ -19420,10 +19427,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) @@ -19504,8 +19511,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 @@ -19534,7 +19541,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) @@ -19650,7 +19657,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 @@ -19676,7 +19683,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 @@ -19724,7 +19731,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 @@ -19855,9 +19862,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 @@ -20062,12 +20069,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. @@ -20136,8 +20143,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 @@ -20442,7 +20449,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 @@ -20478,10 +20485,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 ---------- @@ -20544,7 +20551,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: @@ -20565,7 +20572,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: @@ -20654,7 +20661,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 @@ -20676,9 +20683,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: @@ -20694,7 +20701,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.) @@ -20714,9 +20721,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 @@ -20752,11 +20759,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 @@ -20767,16 +20774,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. @@ -20887,8 +20894,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.) @@ -20900,7 +20907,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: @@ -20908,8 +20915,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 @@ -20940,7 +20947,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 @@ -20965,9 +20972,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: @@ -21049,7 +21056,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: @@ -21067,10 +21074,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"'] @@ -21122,8 +21129,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] @@ -21214,7 +21221,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. @@ -21262,7 +21269,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 @@ -21311,7 +21318,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"'] @@ -21355,8 +21362,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 @@ -21378,7 +21385,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 @@ -21504,39 +21511,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] -| ... -| @@ -21587,10 +21594,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 @@ -21649,7 +21656,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 @@ -21661,7 +21669,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 @@ -21705,17 +21713,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 @@ -21775,37 +21783,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 --------------------------------------------------------------------------- @@ -21813,14 +21821,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 ---------- @@ -21829,7 +21837,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 @@ -21888,7 +21896,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'. @@ -21904,10 +21912,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: @@ -21919,7 +21927,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. @@ -21932,13 +21940,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: @@ -21970,7 +21978,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 @@ -22004,7 +22012,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. @@ -22012,9 +22020,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: @@ -22036,8 +22045,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 @@ -22070,7 +22079,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 @@ -22090,7 +22099,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: @@ -22133,10 +22142,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 @@ -22144,7 +22153,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: @@ -22163,15 +22172,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. @@ -22193,10 +22202,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 @@ -22204,7 +22213,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 @@ -22220,7 +22229,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 @@ -22234,13 +22243,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: @@ -22277,7 +22286,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 @@ -22293,13 +22302,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 @@ -22367,16 +22376,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 @@ -22386,10 +22395,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 @@ -22412,10 +22421,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 @@ -22429,8 +22438,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 }' @@ -22512,12 +22521,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 @@ -22526,9 +22535,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. @@ -22539,10 +22548,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 @@ -22591,11 +22600,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. @@ -22616,7 +22625,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. @@ -22628,7 +22637,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 @@ -22690,8 +22699,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 @@ -22722,7 +22731,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 @@ -22754,7 +22763,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 @@ -22774,7 +22783,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 @@ -22795,7 +22804,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, @@ -22868,17 +22877,19 @@ operations: * Allocating, reallocating, and releasing memory. * Registration functions. You may register: - - extension functions, - - exit callbacks, + - Extension functions + + - Exit callbacks + + - A version string - - a version string, + - Input parsers - - input parsers, + - Output wrappers - - 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. @@ -22910,8 +22921,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 @@ -22950,7 +22961,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 @@ -22971,16 +22982,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 @@ -22989,10 +23000,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 @@ -23017,8 +23028,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. @@ -23059,13 +23070,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 @@ -23073,7 +23084,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. @@ -23085,15 +23096,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. @@ -23131,7 +23141,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 @@ -23168,8 +23178,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. @@ -23207,7 +23217,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)' @@ -23284,7 +23294,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. @@ -23317,7 +23327,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);' @@ -23333,7 +23343,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'. @@ -23347,8 +23357,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. @@ -23421,7 +23432,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: @@ -23459,14 +23470,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 @@ -23480,13 +23491,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 @@ -23611,8 +23622,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 @@ -23743,8 +23754,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. @@ -23804,7 +23815,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 @@ -23814,12 +23825,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 @@ -23900,8 +23911,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 @@ -23912,9 +23923,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,' @@ -23955,7 +23966,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 @@ -24030,7 +24041,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) @@ -24042,8 +24053,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);' @@ -24090,7 +24101,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 @@ -24138,7 +24149,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 @@ -24146,7 +24157,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 @@ -24291,7 +24302,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. @@ -24437,7 +24448,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); @@ -24472,7 +24483,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. @@ -24486,7 +24497,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: @@ -24570,7 +24581,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" @@ -24709,8 +24720,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: */ @@ -24784,9 +24795,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 @@ -24820,7 +24831,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' @@ -24976,7 +24987,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> @@ -25013,7 +25024,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 */ @@ -25031,11 +25042,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); @@ -25216,7 +25227,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 */ @@ -25322,7 +25333,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 @@ -25334,7 +25345,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" @@ -25395,21 +25406,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: @@ -25433,11 +25444,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. @@ -25445,13 +25456,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. @@ -25494,9 +25505,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 @@ -25540,7 +25551,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 @@ -25550,7 +25561,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: @@ -25573,10 +25584,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()'. @@ -25592,8 +25603,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. @@ -25604,7 +25615,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()' @@ -25615,11 +25626,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: @@ -25633,7 +25645,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()' -------------------------------------------------------------------------- @@ -25655,10 +25667,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. @@ -25741,7 +25753,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. @@ -25794,7 +25806,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'. @@ -25819,7 +25831,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: @@ -25840,9 +25852,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" @@ -25859,7 +25871,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 @@ -25882,15 +25894,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. @@ -25906,7 +25918,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 @@ -25950,7 +25962,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 @@ -25992,17 +26004,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 @@ -26042,8 +26054,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 @@ -26052,7 +26064,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 @@ -26078,31 +26090,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. @@ -26161,7 +26173,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 @@ -26343,7 +26355,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::). @@ -26385,7 +26397,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: @@ -26411,7 +26423,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::). @@ -26436,7 +26448,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': @@ -26909,7 +26921,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 @@ -26927,7 +26939,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 @@ -26945,7 +26957,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.) @@ -26956,9 +26968,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. @@ -26973,7 +26985,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 @@ -26986,9 +26998,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, @@ -27005,7 +27017,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) @@ -27136,7 +27148,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. @@ -27150,8 +27162,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::. @@ -27190,7 +27202,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 @@ -27224,8 +27236,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: @@ -27271,7 +27283,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. @@ -27287,9 +27299,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 - @@ -27367,7 +27379,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' @@ -27499,7 +27511,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 @@ -27516,7 +27528,7 @@ configure `gawk' for your system yourself. File: gawk.info, Node: Quick Installation, Next: Shell Startup Files, 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 @@ -27559,8 +27571,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', @@ -27644,7 +27655,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 @@ -27678,15 +27689,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 @@ -27722,8 +27733,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: @@ -27852,8 +27863,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 @@ -28006,7 +28017,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 @@ -28074,7 +28085,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 @@ -28086,7 +28097,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 @@ -28202,12 +28213,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. @@ -28283,17 +28293,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 @@ -28304,48 +28314,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: @@ -28356,8 +28364,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 @@ -28375,7 +28383,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: @@ -28392,10 +28400,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. @@ -28403,6 +28411,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::), @@ -28464,8 +28476,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 @@ -28481,7 +28493,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 @@ -28490,7 +28502,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' @@ -28503,9 +28515,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. @@ -28674,9 +28687,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. @@ -31409,7 +31421,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) @@ -31459,23 +31471,23 @@ Index * --non-decimal-data option: Options. (line 211) * --non-decimal-data option, strtonum() function and: Nondecimal Data. (line 35) -* --optimize option: Options. (line 237) +* --optimize option: Options. (line 236) * --posix option: Options. (line 254) * --posix option, --traditional option and: Options. (line 273) -* --pretty-print option: Options. (line 226) +* --pretty-print option: Options. (line 225) * --profile option <1>: Profiling. (line 12) * --profile option: Options. (line 242) * --re-interval option: Options. (line 279) * --sandbox option: Options. (line 286) * --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 273) -* --use-lc-numeric option: Options. (line 221) +* --use-lc-numeric option: Options. (line 220) * --version option: Options. (line 300) * --with-whiny-user-strftime configuration option: Additional Configuration Options. (line 35) @@ -31500,10 +31512,10 @@ Index * -L option: Options. (line 295) * -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 237) -* -o option: Options. (line 226) +* -O option: Options. (line 236) +* -o option: Options. (line 225) * -P option: Options. (line 254) * -p option: Options. (line 242) * -r option: Options. (line 279) @@ -31614,7 +31626,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 121) + (line 108) * \ (backslash), in regexp constants: Computed Regexps. (line 29) * \ (backslash), in shell commands: Quoting. (line 48) * \ (backslash), regexp operator: Regexp Operators. (line 18) @@ -31646,14 +31658,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) @@ -31683,7 +31695,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. @@ -31705,13 +31717,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) @@ -31721,7 +31733,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) @@ -31747,12 +31759,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) @@ -31770,7 +31782,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) @@ -31831,7 +31843,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) @@ -31883,12 +31895,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 121) + (line 108) * 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) @@ -31905,7 +31917,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) @@ -31974,10 +31986,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) @@ -31988,8 +32000,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 125) + (line 82) +* Brian Kernighan's awk <13>: Escape Sequences. (line 112) * 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) @@ -31999,12 +32011,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) @@ -32012,12 +32024,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) @@ -32030,7 +32042,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) @@ -32066,7 +32078,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) @@ -32110,7 +32122,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) @@ -32159,9 +32171,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) @@ -32208,7 +32220,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) @@ -32216,34 +32228,33 @@ Index * dark corner, escape sequences, for metacharacters: Escape Sequences. (line 143) * 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 98) * dark corner, FILENAME variable: Getline Notes. (line 19) -* dark corner, FNR/NR variables: Auto-set. (line 321) +* dark corner, FNR/NR variables: Auto-set. (line 322) * 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) @@ -32373,7 +32384,7 @@ Index * decimal point character, locale specific: Options. (line 270) * 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) @@ -32387,7 +32398,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) @@ -32414,7 +32425,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 123) +* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 124) * differences in awk and gawk, function arguments (gawk): Calling Built-in. (line 16) * differences in awk and gawk, getline command: Getline. (line 19) @@ -32434,10 +32445,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 137) +* differences in awk and gawk, PROCINFO array: Auto-set. (line 138) * differences in awk and gawk, read timeouts: Read Timeout. (line 6) * differences in awk and gawk, record separators: awk split records. (line 125) @@ -32447,15 +32458,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 272) +* differences in awk and gawk, RT variable: Auto-set. (line 273) * 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 276) +* differences in awk and gawk, SYMTAB variable: Auto-set. (line 277) * differences in awk and gawk, TEXTDOMAIN variable: User-modified. (line 151) * differences in awk and gawk, trunc-mod operation: Arithmetic Ops. @@ -32496,8 +32507,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 142) -* effective user ID of gawk user: Auto-set. (line 146) +* effective group ID of gawk user: Auto-set. (line 143) +* effective user ID of gawk user: Auto-set. (line 147) * egrep utility <1>: Egrep Program. (line 6) * egrep utility: Bracket Expressions. (line 26) * egrep.awk program: Egrep Program. (line 54) @@ -32555,7 +32566,7 @@ Index * ERRNO variable: Auto-set. (line 82) * 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 82) @@ -32588,7 +32599,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 33) @@ -32612,7 +32623,7 @@ Index (line 6) * extension API version: Extension Versioning. (line 6) -* extension API, version number: Auto-set. (line 239) +* extension API, version number: Auto-set. (line 240) * extension example: Extension Example. (line 6) * extension registration: Registration Functions. (line 6) @@ -32633,7 +32644,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) @@ -32661,8 +32672,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) @@ -32688,7 +32698,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) @@ -32748,23 +32758,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 107) +* FNR variable <1>: Auto-set. (line 108) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 321) +* FNR variable, changing: Auto-set. (line 322) * for statement: For Statement. (line 6) * for statement, looping over arrays: Scanning an Array. (line 20) * fork() extension function: Extension Sample Fork. @@ -32778,7 +32788,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) @@ -32788,7 +32798,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) @@ -32814,14 +32824,14 @@ Index * FSF (Free Software Foundation): Manual History. (line 6) * fts() extension function: Extension Sample File Functions. (line 61) -* FUNCTAB array: Auto-set. (line 123) +* FUNCTAB array: Auto-set. (line 124) * 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) @@ -32852,7 +32862,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) @@ -32864,14 +32874,14 @@ Index * G-d: Acknowledgments. (line 94) * Garfinkle, Scott: Contributors. (line 34) * gawk program, dynamic profiling: Profiling. (line 178) -* gawk version: Auto-set. (line 214) +* gawk version: Auto-set. (line 215) * 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. @@ -32885,26 +32895,26 @@ Index * gawk, ERRNO variable in <2>: Auto-set. (line 82) * 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 133) +* gawk, escape sequences: Escape Sequences. (line 120) * gawk, extensions, disabling: Options. (line 254) * 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 123) + (line 26) +* gawk, FUNCTAB array in: Auto-set. (line 124) * 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) @@ -32931,7 +32941,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 137) +* gawk, PROCINFO array in: Auto-set. (line 138) * gawk, regexp constants and: Using Constant Regexps. (line 28) * gawk, regular expressions, case sensitivity: Case-sensitivity. @@ -32939,14 +32949,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 272) +* gawk, RT variable in <1>: Auto-set. (line 273) * 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 276) +* gawk, SYMTAB array in: Auto-set. (line 277) * gawk, TEXTDOMAIN variable in: User-modified. (line 151) * gawk, timestamps: Time Functions. (line 6) * gawk, uses for: Preface. (line 34) @@ -32965,7 +32975,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) @@ -33010,7 +33020,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) @@ -33038,12 +33048,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 187) +* group ID of gawk user: Auto-set. (line 188) * 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) @@ -33085,8 +33095,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) @@ -33103,7 +33113,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) @@ -33122,7 +33132,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) @@ -33146,7 +33156,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. @@ -33167,7 +33177,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) @@ -33175,9 +33185,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) @@ -33223,12 +33233,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. @@ -33270,7 +33280,7 @@ Index * lint checking, POSIXLY_CORRECT environment variable: Options. (line 339) * 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) @@ -33289,9 +33299,9 @@ Index * localization: I18N and L10N. (line 6) * localization, See internationalization, localization: I18N and L10N. (line 6) -* log: Numeric Functions. (line 45) +* log: Numeric Functions. (line 43) * log files, timestamps in: Time Functions. (line 6) -* logarithm: Numeric Functions. (line 45) +* logarithm: Numeric Functions. (line 43) * logical false/true: Truth Values. (line 6) * logical operators, See Boolean expressions: Boolean Ops. (line 6) * login information: Passwd Functions. (line 16) @@ -33312,7 +33322,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) @@ -33320,20 +33330,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 133) -* maximum precision supported by MPFR library: Auto-set. (line 228) +* mawk utility: Escape Sequences. (line 120) +* maximum precision supported by MPFR library: Auto-set. (line 229) * McIlroy, Doug: Glossary. (line 149) * McPhee, Patrick: Contributors. (line 100) * message object files: Explaining gettext. (line 42) @@ -33346,7 +33356,7 @@ Index * messages from extensions: Printing Messages. (line 6) * metacharacters in regular expressions: Regexp Operators. (line 6) * metacharacters, escape sequences for: Escape Sequences. (line 139) -* minimum precision supported by MPFR library: Auto-set. (line 231) +* minimum precision supported by MPFR library: Auto-set. (line 232) * mktime: Time Functions. (line 25) * modifiers, in format specifiers: Format Modifiers. (line 6) * monetary information, localization: Explaining gettext. (line 104) @@ -33395,7 +33405,7 @@ Index (line 47) * nexti debugger command: Debugger Execution Control. (line 49) -* NF variable <1>: Auto-set. (line 112) +* NF variable <1>: Auto-set. (line 113) * NF variable: Fields. (line 33) * NF variable, decrementing: Changing Fields. (line 107) * ni debugger command (alias for nexti): Debugger Execution Control. @@ -33404,9 +33414,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 132) +* NR variable <1>: Auto-set. (line 133) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 321) +* NR variable, changing: Auto-set. (line 322) * null strings <1>: Basic Data Typing. (line 26) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. @@ -33418,9 +33428,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) @@ -33451,7 +33461,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. @@ -33501,10 +33511,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) @@ -33515,16 +33525,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 196) +* parent process ID of gawk process: Auto-set. (line 197) * 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) @@ -33536,8 +33546,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) @@ -33551,7 +33561,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) @@ -33569,7 +33579,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 121) + (line 108) * portability, close() function and: Close Files And Pipes. (line 81) * portability, data files as single record: gawk split records. @@ -33580,15 +33590,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 359) -* 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. @@ -33608,7 +33618,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 121) + (line 108) * 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. @@ -33618,13 +33628,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) @@ -33687,24 +33696,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 190) -* process ID of gawk process: Auto-set. (line 193) +* process group idIDof gawk process: Auto-set. (line 191) +* process ID of gawk process: Auto-set. (line 194) * 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 137) +* PROCINFO array: Auto-set. (line 138) * 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 249) +* PROCINFO array, uses: Auto-set. (line 250) * PROCINFO, values of sorted_in: Controlling Scanning. (line 26) * profiling awk programs: Profiling. (line 6) * profiling awk programs, dynamically: Profiling. (line 178) -* program identifiers: Auto-set. (line 155) +* program identifiers: Auto-set. (line 156) * program, definition of: Getting Started. (line 21) * programming conventions, --non-decimal-data option: Nondecimal Data. (line 35) @@ -33730,13 +33739,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 213) @@ -33748,12 +33757,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 50) +* rand: Numeric Functions. (line 48) * random numbers, Cliff: Cliff Random Function. (line 6) * random numbers, rand()/srand() functions: Numeric Functions. - (line 50) -* random numbers, seed of: Numeric Functions. (line 80) + (line 48) +* random numbers, seed of: Numeric Functions. (line 78) * range expressions (regexps): Bracket Expressions. (line 6) * range patterns: Ranges. (line 6) * range patterns, line continuation and: Ranges. (line 65) @@ -33838,12 +33847,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) @@ -33862,10 +33871,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 259) -* RLENGTH variable, match() function and: String Functions. (line 227) +* RLENGTH variable: Auto-set. (line 260) +* 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) @@ -33888,9 +33897,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 265) -* RSTART variable, match() function and: String Functions. (line 227) -* RT variable <1>: Auto-set. (line 272) +* RSTART variable: Auto-set. (line 266) +* RSTART variable, match() function and: String Functions. (line 228) +* RT variable <1>: Auto-set. (line 273) * RT variable <2>: Multiple Line. (line 129) * RT variable: awk split records. (line 125) * Rubin, Paul <1>: Contributors. (line 15) @@ -33910,17 +33919,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 304) +* Schorr, Andrew <2>: Auto-set. (line 305) * 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) @@ -33928,9 +33937,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 80) +* sed utility: Full Line Fields. (line 22) +* seeding random number generator: Numeric Functions. (line 78) * semicolon (;), AWKPATH variable and: PC Using. (line 10) * semicolon (;), separating statements in actions <1>: Statements. (line 10) @@ -33991,26 +33999,26 @@ Index * sidebar, A Constant's Base Does Not Affect Its Value: Nondecimal-numbers. (line 64) * sidebar, Backslash Before Regular Characters: Escape Sequences. - (line 119) -* sidebar, Changing FS Does Not Affect the Fields: Field Splitting Summary. - (line 38) -* sidebar, Changing NR and FNR: Auto-set. (line 319) + (line 106) +* sidebar, Changing FS Does Not Affect the Fields: Full Line Fields. + (line 14) +* sidebar, Changing NR and FNR: Auto-set. (line 320) * sidebar, Controlling Output Buffering with system(): I/O Functions. - (line 137) + (line 138) * sidebar, Escape Sequences for Metacharacters: Escape Sequences. (line 137) * 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) @@ -34019,7 +34027,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 210) * SIGINT signal (MS-Windows): Profiling. (line 213) * signals, HUP/SIGHUP, for profiling: Profiling. (line 210) @@ -34031,8 +34039,8 @@ Index * SIGUSR1 signal, for dynamic profiling: Profiling. (line 187) * silent debugger command: Debugger Execution Control. (line 10) -* sin: Numeric Functions. (line 91) -* sine: Numeric Functions. (line 91) +* sin: Numeric Functions. (line 89) +* sine: Numeric Functions. (line 89) * single quote ('): One-shot. (line 15) * single quote (') in gawk command lines: Long. (line 35) * single quote ('), in shell commands: Quoting. (line 48) @@ -34046,46 +34054,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 94) +* sqrt: Numeric Functions. (line 92) * square brackets ([]), regexp operator: Regexp Operators. (line 56) -* square root: Numeric Functions. (line 94) -* srand: Numeric Functions. (line 98) +* square root: Numeric Functions. (line 92) +* srand: Numeric Functions. (line 96) * stack frame: Debugging Terms. (line 10) * Stallman, Richard <1>: Glossary. (line 296) * Stallman, Richard <2>: Contributors. (line 23) @@ -34108,23 +34116,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) @@ -34134,13 +34141,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) @@ -34153,16 +34160,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 244) +* 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 245) * switch statement: Switch Statement. (line 6) -* SYMTAB array: Auto-set. (line 276) +* SYMTAB array: Auto-set. (line 277) * 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) @@ -34176,7 +34183,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) @@ -34212,8 +34219,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) @@ -34226,10 +34233,10 @@ Index (line 37) * troubleshooting, awk uses FS not IFS: Field Separators. (line 30) * troubleshooting, backslash before nonspecial character: Escape Sequences. - (line 121) + (line 108) * 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) @@ -34239,8 +34246,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) @@ -34249,8 +34256,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) @@ -34265,7 +34272,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) @@ -34282,9 +34289,9 @@ Index * uniq.awk program: Uniq Program. (line 65) * Unix: Glossary. (line 611) * Unix awk, backslashes in escape sequences: Escape Sequences. - (line 133) + (line 120) * 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) @@ -34336,10 +34343,10 @@ Index * variables, uninitialized, as array subscripts: Uninitialized Subscripts. (line 6) * variables, user-defined: Variables. (line 6) -* version of gawk: Auto-set. (line 214) -* version of gawk extension API: Auto-set. (line 239) -* version of GNU MP library: Auto-set. (line 225) -* version of GNU MPFR library: Auto-set. (line 221) +* version of gawk: Auto-set. (line 215) +* version of gawk extension API: Auto-set. (line 240) +* version of GNU MP library: Auto-set. (line 226) +* version of GNU MPFR library: Auto-set. (line 222) * vertical bar (|): Regexp Operators. (line 70) * vertical bar (|), | operator (I/O) <1>: Precedence. (line 65) * vertical bar (|), | operator (I/O): Getline/Pipe. (line 9) @@ -34351,7 +34358,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. @@ -34396,7 +34403,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) @@ -34413,7 +34420,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) @@ -34430,558 +34437,558 @@ Index Tag Table: Node: Top1204 Node: Foreword342225 -Node: Foreword446617 -Node: Preface48051 -Ref: Preface-Footnote-150922 -Ref: Preface-Footnote-251029 -Ref: Preface-Footnote-351262 -Node: History51404 -Node: Names53752 -Ref: Names-Footnote-154846 -Node: This Manual54992 -Ref: This Manual-Footnote-160821 -Node: Conventions60921 -Node: Manual History63261 -Ref: Manual History-Footnote-166252 -Ref: Manual History-Footnote-266293 -Node: How To Contribute66367 -Node: Acknowledgments67498 -Node: Getting Started72306 -Node: Running gawk74740 -Node: One-shot75930 -Node: Read Terminal77155 -Node: Long79182 -Node: Executable Scripts80698 -Ref: Executable Scripts-Footnote-183487 -Node: Comments83589 -Node: Quoting86062 -Node: DOS Quoting91568 -Node: Sample Data Files92243 -Node: Very Simple94836 -Node: Two Rules99727 -Node: More Complex101613 -Node: Statements/Lines104475 -Ref: Statements/Lines-Footnote-1108931 -Node: Other Features109196 -Node: When110127 -Ref: When-Footnote-1111883 -Node: Intro Summary111948 -Node: Invoking Gawk112831 -Node: Command Line114346 -Node: Options115137 -Ref: Options-Footnote-1130920 -Node: Other Arguments130945 -Node: Naming Standard Input133906 -Node: Environment Variables134999 -Node: AWKPATH Variable135557 -Ref: AWKPATH Variable-Footnote-1138967 -Ref: AWKPATH Variable-Footnote-2139012 -Node: AWKLIBPATH Variable139272 -Node: Other Environment Variables140528 -Node: Exit Status144019 -Node: Include Files144694 -Node: Loading Shared Libraries148282 -Node: Obsolete149709 -Node: Undocumented150406 -Node: Invoking Summary150673 -Node: Regexp152339 -Node: Regexp Usage153798 -Node: Escape Sequences155831 -Node: Regexp Operators162079 -Ref: Regexp Operators-Footnote-1169513 -Ref: Regexp Operators-Footnote-2169660 -Node: Bracket Expressions169758 -Ref: table-char-classes171775 -Node: Leftmost Longest174715 -Node: Computed Regexps176017 -Node: GNU Regexp Operators179414 -Node: Case-sensitivity183116 -Ref: Case-sensitivity-Footnote-1186006 -Ref: Case-sensitivity-Footnote-2186241 -Node: Regexp Summary186349 -Node: Reading Files187818 -Node: Records189912 -Node: awk split records190644 -Node: gawk split records195558 -Ref: gawk split records-Footnote-1200097 -Node: Fields200134 -Ref: Fields-Footnote-1202932 -Node: Nonconstant Fields203018 -Ref: Nonconstant Fields-Footnote-1205254 -Node: Changing Fields205456 -Node: Field Separators211388 -Node: Default Field Splitting214092 -Node: Regexp Field Splitting215209 -Node: Single Character Fields218559 -Node: Command Line Field Separator219618 -Node: Full Line Fields222830 -Ref: Full Line Fields-Footnote-1223338 -Node: Field Splitting Summary223384 -Ref: Field Splitting Summary-Footnote-1226515 -Node: Constant Size226616 -Node: Splitting By Content231222 -Ref: Splitting By Content-Footnote-1235295 -Node: Multiple Line235335 -Ref: Multiple Line-Footnote-1241224 -Node: Getline241403 -Node: Plain Getline243614 -Node: Getline/Variable246254 -Node: Getline/File247401 -Node: Getline/Variable/File248785 -Ref: Getline/Variable/File-Footnote-1250386 -Node: Getline/Pipe250473 -Node: Getline/Variable/Pipe253156 -Node: Getline/Coprocess254287 -Node: Getline/Variable/Coprocess255539 -Node: Getline Notes256278 -Node: Getline Summary259070 -Ref: table-getline-variants259482 -Node: Read Timeout260311 -Ref: Read Timeout-Footnote-1264125 -Node: Command-line directories264183 -Node: Input Summary265087 -Node: Input Exercises268339 -Node: Printing269067 -Node: Print270844 -Node: Print Examples272301 -Node: Output Separators275080 -Node: OFMT277098 -Node: Printf278452 -Node: Basic Printf279237 -Node: Control Letters280808 -Node: Format Modifiers284792 -Node: Printf Examples290799 -Node: Redirection293281 -Node: Special FD300120 -Ref: Special FD-Footnote-1303277 -Node: Special Files303351 -Node: Other Inherited Files303967 -Node: Special Network304967 -Node: Special Caveats305828 -Node: Close Files And Pipes306779 -Ref: Close Files And Pipes-Footnote-1313958 -Ref: Close Files And Pipes-Footnote-2314106 -Node: Output Summary314256 -Node: Output Exercises315252 -Node: Expressions315932 -Node: Values317117 -Node: Constants317793 -Node: Scalar Constants318473 -Ref: Scalar Constants-Footnote-1319332 -Node: Nondecimal-numbers319582 -Node: Regexp Constants322582 -Node: Using Constant Regexps323107 -Node: Variables326245 -Node: Using Variables326900 -Node: Assignment Options328810 -Node: Conversion330685 -Node: Strings And Numbers331209 -Ref: Strings And Numbers-Footnote-1334273 -Node: Locale influences conversions334382 -Ref: table-locale-affects337127 -Node: All Operators337715 -Node: Arithmetic Ops338345 -Node: Concatenation340850 -Ref: Concatenation-Footnote-1343669 -Node: Assignment Ops343775 -Ref: table-assign-ops348758 -Node: Increment Ops350036 -Node: Truth Values and Conditions353474 -Node: Truth Values354557 -Node: Typing and Comparison355606 -Node: Variable Typing356399 -Node: Comparison Operators360051 -Ref: table-relational-ops360461 -Node: POSIX String Comparison363976 -Ref: POSIX String Comparison-Footnote-1365048 -Node: Boolean Ops365186 -Ref: Boolean Ops-Footnote-1369665 -Node: Conditional Exp369756 -Node: Function Calls371483 -Node: Precedence375363 -Node: Locales379031 -Node: Expressions Summary380662 -Node: Patterns and Actions383236 -Node: Pattern Overview384356 -Node: Regexp Patterns386035 -Node: Expression Patterns386578 -Node: Ranges390358 -Node: BEGIN/END393464 -Node: Using BEGIN/END394226 -Ref: Using BEGIN/END-Footnote-1396963 -Node: I/O And BEGIN/END397069 -Node: BEGINFILE/ENDFILE399383 -Node: Empty402284 -Node: Using Shell Variables402601 -Node: Action Overview404877 -Node: Statements407204 -Node: If Statement409052 -Node: While Statement410550 -Node: Do Statement412578 -Node: For Statement413720 -Node: Switch Statement416875 -Node: Break Statement419263 -Node: Continue Statement421304 -Node: Next Statement423129 -Node: Nextfile Statement425509 -Node: Exit Statement428139 -Node: Built-in Variables430542 -Node: User-modified431675 -Ref: User-modified-Footnote-1439355 -Node: Auto-set439417 -Ref: Auto-set-Footnote-1452784 -Ref: Auto-set-Footnote-2452989 -Node: ARGC and ARGV453045 -Node: Pattern Action Summary457249 -Node: Arrays459676 -Node: Array Basics461005 -Node: Array Intro461849 -Ref: figure-array-elements463813 -Ref: Array Intro-Footnote-1466337 -Node: Reference to Elements466465 -Node: Assigning Elements468915 -Node: Array Example469406 -Node: Scanning an Array471164 -Node: Controlling Scanning474180 -Ref: Controlling Scanning-Footnote-1479369 -Node: Numeric Array Subscripts479685 -Node: Uninitialized Subscripts481870 -Node: Delete483487 -Ref: Delete-Footnote-1486231 -Node: Multidimensional486288 -Node: Multiscanning489383 -Node: Arrays of Arrays490972 -Node: Arrays Summary495733 -Node: Functions497838 -Node: Built-in498711 -Node: Calling Built-in499789 -Node: Numeric Functions501777 -Ref: Numeric Functions-Footnote-1506601 -Ref: Numeric Functions-Footnote-2506958 -Ref: Numeric Functions-Footnote-3507006 -Node: String Functions507275 -Ref: String Functions-Footnote-1530747 -Ref: String Functions-Footnote-2530876 -Ref: String Functions-Footnote-3531124 -Node: Gory Details531211 -Ref: table-sub-escapes532992 -Ref: table-sub-proposed534512 -Ref: table-posix-sub535876 -Ref: table-gensub-escapes537416 -Ref: Gory Details-Footnote-1538248 -Node: I/O Functions538399 -Ref: I/O Functions-Footnote-1545500 -Node: Time Functions545647 -Ref: Time Functions-Footnote-1556116 -Ref: Time Functions-Footnote-2556184 -Ref: Time Functions-Footnote-3556342 -Ref: Time Functions-Footnote-4556453 -Ref: Time Functions-Footnote-5556565 -Ref: Time Functions-Footnote-6556792 -Node: Bitwise Functions557058 -Ref: table-bitwise-ops557620 -Ref: Bitwise Functions-Footnote-1561928 -Node: Type Functions562097 -Node: I18N Functions563246 -Node: User-defined564891 -Node: Definition Syntax565695 -Ref: Definition Syntax-Footnote-1571101 -Node: Function Example571170 -Ref: Function Example-Footnote-1574087 -Node: Function Caveats574109 -Node: Calling A Function574627 -Node: Variable Scope575582 -Node: Pass By Value/Reference578570 -Node: Return Statement582080 -Node: Dynamic Typing585064 -Node: Indirect Calls585993 -Ref: Indirect Calls-Footnote-1597297 -Node: Functions Summary597425 -Node: Library Functions600124 -Ref: Library Functions-Footnote-1603742 -Ref: Library Functions-Footnote-2603885 -Node: Library Names604056 -Ref: Library Names-Footnote-1607516 -Ref: Library Names-Footnote-2607736 -Node: General Functions607822 -Node: Strtonum Function608925 -Node: Assert Function611945 -Node: Round Function615269 -Node: Cliff Random Function616810 -Node: Ordinal Functions617826 -Ref: Ordinal Functions-Footnote-1620891 -Ref: Ordinal Functions-Footnote-2621143 -Node: Join Function621354 -Ref: Join Function-Footnote-1623125 -Node: Getlocaltime Function623325 -Node: Readfile Function627066 -Node: Shell Quoting629036 -Node: Data File Management630437 -Node: Filetrans Function631069 -Node: Rewind Function635128 -Node: File Checking636513 -Ref: File Checking-Footnote-1637841 -Node: Empty Files638042 -Node: Ignoring Assigns640021 -Node: Getopt Function641572 -Ref: Getopt Function-Footnote-1653032 -Node: Passwd Functions653235 -Ref: Passwd Functions-Footnote-1662086 -Node: Group Functions662174 -Ref: Group Functions-Footnote-1670077 -Node: Walking Arrays670290 -Node: Library Functions Summary671893 -Node: Library Exercises673294 -Node: Sample Programs674574 -Node: Running Examples675344 -Node: Clones676072 -Node: Cut Program677296 -Node: Egrep Program687026 -Ref: Egrep Program-Footnote-1694530 -Node: Id Program694640 -Node: Split Program698284 -Ref: Split Program-Footnote-1701730 -Node: Tee Program701858 -Node: Uniq Program704645 -Node: Wc Program712066 -Ref: Wc Program-Footnote-1716314 -Node: Miscellaneous Programs716406 -Node: Dupword Program717619 -Node: Alarm Program719650 -Node: Translate Program724454 -Ref: Translate Program-Footnote-1729018 -Node: Labels Program729288 -Ref: Labels Program-Footnote-1732637 -Node: Word Sorting732721 -Node: History Sorting736791 -Node: Extract Program738627 -Node: Simple Sed746159 -Node: Igawk Program749221 -Ref: Igawk Program-Footnote-1763547 -Ref: Igawk Program-Footnote-2763748 -Ref: Igawk Program-Footnote-3763870 -Node: Anagram Program763985 -Node: Signature Program767047 -Node: Programs Summary768294 -Node: Programs Exercises769487 -Ref: Programs Exercises-Footnote-1773618 -Node: Advanced Features773709 -Node: Nondecimal Data775657 -Node: Array Sorting777247 -Node: Controlling Array Traversal777944 -Ref: Controlling Array Traversal-Footnote-1786275 -Node: Array Sorting Functions786393 -Ref: Array Sorting Functions-Footnote-1790285 -Node: Two-way I/O790479 -Ref: Two-way I/O-Footnote-1795423 -Ref: Two-way I/O-Footnote-2795609 -Node: TCP/IP Networking795691 -Node: Profiling798563 -Node: Advanced Features Summary806837 -Node: Internationalization808770 -Node: I18N and L10N810250 -Node: Explaining gettext810936 -Ref: Explaining gettext-Footnote-1815965 -Ref: Explaining gettext-Footnote-2816149 -Node: Programmer i18n816314 -Ref: Programmer i18n-Footnote-1821180 -Node: Translator i18n821229 -Node: String Extraction822023 -Ref: String Extraction-Footnote-1823154 -Node: Printf Ordering823240 -Ref: Printf Ordering-Footnote-1826026 -Node: I18N Portability826090 -Ref: I18N Portability-Footnote-1828539 -Node: I18N Example828602 -Ref: I18N Example-Footnote-1831402 -Node: Gawk I18N831474 -Node: I18N Summary832112 -Node: Debugger833451 -Node: Debugging834473 -Node: Debugging Concepts834914 -Node: Debugging Terms836771 -Node: Awk Debugging839346 -Node: Sample Debugging Session840238 -Node: Debugger Invocation840758 -Node: Finding The Bug842142 -Node: List of Debugger Commands848617 -Node: Breakpoint Control849949 -Node: Debugger Execution Control853641 -Node: Viewing And Changing Data857005 -Node: Execution Stack860370 -Node: Debugger Info862008 -Node: Miscellaneous Debugger Commands866025 -Node: Readline Support871217 -Node: Limitations872109 -Node: Debugging Summary874206 -Node: Arbitrary Precision Arithmetic875374 -Node: Computer Arithmetic876790 -Ref: table-numeric-ranges880391 -Ref: Computer Arithmetic-Footnote-1881250 -Node: Math Definitions881307 -Ref: table-ieee-formats884594 -Ref: Math Definitions-Footnote-1885198 -Node: MPFR features885303 -Node: FP Math Caution886974 -Ref: FP Math Caution-Footnote-1888024 -Node: Inexactness of computations888393 -Node: Inexact representation889341 -Node: Comparing FP Values890696 -Node: Errors accumulate891769 -Node: Getting Accuracy893202 -Node: Try To Round895861 -Node: Setting precision896760 -Ref: table-predefined-precision-strings897444 -Node: Setting the rounding mode899238 -Ref: table-gawk-rounding-modes899602 -Ref: Setting the rounding mode-Footnote-1903056 -Node: Arbitrary Precision Integers903235 -Ref: Arbitrary Precision Integers-Footnote-1908139 -Node: POSIX Floating Point Problems908288 -Ref: POSIX Floating Point Problems-Footnote-1912164 -Node: Floating point summary912202 -Node: Dynamic Extensions914394 -Node: Extension Intro915946 -Node: Plugin License917212 -Node: Extension Mechanism Outline918009 -Ref: figure-load-extension918437 -Ref: figure-register-new-function919917 -Ref: figure-call-new-function920921 -Node: Extension API Description922907 -Node: Extension API Functions Introduction924357 -Node: General Data Types929193 -Ref: General Data Types-Footnote-1934880 -Node: Memory Allocation Functions935179 -Ref: Memory Allocation Functions-Footnote-1938009 -Node: Constructor Functions938105 -Node: Registration Functions939839 -Node: Extension Functions940524 -Node: Exit Callback Functions942820 -Node: Extension Version String944068 -Node: Input Parsers944718 -Node: Output Wrappers954533 -Node: Two-way processors959049 -Node: Printing Messages961253 -Ref: Printing Messages-Footnote-1962330 -Node: Updating `ERRNO'962482 -Node: Requesting Values963222 -Ref: table-value-types-returned963950 -Node: Accessing Parameters964908 -Node: Symbol Table Access966139 -Node: Symbol table by name966653 -Node: Symbol table by cookie968633 -Ref: Symbol table by cookie-Footnote-1972772 -Node: Cached values972835 -Ref: Cached values-Footnote-1976339 -Node: Array Manipulation976430 -Ref: Array Manipulation-Footnote-1977528 -Node: Array Data Types977567 -Ref: Array Data Types-Footnote-1980224 -Node: Array Functions980316 -Node: Flattening Arrays984170 -Node: Creating Arrays991057 -Node: Extension API Variables995824 -Node: Extension Versioning996460 -Node: Extension API Informational Variables998361 -Node: Extension API Boilerplate999449 -Node: Finding Extensions1003265 -Node: Extension Example1003825 -Node: Internal File Description1004597 -Node: Internal File Ops1008664 -Ref: Internal File Ops-Footnote-11020322 -Node: Using Internal File Ops1020462 -Ref: Using Internal File Ops-Footnote-11022845 -Node: Extension Samples1023118 -Node: Extension Sample File Functions1024642 -Node: Extension Sample Fnmatch1032244 -Node: Extension Sample Fork1033726 -Node: Extension Sample Inplace1034939 -Node: Extension Sample Ord1036614 -Node: Extension Sample Readdir1037450 -Ref: table-readdir-file-types1038326 -Node: Extension Sample Revout1039137 -Node: Extension Sample Rev2way1039728 -Node: Extension Sample Read write array1040469 -Node: Extension Sample Readfile1042408 -Node: Extension Sample Time1043503 -Node: Extension Sample API Tests1044852 -Node: gawkextlib1045343 -Node: Extension summary1047993 -Node: Extension Exercises1051675 -Node: Language History1052397 -Node: V7/SVR3.11054054 -Node: SVR41056235 -Node: POSIX1057680 -Node: BTL1059069 -Node: POSIX/GNU1059803 -Node: Feature History1065432 -Node: Common Extensions1078530 -Node: Ranges and Locales1079854 -Ref: Ranges and Locales-Footnote-11084493 -Ref: Ranges and Locales-Footnote-21084520 -Ref: Ranges and Locales-Footnote-31084754 -Node: Contributors1084975 -Node: History summary1090515 -Node: Installation1091884 -Node: Gawk Distribution1092840 -Node: Getting1093324 -Node: Extracting1094148 -Node: Distribution contents1095790 -Node: Unix Installation1101855 -Node: Quick Installation1102538 -Node: Shell Startup Files1104956 -Node: Additional Configuration Options1106035 -Node: Configuration Philosophy1107776 -Node: Non-Unix Installation1110127 -Node: PC Installation1110585 -Node: PC Binary Installation1111911 -Node: PC Compiling1113759 -Ref: PC Compiling-Footnote-11116780 -Node: PC Testing1116885 -Node: PC Using1118061 -Node: Cygwin1122176 -Node: MSYS1122999 -Node: VMS Installation1123497 -Node: VMS Compilation1124289 -Ref: VMS Compilation-Footnote-11125511 -Node: VMS Dynamic Extensions1125569 -Node: VMS Installation Details1127253 -Node: VMS Running1129505 -Node: VMS GNV1132346 -Node: VMS Old Gawk1133080 -Node: Bugs1133550 -Node: Other Versions1137454 -Node: Installation summary1143667 -Node: Notes1144723 -Node: Compatibility Mode1145588 -Node: Additions1146370 -Node: Accessing The Source1147295 -Node: Adding Code1148731 -Node: New Ports1154903 -Node: Derived Files1159385 -Ref: Derived Files-Footnote-11164860 -Ref: Derived Files-Footnote-21164894 -Ref: Derived Files-Footnote-31165490 -Node: Future Extensions1165604 -Node: Implementation Limitations1166210 -Node: Extension Design1167458 -Node: Old Extension Problems1168612 -Ref: Old Extension Problems-Footnote-11170129 -Node: Extension New Mechanism Goals1170186 -Ref: Extension New Mechanism Goals-Footnote-11173546 -Node: Extension Other Design Decisions1173735 -Node: Extension Future Growth1175843 -Node: Old Extension Mechanism1176679 -Node: Notes summary1178441 -Node: Basic Concepts1179627 -Node: Basic High Level1180308 -Ref: figure-general-flow1180580 -Ref: figure-process-flow1181179 -Ref: Basic High Level-Footnote-11184408 -Node: Basic Data Typing1184593 -Node: Glossary1187921 -Node: Copying1213079 -Node: GNU Free Documentation License1250635 -Node: Index1275771 +Node: Foreword446667 +Node: Preface48100 +Ref: Preface-Footnote-150971 +Ref: Preface-Footnote-251078 +Ref: Preface-Footnote-351311 +Node: History51453 +Node: Names53799 +Ref: Names-Footnote-154893 +Node: This Manual55039 +Ref: This Manual-Footnote-161526 +Node: Conventions61626 +Node: Manual History63964 +Ref: Manual History-Footnote-166946 +Ref: Manual History-Footnote-266987 +Node: How To Contribute67061 +Node: Acknowledgments68190 +Node: Getting Started72994 +Node: Running gawk75427 +Node: One-shot76617 +Node: Read Terminal77865 +Node: Long79892 +Node: Executable Scripts81408 +Ref: Executable Scripts-Footnote-184197 +Node: Comments84300 +Node: Quoting86782 +Node: DOS Quoting92306 +Node: Sample Data Files92981 +Node: Very Simple95576 +Node: Two Rules100474 +Node: More Complex102360 +Node: Statements/Lines105222 +Ref: Statements/Lines-Footnote-1109677 +Node: Other Features109942 +Node: When110873 +Ref: When-Footnote-1112627 +Node: Intro Summary112692 +Node: Invoking Gawk113575 +Node: Command Line115089 +Node: Options115887 +Ref: Options-Footnote-1131689 +Node: Other Arguments131714 +Node: Naming Standard Input134662 +Node: Environment Variables135755 +Node: AWKPATH Variable136313 +Ref: AWKPATH Variable-Footnote-1139726 +Ref: AWKPATH Variable-Footnote-2139771 +Node: AWKLIBPATH Variable140031 +Node: Other Environment Variables141287 +Node: Exit Status144775 +Node: Include Files145451 +Node: Loading Shared Libraries149048 +Node: Obsolete150475 +Node: Undocumented151172 +Node: Invoking Summary151439 +Node: Regexp153103 +Node: Regexp Usage154557 +Node: Escape Sequences156594 +Node: Regexp Operators162835 +Ref: Regexp Operators-Footnote-1170261 +Ref: Regexp Operators-Footnote-2170408 +Node: Bracket Expressions170506 +Ref: table-char-classes172521 +Node: Leftmost Longest175445 +Node: Computed Regexps176747 +Node: GNU Regexp Operators180144 +Node: Case-sensitivity183817 +Ref: Case-sensitivity-Footnote-1186702 +Ref: Case-sensitivity-Footnote-2186937 +Node: Regexp Summary187045 +Node: Reading Files188512 +Node: Records190606 +Node: awk split records191339 +Node: gawk split records196254 +Ref: gawk split records-Footnote-1200794 +Node: Fields200831 +Ref: Fields-Footnote-1203607 +Node: Nonconstant Fields203693 +Ref: Nonconstant Fields-Footnote-1205936 +Node: Changing Fields206140 +Node: Field Separators212069 +Node: Default Field Splitting214774 +Node: Regexp Field Splitting215891 +Node: Single Character Fields219241 +Node: Command Line Field Separator220300 +Node: Full Line Fields223512 +Ref: Full Line Fields-Footnote-1225041 +Ref: Full Line Fields-Footnote-2225087 +Node: Field Splitting Summary225188 +Node: Constant Size227262 +Node: Splitting By Content231851 +Ref: Splitting By Content-Footnote-1235906 +Node: Multiple Line235946 +Ref: Multiple Line-Footnote-1241832 +Node: Getline242011 +Node: Plain Getline244223 +Node: Getline/Variable246863 +Node: Getline/File248011 +Node: Getline/Variable/File249395 +Ref: Getline/Variable/File-Footnote-1250998 +Node: Getline/Pipe251085 +Node: Getline/Variable/Pipe253768 +Node: Getline/Coprocess254899 +Node: Getline/Variable/Coprocess256151 +Node: Getline Notes256890 +Node: Getline Summary259682 +Ref: table-getline-variants260094 +Node: Read Timeout260923 +Ref: Read Timeout-Footnote-1264742 +Node: Command-line directories264800 +Node: Input Summary265705 +Node: Input Exercises268958 +Node: Printing269686 +Node: Print271463 +Node: Print Examples272920 +Node: Output Separators275699 +Node: OFMT277717 +Node: Printf279071 +Node: Basic Printf279856 +Node: Control Letters281425 +Node: Format Modifiers285409 +Node: Printf Examples291410 +Node: Redirection293896 +Node: Special FD300737 +Ref: Special FD-Footnote-1303897 +Node: Special Files303971 +Node: Other Inherited Files304588 +Node: Special Network305588 +Node: Special Caveats306450 +Node: Close Files And Pipes307401 +Ref: Close Files And Pipes-Footnote-1314583 +Ref: Close Files And Pipes-Footnote-2314731 +Node: Output Summary314881 +Node: Output Exercises315879 +Node: Expressions316559 +Node: Values317744 +Node: Constants318422 +Node: Scalar Constants319113 +Ref: Scalar Constants-Footnote-1319972 +Node: Nondecimal-numbers320222 +Node: Regexp Constants323240 +Node: Using Constant Regexps323765 +Node: Variables326908 +Node: Using Variables327563 +Node: Assignment Options329474 +Node: Conversion331349 +Node: Strings And Numbers331873 +Ref: Strings And Numbers-Footnote-1334938 +Node: Locale influences conversions335047 +Ref: table-locale-affects337794 +Node: All Operators338382 +Node: Arithmetic Ops339012 +Node: Concatenation341517 +Ref: Concatenation-Footnote-1344336 +Node: Assignment Ops344442 +Ref: table-assign-ops349421 +Node: Increment Ops350693 +Node: Truth Values and Conditions354131 +Node: Truth Values355216 +Node: Typing and Comparison356265 +Node: Variable Typing357075 +Node: Comparison Operators360728 +Ref: table-relational-ops361138 +Node: POSIX String Comparison364633 +Ref: POSIX String Comparison-Footnote-1365705 +Node: Boolean Ops365843 +Ref: Boolean Ops-Footnote-1370322 +Node: Conditional Exp370413 +Node: Function Calls372140 +Node: Precedence376020 +Node: Locales379681 +Node: Expressions Summary381313 +Node: Patterns and Actions383873 +Node: Pattern Overview384993 +Node: Regexp Patterns386672 +Node: Expression Patterns387215 +Node: Ranges390996 +Node: BEGIN/END394102 +Node: Using BEGIN/END394863 +Ref: Using BEGIN/END-Footnote-1397597 +Node: I/O And BEGIN/END397703 +Node: BEGINFILE/ENDFILE400017 +Node: Empty402918 +Node: Using Shell Variables403235 +Node: Action Overview405508 +Node: Statements407834 +Node: If Statement409682 +Node: While Statement411177 +Node: Do Statement413206 +Node: For Statement414350 +Node: Switch Statement417507 +Node: Break Statement419889 +Node: Continue Statement421930 +Node: Next Statement423757 +Node: Nextfile Statement426138 +Node: Exit Statement428768 +Node: Built-in Variables431171 +Node: User-modified432304 +Ref: User-modified-Footnote-1439985 +Node: Auto-set440047 +Ref: Auto-set-Footnote-1453419 +Ref: Auto-set-Footnote-2453624 +Node: ARGC and ARGV453680 +Node: Pattern Action Summary457898 +Node: Arrays460325 +Node: Array Basics461654 +Node: Array Intro462498 +Ref: figure-array-elements464462 +Ref: Array Intro-Footnote-1466988 +Node: Reference to Elements467116 +Node: Assigning Elements469568 +Node: Array Example470059 +Node: Scanning an Array471817 +Node: Controlling Scanning474833 +Ref: Controlling Scanning-Footnote-1480029 +Node: Numeric Array Subscripts480345 +Node: Uninitialized Subscripts482530 +Node: Delete484147 +Ref: Delete-Footnote-1486890 +Node: Multidimensional486947 +Node: Multiscanning490044 +Node: Arrays of Arrays491633 +Node: Arrays Summary496392 +Node: Functions498484 +Node: Built-in499357 +Node: Calling Built-in500435 +Node: Numeric Functions502426 +Ref: Numeric Functions-Footnote-1507245 +Ref: Numeric Functions-Footnote-2507602 +Ref: Numeric Functions-Footnote-3507650 +Node: String Functions507922 +Ref: String Functions-Footnote-1531397 +Ref: String Functions-Footnote-2531526 +Ref: String Functions-Footnote-3531774 +Node: Gory Details531861 +Ref: table-sub-escapes533642 +Ref: table-sub-proposed535162 +Ref: table-posix-sub536526 +Ref: table-gensub-escapes538062 +Ref: Gory Details-Footnote-1538894 +Node: I/O Functions539045 +Ref: I/O Functions-Footnote-1546263 +Node: Time Functions546410 +Ref: Time Functions-Footnote-1556898 +Ref: Time Functions-Footnote-2556966 +Ref: Time Functions-Footnote-3557124 +Ref: Time Functions-Footnote-4557235 +Ref: Time Functions-Footnote-5557347 +Ref: Time Functions-Footnote-6557574 +Node: Bitwise Functions557840 +Ref: table-bitwise-ops558402 +Ref: Bitwise Functions-Footnote-1562711 +Node: Type Functions562880 +Node: I18N Functions564031 +Node: User-defined565676 +Node: Definition Syntax566481 +Ref: Definition Syntax-Footnote-1571888 +Node: Function Example571959 +Ref: Function Example-Footnote-1574878 +Node: Function Caveats574900 +Node: Calling A Function575418 +Node: Variable Scope576376 +Node: Pass By Value/Reference579364 +Node: Return Statement582859 +Node: Dynamic Typing585840 +Node: Indirect Calls586769 +Ref: Indirect Calls-Footnote-1598071 +Node: Functions Summary598199 +Node: Library Functions600901 +Ref: Library Functions-Footnote-1604510 +Ref: Library Functions-Footnote-2604653 +Node: Library Names604824 +Ref: Library Names-Footnote-1608278 +Ref: Library Names-Footnote-2608501 +Node: General Functions608587 +Node: Strtonum Function609690 +Node: Assert Function612712 +Node: Round Function616036 +Node: Cliff Random Function617577 +Node: Ordinal Functions618593 +Ref: Ordinal Functions-Footnote-1621656 +Ref: Ordinal Functions-Footnote-2621908 +Node: Join Function622119 +Ref: Join Function-Footnote-1623888 +Node: Getlocaltime Function624088 +Node: Readfile Function627832 +Node: Shell Quoting629802 +Node: Data File Management631203 +Node: Filetrans Function631835 +Node: Rewind Function635891 +Node: File Checking637278 +Ref: File Checking-Footnote-1638610 +Node: Empty Files638811 +Node: Ignoring Assigns640790 +Node: Getopt Function642341 +Ref: Getopt Function-Footnote-1653803 +Node: Passwd Functions654003 +Ref: Passwd Functions-Footnote-1662852 +Node: Group Functions662940 +Ref: Group Functions-Footnote-1670834 +Node: Walking Arrays671047 +Node: Library Functions Summary672650 +Node: Library Exercises674051 +Node: Sample Programs675331 +Node: Running Examples676101 +Node: Clones676829 +Node: Cut Program678053 +Node: Egrep Program687772 +Ref: Egrep Program-Footnote-1695270 +Node: Id Program695380 +Node: Split Program699025 +Ref: Split Program-Footnote-1702473 +Node: Tee Program702601 +Node: Uniq Program705390 +Node: Wc Program712809 +Ref: Wc Program-Footnote-1717059 +Node: Miscellaneous Programs717153 +Node: Dupword Program718366 +Node: Alarm Program720397 +Node: Translate Program725201 +Ref: Translate Program-Footnote-1729766 +Node: Labels Program730036 +Ref: Labels Program-Footnote-1733387 +Node: Word Sorting733471 +Node: History Sorting737542 +Node: Extract Program739378 +Node: Simple Sed746903 +Node: Igawk Program749971 +Ref: Igawk Program-Footnote-1764295 +Ref: Igawk Program-Footnote-2764496 +Ref: Igawk Program-Footnote-3764618 +Node: Anagram Program764733 +Node: Signature Program767790 +Node: Programs Summary769037 +Node: Programs Exercises770230 +Ref: Programs Exercises-Footnote-1774361 +Node: Advanced Features774452 +Node: Nondecimal Data776400 +Node: Array Sorting777990 +Node: Controlling Array Traversal778687 +Ref: Controlling Array Traversal-Footnote-1787020 +Node: Array Sorting Functions787138 +Ref: Array Sorting Functions-Footnote-1791027 +Node: Two-way I/O791223 +Ref: Two-way I/O-Footnote-1796164 +Ref: Two-way I/O-Footnote-2796350 +Node: TCP/IP Networking796432 +Node: Profiling799305 +Node: Advanced Features Summary807582 +Node: Internationalization809515 +Node: I18N and L10N810995 +Node: Explaining gettext811681 +Ref: Explaining gettext-Footnote-1816706 +Ref: Explaining gettext-Footnote-2816890 +Node: Programmer i18n817055 +Ref: Programmer i18n-Footnote-1821921 +Node: Translator i18n821970 +Node: String Extraction822764 +Ref: String Extraction-Footnote-1823895 +Node: Printf Ordering823981 +Ref: Printf Ordering-Footnote-1826767 +Node: I18N Portability826831 +Ref: I18N Portability-Footnote-1829286 +Node: I18N Example829349 +Ref: I18N Example-Footnote-1832152 +Node: Gawk I18N832224 +Node: I18N Summary832862 +Node: Debugger834201 +Node: Debugging835223 +Node: Debugging Concepts835664 +Node: Debugging Terms837517 +Node: Awk Debugging840089 +Node: Sample Debugging Session840983 +Node: Debugger Invocation841503 +Node: Finding The Bug842887 +Node: List of Debugger Commands849362 +Node: Breakpoint Control850695 +Node: Debugger Execution Control854391 +Node: Viewing And Changing Data857755 +Node: Execution Stack861133 +Node: Debugger Info862770 +Node: Miscellaneous Debugger Commands866787 +Node: Readline Support871816 +Node: Limitations872708 +Node: Debugging Summary874822 +Node: Arbitrary Precision Arithmetic875990 +Node: Computer Arithmetic877406 +Ref: table-numeric-ranges881004 +Ref: Computer Arithmetic-Footnote-1881863 +Node: Math Definitions881920 +Ref: table-ieee-formats885208 +Ref: Math Definitions-Footnote-1885812 +Node: MPFR features885917 +Node: FP Math Caution887588 +Ref: FP Math Caution-Footnote-1888638 +Node: Inexactness of computations889007 +Node: Inexact representation889966 +Node: Comparing FP Values891323 +Node: Errors accumulate892405 +Node: Getting Accuracy893838 +Node: Try To Round896500 +Node: Setting precision897399 +Ref: table-predefined-precision-strings898083 +Node: Setting the rounding mode899872 +Ref: table-gawk-rounding-modes900236 +Ref: Setting the rounding mode-Footnote-1903691 +Node: Arbitrary Precision Integers903870 +Ref: Arbitrary Precision Integers-Footnote-1908769 +Node: POSIX Floating Point Problems908918 +Ref: POSIX Floating Point Problems-Footnote-1912791 +Node: Floating point summary912829 +Node: Dynamic Extensions915023 +Node: Extension Intro916575 +Node: Plugin License917841 +Node: Extension Mechanism Outline918638 +Ref: figure-load-extension919066 +Ref: figure-register-new-function920546 +Ref: figure-call-new-function921550 +Node: Extension API Description923536 +Node: Extension API Functions Introduction924986 +Node: General Data Types929810 +Ref: General Data Types-Footnote-1935549 +Node: Memory Allocation Functions935848 +Ref: Memory Allocation Functions-Footnote-1938687 +Node: Constructor Functions938783 +Node: Registration Functions940517 +Node: Extension Functions941202 +Node: Exit Callback Functions943499 +Node: Extension Version String944747 +Node: Input Parsers945412 +Node: Output Wrappers955289 +Node: Two-way processors959804 +Node: Printing Messages962008 +Ref: Printing Messages-Footnote-1963084 +Node: Updating `ERRNO'963236 +Node: Requesting Values963976 +Ref: table-value-types-returned964704 +Node: Accessing Parameters965661 +Node: Symbol Table Access966892 +Node: Symbol table by name967406 +Node: Symbol table by cookie969387 +Ref: Symbol table by cookie-Footnote-1973531 +Node: Cached values973594 +Ref: Cached values-Footnote-1977093 +Node: Array Manipulation977184 +Ref: Array Manipulation-Footnote-1978282 +Node: Array Data Types978319 +Ref: Array Data Types-Footnote-1980974 +Node: Array Functions981066 +Node: Flattening Arrays984920 +Node: Creating Arrays991812 +Node: Extension API Variables996581 +Node: Extension Versioning997217 +Node: Extension API Informational Variables999118 +Node: Extension API Boilerplate1000206 +Node: Finding Extensions1004015 +Node: Extension Example1004575 +Node: Internal File Description1005347 +Node: Internal File Ops1009414 +Ref: Internal File Ops-Footnote-11021084 +Node: Using Internal File Ops1021224 +Ref: Using Internal File Ops-Footnote-11023607 +Node: Extension Samples1023880 +Node: Extension Sample File Functions1025406 +Node: Extension Sample Fnmatch1033044 +Node: Extension Sample Fork1034535 +Node: Extension Sample Inplace1035750 +Node: Extension Sample Ord1037425 +Node: Extension Sample Readdir1038261 +Ref: table-readdir-file-types1039137 +Node: Extension Sample Revout1039948 +Node: Extension Sample Rev2way1040538 +Node: Extension Sample Read write array1041278 +Node: Extension Sample Readfile1043218 +Node: Extension Sample Time1044313 +Node: Extension Sample API Tests1045662 +Node: gawkextlib1046153 +Node: Extension summary1048790 +Node: Extension Exercises1052467 +Node: Language History1053189 +Node: V7/SVR3.11054845 +Node: SVR41057026 +Node: POSIX1058471 +Node: BTL1059860 +Node: POSIX/GNU1060594 +Node: Feature History1066218 +Node: Common Extensions1079316 +Node: Ranges and Locales1080640 +Ref: Ranges and Locales-Footnote-11085258 +Ref: Ranges and Locales-Footnote-21085285 +Ref: Ranges and Locales-Footnote-31085519 +Node: Contributors1085740 +Node: History summary1091281 +Node: Installation1092651 +Node: Gawk Distribution1093597 +Node: Getting1094081 +Node: Extracting1094904 +Node: Distribution contents1096539 +Node: Unix Installation1102604 +Node: Quick Installation1103287 +Node: Shell Startup Files1105698 +Node: Additional Configuration Options1106777 +Node: Configuration Philosophy1108516 +Node: Non-Unix Installation1110885 +Node: PC Installation1111343 +Node: PC Binary Installation1112662 +Node: PC Compiling1114510 +Ref: PC Compiling-Footnote-11117531 +Node: PC Testing1117640 +Node: PC Using1118816 +Node: Cygwin1122931 +Node: MSYS1123754 +Node: VMS Installation1124254 +Node: VMS Compilation1125046 +Ref: VMS Compilation-Footnote-11126268 +Node: VMS Dynamic Extensions1126326 +Node: VMS Installation Details1128010 +Node: VMS Running1130262 +Node: VMS GNV1133098 +Node: VMS Old Gawk1133832 +Node: Bugs1134302 +Node: Other Versions1138185 +Node: Installation summary1144607 +Node: Notes1145663 +Node: Compatibility Mode1146528 +Node: Additions1147310 +Node: Accessing The Source1148235 +Node: Adding Code1149671 +Node: New Ports1155836 +Node: Derived Files1160318 +Ref: Derived Files-Footnote-11165793 +Ref: Derived Files-Footnote-21165827 +Ref: Derived Files-Footnote-31166423 +Node: Future Extensions1166537 +Node: Implementation Limitations1167143 +Node: Extension Design1168391 +Node: Old Extension Problems1169545 +Ref: Old Extension Problems-Footnote-11171062 +Node: Extension New Mechanism Goals1171119 +Ref: Extension New Mechanism Goals-Footnote-11174479 +Node: Extension Other Design Decisions1174668 +Node: Extension Future Growth1176776 +Node: Old Extension Mechanism1177612 +Node: Notes summary1179374 +Node: Basic Concepts1180560 +Node: Basic High Level1181241 +Ref: figure-general-flow1181513 +Ref: figure-process-flow1182112 +Ref: Basic High Level-Footnote-11185341 +Node: Basic Data Typing1185526 +Node: Glossary1188854 +Node: Copying1214012 +Node: GNU Free Documentation License1251568 +Node: Index1276704 End Tag Table |