diff options
Diffstat (limited to 'doc/gawk.info')
-rw-r--r-- | doc/gawk.info | 4883 |
1 files changed, 2612 insertions, 2271 deletions
diff --git a/doc/gawk.info b/doc/gawk.info index f1aa1f4a..5863ea0f 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -14,7 +14,7 @@ Free Software Foundation, Inc. This is Edition 4.1 of `GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.1.1 (or later) version of the GNU +Guide for GNU Awk', for the 4.1.2 (or later) version of the GNU implementation of AWK. Permission is granted to copy, distribute and/or modify this document @@ -29,7 +29,7 @@ entitled "GNU Free Documentation License". modify this GNU manual." -File: gawk.info, Node: Top, Next: Foreword, Up: (dir) +File: gawk.info, Node: Top, Next: Foreword3, Up: (dir) General Introduction ******************** @@ -42,7 +42,7 @@ Free Software Foundation, Inc. This is Edition 4.1 of `GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.1.1 (or later) version of the GNU +Guide for GNU Awk', for the 4.1.2 (or later) version of the GNU implementation of AWK. Permission is granted to copy, distribute and/or modify this document @@ -58,8 +58,9 @@ entitled "GNU Free Documentation License". * Menu: -* Foreword:: Some nice words about this +* Foreword3:: Some nice words about this Info file. +* Foreword4:: More nice words. * Preface:: What this Info file is about; brief history and acknowledgments. * Getting Started:: A basic introduction to using @@ -189,8 +190,8 @@ entitled "GNU Free Documentation License". * Regexp Field Splitting:: Using regexps as the field separator. * Single Character Fields:: Making each character a separate field. -* Command Line Field Separator:: Setting `FS' from the - command line. +* Command Line Field Separator:: Setting `FS' from the command + line. * Full Line Fields:: Making the full line be a single field. * Field Splitting Summary:: Some final points and a summary table. @@ -234,10 +235,12 @@ entitled "GNU Free Documentation License". * Printf Examples:: Several examples. * Redirection:: How to redirect output to multiple files and pipes. +* Special FD:: Special files for I/O. * Special Files:: File name interpretation in `gawk'. `gawk' allows access to inherited file descriptors. -* Special FD:: Special files for I/O. +* Other Inherited Files:: Accessing other open files with + `gawk'. * Special Network:: Special files for network communications. * Special Caveats:: Things to watch out for. @@ -330,7 +333,7 @@ entitled "GNU Free Documentation License". record. * Nextfile Statement:: Stop processing the current file. * Exit Statement:: Stop execution of `awk'. -* Built-in Variables:: Summarizes the built-in variables. +* Built-in Variables:: Summarizes the predefined variables. * User-modified:: Built-in variables that you change to control `awk'. * Auto-set:: Built-in variables where `awk' @@ -350,12 +353,12 @@ entitled "GNU Free Documentation License". elements. * Controlling Scanning:: Controlling the order in which arrays are scanned. -* Delete:: The `delete' statement removes an - element from an array. * Numeric Array Subscripts:: How to use numbers as subscripts in `awk'. * Uninitialized Subscripts:: Using Uninitialized variables as subscripts. +* Delete:: The `delete' statement removes an + element from an array. * Multidimensional:: Emulating multidimensional arrays in `awk'. * Multiscanning:: Scanning multidimensional arrays. @@ -414,6 +417,8 @@ entitled "GNU Free Documentation License". * Getlocaltime Function:: A function to get formatted times. * Readfile Function:: A function to read an entire file at once. +* Shell Quoting:: A function to quote strings for the + shell. * Data File Management:: Functions for managing command-line data files. * Filetrans Function:: A function for handling data file @@ -528,7 +533,6 @@ entitled "GNU Free Documentation License". * Extension API Description:: A full description of the API. * Extension API Functions Introduction:: Introduction to the API functions. * General Data Types:: The data types. -* Requesting Values:: How to get a value. * Memory Allocation Functions:: Functions for allocating memory. * Constructor Functions:: Functions for creating values. * Registration Functions:: Functions to register things with @@ -541,6 +545,7 @@ entitled "GNU Free Documentation License". * Two-way processors:: Registering a two-way processor. * Printing Messages:: Functions for printing messages. * Updating `ERRNO':: Functions for updating `ERRNO'. +* Requesting Values:: How to get a value. * Accessing Parameters:: Functions for accessing parameters. * Symbol Table Access:: Functions for accessing global variables. @@ -579,9 +584,9 @@ entitled "GNU Free Documentation License". processor. * Extension Sample Read write array:: Serializing an array to a file. * Extension Sample Readfile:: Reading an entire file into a string. -* Extension Sample API Tests:: Tests for the API. * Extension Sample Time:: An interface to `gettimeofday()' and `sleep()'. +* Extension Sample API Tests:: Tests for the API. * gawkextlib:: The `gawkextlib' project. * Extension summary:: Extension summary. * Extension Exercises:: Exercises. @@ -610,6 +615,7 @@ entitled "GNU Free Documentation License". * Unix Installation:: Installing `gawk' under various versions of Unix. * Quick Installation:: Compiling `gawk' under Unix. +* Shell Startup Files:: Shell convenience functions. * Additional Configuration Options:: Other compile-time options. * Configuration Philosophy:: How it's all supposed to work. * Non-Unix Installation:: Installation on Other Operating @@ -675,10 +681,10 @@ your life together with me. lives in innumerable ways. -File: gawk.info, Node: Foreword, Next: Preface, Prev: Top, Up: Top +File: gawk.info, Node: Foreword3, Next: Foreword4, Prev: Top, Up: Top -Foreword -******** +Foreword to the Third Edition +***************************** Arnold Robbins and I are good friends. We were introduced in 1990 by circumstances--and our favorite programming language, AWK. The @@ -693,7 +699,7 @@ 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 few lines of code. I was excited to try my hand at programming in +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 @@ -762,7 +768,41 @@ want to learn how, then read this book. March, 2001 -File: gawk.info, Node: Preface, Next: Getting Started, Prev: Foreword, Up: Top +File: gawk.info, Node: Foreword4, Next: Preface, Prev: Foreword3, Up: Top + +Foreword to the Fourth Edition +****************************** + +Some things don't change. Thirteen years ago I wrote: "If you use AWK +or want to learn how, then read this book." True then and still true +today. + + Learning to use a programming language is more than mastering the +syntax. One needs to acquire an understanding of how to use the +features of the language to solve practical programming problems. A +focus of this book is many examples that show how to use AWK. + + Some things do change. Our computers are much faster and have more +memory. Consequently, speed and storage inefficiencies of a high level +language matter less. Prototyping in AWK and then rewriting in C for +performance reasons happens less, because more often the prototype is +fast enough. + + Of course, there are computing operations that are best done in C or +C++. With `gawk' 4.1 and later, you do not have to choose between +writing your program in AWK or in C/C++. You can write most of your +program in AWK and the aspects that require C/C++ capabilities can be +written in C/C++ and then the pieces glued together when the `gawk' +module loads the C/C++ module as a dynamic plug-in. *note Dynamic +Extensions::, has all the details, and as expected, many examples to +help you learn the ins and outs. + + Michael Brennan + Author of `mawk' + October, 2014 + + +File: gawk.info, Node: Preface, Next: Getting Started, Prev: Foreword4, Up: Top Preface ******* @@ -775,14 +815,14 @@ 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 (*note Options::), 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'. Thus, we usually 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' allows you to: + Using `awk' you can: * Manage small, personal databases @@ -803,9 +843,9 @@ and other `awk' implementations. * Perform simple network communications - * Profile and debug `awk' programs. + * Profile and debug `awk' programs - * Extend the language with functions written in C or C++. + * Extend the language with functions written in C or C++ This Info file teaches you about the `awk' language and how you can use it effectively. You should already be familiar with basic system @@ -818,9 +858,8 @@ different computing environments. This Info file, while describing the of `awk' called `gawk' (which stands for "GNU `awk'"). `gawk' runs on a broad range of Unix systems, ranging from Intel-architecture PC-based computers up through large-scale systems. `gawk' has also been ported -to Mac OS X, Microsoft Windows (all versions) and OS/2 PCs, and OpenVMS. -(Some other, obsolete systems to which `gawk' was once ported are no -longer supported and the code for those systems has been removed.) +to Mac OS X, Microsoft Windows (all versions) and OS/2 PCs, and +OpenVMS.(3) * Menu: @@ -840,11 +879,14 @@ longer supported and the code for those systems has been removed.) (1) The 2008 POSIX standard is accessible online at `http://www.opengroup.org/onlinepubs/9699919799/'. - (2) These commands are available on POSIX-compliant systems, as well -as on traditional Unix-based systems. If you are using some other + (2) These utilities are available on POSIX-compliant systems, as +well as on traditional Unix-based systems. If you are using some other operating system, you still need to be familiar with the ideas of I/O redirection and pipes. + (3) Some other, obsolete systems to which `gawk' was once ported are +no longer supported and the code for those systems has been removed. + File: gawk.info, Node: History, Next: Names, Up: Preface @@ -872,16 +914,16 @@ V Release 3.1 (1987). The version in System V Release 4 (1989) added some new features and cleaned up the behavior in some of the "dark corners" of the language. The specification for `awk' in the POSIX Command Language and Utilities standard further clarified the language. -Both the `gawk' designers and the original Bell Laboratories `awk' -designers provided feedback for the POSIX specification. +Both the `gawk' designers and the original `awk' designers at Bell +Laboratories provided feedback for the POSIX specification. - Paul Rubin wrote the GNU implementation, `gawk', in 1986. Jay -Fenlason completed it, with advice from Richard Stallman. John Woods -contributed parts of the code as well. In 1988 and 1989, David -Trueman, with help from me, thoroughly reworked `gawk' for compatibility -with the newer `awk'. Circa 1994, I became the primary maintainer. -Current development focuses on bug fixes, performance improvements, -standards compliance and, occasionally, new features. + Paul Rubin wrote `gawk' in 1986. Jay Fenlason completed it, with +advice from Richard Stallman. John Woods contributed parts of the code +as well. In 1988 and 1989, David Trueman, with help from me, +thoroughly reworked `gawk' for compatibility with the newer `awk'. +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 `awk', and with a little help from me, set about adding features to do @@ -894,8 +936,8 @@ the `gawk' distribution). His code finally became part of the main `awk'-level debugger. This version became available as `gawk' version 4.0, in 2011. - *Note Contributors::, for a complete list of those who made -important contributions to `gawk'. + *Note Contributors::, for a full list of those who made important +contributions to `gawk'. File: gawk.info, Node: Names, Next: This Manual, Prev: History, Up: Preface @@ -948,8 +990,8 @@ programming language. in the POSIX standard. It does so in the context of the `gawk' implementation. While doing so, it also attempts to describe important differences between `gawk' and other `awk' implementations.(1) Finally, -any `gawk' features that are not in the POSIX standard for `awk' are -noted. +it notes any `gawk' features that are not in the POSIX standard for +`awk'. There are sidebars scattered throughout the Info file. They add a more complete explanation of points that are relevant, but not likely @@ -958,7 +1000,7 @@ heading "sidebar." Most of the time, the examples use complete `awk' programs. Some of the more advanced sections show only the part of the `awk' program that -illustrates the concept currently being described. +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' @@ -994,7 +1036,7 @@ building blocks for getting most things done in a program. *note Patterns and Actions::, describes how to write patterns for matching records, actions for doing something when a record is matched, -and the built-in variables `awk' and `gawk' use. +and the predefined variables `awk' and `gawk' use. *note Arrays::, covers `awk''s one-and-only data structure: associative arrays. Deleting array elements and whole arrays is also @@ -1002,7 +1044,8 @@ 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. +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 @@ -1019,18 +1062,18 @@ problems. Part III focuses on features specific to `gawk'. It contains the following chapters: - *note Advanced Features::, describes a number of `gawk'-specific -advanced features. Of particular note are the abilities to 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 in `gawk' -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 `awk' debugger. + *note Debugger::, describes the `gawk' debugger. *note Arbitrary Precision Arithmetic::, describes advanced -arithmetic facilities provided by `gawk'. +arithmetic facilities. *note Dynamic Extensions::, describes how to add new variables and functions to `gawk' by writing extensions in C or C++. @@ -1117,8 +1160,8 @@ at all. Descriptions of such features (often called "dark corners") are noted in this Info file with "(d.c.)". They also appear in the index under the heading "dark corner." - As noted by the opening quote, though, any coverage of dark corners -is, by definition, incomplete. + But, as noted by the opening quote, any coverage of dark corners is +by definition incomplete. Extensions to the standard `awk' language that are supported by more than one `awk' implementation are marked "(c.e.)," and listed in the @@ -1158,7 +1201,7 @@ system for Intel, Power Architecture, Sun SPARC, IBM S/390, and other systems.(2) Many GNU/Linux distributions are available for download from the Internet. - The Info file itself has gone through a number of previous editions. + 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 @@ -1171,17 +1214,16 @@ published the first two editions under the title `The GNU Awk User's Guide'. This edition maintains the basic structure of the previous editions. -For FSF edition 4.0, the content has been thoroughly reviewed and -updated. All references to `gawk' versions prior to 4.0 have been -removed. Of significant note for this edition was *note Debugger::. +For FSF edition 4.0, the content was thoroughly reviewed and updated. +All references to `gawk' versions prior to 4.0 were removed. Of +significant note for that edition was *note Debugger::. For FSF edition 4.1, the content has been reorganized into parts, and the major new additions are *note Arbitrary Precision Arithmetic::, and *note Dynamic Extensions::. - This Info file will undoubtedly continue to evolve. An electronic -version comes with the `gawk' distribution from the FSF. If you find -an error in this Info file, please report it! *Note Bugs::, for + This Info file will undoubtedly continue to evolve. If you find an +error in this Info file, please report it! *Note Bugs::, for information on submitting problem reports electronically. ---------- Footnotes ---------- @@ -1217,9 +1259,6 @@ for several years. world, please see `http://awk.info/?contribute' for how to contribute it to the web site. - As of this writing, this website is in search of a maintainer; please -contact me if you are interested. - File: gawk.info, Node: Acknowledgments, Prev: How To Contribute, Up: Preface @@ -1286,12 +1325,14 @@ Michal Jaegermann, Ju"rgen Kahrs, Stepan Kasal, John Malmberg, Dave Pitts, Chet Ramey, Pat Rankin, Andrew Schorr, Corinna Vinschen, and Eli Zaretskii (in alphabetical order) make up the current `gawk' "crack portability team." Without their hard work and help, `gawk' would not -be nearly the fine program it is today. It has been and continues to -be a pleasure working with this team of fine people. +be nearly the robust, portable program it is today. It has been and +continues to be a pleasure working with this team of fine people. Notable code and documentation contributions were made by a number of people. *Note Contributors::, for the full list. + Thanks to Michael Brennan for the Foreword. + Thanks to Patrice Dumas for the new `makeinfo' program. Thanks to Karl Berry who continues to work to keep the Texinfo markup language sane. @@ -1457,21 +1498,21 @@ advice (from Douglas Adams's `The Hitchhiker's Guide to the Galaxy'), to keep you from worrying about the complexities of computer programming: - $ awk "BEGIN { print "Don\47t Panic!" }" + $ awk 'BEGIN { print "Don\47t Panic!" }' -| Don't Panic! `awk' executes statements associated with `BEGIN' before reading any input. If there are no other statements in your program, as is the case here, `awk' just stops, instead of trying to read input it doesn't -know how to process. The `\47' is a magic way of getting a single -quote into the program, without having to engage in ugly shell quoting -tricks. +know how to process. The `\47' is a magic way (explained later) of +getting a single quote into the program, without having to engage in +ugly shell quoting tricks. - NOTE: As a side note, if you use Bash as your shell, you should - execute the command `set +H' before running this program - interactively, to disable the C shell-style command history, which - treats `!' as a special character. We recommend putting this - command into your personal startup file. + NOTE: If you use Bash as your shell, you should execute the + command `set +H' before running this program interactively, to + disable the C shell-style command history, which treats `!' as a + special character. We recommend putting this command into your + personal startup file. This next simple `awk' program emulates the `cat' utility; it copies whatever you type on the keyboard to its standard output (why this @@ -1494,9 +1535,9 @@ File: gawk.info, Node: Long, Next: Executable Scripts, Prev: Read Terminal, 1.1.3 Running Long Programs --------------------------- -Sometimes your `awk' programs can be very long. In this case, it is -more convenient to put the program into a separate file. In order to -tell `awk' to use that file for its program, you type: +Sometimes `awk' programs are very long. In these cases, it is more +convenient to put the program into a separate file. In order to tell +`awk' to use that file for its program, you type: awk -f SOURCE-FILE INPUT-FILE1 INPUT-FILE2 ... @@ -1512,14 +1553,16 @@ into the file `advice'. Then this command: does the same thing as this one: - awk "BEGIN { print \"Don't Panic!\" }" + awk 'BEGIN { print "Don\47t Panic!" }' This was explained earlier (*note Read Terminal::). Note that you don't usually need single quotes around the file name that you specify with `-f', because most file names don't contain any of the shell's special characters. Notice that in `advice', the `awk' program did not have single quotes around it. The quotes are only needed for programs -that are provided on the `awk' command line. +that are provided on the `awk' command line. (Also, placing the +program in a file allows us to use a literal single quote in the program +text, instead of the magic `\47'.) If you want to clearly identify your `awk' program files as such, you can add the extension `.awk' to the file name. This doesn't affect @@ -1563,7 +1606,7 @@ program is written in `awk'. utility reads your program and then processes your data according to 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 hardware.) The `awk' +code that is executed directly by your system's processor.) The `awk' utility is thus termed an "interpreter". Many modern languages are interperted. @@ -1573,8 +1616,8 @@ to pass to that interpreter. The operating system then runs the interpreter with the given argument and the full argument list of the executed program. The first argument in the list is the full file name of the `awk' program. The rest of the argument list contains either -options to `awk', or data files, or both. Note that on many systems -`awk' may be found in `/usr/bin' instead of in `/bin'. Caveat Emptor. +options to `awk', or data files, or both. (Note that on many systems +`awk' may be found in `/usr/bin' instead of in `/bin'.) Some systems limit the length of the interpreter name to 32 characters. Often, this can be dealt with by using a symbolic link. @@ -1714,8 +1757,11 @@ the quoting rules. the characters `$', ``', `\', and `"', all of which must be preceded by a backslash within double-quoted text if they are to be passed on literally to the program. (The leading backslash is - stripped first.) Thus, the example seen in *note Read Terminal::, - is applicable: + stripped first.) Thus, the example seen in *note Read Terminal::: + + awk 'BEGIN { print "Don\47t Panic!" }' + + could instead be written this way: $ awk "BEGIN { print \"Don't Panic!\" }" -| Don't Panic! @@ -1733,10 +1779,10 @@ the quoting rules. awk -F"" 'PROGRAM' FILES # wrong! - In the second case, `awk' will attempt to use the text of the - program as the value of `FS', and the first file name as the text - of the program! This results in syntax errors at best, and - confusing behavior at worst. + In the second case, `awk' attempts to use the text of the program + as the value of `FS', and the first file name as the text of the + program! This results in syntax errors at best, and confusing + behavior at worst. Mixing single and double quotes is difficult. You have to resort to shell quoting tricks, like this: @@ -1781,6 +1827,9 @@ this: $ awk -v sq="'" 'BEGIN { print "Here is a single quote <" sq ">" }' -| Here is a single quote <'> + (Here, the two string constants and the value of `sq' are +concatenated into a single string which is printed by `print'.) + If you really need both single and double quotes in your `awk' program, it is probably best to move it into a separate file, where the shell won't be part of the picture, and you can say what you mean. @@ -1816,12 +1865,12 @@ The second data file, called `inventory-shipped', contains information about monthly shipments. In both files, each line is considered to be one "record". - In the data file `mail-list', each record contains the name of a -person, his/her phone number, his/her email-address, and a code for -their relationship 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 that the person is a relative: + 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 +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 +that the person is a relative: Amelia 555-5553 amelia.zodiacusque@gmail.com F Anthony 555-3412 anthony.asserturo@hotmail.com A @@ -1939,7 +1988,7 @@ different ways to do the same things shown here: * Print the length of the longest line in `data': expand data | awk '{ if (x < length($0)) x = length($0) } - END { print "maximum line length is " x }' + END { print "maximum line length is " x }' This example differs slightly from the previous one: The input is processed by the `expand' utility to change TABs into spaces, so @@ -1962,7 +2011,7 @@ different ways to do the same things shown here: * Print the total number of bytes used by FILES: ls -l FILES | awk '{ x += $5 } - END { print "total bytes: " x }' + END { print "total bytes: " x }' * Print the total number of kilobytes used by FILES: @@ -1991,13 +2040,13 @@ File: gawk.info, Node: Two Rules, Next: More Complex, Prev: Very Simple, Up: ============================= The `awk' utility reads the input files one line at a time. For each -line, `awk' tries the patterns of each of the rules. If several -patterns match, then several actions execute in the order in which they -appear in the `awk' program. If no patterns match, then no actions run. +line, `awk' tries the patterns of each rule. If several patterns +match, then several actions execute in the order in which they appear +in the `awk' program. If no patterns match, then no actions run. After processing all the rules that match the line (and perhaps there are none), `awk' reads the next line. (However, *note Next -Statement::, and also *note Nextfile Statement::). This continues +Statement::, and also *note Nextfile Statement::.) This continues until the program reaches the end of the file. For example, the following `awk' program contains two rules: @@ -2061,11 +2110,11 @@ date the file was last modified. Its output looks like this: The first field contains read-write permissions, the second field contains the number of links to the file, and the third field -identifies the owner of the file. The fourth field identifies the group -of the file. The fifth field contains the size of the file in bytes. -The sixth, seventh, and eighth fields contain the month, day, and time, +identifies the file's owner. The fourth field identifies the file's +group. The fifth field contains the file's size in bytes. The sixth, +seventh, and eighth fields contain the month, day, and time, respectively, that the file was last modified. Finally, the ninth field -contains the file name.(1) +contains the file name. The `$6 == "Nov"' in our `awk' program is an expression that tests whether the sixth field of the output from `ls -l' matches the string @@ -2087,11 +2136,6 @@ displays your output. By manipulating fields and using `print' statements, you can produce some very useful and impressive-looking reports. - ---------- Footnotes ---------- - - (1) The `LC_ALL=C' is needed to produce this traditional-style -output from `ls'. - File: gawk.info, Node: Statements/Lines, Next: Other Features, Prev: More Complex, Up: Getting Started @@ -2388,7 +2432,7 @@ The following list describes options mandated by the POSIX standard: CAUTION: Using `-v' to set the values of the built-in variables may lead to surprising results. `awk' will reset the values of those variables as it needs to, possibly - ignoring any predefined value you may have given. + ignoring any initial value you may have given. `-W GAWK-OPT' Provide an implementation-specific option. This is the POSIX @@ -2439,9 +2483,9 @@ The following list describes options mandated by the POSIX standard: `-d'[FILE] `--dump-variables'[`='FILE] Print a sorted list of global variables, their types, and final - values to FILE. If no FILE is provided, print this list to the - file named `awkvars.out' in the current directory. No space is - allowed between the `-d' and FILE, if FILE is supplied. + values to FILE. If no FILE is provided, print this list to a file + named `awkvars.out' in the current directory. No space is allowed + between the `-d' and FILE, if FILE is supplied. Having a list of all global variables is a good way to look for typographical errors in your programs. You would also use this @@ -2455,10 +2499,10 @@ The following list describes options mandated by the POSIX standard: `--debug'[`='FILE] Enable debugging of `awk' programs (*note Debugging::). By default, the debugger reads commands interactively from the - keyboard. The optional FILE argument allows you to specify a file - with a list of commands for the debugger to execute - non-interactively. No space is allowed between the `-D' and FILE, - if FILE is supplied. + keyboard (standard input). The optional FILE argument allows you + to specify a file with a list of commands for the debugger to + execute non-interactively. No space is allowed between the `-D' + and FILE, if FILE is supplied. `-e' PROGRAM-TEXT `--source' PROGRAM-TEXT @@ -2504,7 +2548,7 @@ The following list describes options mandated by the POSIX standard: `-i' SOURCE-FILE `--include' SOURCE-FILE - Read `awk' source library from SOURCE-FILE. This option is + Read an `awk' source library from SOURCE-FILE. This option is completely equivalent to using the `@include' directive inside your program. This option is very similar to the `-f' option, but there are two important differences. First, when `-i' is used, @@ -2525,8 +2569,8 @@ The following list describes options mandated by the POSIX standard: not be specified in the extension name. The extension initialization routine should be named `dl_load()'. An alternative is to use the `@load' keyword inside the program to - load a shared library. This feature is described in detail in - *note Dynamic Extensions::. + load a shared library. This advanced feature is described in + detail in *note Dynamic Extensions::. `-L'[VALUE] `--lint'[`='VALUE] @@ -2562,6 +2606,8 @@ The following list describes options mandated by the POSIX standard: CAUTION: This option can severely break old programs. Use with care. + This option may disappear in a future version of `gawk'. + `-N' `--use-lc-numeric' Force the use of the locale's decimal point character when parsing @@ -2661,8 +2707,9 @@ 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. (As mentioned in -*note Definition Syntax::, function names must be unique.) +having to be included into each individual program. The `-i' option is +similar in this regard. (As mentioned in *note Definition Syntax::, +function names must be unique.) With standard `awk', library functions can still be used, even if the program is entered at the keyboard, by specifying `-f /dev/tty'. @@ -2719,14 +2766,17 @@ Any additional arguments on the command line are normally treated as input files to be processed in the order specified. However, an argument that has the form `VAR=VALUE', assigns the value VALUE to the variable VAR--it does not specify a file at all. (See *note Assignment -Options::.) +Options::.) In the following example, COUNT=1 is a variable assignment, +not a file name: + + awk -f program.awk file1 count=1 file2 - All these arguments are made available to your `awk' 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. + All the command-line arguments are made available to your `awk' +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. Changing `ARGC' and `ARGV' in your `awk' program lets you control how `awk' processes the input files; this is described in more detail @@ -2820,50 +2870,58 @@ File: gawk.info, Node: AWKPATH Variable, Next: AWKLIBPATH Variable, Up: Envir The previous minor node described how `awk' program files can be named on the command line with the `-f' option. In most `awk' -implementations, you must supply a precise path name for each program -file, unless the file is in the current directory. But in `gawk', if +implementations, you must supply a precise pathname for each program +file, unless the file is in the current directory. But with `gawk', if the file name supplied to the `-f' or `-i' options does not contain a directory separator `/', then `gawk' searches a list of directories (called the "search path"), one by one, looking for a file with the specified name. The search path is a string consisting of directory names separated by -colons(1). `gawk' gets its search path from the `AWKPATH' environment -variable. If that variable does not exist, `gawk' uses a default path, -`.:/usr/local/share/awk'.(2) +colons.(1) `gawk' gets its search path from the `AWKPATH' environment +variable. If that variable does not exist, or if it has an empty value, +`gawk' uses a default path (described shortly). The search path feature is particularly helpful for building libraries of useful `awk' functions. The library files can be placed in a standard directory in the default path and then specified on the -command line with a short file name. Otherwise, the full file name -would have to be typed for each file. +command line with a short file name. Otherwise, you would have to type +the full file name for each file. - By using the `-i' option, or the `-e' and `-f' options, your -command-line `awk' programs can use facilities in `awk' library files -(*note Library Functions::). Path searching is not done if `gawk' is -in compatibility mode. This is true for both `--traditional' and -`--posix'. *Note Options::. + By using the `-i' or `-f' options, your command-line `awk' programs +can use facilities in `awk' library files (*note Library Functions::). +Path searching is not done if `gawk' is in compatibility mode. This is +true for both `--traditional' and `--posix'. *Note Options::. - If the source code is not found after the initial search, the path -is searched again after adding the default `.awk' suffix to the file -name. + If the source code file is not found after the initial search, the +path is searched again after adding the suffix `.awk' to the file name. + + `gawk''s path search mechanism is similar to the shell's. (See `The +Bourne-Again SHell manual' (http://www.gnu.org/software/bash/manual/).) +It treats a null entry in the path as indicating the current directory. +(A null entry is indicated by starting or ending the path with a colon +or by placing two colons next to each other [`::'].) NOTE: To include the current directory in the path, either place - `.' explicitly in the path or write a null entry in the path. (A - null entry is indicated by starting or ending the path with a - colon or by placing two colons next to each other [`::'].) This - path search mechanism is similar to the shell's. (See `The - Bourne-Again SHell manual'. - (http://www.gnu.org/software/bash/manual/)) - - However, `gawk' always looks in the current directory _before_ - searching `AWKPATH', so there is no real reason to include the - current directory in the search path. - - If `AWKPATH' is not defined in the environment, `gawk' places its -default search path into `ENVIRON["AWKPATH"]'. This makes it easy to -determine the actual search path that `gawk' used from within an `awk' -program. + `.' as an entry in the path or write a null entry in the path. + + Different past versions of `gawk' would also look explicitly in + the current directory, either before or after the path search. As + of version 4.1.2, this no longer happens, and if you wish to look + in the current directory, you must include `.' either as a separate + entry, or as a null entry in the search path. + + The default value for `AWKPATH' is `.:/usr/local/share/awk'.(2) +Since `.' is included at the beginning, `gawk' searches first in the +current directory and then in `/usr/local/share/awk'. In practice, +this means that you will rarely need to change the value of `AWKPATH'. + + *Note Shell Startup Files::, for information on functions that help +to manipulate the `AWKPATH' variable. + + `gawk' places the value of the search path that it used into +`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 @@ -2895,6 +2953,18 @@ platform. For example, on GNU/Linux systems, the suffix `.so' is used. The search path specified is also used for extensions loaded via the `@load' keyword (*note Loading Shared Libraries::). + If `AWKLIBPATH' does not exist in the environment, or if it has an +empty value, `gawk' uses a default path; this is typically +`/usr/local/lib/gawk', although it can vary depending upon how `gawk' +was built. + + *Note Shell Startup Files::, for information on functions that help +to manipulate the `AWKLIBPATH' variable. + + `gawk' places the value of the search path that it used into +`ENVIRON["AWKLIBPATH"]'. This provides access to the actual search path +value from within an `awk' program. + File: gawk.info, Node: Other Environment Variables, Prev: AWKLIBPATH Variable, Up: Environment Variables @@ -2905,15 +2975,6 @@ 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. -`POSIXLY_CORRECT' - Causes `gawk' to switch to POSIX compatibility mode, disabling all - traditional and GNU extensions. *Note Options::. - -`GAWK_SOCK_RETRIES' - Controls the number of times `gawk' attempts to retry a two-way - TCP/IP (socket) connection before giving up. *Note TCP/IP - Networking::. - `GAWK_MSEC_SLEEP' Specifies the interval between connection retries, in milliseconds. On systems that do not support the `usleep()' system @@ -2923,6 +2984,15 @@ used by regular users. Specifies the time, in milliseconds, for `gawk' to wait for input before returning with an error. *Note Read Timeout::. +`GAWK_SOCK_RETRIES' + Controls the number of times `gawk' attempts to retry a two-way + TCP/IP (socket) connection before giving up. *Note TCP/IP + Networking::. + +`POSIXLY_CORRECT' + 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 the `gawk' developers for testing and tuning. They are subject to change. The variables are: @@ -2934,7 +3004,7 @@ change. The variables are: the value should be a number, and `gawk' uses that number as the size of the buffer to allocate. (When this variable is not set, `gawk' uses the smaller of the file's size and the "default" - blocksize, which is usually the filesystems I/O blocksize.) + blocksize, which is usually the filesystem's I/O blocksize.) `AWK_HASH' If this variable exists with a value of `gst', `gawk' switches to @@ -2948,11 +3018,11 @@ change. The variables are: where I/O is performed in records, not in blocks. `GAWK_MSG_SRC' - If this variable exists, `gawk' includes the source file name and - line number from which warning and/or fatal messages are - generated. Its purpose is to help isolate the source of a - message, since there can be multiple places which produce the same - warning or error message. + 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. `GAWK_NO_DFA' If this variable exists, `gawk' does not use the DFA regexp matcher @@ -2967,12 +3037,12 @@ change. The variables are: evaluation stack, when needed. `INT_CHAIN_MAX' - The average number of items `gawk' will maintain on a hash chain - for managing arrays indexed by integers. + The intended maximum number of items `gawk' will maintain on a + hash chain for managing arrays indexed by integers. `STR_CHAIN_MAX' - The average number of items `gawk' will maintain on a hash chain - for managing arrays indexed by strings. + The intended maximum number of items `gawk' will maintain on a + hash chain for managing arrays indexed by strings. `TIDYMEM' If this variable exists, `gawk' uses the `mtrace()' library calls @@ -3031,8 +3101,8 @@ and here is `test2': Running `gawk' with `test2' produces the following result: $ gawk -f test2 - -| This is file test1. - -| This is file 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 @@ -3054,9 +3124,9 @@ namely `test3': Running `gawk' with the `test3' script produces the following results: $ gawk -f test3 - -| This is file test1. - -| This is file test2. - -| This is file test3. + -| This is script test1. + -| This is script test2. + -| This is script test3. The file name can, of course, be a pathname. For example: @@ -3126,7 +3196,8 @@ is useful for embedding inside an `awk' source file that requires access to an extension. *note Dynamic Extensions::, describes how to write extensions (in C -or C++) that can be loaded with either `@load' or the `-l' option. +or C++) that can be loaded with either `@load' or the `-l' option. It +also describes the `ordchr' extension. File: gawk.info, Node: Obsolete, Next: Undocumented, Prev: Loading Shared Libraries, Up: Invoking Gawk @@ -3177,7 +3248,8 @@ File: gawk.info, Node: Invoking Summary, Prev: Undocumented, Up: Invoking Gaw affects how `awk' processes input. * You can use a single minus sign (`-') to refer to standard input - on the command line. + on the command line. `gawk' also lets you use the special file + name `/dev/stdin'. * `gawk' pays attention to a number of environment variables. `AWKPATH', `AWKLIBPATH', and `POSIXLY_CORRECT' are the most @@ -3315,9 +3387,9 @@ or newline. While there is nothing to stop you from entering most unprintable characters directly in a string constant or regexp constant, they may look ugly. - The following table lists all the escape sequences used in `awk' and -what they represent. Unless noted otherwise, all these escape sequences -apply to both string constants and regexp constants: + The following list presents all the escape sequences used in `awk' +and what they represent. Unless noted otherwise, all these escape +sequences apply to both string constants and regexp constants: `\\' A literal backslash, `\'. @@ -3354,14 +3426,15 @@ apply to both string constants and regexp constants: hexadecimal digits (`0'-`9', and either `A'-`F' or `a'-`f'). A maximum of two digts are allowed after the `\x'. Any further hexadecimal digits are treated as simple letters or numbers. - (c.e.) + (c.e.) (The `\x' escape sequence is not allowed in POSIX awk.) CAUTION: In ISO C, the escape sequence continues until the first nonhexadecimal digit is seen. For many years, `gawk' would continue incorporating hexadecimal digits into the value until a non-hexadecimal digit or the end of the string was encountered. However, using more than two hexadecimal - digits produces + digits produced undefined results. As of version *FIXME:* + 4.3.0, only two digits are processed. `\/' A literal slash (necessary for regexp constants only). This @@ -3391,11 +3464,11 @@ normally be a regexp operator. For example, `/a\+b/' matches the three characters `a+b'. For complete portability, do not use a backslash before any -character not shown in the previous list. +character not shown in the previous list and that is not an operator. To summarize: - * The escape sequences in the table above are always processed first, + * 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. @@ -3453,7 +3526,7 @@ and converted into corresponding real characters as the very first step in processing regexps. Here is a list of metacharacters. All characters that are not escape -sequences and that are not listed in the table stand for themselves: +sequences and that are not listed in the following stand for themselves: `\' This is used to suppress the special meaning of a character when @@ -3539,7 +3612,7 @@ sequences and that are not listed in the table stand for themselves: To cause `*' to apply to a larger sub-expression, use parentheses: `(ph)*' matches `ph', `phph', `phphph' and so on. - Second, `*' finds as many repetititons as possible. If the text to + Second, `*' finds as many repetitions as possible. If the text to be matched is `phhhhhhhhhhhhhhooey', `ph*' matches all of the `h's. `+' @@ -3641,8 +3714,8 @@ matches either `d' or `]'. Additionally, if you place `]' right after the opening `[', the closing bracket is treated as one of the characters to be matched. - This treatment of `\' in bracket expressions is compatible with -other `awk' implementations and is also mandated by POSIX. The regular + The treatment of `\' in bracket expressions is compatible with other +`awk' implementations and is also mandated by POSIX. The regular expressions in `awk' are a superset of the POSIX specification for Extended Regular Expressions (EREs). POSIX EREs are based on the regular expressions accepted by the traditional `egrep' utility. @@ -3730,10 +3803,11 @@ Consider the following: echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }' - This example uses the `sub()' function (which we haven't discussed -yet; *note String Functions::) to make a change to the input record. -Here, the regexp `/a+/' indicates "one or more `a' characters," and the -replacement text is `<A>'. + This example uses the `sub()' function to make a change to the input +record. (`sub()' replaces the first instance of any text matched by +the first argument with the string provided as the second argument; +*note String Functions::). Here, the regexp `/a+/' indicates "one or +more `a' characters," and the replacement text is `<A>'. The input contains four `a' characters. `awk' (and POSIX) regular expressions always match the leftmost, _longest_ sequence of input @@ -3809,15 +3883,15 @@ constants," for several reasons: Using `\n' in Bracket Expressions of Dynamic Regexps - Some versions of `awk' do not allow the newline character to be used -inside a bracket expression for a dynamic regexp: + Some older versions of `awk' do not allow the newline character to +be used inside a bracket expression for a dynamic regexp: $ awk '$0 ~ "[ \t\n]"' error--> awk: newline in character class [ error--> ]... error--> source line number 1 error--> context is - error--> >>> <<< + error--> $0 ~ "[ >>> \t\n]" <<< But a newline in a regexp constant works with no problem: @@ -3916,7 +3990,7 @@ No options 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' does support them. Characters described by octal and + BWK `awk' supports them. Characters described by octal and hexadecimal escape sequences are treated literally, even if they represent regexp metacharacters. @@ -4025,10 +4099,6 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp Within bracket expressions, POSIX character classes let you specify certain groups of characters in a locale-independent fashion. - * `gawk''s `IGNORECASE' variable lets you control the case - sensitivity of regexp matching. In other `awk' versions, use - `tolower()' or `toupper()'. - * Regular expressions match the leftmost longest text in the string being matched. This matters for cases where you need to know the extent of the match, such as for text substitution and when the @@ -4037,6 +4107,10 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp * Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. + * `gawk''s `IGNORECASE' variable lets you control the case + sensitivity of regexp matching. In other `awk' versions, use + `tolower()' or `toupper()'. + File: gawk.info, Node: Reading Files, Next: Printing, Prev: Regexp, Up: Top @@ -4049,8 +4123,8 @@ standard input (by default, this is the keyboard, but often it is a pipe from another command) or from files whose names you specify on the `awk' command line. If you specify input files, `awk' reads them in order, processing all the data from one before going on to the next. -The name of the current input file can be found in the built-in variable -`FILENAME' (*note Built-in Variables::). +The name of the current input file can be found in the predefined +variable `FILENAME' (*note Built-in Variables::). The input is read in units called "records", and is processed by the rules of your program one record at a time. By default, each record is @@ -4089,9 +4163,9 @@ File: gawk.info, Node: Records, Next: Fields, Up: Reading Files `awk' divides the input for your program into records and fields. It keeps track of the number of records that have been read so far from -the current input file. This value is stored in a built-in variable -called `FNR' which is reset to zero when a new file is started. -Another built-in variable, `NR', records the total number of input +the current input file. This value is stored in a predefined variable +called `FNR' which is reset to zero every time a new file is started. +Another 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. @@ -4110,7 +4184,7 @@ Records are separated by a character called the "record separator". By default, the record separator is the newline character. This is why records are, by default, single lines. A different character can be used for the record separator by assigning the character to the -built-in variable `RS'. +predefined variable `RS'. Like any other variable, the value of `RS' can be changed in the `awk' program with the assignment operator, `=' (*note Assignment @@ -4198,9 +4272,10 @@ character such as `/' is more likely to produce correct behavior in the majority of cases, but there are no guarantees. The moral is: Know Your Data. - There is one unusual case, that occurs when `gawk' is being fully -POSIX-compliant (*note Options::). Then, the following (extreme) -pipeline prints a surprising `1': + When using regular characters as the record separator, there is one +unusual case that occurs when `gawk' is being fully POSIX-compliant +(*note Options::). Then, the following (extreme) pipeline prints a +surprising `1': $ echo | gawk --posix 'BEGIN { RS = "a" } ; { print NF }' -| 1 @@ -4265,9 +4340,9 @@ trailing whitespace: -| ] The square brackets delineate the contents of `RT', letting you see the -leading and trailing whitespace. The final value of `RT' `RT' is a -newline. *Note Simple Sed::, for a more useful example of `RS' as a -regexp and `RT'. +leading and trailing whitespace. The final value of `RT' is a newline. +*Note Simple Sed::, for a more useful example of `RS' as a regexp and +`RT'. If you set `RS' to a regular expression that allows optional trailing text, such as `RS = "abc(XYZ)?"' it is possible, due to @@ -4282,13 +4357,13 @@ that this will never happen. the beginning and end of a _line_. As a result, something like `RS = "^[[:upper:]]"' can only match at the beginning of a file. This is because `gawk' views the input file as one long string - that happens to contain newline characters in it. It is thus best - to avoid anchor characters in the value of `RS'. + that happens to contain newline characters. It is thus best to + avoid anchor characters in the value of `RS'. The use of `RS' as a regular expression and the `RT' variable are `gawk' extensions; they are not available in compatibility mode (*note Options::). In compatibility mode, only the first character of the -value of `RS' is used to determine the end of the record. +value of `RS' determines the end of the record. `RS = "\0"' Is Not Portable @@ -4317,11 +4392,12 @@ terminator. In effect, this means that `RS = "\0"' is the same as `RS It happens that recent versions of `mawk' can use the NUL character as a record separator. However, this is a special case: `mawk' does not -allow embedded NUL characters in strings. +allow embedded NUL characters in strings. (This may change in a future +version of `mawk'.) - *Note Readfile Function::, for an interesting, portable way to read -whole files. If you are using `gawk', see *note Extension Sample -Readfile::, for another option. + *Note Readfile Function::, for an interesting way to read whole +files. If you are using `gawk', see *note Extension Sample Readfile::, +for another option. ---------- Footnotes ---------- @@ -4360,7 +4436,7 @@ Here the first field, or `$1', is `This', the second field, or `$2', is Because there is no space between the `e' and the `.', the period is considered part of the seventh field. - `NF' is a built-in variable whose value is the number of fields in + `NF' is a predefined variable whose value is the number of fields in the current record. `awk' automatically updates the value of `NF' each time it reads a record. No matter how many fields there are, the last field in a record can be represented by `$NF'. So, `$NF' is the same @@ -4378,13 +4454,11 @@ examples: -| Julie 555-6699 julie.perscrutabor@skeeve.com F This example prints each record in the file `mail-list' whose first -field contains the string `li'. The operator `~' is called a "matching -operator" (*note Regexp Usage::); it tests whether a string (here, the -field `$1') matches a given regular expression. +field contains the string `li'. By contrast, the following example looks for `li' in _the entire -record_ and prints the first field and the last field for each matching -input record: +record_ and prints the first and last fields for each matching input +record: $ awk '/li/ { print $1, $NF }' mail-list -| Amelia F @@ -4439,9 +4513,9 @@ program. Other `awk' implementations may behave differently.) As mentioned in *note Fields::, `awk' stores the current record's number of fields in the built-in variable `NF' (also *note Built-in -Variables::). The expression `$NF' is not a special feature--it is the -direct consequence of evaluating `NF' and using its value as a field -number. +Variables::). Thus, the expression `$NF' is not a special feature--it +is the direct consequence of evaluating `NF' and using its value as a +field number. ---------- Footnotes ---------- @@ -4560,12 +4634,12 @@ value six. value of `NF' and recomputes `$0'. (d.c.) Here is an example: $ echo a b c d e f | awk '{ print "NF =", NF; - > NF = 3; print $0 }' + > NF = 3; print $0 }' -| NF = 6 -| a b c CAUTION: Some versions of `awk' don't rebuild `$0' when `NF' is - decremented. Caveat emptor. + decremented. Finally, there are times when it is convenient to force `awk' to rebuild the entire record, using the current value of the fields and @@ -4590,8 +4664,8 @@ as it was read from the input. This includes any leading or trailing whitespace, and the exact whitespace (or other characters) that separate the fields. - It is a not-uncommon error to try to change the field separators in -a record simply by setting `FS' and `OFS', and then expecting a plain + It is a common error to try to change the field separators in a +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 @@ -4628,7 +4702,7 @@ the following line: is split into three fields: `m', `*g', and `*gai*pan'. Note the leading spaces in the values of the second and third fields. - The field separator is represented by the built-in variable `FS'. + The field separator is represented by the predefined variable `FS'. Shell programmers take note: `awk' does _not_ use the name `IFS' that is used by the POSIX-compliant shells (such as the Unix Bourne shell, `sh', or Bash). @@ -4741,9 +4815,9 @@ play whenever `$0' is recomputed. For instance, study this pipeline: The first `print' statement prints the record as it was read, with leading whitespace intact. The assignment to `$2' rebuilds `$0' by concatenating `$1' through `$NF' together, separated by the value of -`OFS'. Because the leading whitespace was ignored when finding `$1', -it is not part of the new `$0'. Finally, the last `print' statement -prints the new `$0'. +`OFS' (which is a space by default). Because the leading whitespace +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 @@ -4758,7 +4832,7 @@ beginning of the record. `gawk' also works this way. For example: $ echo 'xxAA xxBxx C' | > gawk -F '(^x+)|( +)' '{ for (i = 1; i <= NF; i++) - > printf "-->%s<--\n", $i }' + > printf "-->%s<--\n", $i }' -| --><-- -| -->AA<-- -| -->xxBxx<-- @@ -4803,13 +4877,10 @@ For example: sets `FS' to the `,' character. Notice that the option uses an uppercase `F' instead of a lowercase `f'. The latter option (`-f') -specifies a file containing an `awk' program. Case is significant in -command-line options: the `-F' and `-f' options have nothing to do with -each other. You can use both options at the same time to set the `FS' -variable _and_ get an `awk' program from a file. +specifies a file containing an `awk' program. The value used for the argument to `-F' is processed in exactly the -same way as assignments to the built-in variable `FS'. Any special +same way as assignments to the predefined variable `FS'. Any special characters in the field separator must be escaped appropriately. For example, to use a `\' as the field separator on the command line, you would have to type: @@ -4904,7 +4975,7 @@ occurrences of any two characters." If instead you want fields to be separated by a literal period followed by any single character, use `FS = "\\.."'. - The following table summarizes how fields are split, based on the + The following list summarizes how fields are split, based on the value of `FS' (`==' means "is equal to"): `FS == " "' @@ -4924,7 +4995,7 @@ value of `FS' (`==' means "is equal to"): `FS == ""' Each individual character in the record becomes a separate field. - (This is a `gawk' extension; it is not specified by the POSIX + (This is a common extension; it is not specified by the POSIX standard.) Changing `FS' Does Not Affect the Fields @@ -5295,7 +5366,7 @@ A simple program to process this file is as follows: ... *Note Labels Program::, for a more realistic program that deals with -address lists. The following table summarizes how records are split, +address lists. The following list summarizes how records are split, based on the value of `RS'. (`==' means "is equal to.") `RS == "\n"' @@ -5319,9 +5390,10 @@ based on the value of `RS'. (`==' means "is equal to.") records. (This is a `gawk' extension; it is not specified by the POSIX standard.) - In all cases, `gawk' sets `RT' to the input text that matched the -value specified by `RS'. But if the input file ended without any text -that matches `RS', then `gawk' sets `RT' to the null string. + If not in compatibility mode (*note Options::), `gawk' sets `RT' to +the input text that matched the value specified by `RS'. But if the +input file ended without any text that matches `RS', then `gawk' sets +`RT' to the null string. ---------- Footnotes ---------- @@ -5400,9 +5472,7 @@ processing on the next record _right now_. For example: while (j == 0) { # get more text if (getline <= 0) { - m = "unexpected EOF or error" - m = (m ": " ERRNO) - print m > "/dev/stderr" + print("unexpected EOF or error:", ERRNO) > "/dev/stderr" exit } # build up the line using string concatenation @@ -5524,7 +5594,7 @@ Use `getline VAR < FILE' to read input from the file FILE, and put it in the variable VAR. As above, FILE is a string-valued expression that specifies the file from which to read. - In this version of `getline', none of the built-in variables are + In this version of `getline', none of the predefined variables are changed and the record is not split into fields. The only variable changed is VAR.(1) For example, the following program copies all the input files to the output, except for records that say @@ -5605,9 +5675,9 @@ the program might produce: bill ttyp1 Jul 13 14:23 (murphy:0) bletch -Notice that this program ran the command `who' and printed the previous -result. (If you try this program yourself, you will of course get -different results, depending upon who is logged in on your system.) +Notice that this program ran the command `who' and printed the result. +(If you try this program yourself, you will of course get different +results, depending upon who is logged in on your system.) This variation of `getline' splits the record into fields, sets the value of `NF', and recomputes the value of `$0'. The values of `NR' @@ -5623,10 +5693,10 @@ all `awk' implementations. NOTE: Unfortunately, `gawk' has not been consistent in its treatment of a construct like `"echo " "date" | getline'. Most versions, including the current version, treat it at as `("echo " - "date") | getline'. (This how BWK `awk' behaves.) Some versions - changed and treated it as `"echo " ("date" | getline)'. (This is - how `mawk' behaves.) In short, _always_ use explicit parentheses, - and then you won't have to worry. + "date") | getline'. (This is also how BWK `awk' behaves.) Some + versions changed and treated it as `"echo " ("date" | getline)'. + (This is how `mawk' behaves.) In short, _always_ use explicit + parentheses, and then you won't have to worry. File: gawk.info, Node: Getline/Variable/Pipe, Next: Getline/Coprocess, Prev: Getline/Pipe, Up: Getline @@ -5645,8 +5715,8 @@ following program reads the current date and time into the variable print "Report printed on " current_time } - In this version of `getline', none of the built-in variables are -changed and the record is not split into fields. + In this version of `getline', none of the predefined variables are +changed and the record is not split into fields. However, `RT' is set. According to POSIX, `EXPRESSION | getline VAR' is ambiguous if EXPRESSION contains unparenthesized operators other than `$'; for @@ -5695,7 +5765,7 @@ When you use `COMMAND |& getline VAR', the output from the coprocess COMMAND is sent through a two-way pipe to `getline' and into the variable VAR. - In this version of `getline', none of the built-in variables are + In this version of `getline', none of the predefined variables are changed and the record is not split into fields. The only variable changed is VAR. However, `RT' is set. @@ -5728,7 +5798,7 @@ in mind: `getline' command causes `awk' to set the value of `FILENAME'. Normally, `FILENAME' does not have a value inside `BEGIN' rules, because you have not yet started to process the command-line data - files. (d.c.) (*Note BEGIN/END::, also *note Auto-set::.) + files. (d.c.) (See *note BEGIN/END::; also *note Auto-set::.) * Using `FILENAME' with `getline' (`getline < FILENAME') is likely to be a source for confusion. `awk' opens a separate input stream @@ -5761,7 +5831,7 @@ in mind: `gawk' treats `getline' like a function call, and evaluates the expression `a[++c]' before attempting to read from `f'. However, some versions of `awk' only evaluate the expression once they know - that there is a string value to be assigned. Caveat Emptor. + that there is a string value to be assigned. File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline @@ -5770,23 +5840,22 @@ File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline ------------------------------------ *note table-getline-variants:: summarizes the eight variants of -`getline', listing which built-in variables are set by each one, and +`getline', listing which predefined variables are set by each one, and whether the variant is standard or a `gawk' extension. Note: for each -variant, `gawk' sets the `RT' built-in variable. +variant, `gawk' sets the `RT' predefined variable. -Variant Effect Standard / - Extension +Variant Effect `awk' / `gawk' ------------------------------------------------------------------------- -`getline' Sets `$0', `NF', `FNR', Standard +`getline' Sets `$0', `NF', `FNR', `awk' `NR', and `RT' -`getline' VAR Sets VAR, `FNR', `NR', and Standard +`getline' VAR Sets VAR, `FNR', `NR', and `awk' `RT' -`getline <' FILE Sets `$0', `NF', and `RT' Standard -`getline VAR < FILE' Sets VAR and `RT' Standard -COMMAND `| getline' Sets `$0', `NF', and `RT' Standard -COMMAND `| getline' VAR Sets VAR and `RT' Standard -COMMAND `|& getline' Sets `$0', `NF', and `RT' Extension -COMMAND `|& getline' Sets VAR and `RT' Extension +`getline <' FILE Sets `$0', `NF', and `RT' `awk' +`getline VAR < FILE' Sets VAR and `RT' `awk' +COMMAND `| getline' Sets `$0', `NF', and `RT' `awk' +COMMAND `| getline' VAR Sets VAR and `RT' `awk' +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 @@ -5802,7 +5871,7 @@ 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 -setting a special element in the `PROCINFO' (*note Auto-set::) array: +setting a special element in the `PROCINFO' array (*note Auto-set::): PROCINFO["input_name", "READ_TIMEOUT"] = TIMEOUT IN MILLISECONDS @@ -5826,9 +5895,9 @@ for more than five seconds: print $0 `gawk' terminates the read operation if input does not arrive after -waiting for the timeout period, returns failure and sets the `ERRNO' -variable to an appropriate string value. A negative or zero value for -the timeout is the same as specifying no timeout at all. +waiting for the timeout period, returns failure and sets `ERRNO' to an +appropriate string value. A negative or zero value for the timeout is +the same as specifying no timeout at all. A timeout can also be set for reading from the keyboard in the implicit loop that reads input records and matches them against @@ -5926,6 +5995,10 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li A regexp Text that matches the `gawk' regexp + * `FNR' indicates how many records have been read from the current + input file; `NR' indicates how many records have been read in + total. + * `gawk' sets `RT' to the text matched by `RS'. * After splitting the input into records, `awk' further splits the @@ -5943,32 +6016,31 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li * Field splitting is more complicated than record splitting. - Field separator value Fields are split ... `awk' / - `gawk' + Field separator value Fields are split ... `awk' / + `gawk' ---------------------------------------------------------------------- - `FS == " "' On runs of whitespace `awk' - `FS == ANY SINGLE On that character `awk' - CHARACTER' - `FS == REGEXP' On text matching the `awk' - regexp - `FS == ""' Each individual character `gawk' - is a separate field - `FIELDWIDTHS == LIST OF Based on character `gawk' - COLUMNS' position - `FPAT == REGEXP' On text around text `gawk' - matching the regexp - - Using `FS = "\n"' causes the entire record to be a single field + `FS == " "' On runs of whitespace `awk' + `FS == ANY SINGLE On that character `awk' + CHARACTER' + `FS == REGEXP' On text matching the regexp `awk' + `FS == ""' Each individual character is `gawk' + a separate field + `FIELDWIDTHS == LIST OF Based on character position `gawk' + COLUMNS' + `FPAT == REGEXP' On the text surrounding text `gawk' + matching the regexp + + * Using `FS = "\n"' causes the entire record to be a single field (assuming that newlines separate records). * `FS' may be set from the command line using the `-F' option. This can also be done using command-line variable assignment. - * `PROCINFO["FS"]' can be used to see how fields are being split. + * Use `PROCINFO["FS"]' to see how fields are being split. * Use `getline' in its various forms to read additional records, from the default input stream, from a file, or from a pipe or - co-process. + coprocess. * Use `PROCINFO[FILE, "READ_TIMEOUT"]' to cause reads to timeout for FILE. @@ -6026,6 +6098,7 @@ function. * Printf:: The `printf' statement. * Redirection:: How to redirect output to multiple files and pipes. +* Special FD:: Special files for I/O. * Special Files:: File name interpretation in `gawk'. `gawk' allows access to inherited file descriptors. @@ -6039,10 +6112,10 @@ File: gawk.info, Node: Print, Next: Print Examples, Up: Printing 5.1 The `print' Statement ========================= -The `print' statement is used for producing output with simple, -standardized formatting. You specify only the strings or numbers to -print, in a list separated by commas. They are output, separated by -single spaces, followed by a newline. The statement looks like this: +Use the `print' statement to produce output with simple, standardized +formatting. You specify only the strings or numbers to print, in a +list separated by commas. They are output, separated by single spaces, +followed by a newline. The statement looks like this: print ITEM1, ITEM2, ... @@ -6057,14 +6130,14 @@ Numeric values are converted to strings and then printed. The simple statement `print' with no items is equivalent to `print $0': it prints the entire current record. To print a blank line, use -`print ""', where `""' is the empty string. To print a fixed piece of -text, use a string constant, such as `"Don't Panic"', as one item. If -you forget to use the double-quote characters, your text is taken as an -`awk' expression, and you will probably get an error. Keep in mind -that a space is printed between any two items. +`print ""'. To print a fixed piece of text, use a string constant, +such as `"Don't Panic"', as one item. If you forget to use the +double-quote characters, your text is taken as an `awk' expression, and +you will probably get an error. Keep in mind that a space is printed +between any two items. Note that the `print' statement is a statement and not an -expression--you can't use it the pattern part of a pattern-action +expression--you can't use it in the pattern part of a PATTERN-ACTION statement, for example. @@ -6157,7 +6230,7 @@ As mentioned previously, a `print' statement contains a list of items separated by commas. In the output, the items are normally separated by single spaces. However, this doesn't need to be the case; a single space is simply the default. Any string of characters may be used as -the "output field separator" by setting the built-in variable `OFS'. +the "output field separator" by setting the predefined variable `OFS'. The initial value of this variable is the string `" "'--that is, a single space. @@ -6219,12 +6292,12 @@ to format numbers (or strings), and that there are a number of different ways in which numbers can be formatted. The different format specifications are discussed more fully in *note Control Letters::. - The built-in variable `OFMT' contains the default format -specification that `print' uses with `sprintf()' when it wants to -convert a number to a string for printing. The default value of `OFMT' -is `"%.6g"'. The way `print' prints numbers can be changed by -supplying different format specifications as the value of `OFMT', as -shown in the following example: + The predefined variable `OFMT' contains the format specification +that `print' uses with `sprintf()' when it wants to convert a number to +a string for printing. The default value of `OFMT' is `"%.6g"'. The +way `print' prints numbers can be changed by supplying a different +format specification for the value of `OFMT', as shown in the following +example: $ awk 'BEGIN { > OFMT = "%.0f" # print numbers as integers (rounds) @@ -6246,8 +6319,6 @@ by `print', use `printf'. With `printf' you can specify the width to use for each item, as well as various formatting choices for numbers (such as what output base to use, whether to print an exponent, whether to print a sign, and how many digits to print after the decimal point). -You do this by supplying a string, called the "format string", that -controls how and where to print the other arguments. * Menu: @@ -6266,10 +6337,10 @@ A simple `printf' statement looks like this: printf FORMAT, ITEM1, ITEM2, ... -The entire list of arguments may optionally be enclosed in parentheses. -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 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::). The difference between `printf' and `print' is the FORMAT argument. This is an expression whose value is taken as a string; it specifies @@ -6290,10 +6361,10 @@ statements. For example: $ awk 'BEGIN { > ORS = "\nOUCH!\n"; OFS = "+" - > msg = "Dont Panic!" + > msg = "Don\47t Panic!" > printf "%s\n", msg > }' - -| Dont Panic! + -| Don't Panic! Here, neither the `+' nor the `OUCH' appear in the output message. @@ -6311,9 +6382,9 @@ print. The rest of the format specifier is made up of optional width. Here is a list of the format-control letters: `%c' - Print a number as an ASCII character; thus, `printf "%c", 65' - outputs the letter `A'. The output for a string value is the first - character of the string. + Print a number as a character; thus, `printf "%c", 65' outputs the + letter `A'. The output for a string value is the first character + of the string. NOTE: The POSIX standard says the first character of a string is printed. In locales with multibyte characters, `gawk' @@ -6406,7 +6477,7 @@ File: gawk.info, Node: Format Modifiers, Next: Printf Examples, Prev: Control A format specification can also include "modifiers" that can control how much of the item's value is printed, as well as how much space it gets. The modifiers come between the `%' and the format-control letter. -We will use the bullet symbol "*" in the following examples to represent +We use the bullet symbol "*" in the following examples to represent spaces in the output. Here are the possible modifiers, in the order in which they may appear: @@ -6426,8 +6497,7 @@ which they may appear: At first glance, this feature doesn't seem to be of much use. It is in fact a `gawk' extension, intended for use in translating messages at runtime. *Note Printf Ordering::, which describes how - and why to use positional specifiers. For now, we will not use - them. + and why to use positional specifiers. For now, we ignore them. `-' The minus sign, used before the width modifier (see later on in @@ -6457,10 +6527,10 @@ which they may appear: trailing zeros are not removed from the result. `0' - A leading `0' (zero) acts as a flag that indicates that output - should be padded with zeros instead of spaces. This applies only - to the numeric output formats. This flag only has an effect when - the field width is wider than the value to print. + A leading `0' (zero) acts as a flag indicating that output should + be padded with zeros instead of spaces. This applies only to the + numeric output formats. This flag only has an effect when the + field width is wider than the value to print. `'' A single quote or apostrophe character is a POSIX extension to ISO @@ -6608,14 +6678,14 @@ beginning of the `awk' program: awk 'BEGIN { print "Name Number" print "---- ------" } - { printf "%-10s %s\n", $1, $2 }' mail-list + { 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: awk 'BEGIN { printf "%-10s %s\n", "Name", "Number" printf "%-10s %s\n", "----", "------" } - { printf "%-10s %s\n", $1, $2 }' mail-list + { printf "%-10s %s\n", $1, $2 }' mail-list Printing each column heading with the same format specification used for the column elements ensures that the headings are aligned just like @@ -6627,10 +6697,10 @@ be emphasized by storing it in a variable, like this: awk 'BEGIN { format = "%-10s %s\n" printf format, "Name", "Number" printf format, "----", "------" } - { printf format, $1, $2 }' mail-list + { printf format, $1, $2 }' mail-list -File: gawk.info, Node: Redirection, Next: Special Files, Prev: Printf, Up: Printing +File: gawk.info, Node: Redirection, Next: Special FD, Prev: Printf, Up: Printing 5.6 Redirecting Output of `print' and `printf' ============================================== @@ -6640,7 +6710,7 @@ output, usually the screen. Both `print' and `printf' can also send their output to other places. This is called "redirection". NOTE: When `--sandbox' is specified (*note Options::), redirecting - output to files and pipes is disabled. + output to files, pipes and coprocesses is disabled. A redirection appears after the `print' or `printf' statement. Redirections in `awk' are written just like redirections in shell @@ -6711,16 +6781,10 @@ work identically for `printf': maintenance: report = "mail bug-system" - print "Awk script failed:", $0 | report - m = ("at record number " FNR " of " FILENAME) - print m | report + print("Awk script failed:", $0) | report + print("at record number", FNR, "of", FILENAME) | report close(report) - The message is built using string concatenation and saved in the - variable `m'. It's then sent down the pipeline to the `mail' - program. (The parentheses group the items to concatenate--see - *note Concatenation::.) - The `close()' function is called here because it's a good idea to close the pipe as soon as all the intended output has been sent to it. *Note Close Files And Pipes::, for more information. @@ -6786,40 +6850,30 @@ uppercase characters converted to lowercase (*note String Functions::). The program builds up a list of command lines, using the `mv' utility to rename the files. It then sends the list to the shell for execution. - -File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Redirection, Up: Printing - -5.7 Special File Names in `gawk' -================================ - -`gawk' provides a number of special file names that it interprets -internally. These file names provide access to standard file -descriptors and TCP/IP networking. - -* Menu: - -* Special FD:: Special files for I/O. -* Special Network:: Special files for network communications. -* Special Caveats:: Things to watch out for. + *Note Shell Quoting::, for a function that can help in generating +command lines to be fed to the shell. -File: gawk.info, Node: Special FD, Next: Special Network, Up: Special Files +File: gawk.info, Node: Special FD, Next: Special Files, Prev: Redirection, Up: Printing -5.7.1 Special Files for Standard Descriptors --------------------------------------------- +5.7 Special Files for Standard Pre-Opened Data Streams +====================================================== Running programs conventionally have three input and output streams already available to them for reading and writing. These are known as the "standard input", "standard output", and "standard error output". -These streams are, by default, connected to your keyboard and screen, -but they are often redirected with the shell, via the `<', `<<', `>', -`>>', `>&', and `|' operators. Standard error is typically used for -writing error messages; the reason there are two separate streams, +These open streams (and any other open file or pipe) are often referred +to by the technical term "file descriptors". + + These streams are, by default, connected to your keyboard and +screen, but they are often redirected with the shell, via the `<', `<<', +`>', `>>', `>&', and `|' operators. Standard error is typically used +for writing error messages; the reason there are two separate streams, standard output and standard error, is so that they can be redirected separately. - In other implementations of `awk', the only way to write an error -message to standard error in an `awk' program is as follows: + In traditional implementations of `awk', the only way to write an +error message to standard error in an `awk' program is as follows: print "Serious error detected!" | "cat 1>&2" @@ -6834,19 +6888,18 @@ error messages to the screen, like this: (`/dev/tty' is a special file supplied by the operating system that is connected to your keyboard and screen. It represents the "terminal,"(1) which on modern systems is a keyboard and screen, not a serial console.) -This usually has the same effect but not always: although the standard -error stream is usually the screen, it can be redirected; when 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 +This generally has the same effect but not always: although the +standard error stream is usually the screen, it can be redirected; when +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' provides special file names for accessing the three standard -streams. (c.e.) It also provides syntax for accessing any other -inherited open files. If the file name matches one of these special -names when `gawk' redirects input or output, then it directly uses the -stream that the file name stands for. These special file names work -for all operating systems that `gawk' has been ported to, not just -those that are POSIX-compliant: + `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 +stands for. These special file names work for all operating systems +that `gawk' has been ported to, not just those that are POSIX-compliant: `/dev/stdin' The standard input (file descriptor 0). @@ -6857,16 +6910,8 @@ those that are POSIX-compliant: `/dev/stderr' The standard error output (file descriptor 2). -`/dev/fd/N' - The file associated with file descriptor N. Such a file must be - opened by the program initiating the `awk' execution (typically - the shell). Unless special pains are taken in the shell from which - `gawk' is invoked, only descriptors 0, 1, and 2 are available. - - The file names `/dev/stdin', `/dev/stdout', and `/dev/stderr' are -aliases for `/dev/fd/0', `/dev/fd/1', and `/dev/fd/2', respectively. -However, they are more self-explanatory. The proper way to write an -error message in a `gawk' program is to use `/dev/stderr', like this: + With these facilities, the proper way to write an error message then +becomes: print "Serious error detected!" > "/dev/stderr" @@ -6874,21 +6919,60 @@ error message in a `gawk' program is to use `/dev/stderr', like this: redirection, the value must be a string. It is a common error to omit the quotes, which leads to confusing results. - Finally, using the `close()' function on a file name of the form -`"/dev/fd/N"', for file descriptor numbers above two, does actually -close the given file descriptor. - - The `/dev/stdin', `/dev/stdout', and `/dev/stderr' special files are -also recognized internally by several other versions of `awk'. + `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::). ---------- Footnotes ---------- (1) The "tty" in `/dev/tty' stands for "Teletype," a serial terminal. -File: gawk.info, Node: Special Network, Next: Special Caveats, Prev: Special FD, Up: Special Files +File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Special FD, Up: Printing + +5.8 Special File Names in `gawk' +================================ + +Besides access to standard input, stanard output, and standard error, +`gawk' provides access to any open file descriptor. Additionally, +there are special file names reserved for TCP/IP networking. -5.7.2 Special Files for Network Communications +* Menu: + +* Other Inherited Files:: Accessing other open files with + `gawk'. +* Special Network:: Special files for network communications. +* Special Caveats:: Things to watch out for. + + +File: gawk.info, Node: Other Inherited Files, Next: Special Network, Up: Special Files + +5.8.1 Accessing Other Open Files With `gawk' +-------------------------------------------- + +Besides the `/dev/stdin', `/dev/stdout', and `/dev/stderr' special file +names mentioned earlier, `gawk' provides syntax for accessing any other +inherited open file: + +`/dev/fd/N' + The file associated with file descriptor N. Such a file must be + opened by the program initiating the `awk' execution (typically + the shell). Unless special pains are taken in the shell from which + `gawk' is invoked, only descriptors 0, 1, and 2 are available. + + The file names `/dev/stdin', `/dev/stdout', and `/dev/stderr' are +essentially aliases for `/dev/fd/0', `/dev/fd/1', and `/dev/fd/2', +respectively. However, those names are more self-explanatory. + + Note that using `close()' on a file name of the form `"/dev/fd/N"', +for file descriptor numbers above two, does actually close the given +file descriptor. + + +File: gawk.info, Node: Special Network, Next: Special Caveats, Prev: Other Inherited Files, Up: Special Files + +5.8.2 Special Files for Network Communications ---------------------------------------------- `gawk' programs can open a two-way TCP/IP connection, acting as either @@ -6908,14 +6992,18 @@ mentioned here only for completeness. Full discussion is delayed until File: gawk.info, Node: Special Caveats, Prev: Special Network, Up: Special Files -5.7.3 Special File Name Caveats +5.8.3 Special File Name Caveats ------------------------------- -Here is a list of things to bear in mind when using the special file -names that `gawk' provides: +Here are some things to bear in mind when using the special file names +that `gawk' provides: - * Recognition of these special file names is disabled if `gawk' is in - compatibility mode (*note Options::). + * Recognition of the file names for the three standard pre-opened + files is disabled only in POSIX mode. + + * Recognition of the other special file names is disabled if `gawk' + is in compatibility mode (either `--traditional' or `--posix'; + *note Options::). * `gawk' _always_ interprets these special file names. For example, using `/dev/fd/4' for output actually writes on file descriptor 4, @@ -6928,7 +7016,7 @@ names that `gawk' provides: File: gawk.info, Node: Close Files And Pipes, Next: Output Summary, Prev: Special Files, Up: Printing -5.8 Closing Input and Output Redirections +5.9 Closing Input and Output Redirections ========================================= If the same file name or the same shell command is used with `getline' @@ -7042,7 +7130,8 @@ 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. It is, more likely, a close of a file that was never opened with a -redirection, so `awk' silently does nothing. +redirection, so `awk' silently does nothing, except return a negative +value. When using the `|&' operator to communicate with a coprocess, it is occasionally useful to be able to close one end of the two-way pipe @@ -7051,8 +7140,8 @@ to `close()'. As in any other call to `close()', the first argument is the name of the command or special file used to start the coprocess. The second argument should be a string, with either of the values `"to"' or `"from"'. Case does not matter. As this is an advanced -feature, a more complete discussion is delayed until *note Two-way -I/O::, which discusses it in more detail and gives an example. +feature, discussion is delayed until *note Two-way I/O::, which +describes it in more detail and gives an example. Using `close()''s Return Value @@ -7067,8 +7156,8 @@ value from `close()': (d.c.) `gawk' treats `close()' as a function. The return value is -1 if the argument names something that was never opened with a redirection, or if there is a system problem closing the file or process. In these -cases, `gawk' sets the built-in variable `ERRNO' to a string describing -the problem. +cases, `gawk' sets the predefined variable `ERRNO' to a string +describing the problem. In `gawk', when closing a pipe or coprocess (input or output), the return value is the exit status of the command.(2) Otherwise, it is the @@ -7095,8 +7184,8 @@ value. File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Files And Pipes, Up: Printing -5.9 Summary -=========== +5.10 Summary +============ * The `print' statement prints comma-separated expressions. Each expression is separated by the value of `OFS' and terminated by @@ -7108,20 +7197,20 @@ File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Fi flags that modify the behavior of the format control letters. * Output from both `print' and `printf' may be redirected to files, - pipes, and co-processes. + pipes, and coprocesses. * `gawk' provides special file names for access to standard input, output and error, and for network communications. - * Use `close()' to close open file, pipe and co-process redirections. - For co-processes, it is possible to close only one direction of the + * Use `close()' to close open file, pipe and coprocess redirections. + For coprocesses, it is possible to close only one direction of the communications. File: gawk.info, Node: Output Exercises, Prev: Output Summary, Up: Printing -5.10 Exercises +5.11 Exercises ============== 1. Rewrite the program: @@ -7351,7 +7440,7 @@ and: are exactly equivalent. One rather bizarre consequence of this rule is that the following Boolean expression is valid, but does not do what -the user probably intended: +its author probably intended: # Note that /foo/ is on the left of the ~ if (/foo/ ~ $1) print "found foo" @@ -7377,9 +7466,10 @@ of the `match()' function, and as the third argument of the `split()' and `patsplit()' functions (*note String Functions::). Modern implementations of `awk', including `gawk', allow the third argument of `split()' to be a regexp constant, but some older implementations do -not. (d.c.) This can lead to confusion when attempting to use regexp -constants as arguments to user-defined functions (*note User-defined::). -For example: +not. (d.c.) Because some built-in functions accept regexp constants +as arguments, it can be confusing when attempting to use regexp +constants as arguments to user-defined functions (*note +User-defined::). For example: function mysub(pat, repl, str, global) { @@ -7443,23 +7533,23 @@ 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()', -`patsplit()' and `split()' 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 field separator), and `NF' (the number of fields in the current input -record). *Note Built-in Variables::, for a list of the built-in -variables. These built-in variables can be used and assigned just like -all other variables, but their values are also used or changed -automatically by `awk'. All built-in variables' names are entirely +record). *Note Built-in Variables::, for a list of the predefined +variables. These predefined variables can be used and assigned just +like all other variables, but their values are also used or changed +automatically by `awk'. All predefined variables' names are entirely uppercase. Variables in `awk' can be assigned either numeric or string values. The kind of value a variable holds can change over the life of a program. By default, variables are initialized to the empty string, which is zero if converted to a number. There is no need to explicitly -"initialize" a variable in `awk', which is what you would do in C and -in most other traditional languages. +initialize a variable in `awk', which is what you would do in C and in +most other traditional languages. File: gawk.info, Node: Assignment Options, Prev: Using Variables, Up: Variables @@ -7555,7 +7645,7 @@ the string as numerals: `"2.5"' converts to 2.5, `"1e3"' converts to interpreted as valid numbers convert to zero. The exact manner in which numbers are converted into strings is -controlled by the `awk' built-in variable `CONVFMT' (*note Built-in +controlled by the `awk' predefined variable `CONVFMT' (*note Built-in Variables::). Numbers are converted using the `sprintf()' function with `CONVFMT' as the format specifier (*note String Functions::). @@ -7634,8 +7724,8 @@ difference in behavior, on a GNU/Linux system: The `en_DK.utf-8' locale is for English in Denmark, where the comma acts as the decimal point separator. In the normal `"C"' locale, `gawk' -treats `4,321' as `4', while in the Danish locale, it's treated as the -full number, 4.321. +treats `4,321' as 4, while in the Danish locale, it's treated as the +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 @@ -8017,8 +8107,7 @@ A workaround is: awk '/[=]=/' /dev/null - `gawk' does not have this problem; BWK `awk' and `mawk' also do not -(*note Other Versions::). + `gawk' does not have this problem; BWK `awk' and `mawk' also do not. File: gawk.info, Node: Increment Ops, Prev: Assignment Ops, Up: All Operators @@ -8195,9 +8284,9 @@ determine how they are compared. Variable typing follows these rules: STRING attribute. * Fields, `getline' input, `FILENAME', `ARGV' elements, `ENVIRON' - elements, and the elements of an array created by `patsplit()', - `split()' and `match()' that are numeric strings have the STRNUM - attribute. Otherwise, they have the STRING attribute. + elements, and the elements of an array created by `match()', + `split()' and `patsplit()' that are numeric strings have the + STRNUM attribute. Otherwise, they have the STRING attribute. Uninitialized variables also have the STRNUM attribute. * Attributes propagate across assignments but are not changed by any @@ -8247,21 +8336,21 @@ In contrast, the eight characters `" +3.14"' appearing in program text comprise a string constant. The following examples print `1' when the comparison between the two different constants is true, `0' otherwise: - $ echo ' +3.14' | gawk '{ print $0 == " +3.14" }' True + $ echo ' +3.14' | awk '{ print($0 == " +3.14") }' True -| 1 - $ echo ' +3.14' | gawk '{ print $0 == "+3.14" }' False + $ echo ' +3.14' | awk '{ print($0 == "+3.14") }' False -| 0 - $ echo ' +3.14' | gawk '{ print $0 == "3.14" }' False + $ echo ' +3.14' | awk '{ print($0 == "3.14") }' False -| 0 - $ echo ' +3.14' | gawk '{ print $0 == 3.14 }' True + $ echo ' +3.14' | awk '{ print($0 == 3.14) }' True -| 1 - $ echo ' +3.14' | gawk '{ print $1 == " +3.14" }' False + $ echo ' +3.14' | awk '{ print($1 == " +3.14") }' False -| 0 - $ echo ' +3.14' | gawk '{ print $1 == "+3.14" }' True + $ echo ' +3.14' | awk '{ print($1 == "+3.14") }' True -| 1 - $ echo ' +3.14' | gawk '{ print $1 == "3.14" }' False + $ echo ' +3.14' | awk '{ print($1 == "3.14") }' False -| 0 - $ echo ' +3.14' | gawk '{ print $1 == 3.14 }' True + $ echo ' +3.14' | awk '{ print($1 == 3.14) }' True -| 1 @@ -8314,8 +8403,9 @@ Unless `b' happens to be zero or the null string, the `if' part of the test always succeeds. Because the operators are so similar, this kind of error is very difficult to spot when scanning the source code. - The following table of expressions illustrates the kind of comparison -`gawk' performs, as well as what the result of the comparison is: + The following list of expressions illustrates the kinds of +comparisons `awk' performs, as well as what the result of each +comparison is: `1.5 <= 2.0' numeric comparison (true) @@ -8366,9 +8456,9 @@ regexp constant (`/'...`/') or an ordinary expression. In the latter case, the value of the expression as a string is used as a dynamic regexp (*note Regexp Usage::; also *note Computed Regexps::). - In modern implementations of `awk', a constant regular expression in -slashes by itself is also an expression. The regexp `/REGEXP/' is an -abbreviation for the following comparison expression: + A constant regular expression in slashes by itself is also an +expression. The regexp `/REGEXP/' is an abbreviation for the following +comparison expression: $0 ~ /REGEXP/ @@ -8384,9 +8474,9 @@ File: gawk.info, Node: POSIX String Comparison, Prev: Comparison Operators, U The POSIX standard says that string comparison is performed based on the locale's "collating order". This is the order in which characters -sort, as defined by the locale (for more discussion, *note Ranges and -Locales::). This order is usually very different from the results -obtained when doing straight character-by-character comparison.(1) +sort, as defined by the locale (for more discussion, *note Locales::). +This order is usually very different from the results obtained when +doing straight character-by-character comparison.(1) Because this behavior differs considerably from existing practice, `gawk' only implements it when in POSIX mode (*note Options::). Here @@ -8443,13 +8533,15 @@ Boolean operators are: `BOOLEAN1 || BOOLEAN2' True if at least one of BOOLEAN1 or BOOLEAN2 is true. For example, the following statement prints all records in the input - that contain _either_ `edu' or `li' or both: + that contain _either_ `edu' or `li': if ($0 ~ /edu/ || $0 ~ /li/) print The subexpression BOOLEAN2 is evaluated only if BOOLEAN1 is false. This can make a difference when BOOLEAN2 contains expressions that - have side effects. + have side effects. (Thus, this test never really distinguishes + records that contain both `edu' and `li'--as soon as `edu' is + matched, the full test succeeds.) `! BOOLEAN' True if BOOLEAN is false. For example, the following program @@ -8457,7 +8549,7 @@ Boolean operators are: variable is not defined: BEGIN { if (! ("HOME" in ENVIRON)) - print "no home!" } + print "no home!" } (The `in' operator is described in *note Reference to Elements::.) @@ -8680,7 +8772,7 @@ violates the precedence rules; for example, `$$0++--' is not a valid expression because the first `$' has higher precedence than the `++'; to avoid the problem the expression can be rewritten as `$($0++)--'. - This table presents `awk''s operators, in order of highest to lowest + This list presents `awk''s operators, in order of highest to lowest precedence: `('...`)' @@ -8755,8 +8847,8 @@ system about the local character set and language. The ISO C standard defines a default `"C"' locale, which is an environment that is typical of what many C programmers are used to. - Once upon a time, the locale setting used to affect regexp matching -(*note Ranges and Locales::), but this is no longer true. + Once upon a time, the locale setting used to affect regexp matching, +but this is no longer true (*note Ranges and Locales::). Locales can affect record splitting. For the normal case of `RS = "\n"', the locale is largely irrelevant. For other single-character @@ -8808,10 +8900,11 @@ File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions * `awk' provides the usual arithmetic operators (addition, subtraction, multiplication, division, modulus), and unary plus and minus. It also provides comparison operators, boolean - operators, and regexp matching operators. String concatenation is - accomplished by placing two expressions next to each other; there - is no explicit operator. The three-operand `?:' operator provides - an "if-else" test within expressions. + operators, array membership testing, and regexp matching + operators. String concatenation is accomplished by placing two + expressions next to each other; there is no explicit operator. + The three-operand `?:' operator provides an "if-else" test within + expressions. * Assignment operators provide convenient shorthands for common arithmetic operations. @@ -8819,8 +8912,8 @@ File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions * In `awk', a value is considered to be true if it is non-zero _or_ non-null. Otherwise, the value is false. - * A value's type is set upon each assignment and may change over its - lifetime. The type determines how it behaves in comparisons + * A variable's type is set upon each assignment and may change over + its lifetime. The type determines how it behaves in comparisons (string or numeric). * Function calls return a value which may be used as part of a larger @@ -8846,7 +8939,7 @@ File: gawk.info, Node: Patterns and Actions, Next: Arrays, Prev: Expressions, As you have already seen, each `awk' statement consists of a pattern with an associated action. This major node describes how you build patterns and actions, what kinds of things you can do within actions, -and `awk''s built-in variables. +and `awk''s predefined variables. The pattern-action rules and the statements available for use within actions form the core of `awk' programming. In a sense, everything @@ -8860,7 +8953,7 @@ top of. Now it's time to start building something useful. * Action Overview:: What goes into an action. * Statements:: Describes the various control statements in detail. -* Built-in Variables:: Summarizes the built-in variables. +* Built-in Variables:: Summarizes the predefined variables. * Pattern Action Summary:: Patterns and Actions summary. @@ -8891,7 +8984,7 @@ summary of the types of `awk' patterns: number) or non-null (if a string). (*Note Expression Patterns::.) `BEGPAT, ENDPAT' - A pair of patterns separated by a comma, specifying a range of + A pair of patterns separated by a comma, specifying a "range" of records. The range includes both the initial record that matches BEGPAT and the final record that matches ENDPAT. (*Note Ranges::.) @@ -9102,7 +9195,7 @@ input is read. For example: $ awk ' > BEGIN { print "Analysis of \"li\"" } - > /li/ { ++n } + > /li/ { ++n } > END { print "\"li\" appears in", n, "records." }' mail-list -| Analysis of "li" -| "li" appears in 4 records. @@ -9171,9 +9264,10 @@ and `NF' were _undefined_ inside an `END' rule. The POSIX standard specifies that `NF' is available in an `END' rule. It contains the number of fields from the last input record. Most probably due to an oversight, the standard does not say that `$0' is also preserved, -although logically one would think that it should be. In fact, `gawk' -does preserve the value of `$0' for use in `END' rules. Be aware, -however, that BWK `awk', and possibly other implementations, do not. +although logically one would think that it should be. In fact, all of +BWK `awk', `mawk', and `gawk' preserve the value of `$0' for use in +`END' rules. Be aware, however, that some other implementations and +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 @@ -9242,9 +9336,9 @@ makes it possible to catch and process I/O errors at the level of the `awk' program. The `next' statement (*note Next Statement::) is not allowed inside -either a `BEGINFILE' or and `ENDFILE' rule. The `nextfile' statement -(*note Nextfile Statement::) is allowed only inside a `BEGINFILE' rule, -but not inside an `ENDFILE' rule. +either a `BEGINFILE' or an `ENDFILE' rule. The `nextfile' statement is +allowed only inside a `BEGINFILE' rule, but not inside an `ENDFILE' +rule. The `getline' statement (*note Getline::) is restricted inside both `BEGINFILE' and `ENDFILE': only redirected forms of `getline' are @@ -9279,9 +9373,9 @@ hold a pattern that the `awk' program searches for. There are two ways to get the value of the shell variable into the body of the `awk' program. - The most common method is to use shell quoting to substitute the -variable's value into the program inside the script. For example, -consider the following program: + A common method is to use shell quoting to substitute the variable's +value into the program inside the script. For example, consider the +following program: printf "Enter search pattern: " read pattern @@ -9472,18 +9566,18 @@ thing the `while' statement does is test the CONDITION. If the CONDITION is true, it executes the statement BODY. (The CONDITION is true when the value is not zero and not a null string.) After BODY has been executed, CONDITION is tested again, and if it is still true, BODY -is executed again. This process repeats until the CONDITION is no -longer true. If the CONDITION is initially false, the body of the loop -is never executed and `awk' continues with the statement following the -loop. This example prints the first three fields of each record, one -per line: - - awk '{ - i = 1 - while (i <= 3) { - print $i - i++ - } +executes again. This process repeats until the CONDITION is no longer +true. If the CONDITION is initially false, the body of the loop never +executes and `awk' continues with the statement following the loop. +This example prints the first three fields of each record, one per line: + + awk ' + { + i = 1 + while (i <= 3) { + print $i + i++ + } }' inventory-shipped The body of this loop is a compound statement enclosed in braces, @@ -9514,22 +9608,22 @@ the CONDITION is true. It looks like this: BODY while (CONDITION) - Even if the CONDITION is false at the start, the BODY is executed at + Even if the CONDITION is false at the start, the BODY executes at least once (and only once, unless executing BODY makes CONDITION true). Contrast this with the corresponding `while' statement: while (CONDITION) - BODY + BODY This statement does not execute BODY even once if the CONDITION is false to begin with. The following is an example of a `do' statement: { - i = 1 - do { - print $0 - i++ - } while (i <= 10) + i = 1 + do { + print $0 + i++ + } while (i <= 10) } This program prints each input record 10 times. However, it isn't a @@ -9558,9 +9652,10 @@ INCREMENT. Typically, INITIALIZATION sets a variable to either zero or one, INCREMENT adds one to it, and CONDITION compares it against the desired number of iterations. For example: - awk '{ - for (i = 1; i <= 3; i++) - print $i + awk ' + { + for (i = 1; i <= 3; i++) + print $i }' inventory-shipped This prints the first three fields of each input record, with one field @@ -9584,7 +9679,7 @@ whatsoever. For example, the following statement prints all the powers of two between 1 and 100: for (i = 1; i <= 100; i *= 2) - print i + print i If there is nothing to be done, any of the three expressions in the parentheses following the `for' keyword may be omitted. Thus, @@ -9842,11 +9937,11 @@ rules. *Note BEGINFILE/ENDFILE::. According to the POSIX standard, the behavior is undefined if the `next' statement is used in a `BEGIN' or `END' rule. `gawk' treats it -as a syntax error. Although POSIX permits it, most other `awk' -implementations don't allow the `next' statement inside function bodies -(*note User-defined::). Just as with any other `next' statement, a -`next' statement inside a function body reads the next record and -starts processing it with the first rule in the program. +as a syntax error. Although POSIX does not disallow it, most other +`awk' implementations don't allow the `next' statement inside function +bodies (*note User-defined::). Just as with any other `next' +statement, a `next' statement inside a function body reads the next +record and starts processing it with the first rule in the program. File: gawk.info, Node: Nextfile Statement, Next: Exit Statement, Prev: Next Statement, Up: Statements @@ -9890,17 +9985,17 @@ 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 `gawk' extension. As of + NOTE: For many years, `nextfile' was a 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=607). - The current version of BWK `awk', and `mawk' (*note Other -Versions::) also support `nextfile'. However, they don't allow the -`nextfile' statement inside function bodies (*note User-defined::). -`gawk' does; a `nextfile' inside a function body reads the next record -and starts processing it with the first rule in the program, just as -any other `nextfile' statement. + The current version of BWK `awk', and `mawk' also support +`nextfile'. However, they don't allow the `nextfile' statement inside +function bodies (*note User-defined::). `gawk' does; a `nextfile' +inside a function body reads the next record and starts processing it +with the first rule in the program, just as any other `nextfile' +statement. File: gawk.info, Node: Exit Statement, Prev: Nextfile Statement, Up: Statements @@ -9924,8 +10019,8 @@ stop immediately. An `exit' statement that is not part of a `BEGIN' or `END' rule stops the execution of any further automatic rules for the current record, skips reading any remaining input records, and executes the -`END' rule if there is one. Any `ENDFILE' rules are also skipped; they -are not executed. +`END' rule if there is one. `gawk' also skips any `ENDFILE' rules; +they do not execute. In such a case, if you don't want the `END' rule to do its job, set a variable to nonzero before the `exit' statement and check that @@ -9962,8 +10057,8 @@ statement with a nonzero argument, as shown in the following example: File: gawk.info, Node: Built-in Variables, Next: Pattern Action Summary, Prev: Statements, Up: Patterns and Actions -7.5 Built-in Variables -====================== +7.5 Predefined Variables +======================== Most `awk' variables are available to use for your own purposes; they never change unless your program assigns values to them, and they never @@ -9973,7 +10068,7 @@ of these automatically, so that they enable you to tell `awk' how to do certain things. Others are set automatically by `awk', so that they carry information from the internal workings of `awk' to your program. - This minor node documents all of `gawk''s built-in variables, most + This minor node documents all of `gawk''s predefined variables, most of which are also documented in the major nodes describing their areas of activity. @@ -10012,7 +10107,7 @@ description of each variable.) use binary I/O. Any other string value is treated the same as `"rw"', but causes `gawk' to generate a warning message. `BINMODE' is described in more detail in *note PC Using::. `mawk' - *note Other Versions::), also supports this variable, but only + (*note Other Versions::), also supports this variable, but only using numeric values. ``CONVFMT'' @@ -10095,9 +10190,8 @@ description of each variable.) printing with the `print' statement. It works by being passed as the first argument to the `sprintf()' function (*note String Functions::). Its default value is `"%.6g"'. Earlier versions of - `awk' also used `OFMT' to specify the format for converting - numbers to strings in general expressions; this is now done by - `CONVFMT'. + `awk' used `OFMT' to specify the format for converting numbers to + strings in general expressions; this is now done by `CONVFMT'. `OFS' This is the output field separator (*note Output Separators::). @@ -10206,8 +10300,8 @@ Options::), they are not special. the command line. While you can change the value of `ARGIND' within your `awk' - program, `gawk' automatically sets it to a new value when the next - file is opened. + program, `gawk' automatically sets it to a new value when it opens + the next file. `ENVIRON' An associative array containing the values of the environment. @@ -10257,9 +10351,9 @@ Options::), they are not special. Getline::) inside a `BEGIN' rule can give `FILENAME' a value. `FNR' - The current record number in the current file. `FNR' is - incremented each time a new record is read (*note Records::). It - is reinitialized to zero each time a new input file is started. + The current record number in the current file. `awk' increments + `FNR' each time it reads a new record (*note Records::). `awk' + resets `FNR' to zero each time it starts a new input file. `NF' The number of fields in the current input record. `NF' is set @@ -10283,8 +10377,8 @@ Options::), they are not special. `NR' The number of input records `awk' has processed since the - beginning of the program's execution (*note Records::). `NR' is - incremented each time a new record is read. + beginning of the program's execution (*note Records::). `awk' + increments `NR' each time it reads a new record. `PROCINFO #' The elements of this array provide access to information about the @@ -10349,7 +10443,7 @@ 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 (INDEX + 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 Array::. @@ -10367,7 +10461,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 numbers (*note + version of `gawk' supports arbitrary precision arithmetic (*note Arbitrary Precision Arithmetic::): `PROCINFO["mpfr_version"]' @@ -10400,14 +10494,14 @@ Options::), they are not special. The `PROCINFO' array has the following additional uses: - * It may be used to cause coprocesses to communicate over - pseudo-ttys instead of through two-way pipes; this is - discussed further in *note Two-way I/O::. - * It may be used to provide a timeout when reading from any open input file, pipe, or coprocess. *Note Read Timeout::, for more information. + * It may be used to cause coprocesses to communicate over + pseudo-ttys instead of through two-way pipes; this is + discussed further in *note Two-way I/O::. + `RLENGTH' The length of the substring matched by the `match()' function (*note String Functions::). `RLENGTH' is set by invoking the @@ -10426,9 +10520,14 @@ Options::), they are not special. separator. It is set every time a record is read. `SYMTAB #' - An array whose indices are the names of all currently defined - global variables and arrays in the program. The array may be used - for indirect access to read or write the value of a variable: + An array whose indices are the names of all defined global + variables and arrays in the program. `SYMTAB' makes `gawk''s + symbol table visible to the `awk' programmer. It is built as + `gawk' parses the program and is complete before the program + starts to run. + + The array may be used for indirect access to read or write the + value of a variable: foo = 5 SYMTAB["foo"] = 4 @@ -10596,6 +10695,12 @@ Because `-q' is not a valid `gawk' option, it and the following `-v' 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 +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::). + File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up: Patterns and Actions @@ -10625,8 +10730,8 @@ File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up: * The control statements in `awk' are `if'-`else', `while', `for', and `do'-`while'. `gawk' adds the `switch' statement. There are - two flavors of `for' statement: one for for performing general - looping, and the other iterating through an array. + two flavors of `for' statement: one for performing general + looping, and the other for iterating through an array. * `break' and `continue' let you exit early or start the next iteration of a loop (or get out of a `switch'). @@ -10638,11 +10743,16 @@ File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up: * The `exit' statement terminates your program. When executed from an action (or function body) it transfers control to the `END' statements. From an `END' statement body, it exits immediately. - You may pass an optional numeric value to be used at `awk''s exit + You may pass an optional numeric value to be used as `awk''s exit status. - * Some built-in variables provide control over `awk', mainly for I/O. - Other variables convey information from `awk' to your program. + * Some predefined variables provide control over `awk', mainly for + I/O. Other variables convey information from `awk' to your + program. + + * `ARGC' and `ARGV' make the command-line arguments available to + your program. Manipulating them from a `BEGIN' rule lets you + control how `awk' will process the provided data files. @@ -10663,26 +10773,21 @@ about array usage. The major node moves on to discuss `gawk''s facility for sorting arrays, and ends with a brief description of `gawk''s ability to support true arrays of arrays. - `awk' maintains a single set of names that may be used for naming -variables, arrays, and functions (*note User-defined::). Thus, you -cannot have a variable and an array with the same name in the same -`awk' program. - * Menu: * Array Basics:: The basics of arrays. -* Delete:: The `delete' statement removes an element - from an array. * Numeric Array Subscripts:: How to use numbers as subscripts in `awk'. * Uninitialized Subscripts:: Using Uninitialized variables as subscripts. +* Delete:: The `delete' statement removes an element + from an array. * Multidimensional:: Emulating multidimensional arrays in `awk'. * Arrays of Arrays:: True multidimensional arrays. * Arrays Summary:: Summary of arrays. -File: gawk.info, Node: Array Basics, Next: Delete, Up: Arrays +File: gawk.info, Node: Array Basics, Next: Numeric Array Subscripts, Up: Arrays 8.1 The Basics of Arrays ======================== @@ -10721,8 +10826,8 @@ program. Arrays in `awk' superficially resemble arrays in other programming languages, but there are fundamental differences. In `awk', it isn't necessary to specify the size of an array before starting to use it. -Additionally, any number or string in `awk', not just consecutive -integers, may be used as an array index. +Additionally, any number or string, not just consecutive integers, may +be used as an array index. In most other languages, arrays must be "declared" before use, including a specification of how many elements or components they @@ -10901,14 +11006,14 @@ encountering repeated numbers, gaps, or lines that don't begin with a number: { - if ($1 > max) - max = $1 - arr[$1] = $0 + if ($1 > max) + max = $1 + arr[$1] = $0 } END { - for (x = 1; x <= max; x++) - print arr[x] + for (x = 1; x <= max; x++) + print arr[x] } The first rule keeps track of the largest line number seen so far; @@ -10936,9 +11041,9 @@ overrides the others. Gaps in the line numbers can be handled with an easy improvement to the program's `END' rule, as follows: END { - for (x = 1; x <= max; x++) - if (x in arr) - print arr[x] + for (x = 1; x <= max; x++) + if (x in arr) + print arr[x] } @@ -10956,7 +11061,7 @@ lowest index up to the highest. This technique won't do the job in has a special kind of `for' statement for scanning an array: for (VAR in ARRAY) - BODY + BODY This loop executes BODY once for each index in ARRAY that the program has previously used, with the variable VAR set to that index. @@ -11013,7 +11118,7 @@ all `awk' versions do so. Consider this program, named `loopcheck.awk': } } - Here is what happens when run with `gawk': + Here is what happens when run with `gawk' (and `mawk'): $ gawk -f loopcheck.awk -| here @@ -11116,7 +11221,8 @@ available: to run. Changing `PROCINFO["sorted_in"]' in the loop body does not affect the loop. For example: - $ gawk 'BEGIN { + $ gawk ' + > BEGIN { > a[4] = 4 > a[3] = 3 > for (i in a) @@ -11124,7 +11230,8 @@ affect the loop. For example: > }' -| 4 4 -| 3 3 - $ gawk 'BEGIN { + $ gawk ' + > BEGIN { > PROCINFO["sorted_in"] = "@ind_str_asc" > a[4] = 4 > a[3] = 3 @@ -11176,93 +11283,15 @@ ordering when the numeric values are equal ensures that `gawk' behaves consistently across different environments. -File: gawk.info, Node: Delete, Next: Numeric Array Subscripts, Prev: Array Basics, Up: Arrays - -8.2 The `delete' Statement -========================== - -To remove an individual element of an array, use the `delete' statement: - - delete ARRAY[INDEX-EXPRESSION] - - Once an array element has been deleted, any value the element once -had is no longer available. It is as if the element had never been -referred to or been given a value. The following is an example of -deleting elements in an array: - - for (i in frequencies) - delete frequencies[i] - -This example removes all the elements from the array `frequencies'. -Once an element is deleted, a subsequent `for' statement to scan the -array does not report that element and the `in' operator to check for -the presence of that element returns zero (i.e., false): - - delete foo[4] - if (4 in foo) - print "This will never be printed" - - It is important to note that deleting an element is _not_ the same -as assigning it a null value (the empty string, `""'). For example: - - foo[4] = "" - if (4 in foo) - print "This is printed, even though foo[4] is empty" - - It is not an error to delete an element that does not exist. -However, if `--lint' is provided on the command line (*note Options::), -`gawk' issues a warning message when an element that is not in the -array is deleted. - - All the elements of an array may be deleted with a single statement -by leaving off the subscript in the `delete' statement, as follows: - - delete ARRAY - - Using this version of the `delete' statement is about three times -more efficient than the equivalent loop that deletes each element one -at a time. - - NOTE: For many years, using `delete' without a subscript was a - `gawk' extension. As of September, 2012, it was accepted for - inclusion into the POSIX standard. See the Austin Group website - (http://austingroupbugs.net/view.php?id=544). This form of the - `delete' statement is also supported by BWK `awk' and `mawk', as - well as by a number of other implementations (*note Other - Versions::). - - The following statement provides a portable but nonobvious way to -clear out an array:(1) - - split("", array) - - The `split()' function (*note String Functions::) clears out the -target array first. This call asks it to split apart the null string. -Because there is no data to split out, the function simply clears the -array and then returns. - - CAUTION: Deleting an array does not change its type; you cannot - delete an array and then use the array's name as a scalar (i.e., a - regular variable). For example, the following does not work: - - a[1] = 3 - delete a - a = 3 - - ---------- Footnotes ---------- - - (1) Thanks to Michael Brennan for pointing this out. - - -File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscripts, Prev: Delete, Up: Arrays +File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscripts, Prev: Array Basics, Up: Arrays -8.3 Using Numbers to Subscript Arrays +8.2 Using Numbers to Subscript Arrays ===================================== An important aspect to remember about arrays is that _array subscripts are always strings_. When a numeric value is used as a subscript, it is converted to a string value before being used for subscripting -(*note Conversion::). This means that the value of the built-in +(*note Conversion::). This means that the value of the predefined variable `CONVFMT' can affect how your program accesses elements of an array. For example: @@ -11285,9 +11314,9 @@ two significant digits. This test fails, since `"12.15"' is different from `"12.153"'. According to the rules for conversions (*note Conversion::), integer -values are always converted to strings as integers, no matter what the -value of `CONVFMT' may happen to be. So the usual case of the -following works: +values always convert to strings as integers, no matter what the value +of `CONVFMT' may happen to be. So the usual case of the following +works: for (i = 1; i <= maxsub; i++) do something with array[i] @@ -11300,14 +11329,14 @@ example, that `array[17]', `array[021]', and `array[0x11]' all refer to the same element! As with many things in `awk', the majority of the time things work -as one would expect them to. But it is useful to have a precise +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 effect on your programs. -File: gawk.info, Node: Uninitialized Subscripts, Next: Multidimensional, Prev: Numeric Array Subscripts, Up: Arrays +File: gawk.info, Node: Uninitialized Subscripts, Next: Delete, Prev: Numeric Array Subscripts, Up: Arrays -8.4 Using Uninitialized Variables as Subscripts +8.3 Using Uninitialized Variables as Subscripts =============================================== Suppose it's necessary to write a program to print the input data in @@ -11353,7 +11382,86 @@ string as a subscript if `--lint' is provided on the command line (*note Options::). -File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Uninitialized Subscripts, Up: Arrays +File: gawk.info, Node: Delete, Next: Multidimensional, Prev: Uninitialized Subscripts, Up: Arrays + +8.4 The `delete' Statement +========================== + +To remove an individual element of an array, use the `delete' statement: + + delete ARRAY[INDEX-EXPRESSION] + + Once an array element has been deleted, any value the element once +had is no longer available. It is as if the element had never been +referred to or been given a value. The following is an example of +deleting elements in an array: + + for (i in frequencies) + delete frequencies[i] + +This example removes all the elements from the array `frequencies'. +Once an element is deleted, a subsequent `for' statement to scan the +array does not report that element and the `in' operator to check for +the presence of that element returns zero (i.e., false): + + delete foo[4] + if (4 in foo) + print "This will never be printed" + + It is important to note that deleting an element is _not_ the same +as assigning it a null value (the empty string, `""'). For example: + + foo[4] = "" + if (4 in foo) + print "This is printed, even though foo[4] is empty" + + It is not an error to delete an element that does not exist. +However, if `--lint' is provided on the command line (*note Options::), +`gawk' issues a warning message when an element that is not in the +array is deleted. + + All the elements of an array may be deleted with a single statement +by leaving off the subscript in the `delete' statement, as follows: + + delete ARRAY + + Using this version of the `delete' statement is about three times +more efficient than the equivalent loop that deletes each element one +at a time. + + This form of the `delete' statement is also supported by BWK `awk' +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 + inclusion into the POSIX standard. See the Austin Group website + (http://austingroupbugs.net/view.php?id=544). + + The following statement provides a portable but nonobvious way to +clear out an array:(1) + + split("", array) + + The `split()' function (*note String Functions::) clears out the +target array first. This call asks it to split apart the null string. +Because there is no data to split out, the function simply clears the +array and then returns. + + CAUTION: Deleting all the elements from an array does not change + its type; you cannot clear an array and then use the array's name + as a scalar (i.e., a regular variable). For example, the following + does not work: + + a[1] = 3 + delete a + a = 3 + + ---------- Footnotes ---------- + + (1) Thanks to Michael Brennan for pointing this out. + + +File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Delete, Up: Arrays 8.5 Multidimensional Arrays =========================== @@ -11365,7 +11473,7 @@ File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Uninit 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 most languages, including `awk') to refer to an element of a +(in many languages, including `awk') to refer to an element of a two-dimensional array named `grid' is with `grid[X,Y]'. Multidimensional arrays are supported in `awk' through concatenation @@ -11506,8 +11614,9 @@ multidimensional subscript). So the following is valid in `gawk': Each subarray and the main array can be of different length. In fact, the elements of an array or its subarray do not all have to have the same type. This means that the main array and any of its subarrays -can be non-rectangular, or jagged in structure. One can assign a scalar -value to the index `4' of the main array `a': +can be non-rectangular, or jagged in structure. You can assign a scalar +value to the index `4' of the main array `a', even though `a[1]' is +itself an array and not a scalar: a[4] = "An element in a jagged array" @@ -11568,6 +11677,8 @@ an array element is itself an array: print array[i][j] } } + else + print array[i] } If the structure of a jagged array of arrays is known in advance, @@ -11798,8 +11909,9 @@ brackets ([ ]): user-defined function that can be used to obtain a random non-negative integer less than N: - function randint(n) { - return int(n * rand()) + function randint(n) + { + return int(n * rand()) } The multiplication produces a random number greater than zero and @@ -11816,8 +11928,7 @@ brackets ([ ]): # Roll 3 six-sided dice and # print total number of points. { - printf("%d points\n", - roll(6)+roll(6)+roll(6)) + printf("%d points\n", roll(6) + roll(6) + roll(6)) } CAUTION: In most `awk' implementations, including `gawk', @@ -11904,8 +12015,7 @@ 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 in alphabetic -order. +which comes towards the end since 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 @@ -11938,7 +12048,8 @@ Options::): When comparing strings, `IGNORECASE' affects the sorting (*note Array Sorting Functions::). If the SOURCE array contains subarrays as values (*note Arrays of Arrays::), they will come - last, after all scalar values. + last, after all scalar values. Subarrays are _not_ recursively + sorted. For example, if the contents of `a' are as follows: @@ -12041,7 +12152,10 @@ Options::): If FIND is not found, `index()' returns zero. - It is a fatal error to use a regexp constant for FIND. + With BWK `awk' and `gawk', it is a fatal error to use a regexp + constant for FIND. Other implementations allow it, simply + treating the regexp constant as an expression meaning `$0 ~ + /regexp/'. (d.c.). `length('[STRING]`)' Return the number of characters in STRING. If STRING is a number, @@ -12101,21 +12215,20 @@ Options::): `match()', the order is the same as for the `~' operator: `STRING ~ REGEXP'. - The `match()' function sets the built-in variable `RSTART' to the - index. It also sets the built-in variable `RLENGTH' to the length - in characters of the matched substring. If no match is found, - `RSTART' is set to zero, and `RLENGTH' to -1. + The `match()' function sets the predefined variable `RSTART' to + the index. It also sets the predefined variable `RLENGTH' to the + length in characters of the matched substring. If no match is + found, `RSTART' is set to zero, and `RLENGTH' to -1. For example: { - if ($1 == "FIND") - regex = $2 - else { - where = match($0, regex) - if (where != 0) - print "Match of", regex, "found at", - where, "in", $0 + if ($1 == "FIND") + regex = $2 + else { + where = match($0, regex) + if (where != 0) + print "Match of", regex, "found at", where, "in", $0 } } @@ -12184,7 +12297,7 @@ Options::): The `patsplit()' function splits strings into pieces in a manner similar to the way input lines are split into fields using `FPAT' - (*note Splitting By Content::. + (*note Splitting By Content::). Before splitting the string, `patsplit()' deletes any previously existing elements in the arrays ARRAY and SEPS. @@ -12195,15 +12308,14 @@ Options::): first piece is stored in `ARRAY[1]', the second piece in `ARRAY[2]', and so forth. The string value of the third argument, FIELDSEP, is a regexp describing where to split STRING (much as - `FS' can be a regexp describing where to split input records; - *note Regexp Field Splitting::). If FIELDSEP is omitted, the - value of `FS' is used. `split()' returns the number of elements - created. SEPS is a `gawk' extension with `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). + `FS' can be a regexp describing where to split input records). If + FIELDSEP is omitted, the value of `FS' is used. `split()' returns + the number of elements created. SEPS is a `gawk' extension with + `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). The `split()' function splits strings into pieces in a manner similar to the way input lines are split into fields. For example: @@ -12409,6 +12521,17 @@ Options::): Nonalphabetic characters are left unchanged. For example, `toupper("MiXeD cAsE 123")' returns `"MIXED CASE 123"'. + Matching the Null String + + In `awk', the `*' operator can match the null string. This is +particularly important for the `sub()', `gsub()', and `gensub()' +functions. For example: + + $ echo abc | awk '{ gsub(/m*/, "X"); print }' + -| XaXbXcX + +Although this makes a certain amount of sense, it can be surprising. + ---------- Footnotes ---------- (1) Unless you use the `--non-decimal-data' option, which isn't @@ -12428,8 +12551,8 @@ File: gawk.info, Node: Gory Details, Up: String Functions 9.1.3.1 More About `\' and `&' with `sub()', `gsub()', and `gensub()' ..................................................................... - CAUTION: This section has been known to cause headaches. You - might want to skip it upon first reading. + CAUTION: This subsubsection has been reported to cause headaches. + You might want to skip it upon first reading. When using `sub()', `gsub()', or `gensub()', and trying to get literal backslashes and ampersands into the replacement text, you need @@ -12563,17 +12686,6 @@ Table 9.4: Escape Sequence Processing For `gensub()' and the special cases for `sub()' and `gsub()', we recommend the use of `gawk' and `gensub()' when you have to do substitutions. - Matching the Null String - - In `awk', the `*' operator can match the null string. This is -particularly important for the `sub()', `gsub()', and `gensub()' -functions. For example: - - $ echo abc | awk '{ gsub(/m*/, "X"); print }' - -| XaXbXcX - -Although this makes a certain amount of sense, it can be surprising. - ---------- Footnotes ---------- (1) This was rather naive of him, despite there being a note in this @@ -12623,11 +12735,10 @@ parameters are enclosed in square brackets ([ ]): function--`gawk' also buffers its output and the `fflush()' function forces `gawk' to flush its buffers. - `fflush()' was added to BWK `awk' in April of 1992. For two - decades, it was not part of the POSIX standard. As of 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 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). POSIX standardizes `fflush()' as follows: If there is no argument, or if the argument is the null string (`""'), then `awk' flushes @@ -12814,7 +12925,7 @@ enclosed in square brackets ([ ]): If DATESPEC does not contain enough elements or if the resulting time is out of range, `mktime()' returns -1. -`strftime(' [FORMAT [`,' TIMESTAMP [`,' UTC-FLAG] ] ]`)' +`strftime('[FORMAT [`,' TIMESTAMP [`,' UTC-FLAG] ] ]`)' Format the time specified by TIMESTAMP based on the contents of the FORMAT string and return the result. It is similar to the function of the same name in ISO C. If UTC-FLAG is present and is @@ -13029,7 +13140,7 @@ to the standard output and interprets the current time according to the format specifiers in the string. For example: $ date '+Today is %A, %B %d, %Y.' - -| Today is Monday, May 05, 2014. + -| Today is Monday, September 22, 2014. Here is the `gawk' version of the `date' utility. It has a shell "wrapper" to handle the `-u' option, which requires that `date' run as @@ -13118,12 +13229,13 @@ a given value. Finally, two other common operations are to shift the bits left or right. For example, if you have a bit string `10111001' and you shift -it right by three bits, you end up with `00010111'.(1) If you start over -again with `10111001' and shift it left by three bits, you end up with -`11001000'. `gawk' provides built-in functions that implement the -bitwise operations just described. They are: +it right by three bits, you end up with `00010111'.(1) If you start +over again with `10111001' and shift it left by three bits, you end up +with `11001000'. The following list describes `gawk''s built-in +functions that implement the bitwise operations. Optional parameters +are enclosed in square brackets ([ ]): -``and(V1, V2' [`,' ...]`)'' +``and('V1`,' V2 [`,' ...]`)'' Return the bitwise AND of the arguments. There must be at least two. @@ -13133,13 +13245,13 @@ bitwise operations just described. They are: ``lshift(VAL, COUNT)'' Return the value of VAL, shifted left by COUNT bits. -``or(V1, V2' [`,' ...]`)'' +``or('V1`,' V2 [`,' ...]`)'' Return the bitwise OR of the arguments. There must be at least two. ``rshift(VAL, COUNT)'' Return the value of VAL, shifted right by COUNT bits. -``xor(V1, V2' [`,' ...]`)'' +``xor('V1`,' V2 [`,' ...]`)'' Return the bitwise XOR of the arguments. There must be at least two. @@ -13214,7 +13326,7 @@ Nondecimal-numbers::), and then demonstrates the results of the (1) This example shows that 0's come in on the left side. For `gawk', this is always true, but in some languages, it's possible to -have the left side fill with 1's. Caveat emptor. +have the left side fill with 1's. File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Functions, Up: Built-in @@ -13224,7 +13336,7 @@ File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Fu `gawk' provides a single function that lets you distinguish an array from a scalar variable. This is necessary for writing code that -traverses every element of an array of arrays. (*note Arrays of +traverses every element of an array of arrays (*note Arrays of Arrays::). `isarray(X)' @@ -13236,12 +13348,12 @@ itself an array or not. The second is inside the body of a user-defined function (not discussed yet; *note User-defined::), to test if a parameter is an array or not. - Note, however, that 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' will end up turning -it into a scalar. + 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. File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in @@ -13337,7 +13449,7 @@ call. A function cannot have two parameters with the same name, nor may it have a parameter with the same name as the function itself. In addition, according to the POSIX standard, function parameters cannot -have the same name as one of the special built-in variables (*note +have the same name as one of the special predefined variables (*note Built-in Variables::). Not all versions of `awk' enforce this restriction. @@ -13452,7 +13564,7 @@ extra whitespace signifies the start of the local variable list): function delarray(a, i) { for (i in a) - delete a[i] + delete a[i] } When working with arrays, it is often necessary to delete all the @@ -13460,8 +13572,8 @@ elements in an array and start over with a new list of elements (*note Delete::). Instead of having to repeat this loop everywhere that you need to clear out an array, your program can just call `delarray'. (This guarantees portability. The use of `delete ARRAY' to delete the -contents of an entire array is a recent(1) addition to the POSIX -standard.) +contents of an entire array is a relatively recent(1) addition to the +POSIX standard.) The following is an example of a recursive function. It takes a string as an input parameter and returns the string in backwards order. @@ -13484,7 +13596,7 @@ way: > gawk -e '{ print rev($0) }' -f rev.awk -| !cinaP t'noD - The C `ctime()' function takes a timestamp and returns it in a + The C `ctime()' function takes a timestamp and returns it as a string, formatted in a well-known fashion. The following example uses the built-in `strftime()' function (*note Time Functions::) to create an `awk' version of `ctime()': @@ -13495,12 +13607,18 @@ an `awk' version of `ctime()': function ctime(ts, format) { - format = PROCINFO["strftime"] + format = "%a %b %e %H:%M:%S %Z %Y" + if (ts == 0) ts = systime() # use current time as default return strftime(format, ts) } + 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"]'. + ---------- Footnotes ---------- (1) Late in 2012. @@ -14042,7 +14160,7 @@ mechanism allows you to sort arbitrary data in an arbitrary fashion. # quicksort_swap --- helper function for quicksort, should really be inline - function quicksort_swap(data, i, j, temp) + function quicksort_swap(data, i, j, temp) { temp = data[i] data[i] = data[j] @@ -14145,6 +14263,63 @@ names of the two comparison functions: -| sort: <87.1 93.4 95.6 100.0> -| rsort: <100.0 95.6 93.4 87.1> + Another example where indirect functions calls are useful can be +found in processing arrays. *note Walking Arrays::, presented a simple +function for "walking" an array of arrays. That function simply +printed the name and value of each scalar array element. However, it is +easy to generalize that function, by passing in the name of a function +to call when walking an array. The modified function looks like this: + + function process_array(arr, name, process, do_arrays, i, new_name) + { + for (i in arr) { + new_name = (name "[" i "]") + if (isarray(arr[i])) { + if (do_arrays) + @process(new_name, arr[i]) + process_array(arr[i], new_name, process, do_arrays) + } else + @process(new_name, arr[i]) + } + } + + The arguments are as follows: + +`arr' + The array. + +`name' + The name of the array (a string). + +`process' + The name of the function to call. + +`do_arrays' + If this is true, the function can handle elements that are + subarrays. + + If subarrays are to be processed, that is done before walking them +further. + + When run with the following scaffolding, the function produces the +same results as does the earlier `walk_array()' function: + + BEGIN { + a[1] = 1 + a[2][1] = 21 + a[2][2] = 22 + a[3] = 3 + a[4][1][1] = 411 + a[4][2] = 42 + + process_array(a, "a", "do_print", 0) + } + + function do_print(name, element) + { + printf "%s = %s\n", name, element + } + Remember that you must supply a leading `@' in front of an indirect function call. @@ -14177,11 +14352,12 @@ File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions functions. * POSIX `awk' provides three kinds of built-in functions: numeric, - string, and I/O. `gawk' provides functions that work with values - representing time, do bit manipulation, sort arrays, and - internationalize and localize programs. `gawk' also provides - several extensions to some of standard functions, typically in the - form of additional arguments. + 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 + localize programs. `gawk' also provides several extensions to + some of standard functions, typically in the form of additional + arguments. * Functions accept zero or more arguments and return a value. The expressions that provide the argument values are completely @@ -14356,7 +14532,7 @@ to start that variable's name with a capital letter--for example, `getopt()''s `Opterr' and `Optind' variables (*note Getopt Function::). The leading capital letter indicates that it is global, while the fact that the variable name is not all capital letters indicates that the -variable is not one of `awk''s built-in variables, such as `FS'. +variable is not one of `awk''s predefined variables, such as `FS'. It is also important that _all_ variables in library functions that do not need to save state are, in fact, declared local.(2) If this is @@ -14366,8 +14542,9 @@ program, leading to bugs that are very difficult to track down: function lib_func(x, y, l1, l2) { ... - USE VARIABLE some_var # some_var should be local - ... # but is not by oversight + # some_var should be local but by oversight is not + USE VARIABLE some_var + ... } A different convention, common in the Tcl community, is to use a @@ -14416,6 +14593,7 @@ programming use. * Join Function:: A function to join an array into a string. * Getlocaltime Function:: A function to get formatted times. * Readfile Function:: A function to read an entire file at once. +* Shell Quoting:: A function to quote strings for the shell. File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions @@ -14475,7 +14653,7 @@ versions of `awk': # a[5] = "123.45" # a[6] = "1.e3" # a[7] = "1.32" - # a[7] = "1.32E2" + # a[8] = "1.32E2" # # for (i = 1; i in a; i++) # print a[i], strtonum(a[i]), mystrtonum(a[i]) @@ -14484,9 +14662,11 @@ versions of `awk': The function first looks for C-style octal numbers (base 8). If the input string matches a regular expression describing octal numbers, then `mystrtonum()' loops through each character in the string. It -sets `k' to the index in `"01234567"' of the current octal digit. -Since the return value is one-based, the `k--' adjusts `k' so it can be -used in computing the return value. +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. Similar logic applies to the code that checks for and converts a hexadecimal value, which starts with `0x' or `0X'. The use of @@ -14512,7 +14692,7 @@ condition or set of conditions is true. Before proceeding with a particular computation, you make a statement about what you believe to be the case. Such a statement is known as an "assertion". The C language provides an `<assert.h>' header file and corresponding -`assert()' macro that the programmer can use to make assertions. If an +`assert()' macro that a programmer can use to make assertions. If an assertion fails, the `assert()' macro arranges to print a diagnostic message describing the condition that should have been true but was not, and then it kills the program. In C, using `assert()' looks this: @@ -14852,7 +15032,7 @@ current time formatted in the same way as the `date' utility: now = systime() # return date(1)-style output - ret = strftime(PROCINFO["strftime"], now) + ret = strftime("%a %b %e %H:%M:%S %Z %Y", now) # clear out target array delete time @@ -14889,7 +15069,7 @@ the `getlocaltime()' function would have allowed the user to supply an optional timestamp value to use instead of the current time. -File: gawk.info, Node: Readfile Function, Prev: Getlocaltime Function, Up: General Functions +File: gawk.info, Node: Readfile Function, Next: Shell Quoting, Prev: Getlocaltime Function, Up: General Functions 10.2.8 Reading A Whole File At Once ----------------------------------- @@ -14948,6 +15128,61 @@ string. Thus calling code may use something like: This tests the result to see if it is empty or not. An equivalent test would be `contents == ""'. + *Note Extension Sample Readfile::, for an extension function that +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 +------------------------------------------- + +Michael Brennan offers the following programming pattern, which he uses +frequently: + + #! /bin/sh + + awkp=' + ... + ' + + INPUT_PROGRAM | awk "$awkp" | /bin/sh + + For example, a program of his named `flac-edit' has this form: + + $ flac-edit -song="Whoope! That's Great" file.flac + + It generates the following output, which is to be piped to the shell +(`/bin/sh'): + + chmod +w file.flac + metaflac --remove-tag=TITLE file.flac + LANG=en_US.88591 metaflac --set-tag=TITLE='Whoope! That'"'"'s Great' file.flac + chmod -w file.flac + + 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 `"\"'\""'. + + # shell_quote --- quote an argument for passing to the shell + + function shell_quote(s, # parameter + SINGLE, QSINGLE, i, X, n, ret) # locals + { + if (s == "") + return "\"\"" + + SINGLE = "\x27" # single quote + QSINGLE = "\"\x27\"" + n = split(s, X, SINGLE) + + ret = SINGLE X[1] SINGLE + for (i = 2; i <= n; i++) + ret = ret QSINGLE SINGLE X[i] SINGLE + + return ret + } + File: gawk.info, Node: Data File Management, Next: Getopt Function, Prev: General Functions, Up: Library Functions @@ -14997,15 +15232,14 @@ does so _portably_; this works with any implementation of `awk': # that each take the name of the file being started or # finished, respectively. - FILENAME != _oldfilename \ - { + FILENAME != _oldfilename { if (_oldfilename != "") endfile(_oldfilename) _oldfilename = FILENAME beginfile(FILENAME) } - END { endfile(FILENAME) } + END { endfile(FILENAME) } This file must be loaded before the user's "main" program, so that the rule it supplies is executed first. @@ -15043,7 +15277,7 @@ solves the problem: beginfile(FILENAME) } - END { endfile(_filename_) } + END { endfile(_filename_) } *note Wc Program::, shows how this library function can be used and how it simplifies writing the main program. @@ -15096,15 +15330,12 @@ over with it from the top. For lack of a better name, we'll call it nextfile } - This code relies on the `ARGIND' variable (*note Auto-set::), which -is specific to `gawk'. If you are not using `gawk', you can use ideas -presented in *note Filetrans Function::, to either update `ARGIND' on -your own or modify this code as appropriate. - - The `rewind()' function also relies on the `nextfile' keyword (*note -Nextfile Statement::). Because of this, you should not call it from an -`ENDFILE' rule. (This isn't necessary anyway, since as soon as an -`ENDFILE' rule finishes `gawk' goes to the next file!) + The `rewind()' function relies on the `ARGIND' variable (*note +Auto-set::), which is specific to `gawk'. It also relies on the +`nextfile' keyword (*note Nextfile Statement::). Because of this, you +should not call it from an `ENDFILE' rule. (This isn't necessary +anyway, since as soon as an `ENDFILE' rule finishes `gawk' goes to the +next file!) File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management @@ -15121,7 +15352,7 @@ following program to your `awk' program: BEGIN { for (i = 1; i < ARGC; i++) { - if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \ + if (ARGV[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/ \ || ARGV[i] == "-" || ARGV[i] == "/dev/stdin") continue # assignment or standard input else if ((getline junk < ARGV[i]) < 0) # unreadable @@ -15135,6 +15366,10 @@ following program to your `awk' program: element from `ARGV' with `delete' skips the file (since it's no longer in the list). See also *note ARGC and ARGV::. + The regular expression check purposely does not use character classes +such as `[:alpha:]' and `[:alnum:]' (*note Bracket Expressions::) since +`awk' variable names only allow the English letters. + ---------- Footnotes ---------- (1) The `BEGINFILE' special pattern (*note BEGINFILE/ENDFILE::) @@ -15213,7 +15448,7 @@ programming with a library file does the trick: function disable_assigns(argc, argv, i) { for (i = 1; i < argc; i++) - if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/) + if (argv[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/) argv[i] = ("./" argv[i]) } @@ -15513,10 +15748,14 @@ result of two sample runs of the test program: In both runs, the first `--' terminates the arguments to `awk', so that it does not try to interpret the `-a', etc., as its own options. - NOTE: After `getopt()' is through, it is the responsibility of the - user level code to clear out all the elements of `ARGV' from 1 to - `Optind', so that `awk' does not try to process the command-line - options as file names. + NOTE: After `getopt()' is through, user level code must clear out + all the elements of `ARGV' from 1 to `Optind', so that `awk' does + not try to process the command-line options as file names. + + Using `#!' with the `-E' option may help avoid conflicts between +your program's options and `gawk''s options, since `-E' causes `gawk' +to abandon processing of further options (*note Executable Scripts::, +and *note Options::). Several of the sample programs presented in *note Sample Programs::, use `getopt()' to process their arguments. @@ -15675,8 +15914,8 @@ corresponding to the C functions of the same names: routine, we have chosen to put it in `/usr/local/libexec/awk'; however, you might want it to be in a different directory on your system. - The function `_pw_init()' keeps three copies of the user information -in three associative arrays. The arrays are indexed by username + The function `_pw_init()' fills three copies of the user information +into three associative arrays. The arrays are indexed by username (`_pw_byname'), by user ID number (`_pw_byuid'), and by order of occurrence (`_pw_bycount'). The variable `_pw_inited' is used for efficiency, since `_pw_init()' needs to be called only once. @@ -15686,13 +15925,10 @@ efficiency, since `_pw_init()' needs to be called only once. in the variable `using_fw' whether field splitting with `FIELDWIDTHS' is in effect or not. Doing so is necessary, since these functions could be called from anywhere within a user's program, and the user may -have his or her own way of splitting records and fields. - - The `using_fw' variable checks `PROCINFO["FS"]', which is -`"FIELDWIDTHS"' if field splitting is being done with `FIELDWIDTHS'. -This makes it possible to restore the correct field-splitting mechanism -later. The test can only be true for `gawk'. It is false if using -`FS' or `FPAT', or on some other `awk' implementation. +have his or her own way of splitting records and fields. This makes it +possible to restore the correct field-splitting mechanism later. The +test can only be true for `gawk'. It is false if using `FS' or `FPAT', +or on some other `awk' implementation. The code that checks for using `FPAT', using `using_fpat' and `PROCINFO["FS"]', is similar. @@ -15888,8 +16124,7 @@ the same names: n = split($4, a, "[ \t]*,[ \t]*") for (i = 1; i <= n; i++) if (a[i] in _gr_groupsbyuser) - _gr_groupsbyuser[a[i]] = \ - _gr_groupsbyuser[a[i]] " " $1 + _gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1 else _gr_groupsbyuser[a[i]] = $1 @@ -16051,12 +16286,12 @@ value. Here is a main program to demonstrate: When run, the program produces the following output: $ gawk -f walk_array.awk - -| a[4][1][1] = 411 - -| a[4][2] = 42 -| a[1] = 1 -| a[2][1] = 21 -| a[2][2] = 22 -| a[3] = 3 + -| a[4][1][1] = 411 + -| a[4][2] = 42 File: gawk.info, Node: Library Functions Summary, Next: Library Exercises, Prev: Walking Arrays, Up: Library Functions @@ -16065,8 +16300,8 @@ File: gawk.info, Node: Library Functions Summary, Next: Library Exercises, Pr ============ * Reading programs is an excellent way to learn Good Programming. - The functions provided in this major node and the next are intended - to serve that purpose. + The functions and programs provided in this major node and the next + are intended to serve that purpose. * When writing general-purpose library functions, put some thought into how to name any global variables so that they won't conflict @@ -16257,18 +16492,13 @@ supplied: # # Requires getopt() and join() library functions - function usage( e1, e2) + function usage() { - e1 = "usage: cut [-f list] [-d c] [-s] [files...]" - e2 = "usage: cut [-c list] [files...]" - print e1 > "/dev/stderr" - print e2 > "/dev/stderr" + print("usage: cut [-f list] [-d c] [-s] [files...]") > "/dev/stderr" + print("usage: cut [-c list] [files...]") > "/dev/stderr" exit 1 } -The variables `e1' and `e2' are used so that the function fits nicely -on the screen. - Next comes a `BEGIN' rule that parses the command-line options. It sets `FS' to a single TAB character, because that is `cut''s default field separator. The rule then sets the output field separator to be the @@ -16511,7 +16741,7 @@ Function::). The program begins with a descriptive comment and then a `BEGIN' rule that processes the command-line arguments with `getopt()'. The `-i' (ignore case) option is particularly easy with `gawk'; we just use the -`IGNORECASE' built-in variable (*note Built-in Variables::): +`IGNORECASE' predefined variable (*note Built-in Variables::): # egrep.awk --- simulate egrep in awk # @@ -16670,17 +16900,13 @@ there are no matches, the exit status is one; otherwise it is zero: The `usage()' function prints a usage message in case of invalid options, and then exits: - function usage( e) + function usage() { - e = "Usage: egrep [-csvil] [-e pat] [files ...]" - e = e "\n\tegrep [-csvil] pat [files ...]" - print e > "/dev/stderr" + print("Usage: egrep [-csvil] [-e pat] [files ...]") > "/dev/stderr" + print("\n\tegrep [-csvil] pat [files ...]") > "/dev/stderr" exit 1 } - The variable `e' is used so that the function fits nicely on the -printed page. - ---------- Footnotes ---------- (1) It also introduces a subtle bug; if a match happens, we output @@ -16731,26 +16957,22 @@ and the group numbers: printf("uid=%d", uid) pw = getpwuid(uid) - if (pw != "") - pr_first_field(pw) + pr_first_field(pw) if (euid != uid) { printf(" euid=%d", euid) pw = getpwuid(euid) - if (pw != "") - pr_first_field(pw) + pr_first_field(pw) } printf(" gid=%d", gid) pw = getgrgid(gid) - if (pw != "") - pr_first_field(pw) + pr_first_field(pw) if (egid != gid) { printf(" egid=%d", egid) pw = getgrgid(egid) - if (pw != "") - pr_first_field(pw) + pr_first_field(pw) } for (i = 1; ("group" i) in PROCINFO; i++) { @@ -16759,8 +16981,7 @@ and the group numbers: group = PROCINFO["group" i] printf("%d", group) pw = getgrgid(group) - if (pw != "") - pr_first_field(pw) + pr_first_field(pw) if (("group" (i+1)) in PROCINFO) printf(",") } @@ -16770,8 +16991,10 @@ and the group numbers: function pr_first_field(str, a) { - split(str, a, ":") - printf("(%s)", a[1]) + if (str != "") { + split(str, a, ":") + printf("(%s)", a[1]) + } } The test in the `for' loop is worth noting. Any supplementary @@ -16789,8 +17012,9 @@ then the condition is false the first time it's tested, and the loop body never executes. The `pr_first_field()' function simply isolates out some code that -is used repeatedly, making the whole program slightly shorter and -cleaner. +is used repeatedly, making the whole program shorter and cleaner. In +particular, moving the check for the empty string into this function +saves several lines of code. File: gawk.info, Node: Split Program, Next: Tee Program, Prev: Id Program, Up: Clones @@ -16881,15 +17105,12 @@ moves to the next letter in the alphabet and `s2' starts over again at The `usage()' function simply prints an error message and exits: - function usage( e) + function usage() { - e = "usage: split [-num] [file] [outname]" - print e > "/dev/stderr" + print("usage: split [-num] [file] [outname]") > "/dev/stderr" exit 1 } -The variable `e' is used so that the function fits nicely on the screen. - This program is a bit sloppy; it relies on `awk' to automatically close the last file instead of doing it in an `END' rule. It also assumes that letters are contiguous in the character set, which isn't @@ -17002,10 +17223,10 @@ usage is as follows: The options for `uniq' are: `-d' - Print only repeated lines. + Print only repeated (duplicated) lines. `-u' - Print only nonrepeated lines. + Print only nonrepeated (unique) lines. `-c' Count lines. This option overrides `-d' and `-u'. Both repeated @@ -17055,10 +17276,9 @@ standard output, `/dev/stdout': # # Requires getopt() and join() library functions - function usage( e) + function usage() { - e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]" - print e > "/dev/stderr" + print("Usage: uniq [-udc [-n]] [+n] [ in [ out ]]") > "/dev/stderr" exit 1 } @@ -17112,16 +17332,18 @@ standard output, `/dev/stdout': The following function, `are_equal()', compares the current line, `$0', to the previous line, `last'. It handles skipping fields and characters. If no field count and no character count are specified, -`are_equal()' simply returns one or zero depending upon the result of a -simple string comparison of `last' and `$0'. Otherwise, things get more -complicated. If fields have to be skipped, each line is broken into an -array using `split()' (*note String Functions::); the desired fields -are then joined back into a line using `join()'. The joined lines are -stored in `clast' and `cline'. If no fields are skipped, `clast' and -`cline' are set to `last' and `$0', respectively. Finally, if -characters are skipped, `substr()' is used to strip off the leading -`charcount' characters in `clast' and `cline'. The two strings are -then compared and `are_equal()' returns the result: +`are_equal()' returns one or zero depending upon the result of a simple +string comparison of `last' and `$0'. + + Otherwise, things get more complicated. If fields have to be +skipped, each line is broken into an array using `split()' (*note +String Functions::); the desired fields are then joined back into a line +using `join()'. The joined lines are stored in `clast' and `cline'. +If no fields are skipped, `clast' and `cline' are set to `last' and +`$0', respectively. Finally, if characters are skipped, `substr()' is +used to strip off the leading `charcount' characters in `clast' and +`cline'. The two strings are then compared and `are_equal()' returns +the result: function are_equal( n, m, clast, cline, alast, aline) { @@ -17217,8 +17439,8 @@ one or more input files. Its usage is as follows: If no files are specified on the command line, `wc' reads its standard input. If there are multiple files, it also prints total -counts for all the files. The options and their meanings are shown in -the following list: +counts for all the files. The options and their meanings are as +follows: `-l' Count only lines. @@ -17574,17 +17796,17 @@ there are more characters in the "from" list than in the "to" list, the last character of the "to" list is used for the remaining characters in the "from" list. - Once upon a time, a user proposed that a transliteration function -should be added to `gawk'. The following program was written to prove -that character transliteration could be done with a user-level -function. This program is not as complete as the system `tr' utility -but it does most of the job. + Once upon a time, a user proposed adding a transliteration function +to `gawk'. The following program was written to prove that character +transliteration could be done with a user-level function. This program +is not as complete as the system `tr' utility but it does most of the +job. - The `translate' program demonstrates one of the few weaknesses of -standard `awk': dealing with individual characters is very painful, -requiring repeated use of the `substr()', `index()', and `gsub()' -built-in functions (*note String Functions::).(2) There are two -functions. The first, `stranslate()', takes three arguments: + The `translate' program was written long before `gawk' acquired the +ability to split each character in a string into separate array +elements. Thus, it makes repeated use of the `substr()', `index()', +and `gsub()' built-in functions (*note String Functions::). There are +two functions. The first, `stranslate()', takes three arguments: `from' A list of characters from which to translate. @@ -17601,10 +17823,10 @@ simple loop goes through `from', one character at a time. For each character in `from', if the character appears in `target', it is replaced with the corresponding `to' character. - The `translate()' function simply calls `stranslate()' using `$0' as -the target. The main program sets two global variables, `FROM' and -`TO', from the command line, and then changes `ARGV' so that `awk' -reads from the standard input. + The `translate()' function calls `stranslate()' using `$0' as the +target. The main program sets two global variables, `FROM' and `TO', +from the command line, and then changes `ARGV' so that `awk' reads from +the standard input. Finally, the processing rule simply calls `translate()' for each record: @@ -17681,9 +17903,6 @@ program. enclosed in square brackets (`[a-z]') and quoted, to prevent the shell from attempting a file name expansion. This is not a feature. - (2) This program was also written before `gawk' acquired the ability -to split each character in a string into separate array elements. - File: gawk.info, Node: Labels Program, Next: Word Sorting, Prev: Translate Program, Up: Miscellaneous Programs @@ -17709,12 +17928,12 @@ splits records at blank lines (*note Records::). It sets `MAXLINES' to Most of the work is done in the `printpage()' function. The label lines are stored sequentially in the `line' array. But they have to print horizontally; `line[1]' next to `line[6]', `line[2]' next to -`line[7]', and so on. Two loops are used to accomplish this. The -outer loop, controlled by `i', steps through every 10 lines of data; -this is each row of labels. The inner loop, controlled by `j', goes -through the lines within the row. As `j' goes from 0 to 4, `i+j' is -the `j'-th line in the row, and `i+j+5' is the entry next to it. The -output ends up looking something like this: +`line[7]', and so on. Two loops accomplish this. The outer loop, +controlled by `i', steps through every 10 lines of data; this is each +row of labels. The inner loop, controlled by `j', goes through the +lines within the row. As `j' goes from 0 to 4, `i+j' is the `j'-th +line in the row, and `i+j+5' is the entry next to it. The output ends +up looking something like this: line 1 line 6 line 2 line 7 @@ -17805,7 +18024,7 @@ a useful format. At first glance, a program like this would seem to do the job: - # Print list of word frequencies + # wordfreq-first-try.awk --- print list of word frequencies { for (i = 1; i <= NF; i++) @@ -17959,9 +18178,9 @@ Texinfo input file into separate files. This Info file is written in Texinfo (http://www.gnu.org/software/texinfo/), the GNU project's document formatting language. A single Texinfo source file can be used to -produce both printed and online documentation. The Texinfo language is -described fully, starting with *note (Texinfo)Top:: -texinfo,Texinfo--The GNU Documentation Format. +produce both printed documentation, with TeX, and online documentation. +(The Texinfo language is described fully, starting with *note +(Texinfo)Top:: texinfo,Texinfo--The GNU Documentation Format.) For our purposes, it is enough to know three things about Texinfo input files: @@ -18023,13 +18242,11 @@ upper- and lowercase letters in the directives won't matter. given (`NF' is at least three) and also checking that the command exits with a zero exit status, signifying OK: - # extract.awk --- extract files and run programs - # from texinfo files + # extract.awk --- extract files and run programs from texinfo files BEGIN { IGNORECASE = 1 } - /^@c(omment)?[ \t]+system/ \ - { + /^@c(omment)?[ \t]+system/ { if (NF < 3) { e = ("extract: " FILENAME ":" FNR) e = (e ": badly formed `system' line") @@ -18077,8 +18294,7 @@ with the value of `SUBSEP' (*note Multidimensional::), to rejoin the pieces back into a single line. That line is then printed to the output file: - /^@c(omment)?[ \t]+file/ \ - { + /^@c(omment)?[ \t]+file/ { if (NF != 3) { e = ("extract: " FILENAME ":" FNR ": badly formed `file' line") print e > "/dev/stderr" @@ -18132,7 +18348,7 @@ closing the open file: function unexpected_eof() { printf("extract: %s:%d: unexpected EOF or error\n", - FILENAME, FNR) > "/dev/stderr" + FILENAME, FNR) > "/dev/stderr" exit 1 } @@ -18154,7 +18370,7 @@ 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: - command1 < orig.data | sed 's/old/new/g' | command2 > result + 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 @@ -18341,8 +18557,8 @@ arguments are supplied, then the first nonoption argument should be the `awk' program. If there are no command-line arguments left, `igawk' prints an error message and exits. Otherwise, the first argument is appended to `program'. In any case, after the arguments have been -processed, `program' contains the complete text of the original `awk' -program. +processed, the shell variable `program' contains the complete text of +the original `awk' program. The program is as follows: @@ -18588,7 +18804,7 @@ and it is frequently easier to do certain kinds of string and argument manipulation using the shell than it is in `awk'. Finally, `igawk' shows that it is not always necessary to add new -features to a program; they can often be layered on top. +features to a program; they can often be layered on top.(3) ---------- Footnotes ---------- @@ -18597,7 +18813,10 @@ book. We provide some minimal explanations, but see a good shell programming book if you wish to understand things in more depth. (2) On some very old versions of `awk', the test `getline junk < t' -can loop forever if the file exists but is empty. Caveat emptor. +can loop forever if the file exists but is empty. + + (3) `gawk' does `@include' processing itself in order to support the +use of `awk' programs as Web CGI scripts. File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs @@ -18610,12 +18829,11 @@ word list (such as `/usr/share/dict/words' on many GNU/Linux systems). One word is an anagram of another if both words contain the same letters (for example, "babbling" and "blabbing"). - An elegant algorithm is presented in Column 2, Problem C of Jon -Bentley's `Programming Pearls', second edition. The idea is to give -words that are anagrams a common signature, sort all the words together -by their signature, and then print them. Dr. Bentley observes that -taking the letters in each word and sorting them produces that common -signature. + Column 2, Problem C of Jon Bentley's `Programming Pearls', second +edition, presents an elegant algorithm. The idea is to give words that +are anagrams a common signature, sort all the words together by their +signature, and then print them. Dr. Bentley observes that taking the +letters in each word and sorting them produces that common signature. The following program uses arrays of arrays to bring together words with the same signature and array sorting to print the words in sorted @@ -18724,9 +18942,9 @@ File: gawk.info, Node: Programs Summary, Next: Programs Exercises, Prev: Misc 11.4 Summary ============ - * The functions provided in this major node and the previous one - continue on the theme that reading programs is an excellent way to - learn Good Programming. + * The programs provided in this major node continue on the theme + that reading programs is an excellent way to learn Good + Programming. * Using `#!' to make `awk' programs directly runnable makes them easier to use. Otherwise, invoke the program using `awk -f ...'. @@ -18755,7 +18973,7 @@ File: gawk.info, Node: Programs Exercises, Prev: Programs Summary, Up: Sample ============== 1. Rewrite `cut.awk' (*note Cut Program::) using `split()' with `""' - as the seperator. + as the separator. 2. In *note Egrep Program::, we mentioned that `egrep -i' could be simulated in versions of `awk' without `IGNORECASE' by using @@ -18779,7 +18997,7 @@ File: gawk.info, Node: Programs Exercises, Prev: Programs Summary, Up: Sample that can be in one of a set number of stable conditions depending on its previous condition and on the present values of its inputs."(1) Brian Kernighan suggests that "an alternative approach - to state mechines is to just read the input into an array, then + to state machines is to just read the input into an array, then use indexing. It's almost always easier code, and for most inputs where you would use this, just as fast." Rewrite the logic to follow this suggestion. @@ -18903,11 +19121,10 @@ File: gawk.info, Node: Nondecimal Data, Next: Array Sorting, Up: Advanced Fea =================================== If you run `gawk' with the `--non-decimal-data' option, you can have -nondecimal constants in your input data: +nondecimal values in your input data: $ echo 0123 123 0x123 | - > gawk --non-decimal-data '{ printf "%d, %d, %d\n", - > $1, $2, $3 }' + > gawk --non-decimal-data '{ printf "%d, %d, %d\n", $1, $2, $3 }' -| 83, 123, 291 For this feature to work, write your program so that `gawk' treats @@ -18938,6 +19155,8 @@ request it. programs easier to write and easier to read, and leads to less surprising results. + This option may disappear in a future version of `gawk'. + File: gawk.info, Node: Array Sorting, Next: Two-way I/O, Prev: Nondecimal Data, Up: Advanced Features @@ -18976,7 +19195,7 @@ pre-defined values to `PROCINFO["sorted_in"]' in order to control the order in which `gawk' traverses an array during a `for' loop. In addition, the value of `PROCINFO["sorted_in"]' can be a function -name. This lets you traverse an array based on any custom criterion. +name.(1) This lets you traverse an array based on any custom criterion. The array elements are ordered according to the return value of this function. The comparison function should be defined with at least four arguments: @@ -19091,7 +19310,7 @@ of the previous functions: according to login name. The following program sorts records by a specific field position and can be used for this purpose: - # sort.awk --- simple program to sort by field position + # passwd-sort.awk --- simple program to sort by field position # field position is specified by the global variable POS function cmp_field(i1, v1, i2, v2) @@ -19143,13 +19362,14 @@ seemingly ordered data: elements compare equal. This is usually not a problem, but letting the tied elements come out in arbitrary order can be an issue, especially when comparing item values. The partial ordering of the equal elements -may change during the next loop traversal, if other elements are added -or removed from the array. One way to resolve ties when comparing -elements with otherwise equal values is to include the indices in the -comparison rules. Note that doing this may make the loop traversal -less efficient, so consider it only if necessary. The following -comparison functions force a deterministic order, and are based on the -fact that the (string) indices of two elements are never equal: +may change the next time the array is traversed, if other elements are +added or removed from the array. One way to resolve ties when +comparing elements with otherwise equal values is to include the +indices in the comparison rules. Note that doing this may make the +loop traversal less efficient, so consider it only if necessary. The +following comparison functions force a deterministic order, and are +based on the fact that the (string) indices of two elements are never +equal: function cmp_numeric(i1, v1, i2, v2) { @@ -19188,6 +19408,11 @@ array has been reported to add 15% to 20% overhead to the execution time of `awk' programs. For this reason, sorted array traversal is not the default. + ---------- Footnotes ---------- + + (1) This is why the predefined sorting orders start with an `@' +character, which cannot be part of an identifier. + File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traversal, Up: Array Sorting @@ -19274,7 +19499,7 @@ fill in the result array. Because `IGNORECASE' affects string comparisons, the value of `IGNORECASE' also affects sorting for both `asort()' and `asorti()'. Note also that the locale's sorting order does _not_ come into play; -comparisons are based on character values only.(1) Caveat Emptor. +comparisons are based on character values only.(1) ---------- Footnotes ---------- @@ -19400,7 +19625,7 @@ using regular pipes. (1) Michael Brennan suggests the use of `rand()' to generate unique file names. This is a valid point; nevertheless, temporary files remain -more difficult than two-way pipes. +more difficult to use than two-way pipes. (2) This is very different from the same operator in the C shell and in Bash. @@ -19411,11 +19636,11 @@ File: gawk.info, Node: TCP/IP Networking, Next: Profiling, Prev: Two-way I/O, 12.4 Using `gawk' for Network Programming ========================================= - `EMISTERED': + `EMRED': A host is a host from coast to coast, - and no-one can talk to host that's close, + and nobody talks to a host that's close, unless the host that isn't close - is busy hung or dead. + is busy, hung, or dead. -- Mike O'Brien (aka Mr. Protocol) In addition to being able to open a two-way pipeline to a coprocess on the same system (*note Two-way I/O::), it is possible to make a two-way @@ -19439,8 +19664,8 @@ NET-TYPE PROTOCOL The protocol to use over IP. This must be either `tcp', or `udp', - for a TCP or UDP IP connection, respectively. The use of TCP is - recommended for most applications. + for a TCP or UDP IP connection, respectively. TCP should be used + for most applications. LOCAL-PORT The local TCP or UDP port number to use. Use a port number of `0' @@ -19466,10 +19691,10 @@ REMOTE-PORT Consider the following very simple example: BEGIN { - Service = "/inet/tcp/0/localhost/daytime" - Service |& getline - print $0 - close(Service) + Service = "/inet/tcp/0/localhost/daytime" + Service |& getline + print $0 + close(Service) } This program reads the current date and time from the local system's @@ -19544,9 +19769,9 @@ First, the `awk' program: profiler on this program and data. (This example also illustrates that `awk' programmers sometimes get up very early in the morning to work.) - # gawk profile, created Thu Feb 27 05:16:21 2014 + # gawk profile, created Mon Sep 29 05:16:21 2014 - # BEGIN block(s) + # BEGIN rule(s) BEGIN { 1 print "First BEGIN rule" @@ -19573,7 +19798,7 @@ profiler on this program and data. (This example also illustrates that } } - # END block(s) + # END rule(s) END { 1 print "First END rule" @@ -19648,8 +19873,7 @@ output. They are as follows: you typed when you wrote it. This is because `gawk' creates the profiled version by "pretty printing" its internal representation of the program. The advantage to this is that `gawk' can produce a -standard representation. The disadvantage is that all source-code -comments are lost. Also, things such as: +standard representation. Also, things such as: /foo/ @@ -19659,7 +19883,7 @@ come out as: print $0 } -which is correct, but possibly surprising. +which is correct, but possibly unexpected. Besides creating profiles when a program has completed, `gawk' can produce a profile while it is running. This is useful if your `awk' @@ -19676,7 +19900,7 @@ The shell prints a job number and process ID number; in this case, $ kill -USR1 13992 As usual, the profiled version of the program is written to -`awkprof.out', or to a different file if one specified with the +`awkprof.out', or to a different file if one was specified with the `--profile' option. Along with the regular profile, as shown earlier, the profile file @@ -19711,6 +19935,22 @@ without any execution counts. NOTE: Once upon a time, the `--pretty-print' option would also run your program. This is is no longer the case. + There is a significant difference between the output created when +profiling, and that created when pretty-printing. Pretty-printed output +preserves the original comments that were in the program, although their +placement may not correspond exactly to their original locations in the +source code. + + However, as a deliberate design decision, profiling output _omits_ +the original program's comments. This allows you to focus on the +execution count data and helps you avoid the temptation to use the +profiler for pretty-printing. + + Additionally, pretty-printed output does not have the leading +indentation that the profiling output does. This makes it easy to +pretty-print your code once development is completed, and then use the +result as the final version of your program. + File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanced Features @@ -19720,7 +19960,8 @@ File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanc * The `--non-decimal-data' option causes `gawk' to treat octal- and hexadecimal-looking input data as octal and hexadecimal. This option should be used with caution or not at all; use of - `strtonum()' is preferable. + `strtonum()' is preferable. Note that this option may disappear + in a future version of `gawk'. * You can take over complete control of sorting in `for (INDX in ARRAY)' array traversal by setting `PROCINFO["sorted_in"]' to the @@ -19734,14 +19975,14 @@ File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanc `PROCINFO["sorted_in"]'. * You can use the `|&' operator to create a two-way pipe to a - co-process. You read from the co-process with `getline' and write + coprocess. You read from the coprocess with `getline' and write to it with `print' or `printf'. Use `close()' to close off the - co-process completely, or optionally, close off one side of the + coprocess completely, or optionally, close off one side of the two-way communications. - * By using special "file names" with the `|&' operator, you can open - a TCP/IP (or UDP/IP) connection to remote hosts in the Internet. - `gawk' supports both IPv4 an IPv6. + * By using special file names with the `|&' operator, you can open a + TCP/IP (or UDP/IP) connection to remote hosts in the Internet. + `gawk' supports both IPv4 and IPv6. * You can generate statement count profiles of your program. This can help you determine which parts of your program may be taking @@ -19902,7 +20143,7 @@ are: Character-type information (alphabetic, digit, upper- or lowercase, and so on) as well as character encoding. This information is accessed via the POSIX character classes in regular - expressions, such as `/[[:alnum:]]/' (*note Regexp Operators::). + expressions, such as `/[[:alnum:]]/' (*note Bracket Expressions::). `LC_MONETARY' Monetary information, such as the currency symbol, and whether the @@ -19970,8 +20211,8 @@ internationalization: Return the plural form used for NUMBER of the translation of STRING1 and STRING2 in text domain DOMAIN for locale category CATEGORY. STRING1 is the English singular variant of a message, - and STRING2 the English plural variant of the same message. The - default value for DOMAIN is the current value of `TEXTDOMAIN'. + and STRING2 is the English plural variant of the same message. + The default value for DOMAIN is the current value of `TEXTDOMAIN'. The default value for CATEGORY is `"LC_MESSAGES"'. The same remarks about argument order as for the `dcgettext()' @@ -20024,9 +20265,11 @@ outlined in *note Explaining gettext::, like so: one. This example would be better done with `dcngettext()': if (groggy) - message = dcngettext("%d customer disturbing me\n", "%d customers disturbing me\n", "adminprog") + message = dcngettext("%d customer disturbing me\n", + "%d customers disturbing me\n", "adminprog") else - message = dcngettext("enjoying %d customer\n", "enjoying %d customers\n", "adminprog") + message = dcngettext("enjoying %d customer\n", + "enjoying %d customers\n", "adminprog") printf(message, ncustomers) 4. During development, you might want to put the `.gmo' file in a @@ -20084,7 +20327,7 @@ marked and you've set (and perhaps bound) the text domain, it is time to produce translations. First, use the `--gen-pot' command-line option to create the initial `.pot' file: - $ gawk --gen-pot -f guide.awk > guide.pot + gawk --gen-pot -f guide.awk > guide.pot When run with `--gen-pot', `gawk' does not execute your program. Instead, it parses it as usual and prints all marked strings to @@ -20136,11 +20379,11 @@ example, `string' is the first argument and `length(string)' is the second: $ gawk 'BEGIN { - > string = "Dont Panic" + > string = "Don\47t Panic" > printf "%2$d characters live in \"%1$s\"\n", > string, length(string) > }' - -| 10 characters live in "Dont Panic" + -| 11 characters live in "Don't Panic" If present, positional specifiers come first in the format specification, before the flags, the field width, and/or the precision. @@ -20301,7 +20544,8 @@ Following are the translations: The next step is to make the directory to hold the binary message object file and then to create the `guide.mo' file. We pretend that -our file is to be used in the `en_US.UTF-8' locale. The directory +our file is to be used in the `en_US.UTF-8' locale, since we have to +use a locale name known to the C `gettext' routines. The directory layout shown here is standard for GNU `gettext' on GNU/Linux systems. Other versions of `gettext' may use a different layout: @@ -20310,7 +20554,7 @@ Other versions of `gettext' may use a different layout: The `msgfmt' utility does the conversion from human-readable `.po' file to machine-readable `.mo' file. By default, `msgfmt' creates a file named `messages'. This file must be renamed and placed in the -proper directory so that `gawk' can find it: +proper directory (using the `-o' option) so that `gawk' can find it: $ msgfmt guide-mellow.po -o en_US.UTF-8/LC_MESSAGES/guide.mo @@ -20343,8 +20587,8 @@ File: gawk.info, Node: Gawk I18N, Next: I18N Summary, Prev: I18N Example, Up `gawk' itself has been internationalized using the GNU `gettext' package. (GNU `gettext' is described in complete detail in *note (GNU `gettext' utilities)Top:: gettext, GNU gettext tools.) As of this -writing, the latest version of GNU `gettext' is version 0.19.1 -(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz). +writing, the latest version of GNU `gettext' is version 0.19.3 +(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.3.tar.gz). If a translation of `gawk''s messages exists, then `gawk' produces usage messages, warnings, and fatal errors in the local language. @@ -20429,7 +20673,7 @@ File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debuggi --------------------------- (If you have used debuggers in other languages, you may want to skip -ahead to the next section on the specific features of the `awk' +ahead to the next section on the specific features of the `gawk' debugger.) Of course, a debugging program cannot remove bugs for you, since it @@ -20465,8 +20709,8 @@ functional program that you or someone else wrote). File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging Concepts, Up: Debugging -14.1.2 Additional Debugging Concepts ------------------------------------- +14.1.2 Debugging Concepts +------------------------- Before diving in to the details, we need to introduce several important concepts that apply to just about all debuggers. The following list @@ -20558,13 +20802,13 @@ File: gawk.info, Node: Debugger Invocation, Next: Finding The Bug, Up: Sample 14.2.1 How to Start the Debugger -------------------------------- -Starting the debugger is almost exactly like running `gawk', except you -have to pass an additional option `--debug' or the corresponding short -option `-D'. The file(s) containing the program and any supporting -code are given on the command line as arguments to one or more `-f' -options. (`gawk' is not designed to debug command-line programs, only -programs contained in files.) In our case, we invoke the debugger like -this: +Starting the debugger is almost exactly like running `gawk' normally, +except you have to pass an additional option `--debug', or the +corresponding short option `-D'. The file(s) containing the program +and any supporting code are given on the command line as arguments to +one or more `-f' options. (`gawk' is not designed to debug command-line +programs, only programs contained in files.) In our case, we invoke +the debugger like this: $ gawk -D -f getopt.awk -f join.awk -f uniq.awk -1 inputfile @@ -20573,7 +20817,7 @@ users of GDB or similar debuggers should note that this syntax is slightly different from what they are used to. With the `gawk' debugger, you give the arguments for running the program in the command line to the debugger rather than as part of the `run' command at the -debugger prompt.) +debugger prompt.) The `-1' is an option to `uniq.awk'. Instead of immediately running the program on `inputfile', as `gawk' would ordinarily do, the debugger merely loads all the program source @@ -20721,9 +20965,9 @@ split into, so we try to look: This is kind of disappointing, though. All we found out is that there are five elements in `alast'; `m' and `aline' don't have values -yet since we are at line 68 but haven't executed it yet. This -information is useful enough (we now know that none of the words were -accidentally left out), but what if we want to see inside the array? +since we are at line 68 but haven't executed it yet. This information +is useful enough (we now know that none of the words were accidentally +left out), but what if we want to see inside the array? The first choice would be to use subscripts: @@ -20873,13 +21117,13 @@ controlling breakpoints are: `condition' N `"EXPRESSION"' Add a condition to existing breakpoint or watchpoint N. The - condition is an `awk' expression that the debugger evaluates - whenever the breakpoint or watchpoint is reached. If the condition - is true, then the debugger stops execution and prompts for a - command. Otherwise, the debugger continues executing the program. - If the condition expression is not specified, any existing - condition is removed; i.e., the breakpoint or watchpoint is made - unconditional. + condition is an `awk' expression _enclosed in double quotes_ that + the debugger evaluates whenever the breakpoint or watchpoint is + reached. If the condition is true, then the debugger stops + execution and prompts for a command. Otherwise, the debugger + continues executing the program. If the condition expression is + not specified, any existing condition is removed; i.e., the + breakpoint or watchpoint is made unconditional. `delete' [N1 N2 ...] [N-M] `d' [N1 N2 ...] [N-M] @@ -20998,9 +21242,9 @@ execution of the program than we saw in our earlier example: `until' [[FILENAME`:']N | FUNCTION] `u' [[FILENAME`:']N | FUNCTION] Without any argument, continue execution until a line past the - current line in current stack frame is reached. With an argument, - continue execution until the specified location is reached, or the - current stack frame returns. + current line in the current stack frame is reached. With an + argument, continue execution until the specified location is + reached, or the current stack frame returns. File: gawk.info, Node: Viewing And Changing Data, Next: Execution Stack, Prev: Debugger Execution Control, Up: List of Debugger Commands @@ -21047,9 +21291,9 @@ AWK STATEMENTS This prints the third field in the input record (if the specified field does not exist, it prints `Null field'). A variable can be - an array element, with the subscripts being constant values. To - print the contents of an array, prefix the name of the array with - the `@' symbol: + an array element, with the subscripts being constant string + values. To print the contents of an array, prefix the name of the + array with the `@' symbol: gawk> print @a @@ -21094,7 +21338,7 @@ AWK STATEMENTS File: gawk.info, Node: Execution Stack, Next: Debugger Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands -14.3.4 Dealing with the Stack +14.3.4 Working with the Stack ----------------------------- Whenever you run a program which contains any function calls, `gawk' @@ -21106,11 +21350,13 @@ are: `backtrace' [COUNT] `bt' [COUNT] +`where' [COUNT] Print a backtrace of all function calls (stack frames), or innermost COUNT frames if COUNT > 0. Print the outermost COUNT frames if COUNT < 0. The backtrace displays the name and arguments to each function, the source file name, and the line - number. + number. The alias `where' for `backtrace' is provided for + long-time GDB users who may be used to that command. `down' [COUNT] Move COUNT (default 1) frames down the stack toward the innermost @@ -21147,7 +21393,7 @@ know: The value for WHAT should be one of the following: `args' - Arguments of the selected frame. + List arguments of the selected frame. `break' List all currently set breakpoints. @@ -21156,19 +21402,19 @@ know: List all items in the automatic display list. `frame' - Description of the selected stack frame. + Give a description of the selected stack frame. `functions' List all function definitions including source file names and line numbers. `locals' - Local variables of the selected frame. + List local variables of the selected frame. `source' - The name of the current source file. Each time the program - stops, the current source file is the file containing the - current instruction. When the debugger first starts, the + Print the name of the current source file. Each time the + program stops, the current source file is the file containing + the current instruction. When the debugger first starts, the current source file is the first file included via the `-f' option. The `list FILENAME:LINENO' command can be used at any time to change the current source. @@ -21316,7 +21562,7 @@ categories, as follows: or the file named FILENAME. The possible arguments to `list' are as follows: - `-' + `-' (Minus) Print lines before the lines last printed. `+' @@ -21387,8 +21633,8 @@ Variable name completion File: gawk.info, Node: Limitations, Next: Debugging Summary, Prev: Readline Support, Up: Debugger -14.5 Limitations and Future Plans -================================= +14.5 Limitations +================ We hope you find the `gawk' debugger useful and enjoyable to work with, but as with any program, especially in its early releases, it still has @@ -21427,10 +21673,6 @@ some limitations. A few which are worth being aware of are: * The `gawk' debugger only accepts source supplied with the `-f' option. - Look forward to a future release when these and other missing -features may be added, and of course feel free to try to add them -yourself! - File: gawk.info, Node: Debugging Summary, Prev: Limitations, Up: Debugger @@ -21467,8 +21709,7 @@ File: gawk.info, Node: Arbitrary Precision Arithmetic, Next: Dynamic Extension ************************************************************ This major node introduces some basic concepts relating to how -computers do arithmetic and briefly lists the features in `gawk' for -performing arbitrary precision floating point computations. It then +computers do arithmetic and defines some important terms. It then proceeds to describe floating-point arithmetic, which is what `awk' uses for all its computations, including a discussion of arbitrary precision floating point arithmetic, which is a feature available only @@ -21563,9 +21804,10 @@ Floating point arithmetic ranges. Integer values are usually either 32 or 64 bits in size. Single precision floating point values occupy 32 bits, whereas double precision floating point values occupy 64 bits. Floating point values are always -signed. The possible ranges of values are shown in the following table. +signed. The possible ranges of values are shown in *note +table-numeric-ranges::. -Numeric representation Miniumum value Maximum value +Numeric representation Minimum value Maximum value --------------------------------------------------------------------------- 32-bit signed integer -2,147,483,648 2,147,483,647 32-bit unsigned integer 0 4,294,967,295 @@ -21578,6 +21820,8 @@ Double precision `2.225074e-308' `1.797693e+308' floating point (approximate) +Table 15.1: Value Ranges for Different Numeric Representations + ---------- Footnotes ---------- (1) We don't know why they expect this, but they do. @@ -21610,7 +21854,7 @@ material here. number and infinity produce infinity. "NaN" - "Not A Number."(1). A special value that results from attempting a + "Not A Number."(1) A special value that results from attempting a calculation that has no answer as a real number. In such a case, programs can either receive a floating-point exception, or get `NaN' back as the result. The IEEE 754 standard recommends that @@ -21668,37 +21912,38 @@ ranges. (`awk' uses only the 64-bit double precision format.) *note table-ieee-formats:: lists the precision and exponent field values for the basic IEEE 754 binary formats: -Name Total bits Precision emin emax +Name Total bits Precision Minimum Maximum + exponent exponent --------------------------------------------------------------------------- Single 32 24 -126 +127 Double 64 53 -1022 +1023 Quadruple 128 113 -16382 +16383 -Table 15.1: Basic IEEE Format Context Values +Table 15.2: Basic IEEE Format Values NOTE: The precision numbers include the implied leading one that gives them one extra bit of significand. ---------- Footnotes ---------- - (1) Thanks to Michael Brennan for this description, which I have -paraphrased, and for the examples + (1) Thanks to Michael Brennan for this description, which we have +paraphrased, and for the examples. File: gawk.info, Node: MPFR features, Next: FP Math Caution, Prev: Math Definitions, Up: Arbitrary Precision Arithmetic -15.3 Arbitrary Precison 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, `gawk' uses the GNU MPFR (http://www.mpfr.org) and GNU -MP (http://gmplib.org) (GMP) libraries for arbitrary precision +compiled to do so, `gawk' uses the `http://www.mpfr.org GNU MPFR' and +GNU MP (http://gmplib.org) (GMP) libraries for arbitrary precision arithmetic on numbers. You can see if MPFR support is available like so: $ gawk --version - -| GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2) + -| GNU Awk 4.1.2, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2) -| Copyright (C) 1989, 1991-2014 Free Software Foundation. ... @@ -21716,10 +21961,11 @@ platform-independent results. With the `-M' command-line option, all floating-point arithmetic operators and numeric functions can yield results to any desired precision level supported by MPFR. - Two built-in variables, `PREC' and `ROUNDMODE', provide control over -the working precision and the rounding mode. The precision and the -rounding mode are set globally for every operation to follow. *Note -Auto-set::, for more information. + Two predefined variables, `PREC' and `ROUNDMODE', provide control +over the working precision and the rounding mode. The precision and +the rounding mode are set globally for every operation to follow. +*Note Setting precision::, and *note Setting the rounding mode::, for +more information. File: gawk.info, Node: FP Math Caution, Next: Arbitrary Precision Integers, Prev: MPFR features, Up: Arbitrary Precision Arithmetic @@ -21833,6 +22079,9 @@ you. Code to do this looks something like this: else # not ok +(We assume that you have a simple absolute value function named `abs()' +defined elsewhere in your program.) + File: gawk.info, Node: Errors accumulate, Prev: Comparing FP Values, Up: Inexactness of computations @@ -21915,7 +22164,7 @@ forget that the finite number of bits used to store the value is often just an approximation after proper rounding. The test for equality succeeds if and only if _all_ bits in the two operands are exactly the same. Since this is not necessarily true after floating-point -computations with a particular precision and effective rounding rule, a +computations with a particular precision and effective rounding mode, a straight test for equality may not work. Instead, compare the two numbers to see if they are within the desirable delta of each other. @@ -21978,7 +22227,7 @@ File: gawk.info, Node: Setting precision, Next: Setting the rounding mode, Pr precision or accuracy of individual numbers. Performing an arithmetic operation or calling a built-in function rounds the result to the current working precision. The default working precision is 53 bits, -which you can modify using the built-in variable `PREC'. You can also +which you can modify using the predefined variable `PREC'. You can also set the value to one of the predefined case-insensitive strings shown in *note table-predefined-precision-strings::, to emulate an IEEE 754 binary format. @@ -21991,7 +22240,7 @@ binary format. `"quad"' Basic 128-bit quadruple precision. `"oct"' 256-bit octuple precision. -Table 15.2: Predefined Precision Strings For `PREC' +Table 15.3: Predefined Precision Strings For `PREC' The following example illustrates the effects of changing precision on arithmetic operations: @@ -22005,7 +22254,7 @@ on arithmetic operations: floating-point constant from program source code, `gawk' uses the default precision (that of a C `double'), unless overridden by an assignment to the special variable `PREC' on the command line, to - store it internally as a MPFR number. Changing the precision + store it internally as an MPFR number. Changing the precision using `PREC' in the program text does _not_ change the precision of a constant. @@ -22044,10 +22293,10 @@ Round toward zero `roundTowardZero' `"Z"' or `"z"' Round to nearest, ties away `roundTiesToAway' `"A"' or `"a"' from zero -Table 15.3: `gawk' Rounding Modes +Table 15.4: `gawk' Rounding Modes `ROUNDMODE' has the default value `"N"', which selects the IEEE 754 -rounding mode `roundTiesToEven'. In *note Table 15.3: +rounding mode `roundTiesToEven'. In *note Table 15.4: table-gawk-rounding-modes, the value `"A"' selects `roundTiesToAway'. This is only available if your version of the MPFR library supports it; otherwise setting `ROUNDMODE' to `"A"' has no effect. @@ -22126,15 +22375,15 @@ using GMP arbitrary precision integers. Any number that looks like an integer in a source or data file is stored as an arbitrary precision integer. The size of the integer is limited only by the available memory. For example, the following computes 5^4^3^2, the result of -which is beyond the limits of ordinary hardware double-precision +which is beyond the limits of ordinary hardware double precision floating point values: $ gawk -M 'BEGIN { > x = 5^4^3^2 - > print "# of digits =", length(x) + > print "number of digits =", length(x) > print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20) > }' - -| # of digits = 183231 + -| number of digits = 183231 -| 62060698786608744707 ... 92256259918212890625 If instead you were to compute the same value using arbitrary @@ -22196,7 +22445,7 @@ user-defined function: # div --- do integer division - function div(numerator, denominator, result, i) + function div(numerator, denominator, result) { split("", result) @@ -22208,6 +22457,39 @@ user-defined function: return 0.0 } + The following example program, contributed by Katie Wasserman, uses +`div()' to compute the digits of pi to as many places as you choose to +set: + + # pi.awk --- compute the digits of pi + + BEGIN { + digits = 100000 + two = 2 * 10 ^ digits + pi = two + for (m = digits * 4; m > 0; --m) { + d = m * 2 + 1 + x = pi * m + div(x, d, result) + pi = result["quotient"] + pi = pi + two + } + print pi + } + + When asked about the algorithm used, Katie replied: + + It's not that well known but it's not that obscure either. It's + Euler's modification to Newton's method for calculating pi. Take + a look at lines (23) - (25) here: + `http://mathworld.wolfram.com/PiFormulas.htm'. + + The algorithm I wrote simply expands the multiply by 2 and works + from the innermost expression outwards. I used this to program HP + calculators because it's quite easy to modify for tiny memory + devices with smallish word sizes. See + `http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899'. + ---------- Footnotes ---------- (1) Weisstein, Eric W. `Sylvester's Sequence'. From MathWorld--A @@ -22309,8 +22591,8 @@ File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Prob ============ * Most computer arithmetic is done using either integers or - floating-point values. The default for `awk' is to use - double-precision floating-point values. + floating-point values. Standard `awk' uses double precision + floating-point values. * In the early 1990's, Barbie mistakenly said "Math class is tough!" While math isn't tough, floating-point arithmetic isn't the same @@ -22411,7 +22693,7 @@ write in C or C++, you can write an extension to do it! Extensions are written in C or C++, using the "Application Programming Interface" (API) defined for this purpose by the `gawk' developers. The rest of this major node explains the facilities that -the API provides and how to use them, and presents a small sample +the API provides and how to use them, and presents a small example extension. In addition, it documents the sample extensions included in the `gawk' distribution, and describes the `gawkextlib' project. *Note Extension Design::, for a discussion of the extension mechanism goals @@ -22423,10 +22705,13 @@ File: gawk.info, Node: Plugin License, Next: Extension Mechanism Outline, Pre 16.2 Extension Licensing ======================== -Every dynamic extension should define the global symbol -`plugin_is_GPL_compatible' to assert that it has been licensed under a -GPL-compatible license. If this symbol does not exist, `gawk' emits a -fatal error and exits when it tries to load your extension. +Every dynamic extension must be distributed under a license that is +compatible with the GNU GPL (*note Copying::). + + In order for the extension to tell `gawk' that it is properly +licensed, the extension must define the global symbol +`plugin_is_GPL_compatible'. If this symbol does not exist, `gawk' +emits a fatal error and exits when it tries to load your extension. The declared type of the symbol should be `int'. It does not need to be in any allocated section, though. The code merely asserts that @@ -22441,7 +22726,7 @@ File: gawk.info, Node: Extension Mechanism Outline, Next: Extension API Descri ================================= Communication between `gawk' and an extension is two-way. First, when -an extension is loaded, it is passed a pointer to a `struct' whose +an extension is loaded, `gawk' passes it a pointer to a `struct' whose fields are function pointers. This is shown in *note figure-load-extension::. @@ -22474,8 +22759,8 @@ Figure 16.1: Loading The Extension The extension can call functions inside `gawk' through these function pointers, at runtime, without needing (link-time) access to `gawk''s symbols. One of these function pointers is to a function for -"registering" new built-in functions. This is shown in *note -figure-load-new-function::. +"registering" new functions. This is shown in *note +figure-register-new-function::. register_ext_func({ "chdir", do_chdir, 1 }); @@ -22489,7 +22774,7 @@ figure-load-new-function::. +-------+-+---+-+---+-+------------------+--------------+-+---+ gawk Main Program Address Space Extension -Figure 16.2: Loading The New Function +Figure 16.2: Registering A New Function In the other direction, the extension registers its new functions with `gawk' by passing function pointers to the functions that provide @@ -22522,8 +22807,8 @@ and understandable. Although all of this sounds somewhat complicated, the result is that extension code is quite straightforward to write and to read. You can -see this in the sample extensions `filefuncs.c' (*note Extension -Example::) and also the `testext.c' code for testing the APIs. +see this in the sample extension `filefuncs.c' (*note Extension +Example::) and also in the `testext.c' code for testing the APIs. Some other bits and pieces: @@ -22554,13 +22839,13 @@ describes the API in detail. * Extension API Functions Introduction:: Introduction to the API functions. * General Data Types:: The data types. -* Requesting Values:: How to get a value. * Memory Allocation Functions:: Functions for allocating memory. * Constructor Functions:: Functions for creating values. * Registration Functions:: Functions to register things with `gawk'. * Printing Messages:: Functions for printing messages. * Updating `ERRNO':: Functions for updating `ERRNO'. +* Requesting Values:: How to get a value. * Accessing Parameters:: Functions for accessing parameters. * Symbol Table Access:: Functions for accessing global variables. @@ -22580,6 +22865,8 @@ through function pointers passed into your extension. API function pointers are provided for the following kinds of operations: + * Allocating, reallocating, and releasing memory. + * Registration functions. You may register: - extension functions, @@ -22604,8 +22891,6 @@ operations: * Symbol table access: retrieving a global variable, creating one, or changing one. - * Allocating, reallocating, and releasing memory. - * Creating and releasing cached values; this provides an efficient way to use values for multiple variables and can be a big performance win. @@ -22659,9 +22944,8 @@ operations: * All pointers filled in by `gawk' point to memory managed by `gawk' and should be treated by the extension as read-only. Memory for _all_ strings passed into `gawk' from the extension _must_ come - from calling the API-provided function pointers `api_malloc()', - `api_calloc()' or `api_realloc()', and is managed by `gawk' from - then on. + from calling one of `gawk_malloc()', `gawk_calloc()' or + `gawk_realloc()', and is managed by `gawk' from then on. * The API defines several simple `struct's that map values as seen from `awk'. A value can be a `double', a string, or an array (as @@ -22677,7 +22961,7 @@ operations: * When retrieving a value (such as a parameter or that of a global variable or array element), the extension requests a specific type - (number, string, scalars, value cookie, array, or "undefined"). + (number, string, scalar, value cookie, array, or "undefined"). When the request is "undefined," the returned value will have the real underlying type. @@ -22694,7 +22978,7 @@ macros that you should use in your code. This minor node presents the macros as if they were functions. -File: gawk.info, Node: General Data Types, Next: Requesting Values, Prev: Extension API Functions Introduction, Up: Extension API Description +File: gawk.info, Node: General Data Types, Next: Memory Allocation Functions, Prev: Extension API Functions Introduction, Up: Extension API Description 16.4.2 General Purpose Data Types --------------------------------- @@ -22733,9 +23017,8 @@ that use them. `} awk_string_t;' This represents a mutable string. `gawk' owns the memory pointed to if it supplied the value. Otherwise, it takes ownership of the - memory pointed to. *Such memory must come from calling the - API-provided function pointers `api_malloc()', `api_calloc()', or - `api_realloc()'!* + memory pointed to. *Such memory must come from calling one of the + `gawk_malloc()', `gawk_calloc()', or `gawk_realloc()' functions!* As mentioned earlier, strings are maintained using the current multibyte encoding. @@ -22821,7 +23104,7 @@ can obtain a "scalar cookie"(1) object for that variable, and then use the cookie for getting the variable's value or for changing the variable's value. This is the `awk_scalar_t' type and `scalar_cookie' macro. Given a scalar cookie, `gawk' can directly retrieve or modify -the value, as required, without having to first find it. +the value, as required, without having to find it first. The `awk_value_cookie_t' type and `value_cookie' macro are similar. If you know that you wish to use the same numeric or string _value_ for @@ -22840,62 +23123,30 @@ the value. See also the entry for "Cookie" in the *note Glossary::. -File: gawk.info, Node: Requesting Values, Next: Memory Allocation Functions, Prev: General Data Types, Up: Extension API Description - -16.4.3 Requesting Values ------------------------- +File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Functions, Prev: General Data Types, Up: Extension API Description -All of the functions that return values from `gawk' work in the same -way. You pass in an `awk_valtype_t' value to indicate what kind of -value you expect. If the actual value matches what you requested, the -function returns true and fills in the `awk_value_t' result. -Otherwise, the function returns false, and the `val_type' member -indicates the type of the actual value. You may then print an error -message, or reissue the request for the actual value type, as -appropriate. This behavior is summarized in *note -table-value-types-returned::. - - Type of Actual Value: --------------------------------------------------------------------------- - - String Number Array Undefined ------------------------------------------------------------------------------- - String String String false false - Number Number if can Number false false - be converted, - else false -Type Array false false Array false -Requested: Scalar Scalar Scalar false false - Undefined String Number Array Undefined - Value false false false false - Cookie - -Table 16.1: API Value Types Returned - - -File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Functions, Prev: Requesting Values, Up: Extension API Description - -16.4.4 Memory Allocation Functions and Convenience Macros +16.4.3 Memory Allocation Functions and Convenience Macros --------------------------------------------------------- The API provides a number of "memory allocation" functions for allocating memory that can be passed to `gawk', as well as a number of -convenience macros. +convenience macros. This node presents them all as function +prototypes, in the way that extension code would use them. `void *gawk_malloc(size_t size);' - Call `gawk'-provided `api_malloc()' to allocate storage that may + Call the correct version of `malloc()' to allocate storage that may be passed to `gawk'. `void *gawk_calloc(size_t nmemb, size_t size);' - Call `gawk'-provided `api_calloc()' to allocate storage that may + Call the correct version of `calloc()' to allocate storage that may be passed to `gawk'. `void *gawk_realloc(void *ptr, size_t size);' - Call `gawk'-provided `api_realloc()' to allocate storage that may - be passed to `gawk'. + Call the correct version of `realloc()' to allocate storage that + may be passed to `gawk'. `void gawk_free(void *ptr);' - Call `gawk'-provided `api_free()' to release storage that was + Call the correct version of `free()' to release storage that was allocated with `gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'. @@ -22905,11 +23156,10 @@ C library than was used for the `gawk' executable.(1) If `gawk' were to use its version of `free()' when the memory came from an unrelated version of `malloc()', unexpected behavior would likely result. - Two convenience macros may be used for allocating storage from the -API-provided function pointers `api_malloc()' and `api_realloc()'. If -the allocation fails, they cause `gawk' to exit with a fatal error -message. They should be used as if they were procedure calls that do -not return a value. + Two convenience macros may be used for allocating storage from +`gawk_malloc()' and `gawk_realloc()'. If the allocation fails, they +cause `gawk' to exit with a fatal error message. They should be used +as if they were procedure calls that do not return a value. `#define emalloc(pointer, type, size, message) ...' The arguments to this macro are as follows: @@ -22919,7 +23169,7 @@ not return a value. `type' The type of the pointer variable, used to create a cast for - the call to `api_malloc()'. + the call to `gawk_malloc()'. `size' The total number of bytes to be allocated. @@ -22939,9 +23189,9 @@ not return a value. make_malloced_string(message, strlen(message), & result); `#define erealloc(pointer, type, size, message) ...' - This is like `emalloc()', but it calls `api_realloc()', instead of - `api_malloc()'. The arguments are the same as for the `emalloc()' - macro. + This is like `emalloc()', but it calls `gawk_realloc()', instead + of `gawk_malloc()'. The arguments are the same as for the + `emalloc()' macro. ---------- Footnotes ---------- @@ -22951,7 +23201,7 @@ Unix-like systems as well. File: gawk.info, Node: Constructor Functions, Next: Registration Functions, Prev: Memory Allocation Functions, Up: Extension API Description -16.4.5 Constructor Functions +16.4.4 Constructor Functions ---------------------------- The API provides a number of "constructor" functions for creating @@ -22970,10 +23220,10 @@ extension code would use them. `make_malloced_string(const char *string, size_t length, awk_value_t *result)' This function creates a string value in the `awk_value_t' variable pointed to by `result'. It expects `string' to be a `char *' value - pointing to data previously obtained from the api-provided - functions `api_malloc()', `api_calloc()' or `api_realloc()'. The - idea here is that the data is passed directly to `gawk', which - assumes responsibility for it. It returns `result'. + pointing to data previously obtained from `gawk_malloc()', + `gawk_calloc()' or `gawk_realloc()'. The idea here is that the + data is passed directly to `gawk', which assumes responsibility + for it. It returns `result'. `static inline awk_value_t *' `make_null_string(awk_value_t *result)' @@ -22989,7 +23239,7 @@ extension code would use them. File: gawk.info, Node: Registration Functions, Next: Printing Messages, Prev: Constructor Functions, Up: Extension API Description -16.4.6 Registration Functions +16.4.5 Registration Functions ----------------------------- This minor node describes the API functions for registering parts of @@ -23007,7 +23257,7 @@ your extension with `gawk'. File: gawk.info, Node: Extension Functions, Next: Exit Callback Functions, Up: Registration Functions -16.4.6.1 Registering An Extension Function +16.4.5.1 Registering An Extension Function .......................................... Extension functions are described by the following record: @@ -23025,17 +23275,16 @@ Extension functions are described by the following record: by this name. This is a regular C string. Function names must obey the rules for `awk' identifiers. That is, - they must begin with either a letter or an underscore, which may - be followed by any number of letters, digits, and underscores. - Letter case in function names is significant. + they must begin with either an English letter or an underscore, + which may be followed by any number of letters, digits, and + underscores. Letter case in function names is significant. `awk_value_t *(*function)(int num_actual_args, awk_value_t *result);' - This is a pointer to the C function that provides the desired - functionality. The function must fill in the result with either a + This is a pointer to the C function that provides the extension's + functionality. The function must fill in `*result' with either a number or a string. `gawk' takes ownership of any string memory. - As mentioned earlier, string memory *must* come from the - api-provided functions `api_malloc()', `api_calloc()' or - `api_realloc()'. + As mentioned earlier, string memory *must* come from one of + `gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'. The `num_actual_args' argument tells the C function how many actual parameters were passed from the calling `awk' code. @@ -23046,7 +23295,7 @@ Extension functions are described by the following record: `size_t num_expected_args;' This is the number of arguments the function expects to receive. Each extension function may decide what to do if the number of - arguments isn't what it expected. Following `awk' functions, it + arguments isn't what it expected. As with real `awk' functions, it is likely OK to ignore extra arguments. Once you have a record representing your extension function, you @@ -23061,7 +23310,7 @@ register it with `gawk' using this API function: File: gawk.info, Node: Exit Callback Functions, Next: Extension Version String, Prev: Extension Functions, Up: Registration Functions -16.4.6.2 Registering An Exit Callback Function +16.4.5.2 Registering An Exit Callback Function .............................................. An "exit callback" function is a function that `gawk' calls before it @@ -23091,7 +23340,7 @@ order--that is, in the reverse order in which they are registered with File: gawk.info, Node: Extension Version String, Next: Input Parsers, Prev: Exit Callback Functions, Up: Registration Functions -16.4.6.3 Registering An Extension Version String +16.4.5.3 Registering An Extension Version String ................................................ You can register a version string which indicates the name and version @@ -23107,7 +23356,7 @@ invoked with the `--version' option. File: gawk.info, Node: Input Parsers, Next: Output Wrappers, Prev: Extension Version String, Up: Registration Functions -16.4.6.4 Customized Input Parsers +16.4.5.4 Customized Input Parsers ................................. By default, `gawk' reads text files as its input. It uses the value of @@ -23276,7 +23525,7 @@ records. The parameters are as follows: `*rt_start' should be set to point to the data to be used for `RT', and `*rt_len' should be set to the length of the data. Otherwise, `*rt_len' should be set to zero. `gawk' makes its own - copy of this data, so the extension must manage the storage. + copy of this data, so the extension must manage this storage. The return value is the length of the buffer pointed to by `*out', or `EOF' if end-of-file was reached or an error occurred. @@ -23330,7 +23579,7 @@ whether or not to activate an input parser (*note BEGINFILE/ENDFILE::). File: gawk.info, Node: Output Wrappers, Next: Two-way processors, Prev: Input Parsers, Up: Registration Functions -16.4.6.5 Customized Output Wrappers +16.4.5.5 Customized Output Wrappers ................................... An "output wrapper" is the mirror image of an input parser. It allows @@ -23437,7 +23686,7 @@ just use normally. File: gawk.info, Node: Two-way processors, Prev: Output Wrappers, Up: Registration Functions -16.4.6.6 Customized Two-way Processors +16.4.5.6 Customized Two-way Processors ...................................... A "two-way processor" combines an input parser and an output wrapper for @@ -23490,7 +23739,7 @@ can take this" and "take over for this" functions, File: gawk.info, Node: Printing Messages, Next: Updating `ERRNO', Prev: Registration Functions, Up: Extension API Description -16.4.7 Printing Messages +16.4.6 Printing Messages ------------------------ You can print different kinds of warning messages from your extension, @@ -23519,9 +23768,9 @@ of the ISO C 99 variadic macro feature to hide that parameter. More's the pity. -File: gawk.info, Node: Updating `ERRNO', Next: Accessing Parameters, Prev: Printing Messages, Up: Extension API Description +File: gawk.info, Node: Updating `ERRNO', Next: Requesting Values, Prev: Printing Messages, Up: Extension API Description -16.4.8 Updating `ERRNO' +16.4.7 Updating `ERRNO' ----------------------- The following functions allow you to update the `ERRNO' variable: @@ -23536,11 +23785,44 @@ The following functions allow you to update the `ERRNO' variable: Set `ERRNO' directly to the string value of `ERRNO'. `gawk' makes a copy of the value of `string'. -`void unset_ERRNO();' +`void unset_ERRNO(void);' Unset `ERRNO'. -File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Updating `ERRNO', Up: Extension API Description +File: gawk.info, Node: Requesting Values, Next: Accessing Parameters, Prev: Updating `ERRNO', Up: Extension API Description + +16.4.8 Requesting Values +------------------------ + +All of the functions that return values from `gawk' work in the same +way. You pass in an `awk_valtype_t' value to indicate what kind of +value you expect. If the actual value matches what you requested, the +function returns true and fills in the `awk_value_t' result. +Otherwise, the function returns false, and the `val_type' member +indicates the type of the actual value. You may then print an error +message, or reissue the request for the actual value type, as +appropriate. This behavior is summarized in *note +table-value-types-returned::. + + Type of Actual Value: +-------------------------------------------------------------------------- + + String Number Array Undefined +------------------------------------------------------------------------------ + String String String false false + Number Number if can Number false false + be converted, + else false +Type Array false false Array false +Requested: Scalar Scalar Scalar false false + Undefined String Number Array Undefined + Value false false false false + Cookie + +Table 16.1: API Value Types Returned + + +File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Requesting Values, Up: Extension API Description 16.4.9 Accessing and Updating Parameters ---------------------------------------- @@ -23598,7 +23880,7 @@ termed a "symbol table". Fill in the `awk_value_t' structure pointed to by `result' with the value of the variable named by the string `name', which is a regular C string. `wanted' indicates the type of value expected. - Return true if the actual type matches `wanted', false otherwise + Return true if the actual type matches `wanted', false otherwise. In the latter case, `result->val_type' indicates the actual type (*note Table 16.1: table-value-types-returned.). @@ -23616,7 +23898,7 @@ termed a "symbol table". However, with the exception of the `PROCINFO' array, an extension cannot change any of those variables. - NOTE: It is possible for the lookup of `PROCINFO' to fail. This + CAUTION: It is possible for the lookup of `PROCINFO' to fail. This happens if the `awk' program being run does not reference `PROCINFO'; in this case `gawk' doesn't bother to create the array and populate it. @@ -23638,14 +23920,14 @@ was discussed earlier, in *note General Data Types::. ` awk_valtype_t wanted,' ` awk_value_t *result);' Retrieve the current value of a scalar cookie. Once you have - obtained a scalar_cookie using `sym_lookup()', you can use this + obtained a scalar cookie using `sym_lookup()', you can use this function to get its value more efficiently. Return false if the value cannot be retrieved. `awk_bool_t sym_update_scalar(awk_scalar_t cookie, awk_value_t *value);' Update the value associated with a scalar cookie. Return false if the new value is not of type `AWK_STRING' or `AWK_NUMBER'. Here - too, the built-in variables may not be updated. + too, the predefined variables may not be updated. It is not obvious at first glance how to work with scalar cookies or what their raison d'e^tre really is. In theory, the `sym_lookup()' and @@ -23697,7 +23979,7 @@ usual. Then get a scalar cookie for the variable using `sym_lookup()': /* install initial value */ sym_update("MAGIC_VAR", make_number(42.0, & value)); - /* get cookie */ + /* get the cookie */ sym_lookup("MAGIC_VAR", AWK_SCALAR, & value); /* save the cookie */ @@ -23748,7 +24030,7 @@ variables using `sym_update()' or `sym_update_scalar()', as you like. However, you can understand the point of cached values if you remember that _every_ string value's storage _must_ come from -`api_malloc()', `api_calloc()' or `api_realloc()'. If you have 20 +`gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'. If you have 20 variables, all of which have the same string value, you must create 20 identical copies of the string.(1) @@ -23812,8 +24094,8 @@ Using value cookies in this way saves considerable storage, since all of `VAR1' through `VAR100' share the same value. You might be wondering, "Is this sharing problematic? What happens -if `awk' code assigns a new value to `VAR1', are all the others be -changed too?" +if `awk' code assigns a new value to `VAR1', are all the others changed +too?" That's a great question. The answer is that no, it's not a problem. Internally, `gawk' uses "reference-counted strings". This means that @@ -23879,7 +24161,7 @@ The data types associated with arrays are listed below. ` struct awk_element *next;' ` enum {' ` AWK_ELEMENT_DEFAULT = 0, /* set by gawk */' -` AWK_ELEMENT_DELETE = 1 /* set by extension if should be deleted */' +` AWK_ELEMENT_DELETE = 1 /* set by extension */' ` } flags;' ` awk_value_t index;' ` awk_value_t value;' @@ -23897,8 +24179,8 @@ The data types associated with arrays are listed below. the list. `enum { ... } flags;' - A set of flag values that convey information between `gawk' - and the extension. Currently there is only one: + A set of flag values that convey information between the + extension and `gawk'. Currently there is only one: `AWK_ELEMENT_DELETE'. Setting it causes `gawk' to delete the element from the original array upon release of the flattened array. @@ -23909,8 +24191,8 @@ The data types associated with arrays are listed below. memory pointed to by `index' and `value' belongs to `gawk'. `typedef struct awk_flat_array {' -` awk_const void *awk_const opaque1; /* private data for use by gawk */' -` awk_const void *awk_const opaque2; /* private data for use by gawk */' +` awk_const void *awk_const opaque1; /* for use by gawk */' +` awk_const void *awk_const opaque2; /* for use by gawk */' ` awk_const size_t count; /* how many elements */' ` awk_element_t elements[1]; /* will be extended */' `} awk_flat_array_t;' @@ -23934,7 +24216,7 @@ File: gawk.info, Node: Array Functions, Next: Flattening Arrays, Prev: Array The following functions relate to individual array elements. `awk_bool_t get_element_count(awk_array_t a_cookie, size_t *count);' - For the array represented by `a_cookie', return in `*count' the + For the array represented by `a_cookie', place in `*count' the number of elements it contains. A subarray counts as a single element. Return false if there is an error. @@ -23954,9 +24236,9 @@ The following functions relate to individual array elements. strings (*note Conversion::); thus using integral values is safest. As with _all_ strings passed into `gawk' from an extension, the - string value of `index' must come from the API-provided functions - `api_malloc()', `api_calloc()' or `api_realloc()' and `gawk' - releases the storage. + string value of `index' must come from `gawk_malloc()', + `gawk_calloc()' or `gawk_realloc()', and `gawk' releases the + storage. `awk_bool_t set_array_element(awk_array_t a_cookie,' ` const awk_value_t *const index,' @@ -23978,7 +24260,7 @@ The following functions relate to individual array elements. The following functions relate to arrays as a whole: -`awk_array_t create_array();' +`awk_array_t create_array(void);' Create a new array to which elements may be added. *Note Creating Arrays::, for a discussion of how to create a new array and add elements to it. @@ -24014,7 +24296,8 @@ array in a fashion that makes it easy for C code to traverse the entire array. Test code in `extension/testext.c' does this, and also serves as a nice example showing how to use the APIs. - First, the `gawk' script that drives the test extension: + We walk through that part of the code one step at a time. First, +the `gawk' script that drives the test extension: @load "testext" BEGIN { @@ -24135,8 +24418,7 @@ flag bit set: valrep2str(& flat_array->elements[i].value)); if (strcmp(value3.str_value.str, - flat_array->elements[i].index.str_value.str) - == 0) { + flat_array->elements[i].index.str_value.str) == 0) { flat_array->elements[i].flags |= AWK_ELEMENT_DELETE; printf("dump_array_and_delete: marking element \"%s\" " "for deletion\n", @@ -24226,9 +24508,9 @@ code: The following C code is a simple test extension to create an array with two regular elements and with a subarray. The leading `#include' -directives and boilerplate variable declarations are omitted for -brevity. The first step is to create a new array and then install it -in the symbol table: +directives and boilerplate variable declarations (*note Extension API +Boilerplate::) are omitted for brevity. The first step is to create a +new array and then install it in the symbol table: /* create_new_array --- create a named array */ @@ -24415,8 +24697,8 @@ invoked. The variables are: option. The value of `do_lint' can change if `awk' code modifies the `LINT' -built-in variable (*note Built-in Variables::). The others should not -change during execution. +predefined variable (*note Built-in Variables::). The others should +not change during execution. File: gawk.info, Node: Extension API Boilerplate, Prev: Extension API Variables, Up: Extension API Description @@ -24450,12 +24732,12 @@ in the `gawkapi.h' header file: /* OR: */ static awk_bool_t - init_my_module(void) + init_my_extension(void) { ... } - static awk_bool_t (*init_func)(void) = init_my_module; + static awk_bool_t (*init_func)(void) = init_my_extension; dl_load_func(func_table, some_name, "name_space_in_quotes") @@ -24487,8 +24769,8 @@ in the `gawkapi.h' header file: `static awk_bool_t (*init_func)(void) = NULL;' ` OR' -`static awk_bool_t init_my_module(void) { ... }' -`static awk_bool_t (*init_func)(void) = init_my_module;' +`static awk_bool_t init_my_extension(void) { ... }' +`static awk_bool_t (*init_func)(void) = init_my_extension;' If you need to do some initialization work, you should define a function that does it (creates variables, opens files, etc.) and then define the `init_func' pointer to point to your function. @@ -24542,8 +24824,9 @@ File: gawk.info, Node: Extension Example, Next: Extension Samples, Prev: Find Two useful functions that are not in `awk' are `chdir()' (so that an `awk' program can change its directory) and `stat()' (so that an `awk' -program can gather information about a file). This minor node -implements these functions for `gawk' in an extension. +program can gather information about a file). In order to illustrate +the API in action, this minor node implements these functions for +`gawk' in an extension. * Menu: @@ -24567,8 +24850,7 @@ directory to change to: newdir = "/home/arnold/funstuff" ret = chdir(newdir) if (ret < 0) { - printf("could not change to %s: %s\n", - newdir, ERRNO) > "/dev/stderr" + printf("could not change to %s: %s\n", newdir, ERRNO) > "/dev/stderr" exit 1 } ... @@ -24733,7 +25015,7 @@ arguments: the first is an `int' usually called `nargs', that represents the number of actual arguments for the function. The second is a pointer to an `awk_value_t', usually named `result'. - /* do_chdir --- provide dynamically loaded chdir() builtin for gawk */ + /* do_chdir --- provide dynamically loaded chdir() function for gawk */ static awk_value_t * do_chdir(int nargs, awk_value_t *result) @@ -24921,12 +25203,20 @@ and/or the type of the file. It then returns zero, for success: } } - array_set(array, "type", make_const_string(type, strlen(type), &tmp)); + array_set(array, "type", make_const_string(type, strlen(type), & tmp)); return 0; } - Finally, here is the `do_stat()' function. It starts with variable + The third argument to `stat()' was not discussed previously. This +argument is optional. If present, it causes `do_stat()' to use the +`stat()' system call instead of the `lstat()' system call. This is +done by using a function pointer: `statfunc'. `statfunc' is +initialized to point to `lstat()' (instead of `stat()') to get the file +information, in case the file is a symbolic link. However, if there +were three arguments, `statfunc' is set point to `stat()', instead. + + Here is the `do_stat()' function. It starts with variable declarations and argument checking: /* do_stat --- provide a stat() function for gawk */ @@ -24951,14 +25241,10 @@ declarations and argument checking: return make_number(-1, result); } - The third argument to `stat()' was not discussed previously. This -argument is optional. If present, it causes `stat()' to use the `stat()' -system call instead of the `lstat()' system call. - Then comes the actual work. First, the function gets the arguments. -Next, it gets the information for the file. The code use `lstat()' -(instead of `stat()') to get the file information, in case the file is -a symbolic link. If there's an error, it sets `ERRNO' and returns: +Next, it gets the information for the file. If the called function +(`lstat()' or `stat()') returns an error, the code sets `ERRNO' and +returns: /* file is first arg, array to hold results is second */ if ( ! get_argument(0, AWK_STRING, & file_param) @@ -24985,7 +25271,7 @@ a symbolic link. If there's an error, it sets `ERRNO' and returns: } The tedious work is done by `fill_stat_array()', shown earlier. -When done, return the result from `fill_stat_array()': +When done, the function returns the result from `fill_stat_array()': ret = fill_stat_array(name, array, & sbuf); @@ -25067,14 +25353,14 @@ create a GNU/Linux shared library: for (i in data) printf "data[\"%s\"] = %s\n", i, data[i] print "testff.awk modified:", - strftime("%m %d %y %H:%M:%S", data["mtime"]) + strftime("%m %d %Y %H:%M:%S", data["mtime"]) print "\nInfo for JUNK" ret = stat("JUNK", data) print "ret =", ret for (i in data) printf "data[\"%s\"] = %s\n", i, data[i] - print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"]) + print "JUNK modified:", strftime("%m %d %Y %H:%M:%S", data["mtime"]) } The `AWKLIBPATH' environment variable tells `gawk' where to find @@ -25086,32 +25372,33 @@ directory and run the program: -| Info for testff.awk -| ret = 0 -| data["blksize"] = 4096 - -| data["mtime"] = 1350838628 + -| data["devbsize"] = 512 + -| data["mtime"] = 1412004710 -| data["mode"] = 33204 -| data["type"] = file -| data["dev"] = 2053 -| data["gid"] = 1000 - -| data["ino"] = 1719496 - -| data["ctime"] = 1350838628 + -| data["ino"] = 10358899 + -| data["ctime"] = 1412004710 -| data["blocks"] = 8 -| data["nlink"] = 1 -| data["name"] = testff.awk - -| data["atime"] = 1350838632 + -| data["atime"] = 1412004716 -| data["pmode"] = -rw-rw-r-- - -| data["size"] = 662 + -| data["size"] = 666 -| data["uid"] = 1000 - -| testff.awk modified: 10 21 12 18:57:08 + -| testff.awk modified: 09 29 2014 18:31:50 -| -| Info for JUNK -| ret = -1 - -| JUNK modified: 01 01 70 02:00:00 + -| JUNK modified: 01 01 1970 02:00:00 ---------- Footnotes ---------- (1) In practice, you would probably want to use the GNU Autotools--Automake, Autoconf, Libtool, and `gettext'--to configure and build your libraries. Instructions for doing so are beyond the scope of -this Info file. *Note gawkextlib::, for WWW links to the tools. +this Info file. *Note gawkextlib::, for Internet links to the tools. File: gawk.info, Node: Extension Samples, Next: gawkextlib, Prev: Extension Example, Up: Dynamic Extensions @@ -25139,9 +25426,9 @@ the extension API. * Extension Sample Rev2way:: Reversing data sample two-way processor. * Extension Sample Read write array:: Serializing an array to a file. * Extension Sample Readfile:: Reading an entire file into a string. -* Extension Sample API Tests:: Tests for the API. * Extension Sample Time:: An interface to `gettimeofday()' and `sleep()'. +* Extension Sample API Tests:: Tests for the API. File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample Fnmatch, Up: Extension Samples @@ -25152,7 +25439,7 @@ File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample The `filefuncs' extension provides three different functions, as follows: The usage is: -@load "filefuncs" +`@load "filefuncs"' This is how you load the extension. `result = chdir("/some/directory")' @@ -25208,8 +25495,8 @@ follows: The usage is: `result = fts(pathlist, flags, filedata)' Walk the file trees provided in `pathlist' and fill in the `filedata' array as described below. `flags' is the bitwise OR of - several predefined constant values, also described below. Return - zero if there were no errors, otherwise return -1. + several predefined values, also described below. Return zero if + there were no errors, otherwise return -1. The `fts()' function provides a hook to the C library `fts()' routines for traversing file hierarchies. Instead of returning data @@ -25250,10 +25537,10 @@ requested hierarchies. whether or not `FTS_LOGICAL' is set. `FTS_SEEDOT' - By default, the `fts()' routines do not return entries for - `.' (dot) and `..' (dot-dot). This option causes entries for - dot-dot to also be included. (The extension always includes - an entry for dot, see below.) + By default, the C library `fts()' routines do not return + entries for `.' (dot) and `..' (dot-dot). This option causes + entries for dot-dot to also be included. (The extension + always includes an entry for dot, see below.) `FTS_XDEV' During a traversal, do not cross onto a different mounted @@ -25303,15 +25590,16 @@ Otherwise it returns -1. NOTE: The `fts()' extension does not exactly mimic the interface of the C library `fts()' routines, choosing instead to provide an - interface that is based on associative arrays, which should be - more comfortable to use from an `awk' program. This includes the - lack of a comparison function, since `gawk' already provides - powerful array sorting facilities. While an `fts_read()'-like - interface could have been provided, this felt less natural than - simply creating a multidimensional array to represent the file - hierarchy and its information. + interface that is based on associative arrays, which is more + comfortable to use from an `awk' program. This includes the lack + of a comparison function, since `gawk' already provides powerful + array sorting facilities. While an `fts_read()'-like interface + could have been provided, this felt less natural than simply + creating a multidimensional array to represent the file hierarchy + and its information. - See `test/fts.awk' in the `gawk' distribution for an example. + See `test/fts.awk' in the `gawk' distribution for an example use of +the `fts()' extension function. File: gawk.info, Node: Extension Sample Fnmatch, Next: Extension Sample Fork, Prev: Extension Sample File Functions, Up: Extension Samples @@ -25492,8 +25780,8 @@ returned as a record. number and the file name, separated by a forward slash character. On systems where the directory entry contains the file type, the record has a third field (also separated by a slash) which is a single letter -indicating the type of the file. The letters are file types are shown -in *note table-readdir-file-types::. +indicating the type of the file. The letters and their corresponding +file types are shown in *note table-readdir-file-types::. Letter File Type -------------------------------------------------------------------------- @@ -25506,7 +25794,7 @@ Letter File Type `s' Socket `u' Anything else (unknown) -Table 16.2: File Types Returned By `readdir()' +Table 16.2: File Types Returned By The `readdir' Extension On systems without the file type information, the third field is always `u'. @@ -25577,6 +25865,9 @@ File: gawk.info, Node: Extension Sample Read write array, Next: Extension Samp The `rwarray' extension adds two functions, named `writea()' and `reada()', as follows: +`@load "rwarray"' + This is how you load the extension. + `ret = writea(file, array)' This function takes a string argument, which is the name of the file to which to dump the array, and the array itself as the @@ -25613,7 +25904,7 @@ restored on systems with a different one, but this has not been tried. ret = reada("arraydump.bin", array) -File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample API Tests, Prev: Extension Sample Read write array, Up: Extension Samples +File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample Time, Prev: Extension Sample Read write array, Up: Extension Samples 16.7.10 Reading An Entire File ------------------------------ @@ -25646,21 +25937,9 @@ an input parser: } -File: gawk.info, Node: Extension Sample API Tests, Next: Extension Sample Time, Prev: Extension Sample Readfile, Up: Extension Samples - -16.7.11 API Tests ------------------ - -The `testext' extension exercises parts of the extension API that are -not tested by the other samples. The `extension/testext.c' file -contains both the C code for the extension and `awk' test code inside C -comments that run the tests. The testing framework extracts the `awk' -code and runs the tests. See the source file for more information. - - -File: gawk.info, Node: Extension Sample Time, Prev: Extension Sample API Tests, Up: Extension Samples +File: gawk.info, Node: Extension Sample Time, Next: Extension Sample API Tests, Prev: Extension Sample Readfile, Up: Extension Samples -16.7.12 Extension Time Functions +16.7.11 Extension Time Functions -------------------------------- The `time' extension adds two functions, named `gettimeofday()' and @@ -25689,6 +25968,18 @@ The `time' extension adds two functions, named `gettimeofday()' and delay. +File: gawk.info, Node: Extension Sample API Tests, Prev: Extension Sample Time, Up: Extension Samples + +16.7.12 API Tests +----------------- + +The `testext' extension exercises parts of the extension API that are +not tested by the other samples. The `extension/testext.c' file +contains both the C code for the extension and `awk' test code inside C +comments that run the tests. The testing framework extracts the `awk' +code and runs the tests. See the source file for more information. + + File: gawk.info, Node: gawkextlib, Next: Extension summary, Prev: Extension Samples, Up: Dynamic Extensions 16.8 The `gawkextlib' Project @@ -25701,21 +25992,17 @@ project. As of this writing, there are five extensions: - * XML parser extension, using the Expat - (http://expat.sourceforge.net) XML parsing library. + * GD graphics library extension. * PDF extension. * PostgreSQL extension. - * GD graphics library extension. - * MPFR library extension. This provides access to a number of MPFR functions which `gawk''s native MPFR support does not. - The `time' extension described earlier (*note Extension Sample -Time::) was originally from this project but has been moved in to the -main `gawk' distribution. + * XML parser extension, using the Expat + (http://expat.sourceforge.net) XML parsing library. You can check out the code for the `gawkextlib' project using the Git (http://git-scm.com) distributed source code control system. The @@ -25779,7 +26066,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga tasks. * One of these tasks is to "register" the name and implementation of - a new `awk'-level function with `gawk'. The implementation takes + new `awk'-level functions with `gawk'. The implementation takes the form of a C function pointer with a defined signature. By convention, implementation functions are named `do_XXXX()' for some `awk'-level function `XXXX()'. @@ -25791,6 +26078,8 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga * API function pointers are provided for the following kinds of operations: + * Allocating, reallocating, and releasing memory. + * Registration functions. You may register extension functions, exit callbacks, a version string, input parsers, output wrappers, and two-way processors. @@ -25805,8 +26094,6 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga * Symbol table access: retrieving a global variable, creating one, or changing one. - * Allocating, reallocating, and releasing memory. - * Creating and releasing cached values; this provides an efficient way to use values for multiple variables and can be a big performance win. @@ -25815,7 +26102,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga 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. @@ -25830,7 +26117,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga * _All_ memory passed from an extension to `gawk' must come from the API's memory allocation functions. `gawk' takes responsibility for - the memory and will release it when appropriate. + the memory and releases it when appropriate. * The API provides information about the running version of `gawk' so that an extension can make sure it is compatible with the `gawk' @@ -25844,7 +26131,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga sample extensions. The `gawkextlib' project includes several more, larger, extensions. If you wish to write an extension and contribute it to the community of `gawk' users, the `gawkextlib' - project should be the place to do so. + project is the place to do so. @@ -25877,11 +26164,11 @@ This Info file describes the GNU implementation of `awk', which follows the POSIX specification. Many long-time `awk' users learned `awk' programming with the original `awk' implementation in Version 7 Unix. (This implementation was the basis for `awk' in Berkeley Unix, through -4.3-Reno. Subsequent versions of Berkeley Unix, and some systems -derived from 4.4BSD-Lite, used various versions of `gawk' for their -`awk'.) This major node briefly describes the evolution of the `awk' -language, with cross-references to other parts of the Info file where -you can find more information. +4.3-Reno. Subsequent versions of Berkeley Unix, and, for a while, some +systems derived from 4.4BSD-Lite, used various versions of `gawk' for +their `awk'.) This major node briefly describes the evolution of the +`awk' language, with cross-references to other parts of the Info file +where you can find more information. * Menu: @@ -25931,7 +26218,7 @@ the changes, with cross-references to further details: Functions::). * The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP' - built-in variables (*note Built-in Variables::). + predefined variables (*note Built-in Variables::). * Assignable `$0' (*note Changing Fields::). @@ -25952,12 +26239,10 @@ the changes, with cross-references to further details: Functions::), rather than using only the first character of `FS'. * Dynamic regexps as operands of the `~' and `!~' operators (*note - Regexp Usage::). + Computed Regexps::). * The escape sequences `\b', `\f', and `\r' (*note Escape - Sequences::). (Some vendors have updated their old versions of - `awk' to recognize `\b', `\f', and `\r', but this is not something - you can rely on.) + Sequences::). * Redirection of input for the `getline' function (*note Getline::). @@ -25981,7 +26266,7 @@ The System V Release 4 (1989) version of Unix `awk' added these features * The `-v' option for assigning variables before program execution begins (*note Options::). - * The `--' option for terminating command-line options. + * The `--' signal for terminating command-line options. * The `\a', `\v', and `\x' escape sequences (*note Escape Sequences::). @@ -25996,8 +26281,8 @@ The System V Release 4 (1989) version of Unix `awk' added these features `printf' function (*note Control Letters::). * The ability to dynamically pass the field width and precision - (`"%*.*d"') in the argument list of the `printf' function (*note - Control Letters::). + (`"%*.*d"') in the argument list of `printf' and `sprintf()' + (*note Control Letters::). * The use of regexp constants, such as `/foo/', as expressions, where they are equivalent to using the matching operator, as in `$0 ~ @@ -26024,8 +26309,8 @@ introduced the following changes into the language: * The concept of a numeric string and tighter comparison rules to go with it (*note Typing and Comparison::). - * The use of built-in variables as function parameter names is - forbidden (*note Definition Syntax::. + * The use of predefined variables as function parameter names is + forbidden (*note Definition Syntax::). * More complete documentation of many of the previously undocumented features of the language. @@ -26087,7 +26372,7 @@ can all be disabled with either the `--traditional' or `--posix' options node summarizes the additional features over POSIX `awk' that are in the current version of `gawk'. - * Additional built-in variables: + * Additional predefined variables: - The `ARGIND' `BINMODE', `ERRNO', `FIELDWIDTHS', `FPAT', `IGNORECASE', `LINT', `PROCINFO', `RT', and `TEXTDOMAIN' @@ -26129,11 +26414,6 @@ the current version of `gawk'. - The `BEGINFILE' and `ENDFILE' special patterns. (*note BEGINFILE/ENDFILE::). - - The ability to delete all of an array at once with `delete - ARRAY' (*note Delete::). - - - The `nextfile' statement (*note Nextfile Statement::). - - The `switch' statement (*note Switch Statement::). * Changes to standard `awk' functions: @@ -26142,7 +26422,7 @@ the current version of `gawk'. one end of a two-way pipe to a coprocess (*note Two-way I/O::). - - POSIX compliance for `gsub()' and `sub()'. + - POSIX compliance for `gsub()' and `sub()' with `--posix'. - The `length()' function accepts an array argument and returns the number of elements in the array (*note String @@ -26161,24 +26441,24 @@ the current version of `gawk'. * Additional functions only in `gawk': - - The `and()', `compl()', `lshift()', `or()', `rshift()', and - `xor()' functions for bit manipulation (*note Bitwise - Functions::). + - The `gensub()', `patsplit()', and `strtonum()' functions for + more powerful text manipulation (*note String Functions::). - The `asort()' and `asorti()' functions for sorting arrays (*note Array Sorting::). - - The `bindtextdomain()', `dcgettext()' and `dcngettext()' - functions for internationalization (*note Programmer i18n::). + - The `mktime()', `systime()', and `strftime()' functions for + working with timestamps (*note Time Functions::). - - The `fflush()' function from BWK `awk' (*note I/O + - The `and()', `compl()', `lshift()', `or()', `rshift()', and + `xor()' functions for bit manipulation (*note Bitwise Functions::). - - The `gensub()', `patsplit()', and `strtonum()' functions for - more powerful text manipulation (*note String Functions::). + - The `isarray()' function to check if a variable is an array + or not (*note Type Functions::). - - The `mktime()', `systime()', and `strftime()' functions for - working with timestamps (*note Time Functions::). + - The `bindtextdomain()', `dcgettext()' and `dcngettext()' + functions for internationalization (*note Programmer i18n::). * Changes and/or additions in the command-line options: @@ -26230,7 +26510,7 @@ the current version of `gawk'. * Support for the following obsolete systems was removed from the - code and the documentation for `gawk' version 4.1: + code for `gawk' version 4.1: - Ultrix @@ -26605,7 +26885,7 @@ in POSIX `awk', in the order they were added to `gawk'. - The `-M' and `--bignum' options enable MPFR. - - The `-o' only does pretty-printing. + - The `-o' option only does pretty-printing. - The `-p' option is used for profiling. @@ -26628,30 +26908,26 @@ File: gawk.info, Node: Common Extensions, Next: Ranges and Locales, Prev: Fea A.7 Common Extensions Summary ============================= -This minor node summarizes the common extensions supported by `gawk', -Brian Kernighan's `awk', and `mawk', the three most widely-used freely -available versions of `awk' (*note Other Versions::). - -Feature BWK Awk Mawk GNU Awk --------------------------------------------------------- -`\x' Escape sequence X X X -`FS' as null string X X X -`/dev/stdin' special file X X X -`/dev/stdout' special file X X X -`/dev/stderr' special file X X X -`delete' without subscript X X X -`fflush()' function X X X -`length()' of an array X X X -`nextfile' statement X X X -`**' and `**=' operators X X -`func' keyword X X -`BINMODE' variable X X -`RS' as regexp X X -Time related functions X X - - (Technically speaking, as of late 2012, `fflush()', `delete ARRAY', -and `nextfile' are no longer extensions, since they have been added to -POSIX.) +The following table summarizes the common extensions supported by +`gawk', Brian Kernighan's `awk', and `mawk', the three most widely-used +freely available versions of `awk' (*note Other Versions::). + +Feature BWK Awk Mawk GNU Awk Now standard +----------------------------------------------------------------------- +`\x' Escape sequence X X X +`FS' as null string X X X +`/dev/stdin' special file X X X +`/dev/stdout' special file X X X +`/dev/stderr' special file X X X +`delete' without subscript X X X X +`fflush()' function X X X X +`length()' of an array X X X +`nextfile' statement X X X X +`**' and `**=' operators X X +`func' keyword X X +`BINMODE' variable X X +`RS' as regexp X X +Time related functions X X File: gawk.info, Node: Ranges and Locales, Next: Contributors, Prev: Common Extensions, Up: Language History @@ -26692,14 +26968,14 @@ like `[a-dx-z]' is still equivalent to `[abcdxyz]', as in ASCII. But outside those locales, the ordering was defined to be based on "collation order". - In many locales, `A' and `a' are both less than `B'. In other -words, these locales sort characters in dictionary order, and -`[a-dx-z]' is typically not equivalent to `[abcdxyz]'; instead it might -be equivalent to `[ABCXYabcdxyz]', for example. + What does that mean? In many locales, `A' and `a' are both less +than `B'. In other words, these locales sort characters in dictionary +order, and `[a-dx-z]' is typically not equivalent to `[abcdxyz]'; +instead it might be equivalent to `[ABCXYabcdxyz]', for example. This point needs to be emphasized: Much literature teaches that you should use `[a-z]' to match a lowercase character. But on systems with -non-ASCII locales, this also matched all of the uppercase characters +non-ASCII locales, this also matches all of the uppercase characters except `A' or `Z'! This was a continuous cause of confusion, even well into the twenty-first century. @@ -26826,7 +27102,7 @@ Info file, in approximate chronological order: various PC platforms. * Christos Zoulas provided the `extension()' built-in function for - dynamically adding new modules. (This was obsoleted at `gawk' + dynamically adding new functions. (This was obsoleted at `gawk' 4.1.) * Ju"rgen Kahrs contributed the initial version of the TCP/IP @@ -26896,6 +27172,9 @@ Info file, in approximate chronological order: 4.1 was driven primarily by Arnold Robbins and Andrew Schorr, with notable contributions from the rest of the development team. + * John Malmberg contributed significant improvements to the OpenVMS + port and the related documentation. + * Antonio Giovanni Colombo rewrote a number of examples in the early chapters that were severely dated, for which I am incredibly grateful. @@ -26946,7 +27225,7 @@ 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 did the respective ports. +people who maintain the respective ports. * Menu: @@ -26989,7 +27268,7 @@ There are two ways to get GNU software: supported. If you have the `wget' program, you can use a command like the following: - wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.1.tar.gz + 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 @@ -27008,25 +27287,25 @@ 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.1.tar.gz'), + 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: - gzip -d -c gawk-4.1.1.tar.gz | tar -xvpf - + gzip -d -c gawk-4.1.2.tar.gz | tar -xvpf - On a system with GNU `tar', you can let `tar' do the decompression for you: - tar -xvpzf gawk-4.1.1.tar.gz + tar -xvpzf gawk-4.1.2.tar.gz -Extracting the archive creates a directory named `gawk-4.1.1' in the +Extracting the archive creates a directory named `gawk-4.1.2' in the current directory. The distribution file name is of the form `gawk-V.R.P.tar.gz'. The V represents the major version of `gawk', the R represents the current release of version V, and the P represents a "patch level", meaning that minor bugs have been fixed in the release. The current patch -level is 1, but when retrieving distributions, you should get the +level is 2, but when retrieving distributions, you should get the version with the highest version, release, and patch level. (Note, however, that patch levels greater than or equal to 70 denote "beta" or nonproduction software; you might not want to retrieve such a version @@ -27193,6 +27472,13 @@ Various `.c', `.y', and `.h' files sample extensions included with `gawk'. *Note Dynamic Extensions::, for more information. +`extras/*' + Additional non-essential files. Currently, this directory + contains some shell startup files to be installed in + `/etc/profile.d' to aid in manipulating the `AWKPATH' and + `AWKLIBPATH' environment variables. *Note Shell Startup Files::, + for more information. + `posix/*' Files needed for building `gawk' on POSIX-compliant systems. @@ -27223,11 +27509,12 @@ configure `gawk' for your system yourself. * Menu: * Quick Installation:: Compiling `gawk' under Unix. +* Shell Startup Files:: Shell convenience functions. * Additional Configuration Options:: Other compile-time options. * Configuration Philosophy:: How it's all supposed to work. -File: gawk.info, Node: Quick Installation, Next: Additional Configuration Options, Up: Unix Installation +File: gawk.info, Node: Quick Installation, Next: Shell Startup Files, Up: Unix Installation B.2.1 Compiling `gawk' for Unix-like Systems -------------------------------------------- @@ -27237,12 +27524,12 @@ Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin environment for MS-Windows. After you have extracted the `gawk' distribution, `cd' to -`gawk-4.1.1'. Like most GNU software, `gawk' is configured -automatically for your system by running the `configure' program. This -program is a Bourne shell script that is generated automatically using -GNU Autoconf. (The Autoconf software is described fully starting with -*note (Autoconf)Top:: autoconf,Autoconf--Generating Automatic -Configuration Scripts.) +`gawk-4.1.2'. As with most GNU software, you configure `gawk' for your +system by running the `configure' program. This program is a Bourne +shell script that is generated automatically using GNU Autoconf. (The +Autoconf software is described fully starting with *note +(Autoconf)Top:: autoconf,Autoconf--Generating Automatic Configuration +Scripts.) To configure `gawk', simply run `configure': @@ -27284,9 +27571,43 @@ will be asked for your password, and you will have to have been set up previously as a user who is allowed to run the `sudo' command. -File: gawk.info, Node: Additional Configuration Options, Next: Configuration Philosophy, Prev: Quick Installation, Up: Unix Installation +File: gawk.info, Node: Shell Startup Files, Next: Additional Configuration Options, Prev: Quick Installation, Up: Unix Installation + +B.2.2 Shell Startup Files +------------------------- + +The distribution contains shell startup files `gawk.sh' and `gawk.csh' +containing functions to aid in manipulating the `AWKPATH' and +`AWKLIBPATH' environment variables. On a Fedora system, these files +should be installed in `/etc/profile.d'; on other platforms, the +appropriate location may be different. -B.2.2 Additional Configuration Options +`gawkpath_default' + Reset the `AWKPATH' environment variable to its default value. + +`gawkpath_prepend' + Add the argument to the front of the `AWKPATH' environment + variable. + +`gawkpath_append' + Add the argument to the end of the `AWKPATH' environment variable. + +`gawklibpath_default' + Reset the `AWKLIBPATH' environment variable to its default value. + +`gawklibpath_prepend' + Add the argument to the front of the `AWKLIBPATH' environment + variable. + +`gawklibpath_append' + Add the argument to the end of the `AWKLIBPATH' environment + variable. + + + +File: gawk.info, Node: Additional Configuration Options, Next: Configuration Philosophy, Prev: Shell Startup Files, Up: Unix Installation + +B.2.3 Additional Configuration Options -------------------------------------- There are several additional options you may use on the `configure' @@ -27305,8 +27626,8 @@ command line when compiling `gawk' from scratch, including: User-modified::) has no effect on the running `awk' program. When used with GCC's automatic dead-code-elimination, this option - cuts almost 200K bytes off the size of the `gawk' executable on - GNU/Linux x86 systems. Results on other systems and with other + cuts almost 23K bytes off the size of the `gawk' executable on + GNU/Linux x86_64 systems. Results on other systems and with other compilers are likely to vary. Using this option may bring you some slight performance improvement. @@ -27328,7 +27649,7 @@ that `configure' supplies. File: gawk.info, Node: Configuration Philosophy, Prev: Additional Configuration Options, Up: Unix Installation -B.2.3 The Configuration Process +B.2.4 The Configuration Process ------------------------------- This minor node is of interest only if you know something about using @@ -27392,10 +27713,10 @@ File: gawk.info, Node: PC Installation, Next: VMS Installation, Up: Non-Unix B.3.1 Installation on PC Operating Systems ------------------------------------------ -This minor node covers installation and usage of `gawk' on x86 machines -running MS-DOS, any version of MS-Windows, or OS/2. In this minor -node, the term "Windows32" refers to any of Microsoft -Windows-95/98/ME/NT/2000/XP/Vista/7/8. +This minor node covers installation and usage of `gawk' on Intel +architecture machines running MS-DOS, any version of MS-Windows, or +OS/2. In this minor node, the term "Windows32" refers to any of +Microsoft Windows-95/98/ME/NT/2000/XP/Vista/7/8. The limitations of MS-DOS (and MS-DOS shells under the other operating systems) has meant that various "DOS extenders" are often @@ -27480,7 +27801,7 @@ MS-DOS and Windows32 versions. A list of targets is printed if the `gawk' using the DJGPP tools, enter `make djgpp'. (The DJGPP tools needed for the build may be found at `ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/'.) To build a native -MS-Windows binary of `gawk', type `make mingw32'. +MS-Windows binary of `gawk' using the MinGW tools, type `make mingw32'. The 32 bit EMX version of `gawk' works "out of the box" under OS/2. However, it is highly recommended to use GCC 2.95.3 for the compilation. @@ -27572,8 +27893,8 @@ Networking::). EMX (OS/2 only) supports at least the `|&' operator. The MS-DOS and MS-Windows versions of `gawk' search for program files as described in *note AWKPATH Variable::. However, semicolons (rather than colons) separate elements in the `AWKPATH' variable. If -`AWKPATH' is not set or is empty, then the default search path for -MS-Windows and MS-DOS versions is `.;c:/lib/awk;c:/gnu/lib/awk'. +`AWKPATH' is not set or is empty, then the default search path is +`.;c:/lib/awk;c:/gnu/lib/awk'. The search path for OS/2 (32 bit, EMX) is determined by the prefix directory (most likely `/usr' or `c:/usr') that has been specified as @@ -27597,10 +27918,10 @@ programs) silently translate end-of-line `\r\n' to `\n' on input and `\n' to `\r\n' on output. A special `BINMODE' variable (c.e.) allows control over these translations and is interpreted as follows: - * If `BINMODE' is `"r"', or one, then binary mode is set on read + * If `BINMODE' is `"r"' or one, then binary mode is set on read (i.e., no translations on reads). - * If `BINMODE' is `"w"', or two, then binary mode is set on write + * If `BINMODE' is `"w"' or two, then binary mode is set on write (i.e., no translations on writes). * If `BINMODE' is `"rw"' or `"wr"' or three, binary mode is set for @@ -27664,10 +27985,10 @@ GNU tools, such as Bash, the GNU Compiler Collection (GCC), GNU Make, and other GNU programs. Compilation and installation for Cygwin is the same as for a Unix system: - tar -xvpzf gawk-4.1.1.tar.gz - cd gawk-4.1.1 + tar -xvpzf gawk-4.1.2.tar.gz + cd gawk-4.1.2 ./configure - make + make && make check When compared to GNU/Linux on the same system, the `configure' step on Cygwin takes considerably longer. However, it does finish, and then @@ -27685,13 +28006,13 @@ 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. Caveat Emptor! +translation of `"\r\n"', since it won't. File: gawk.info, Node: VMS Installation, Prev: PC Installation, Up: Non-Unix Installation -B.3.2 How to Compile and Install `gawk' on Vax/VMS and OpenVMS --------------------------------------------------------------- +B.3.2 Compiling and Installing `gawk' on Vax/VMS and OpenVMS +------------------------------------------------------------ This node describes how to compile and install `gawk' under VMS. The older designation "VMS" is used throughout to refer to OpenVMS. @@ -27781,7 +28102,7 @@ than 32 bits. /name=(as_is,short) Compile time macros need to be defined before the first VMS-supplied -header file is included. +header file is included, as follows: #if (__CRTL_VER >= 70200000) && !defined (__VAX) #define _LARGEFILE 1 @@ -27795,6 +28116,12 @@ header file is included. #endif #endif + If you are writing your own extensions to run on VMS, you must +supply these definitions yourself. The `config.h' file created when +building `gawk' on VMS does this for you; if instead you use that file +or a similar one, then you must remember to include it before any +VMS-supplied header files. + File: gawk.info, Node: VMS Installation Details, Next: VMS Running, Prev: VMS Dynamic Extensions, Up: VMS Installation @@ -27882,12 +28209,12 @@ 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 to a VMS exit + The `exit' value is a Unix-style value and is encoded into a VMS exit status value when the program exits. The VMS severity bits will be set based on the `exit' value. A failure is indicated by 1 and VMS sets the `ERROR' status. A fatal -error is indicated by 2 and VMS will set the `FATAL' status. All other +error is indicated by 2 and VMS sets the `FATAL' status. All other values will have the `SUCCESS' status. The exit value is encoded to comply with VMS coding standards and will have the `C_FACILITY_NO' of `0x350000' with the constant `0xA000' added to the number shifted over @@ -27900,9 +28227,9 @@ by 3 bits to make room for the severity codes. A C program that uses `exec()' to call `gawk' will get the original Unix-style exit value. - Older versions of `gawk' treated a Unix exit code 0 as 1, a failure -as 2, a fatal error as 4, and passed all the other numbers through. -This violated the VMS exit status coding requirements. + Older versions of `gawk' for VMS treated a Unix exit code 0 as 1, a +failure as 2, a fatal error as 4, and passed all the other numbers +through. This violated the VMS exit status coding requirements. VAX/VMS floating point uses unbiased rounding. *Note Round Function::. @@ -27933,8 +28260,8 @@ reorganized to supply individual PCSI packages for each component. See The normal build procedure for `gawk' produces a program that is suitable for use with GNV. - The `vms/gawk_build_steps.txt' in the source documents the procedure -for building a VMS PCSI kit that is compatible with GNV. + The file `vms/gawk_build_steps.txt' in the distribution documents +the procedure for building a VMS PCSI kit that is compatible with GNV. File: gawk.info, Node: VMS Old Gawk, Prev: VMS GNV, Up: VMS Installation @@ -27963,10 +28290,10 @@ B.4 Reporting Problems and Bugs please report it to the developers; we cannot promise to do anything but we might well want to fix it. - Before reporting a bug, make sure you have actually found a real bug. -Carefully reread the documentation and see if it really 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, 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 documentation! Before reporting a bug or trying to fix it yourself, try to isolate @@ -27980,20 +28307,21 @@ really in the documentation. Please 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, send email to <bug-gawk@gnu.org>. + 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. If necessary, the primary maintainer can be -reached directly at <arnold@skeeve.com>. The bug reporting address is -preferred since the email list is archived at the GNU Project. _All -email should be in English. This is the only language understood in -common by all the maintainers._ +receive your bug report. Although you can send mail to the maintainers +directly, the bug reporting address is preferred since 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 official recognized ways for reporting bugs. Really. + above are the only official 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 @@ -28002,30 +28330,30 @@ common by all the maintainers._ 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' maintainer won't even see + 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 web sites. + 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 me; I will try to help you out, although I -may not have the time to fix the problem. You can send me electronic -mail at the Internet address noted previously. +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 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. +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. - The people maintaining the non-Unix ports of `gawk' are as follows: + The people maintaining the various `gawk' ports are: +Unix and POSIX systems Arnold Robbins, <arnold@skeeve.com>. MS-DOS with DJGPP Scott Deifik, <scottd.mail@sbcglobal.net>. MS-Windows with MinGW Eli Zaretskii, <eliz@gnu.org>. OS/2 Andreas Buening, <andreas.buening@nexgo.de>. -VMS Pat Rankin, <r.pat.rankin@gmail.com>, and John - Malmberg, <wb8tyw@qsl.net>. +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 @@ -28112,9 +28440,9 @@ Unix `awk' `pawk' Nelson H.F. Beebe at the University of Utah has modified BWK `awk' to provide timing and profiling information. It is different from - `gawk' with the `--profile' option. (*note Profiling::), in that - it uses CPU-based profiling, not line-count profiling. You may - find it at either + `gawk' with the `--profile' option (*note Profiling::), in that it + uses CPU-based profiling, not line-count profiling. You may find + it at either `ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz' or `http://www.math.utah.edu/pub/pawk/pawk-20030606.tar.gz'. @@ -28130,11 +28458,11 @@ Busybox Awk The OpenSolaris POSIX `awk' The versions of `awk' in `/usr/xpg4/bin' and `/usr/xpg6/bin' on Solaris are more-or-less POSIX-compliant. They are based on the - `awk' from Mortice Kern Systems for PCs. This author was able to - make this code compile and work under GNU/Linux with 1-2 hours of - work. Making it more generally portable (using GNU Autoconf - and/or Automake) would take more work, and this has not been done, - at least to our knowledge. + `awk' from Mortice Kern Systems for PCs. We were able to make + this code compile and work under GNU/Linux with 1-2 hours of work. + Making it more generally portable (using GNU Autoconf and/or + 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. @@ -28190,9 +28518,9 @@ B.6 Summary * The `gawk' distribution is available from GNU project's main distribution site, `ftp.gnu.org'. The canonical build recipe is: - wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.1.tar.gz - tar -xvpzf gawk-4.1.1.tar.gz - cd gawk-4.1.1 + wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.2.tar.gz + tar -xvpzf gawk-4.1.2.tar.gz + cd gawk-4.1.2 ./configure && make && make check * `gawk' may be built on non-POSIX systems as well. The currently @@ -28323,9 +28651,9 @@ there are several steps that you need to take in order to make it possible to include them: 1. Before building the new feature into `gawk' itself, consider - writing it as an extension module (*note Dynamic Extensions::). - If that's not possible, continue with the rest of the steps in - this list. + writing it as an extension (*note Dynamic Extensions::). If + that's not possible, continue with the rest of the steps in this + list. 2. Be prepared to sign the appropriate paperwork. In order for the FSF to distribute your changes, you must either place those @@ -28492,9 +28820,9 @@ steps: 6. Be willing to continue to maintain the port. Non-Unix operating systems are supported by volunteers who maintain the code needed - to compile and run `gawk' on their systems. If noone volunteers to - maintain a port, it becomes unsupported and it may be necessary to - remove it from the distribution. + to compile and run `gawk' on their systems. If no-one volunteers + to maintain a port, it becomes unsupported and it may be necessary + to remove it from the distribution. 7. Supply an appropriate `gawkmisc.???' file. Each port has its own `gawkmisc.???' that implements certain operating system specific @@ -28881,7 +29209,7 @@ C.5.3 Other Design Decisions ---------------------------- As an arbitrary design decision, extensions can read the values of -built-in variables and arrays (such as `ARGV' and `FS'), but cannot +predefined variables and arrays (such as `ARGV' and `FS'), but cannot change them, with the exception of `PROCINFO'. The reason for this is to prevent an extension function from @@ -29288,6 +29616,10 @@ Bourne Shell shells (Bash, `ksh', `pdksh', `zsh') are generally upwardly compatible with the Bourne shell. +Braces + The characters `{' and `}'. Braces are used in `awk' for + delimiting actions, compound statements, and function bodies. + Built-in Function The `awk' language provides built-in functions that perform various numerical, I/O-related, and string computations. Examples are @@ -29306,10 +29638,6 @@ Built-in Variable them affects `awk''s running environment. (*Note Built-in Variables::.) -Braces - The characters `{' and `}'. Braces are used in `awk' for - delimiting actions, compound statements, and function bodies. - C The system programming language that most GNU software is written in. The `awk' programming language has C-like syntax, and this @@ -29448,11 +29776,11 @@ FDL Field When `awk' reads an input record, it splits the record into pieces separated by whitespace (or by a separator regexp that you can - change by setting the built-in variable `FS'). Such pieces are + change by setting the predefined variable `FS'). Such pieces are called fields. If the pieces are of fixed length, you can use the built-in variable `FIELDWIDTHS' to describe their lengths. If you wish to specify the contents of fields instead of the field - separator, you can use the built-in variable `FPAT' to do so. + separator, you can use the predefined variable `FPAT' to do so. (*Note Field Separators::, *note Constant Size::, and *note Splitting By Content::.) @@ -29469,7 +29797,7 @@ Format Format strings control the appearance of output in the `strftime()' and `sprintf()' functions, and in the `printf' statement as well. Also, data conversions from numbers to strings - are controlled by the format strings contained in the built-in + are controlled by the format strings contained in the predefined variables `CONVFMT' and `OFMT'. (*Note Control Letters::.) Free Documentation License @@ -31036,7 +31364,7 @@ Index * Menu: -* ! (exclamation point), ! operator: Boolean Ops. (line 67) +* ! (exclamation point), ! operator: Boolean Ops. (line 69) * ! (exclamation point), ! operator <1>: Egrep Program. (line 175) * ! (exclamation point), ! operator <2>: Ranges. (line 48) * ! (exclamation point), ! operator: Precedence. (line 52) @@ -31066,22 +31394,22 @@ Index * % (percent sign), %= operator <1>: Precedence. (line 95) * % (percent sign), %= operator: Assignment Ops. (line 130) * & (ampersand), && operator <1>: Precedence. (line 86) -* & (ampersand), && operator: Boolean Ops. (line 57) +* & (ampersand), && operator: Boolean Ops. (line 59) * & (ampersand), gsub()/gensub()/sub() functions and: Gory Details. (line 6) * ' (single quote): One-shot. (line 15) -* ' (single quote) in gawk command lines: Long. (line 33) +* ' (single quote) in gawk command lines: Long. (line 35) * ' (single quote), in shell commands: Quoting. (line 48) * ' (single quote), vs. apostrophe: Comments. (line 27) -* ' (single quote), with double quotes: Quoting. (line 70) +* ' (single quote), with double quotes: Quoting. (line 73) * () (parentheses), in a profile: Profiling. (line 146) * () (parentheses), regexp operator: Regexp Operators. (line 81) * * (asterisk), * operator, as multiplication operator: Precedence. (line 55) * * (asterisk), * operator, as regexp operator: Regexp Operators. (line 89) -* * (asterisk), * operator, null strings, matching: Gory Details. - (line 143) +* * (asterisk), * operator, null strings, matching: String Functions. + (line 535) * * (asterisk), ** operator <1>: Precedence. (line 49) * * (asterisk), ** operator: Arithmetic Ops. (line 81) * * (asterisk), **= operator <1>: Precedence. (line 95) @@ -31125,30 +31453,30 @@ Index * --include option: Options. (line 159) * --lint option <1>: Options. (line 185) * --lint option: Command Line. (line 20) -* --lint-old option: Options. (line 293) +* --lint-old option: Options. (line 295) * --load option: Options. (line 173) * --non-decimal-data option <1>: Nondecimal Data. (line 6) * --non-decimal-data option: Options. (line 211) * --non-decimal-data option, strtonum() function and: Nondecimal Data. - (line 36) -* --optimize option: Options. (line 235) -* --posix option: Options. (line 252) -* --posix option, --traditional option and: Options. (line 271) -* --pretty-print option: Options. (line 224) + (line 35) +* --optimize option: Options. (line 237) +* --posix option: Options. (line 254) +* --posix option, --traditional option and: Options. (line 273) +* --pretty-print option: Options. (line 226) * --profile option <1>: Profiling. (line 12) -* --profile option: Options. (line 240) -* --re-interval option: Options. (line 277) -* --sandbox option: Options. (line 284) +* --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 97) + (line 96) * --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 271) -* --use-lc-numeric option: Options. (line 219) -* --version option: Options. (line 298) +* --traditional option, --posix option and: Options. (line 273) +* --use-lc-numeric option: Options. (line 221) +* --version option: Options. (line 300) * --with-whiny-user-strftime configuration option: Additional Configuration Options. (line 35) * -b option: Options. (line 68) @@ -31156,42 +31484,42 @@ Index * -c option: Options. (line 81) * -D option: Options. (line 108) * -d option: Options. (line 93) -* -e option: Options. (line 333) +* -e option: Options. (line 336) * -E option: Options. (line 125) * -e option: Options. (line 117) * -f option: Options. (line 25) * -F option: Options. (line 21) * -f option: Long. (line 12) -* -F option, -Ft sets FS to TAB: Options. (line 306) +* -F option, -Ft sets FS to TAB: Options. (line 308) * -F option, command-line: Command Line Field Separator. (line 6) -* -f option, multiple uses: Options. (line 311) +* -f option, multiple uses: Options. (line 313) * -g option: Options. (line 147) * -h option: Options. (line 154) * -i option: Options. (line 159) -* -L option: Options. (line 293) +* -L option: Options. (line 295) * -l option: Options. (line 173) * -M option: Options. (line 205) -* -N option: Options. (line 219) +* -N option: Options. (line 221) * -n option: Options. (line 211) -* -O option: Options. (line 235) -* -o option: Options. (line 224) -* -P option: Options. (line 252) -* -p option: Options. (line 240) -* -r option: Options. (line 277) -* -S option: Options. (line 284) +* -O option: Options. (line 237) +* -o option: Options. (line 226) +* -P option: Options. (line 254) +* -p option: Options. (line 242) +* -r option: Options. (line 279) +* -S option: Options. (line 286) * -v option: Assignment Options. (line 12) -* -V option: Options. (line 298) +* -V option: Options. (line 300) * -v option: Options. (line 32) * -W option: Options. (line 46) * . (period), regexp operator: Regexp Operators. (line 44) * .gmo files: Explaining gettext. (line 42) * .gmo files, specifying directory of <1>: Programmer i18n. (line 47) * .gmo files, specifying directory of: Explaining gettext. (line 54) -* .mo files, converting from .po: I18N Example. (line 63) +* .mo files, converting from .po: I18N Example. (line 64) * .po files <1>: Translator i18n. (line 6) * .po files: Explaining gettext. (line 37) -* .po files, converting to .mo: I18N Example. (line 63) +* .po files, converting to .mo: I18N Example. (line 64) * .pot files: Explaining gettext. (line 31) * / (forward slash) to enclose regular expressions: Regexp. (line 10) * / (forward slash), / operator: Precedence. (line 55) @@ -31201,8 +31529,8 @@ Index (line 148) * / (forward slash), patterns and: Expression Patterns. (line 24) * /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) -* /dev/... special files: Special FD. (line 46) -* /dev/fd/N special files (gawk): Special FD. (line 46) +* /dev/... special files: Special FD. (line 48) +* /dev/fd/N special files (gawk): Special FD. (line 48) * /inet/... special files (gawk): TCP/IP Networking. (line 6) * /inet4/... special files (gawk): TCP/IP Networking. (line 6) * /inet6/... special files (gawk): TCP/IP Networking. (line 6) @@ -31243,10 +31571,10 @@ Index (line 8) * [] (square brackets), regexp operator: Regexp Operators. (line 56) * \ (backslash): Comments. (line 50) -* \ (backslash), \" escape sequence: Escape Sequences. (line 84) +* \ (backslash), \" escape sequence: Escape Sequences. (line 85) * \ (backslash), \' operator (gawk): GNU Regexp Operators. (line 56) -* \ (backslash), \/ escape sequence: Escape Sequences. (line 75) +* \ (backslash), \/ escape sequence: Escape Sequences. (line 76) * \ (backslash), \< operator (gawk): GNU Regexp Operators. (line 30) * \ (backslash), \> operator (gawk): GNU Regexp Operators. @@ -31275,7 +31603,7 @@ Index * \ (backslash), \y operator (gawk): GNU Regexp Operators. (line 38) * \ (backslash), as field separator: Command Line Field Separator. - (line 27) + (line 24) * \ (backslash), continuing lines and: Statements/Lines. (line 19) * \ (backslash), continuing lines and, comments and: Statements/Lines. (line 76) @@ -31286,7 +31614,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 120) + (line 121) * \ (backslash), in regexp constants: Computed Regexps. (line 29) * \ (backslash), in shell commands: Quoting. (line 48) * \ (backslash), regexp operator: Regexp Operators. (line 18) @@ -31338,12 +31666,12 @@ Index * ambiguity, syntactic: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) * ampersand (&), && operator <1>: Precedence. (line 86) -* ampersand (&), && operator: Boolean Ops. (line 57) +* ampersand (&), && operator: Boolean Ops. (line 59) * ampersand (&), gsub()/gensub()/sub() functions and: Gory Details. (line 6) -* anagram.awk program: Anagram Program. (line 22) +* anagram.awk program: Anagram Program. (line 21) * anagrams, finding: Anagram Program. (line 6) -* and: Bitwise Functions. (line 39) +* and: Bitwise Functions. (line 40) * AND bitwise operation: Bitwise Functions. (line 6) * and Boolean-logic operator: Boolean Ops. (line 6) * ANSI: Glossary. (line 34) @@ -31359,25 +31687,25 @@ Index * arctangent: Numeric Functions. (line 11) * ARGC/ARGV variables: Auto-set. (line 15) * ARGC/ARGV variables, command-line arguments: Other Arguments. - (line 12) + (line 15) * ARGC/ARGV variables, how to use: ARGC and ARGV. (line 6) * ARGC/ARGV variables, portability and: Executable Scripts. (line 59) * ARGIND variable: Auto-set. (line 44) -* ARGIND variable, command-line arguments: Other Arguments. (line 12) +* ARGIND variable, command-line arguments: Other Arguments. (line 15) * arguments, command-line <1>: ARGC and ARGV. (line 6) * arguments, command-line <2>: Auto-set. (line 15) * arguments, command-line: Other Arguments. (line 6) * arguments, command-line, invoking awk: Command Line. (line 6) * arguments, in function calls: Function Calls. (line 18) * arguments, processing: Getopt Function. (line 6) -* ARGV array, indexing into: Other Arguments. (line 12) +* ARGV array, indexing into: Other Arguments. (line 15) * arithmetic operators: Arithmetic Ops. (line 6) * array manipulation in extensions: Array Manipulation. (line 6) * array members: Reference to Elements. (line 6) * array scanning order, controlling: Controlling Scanning. (line 14) -* array, number of elements: String Functions. (line 197) +* array, number of elements: String Functions. (line 200) * arrays: Arrays. (line 6) * arrays of arrays: Arrays of Arrays. (line 6) * arrays, an example of using: Array Example. (line 6) @@ -31385,7 +31713,7 @@ Index * arrays, as parameters to functions: Pass By Value/Reference. (line 47) * arrays, associative: Array Intro. (line 50) -* arrays, associative, library functions and: Library Names. (line 57) +* arrays, associative, library functions and: Library Names. (line 58) * arrays, deleting entire contents: Delete. (line 39) * arrays, elements that don't exist: Reference to Elements. (line 23) @@ -31393,13 +31721,12 @@ 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 42) +* arrays, elements, retrieving number of: String Functions. (line 41) * arrays, for statement and: Scanning an Array. (line 20) * arrays, indexing: Array Intro. (line 50) * arrays, merging into strings: Join Function. (line 6) * arrays, multidimensional: Multidimensional. (line 10) * arrays, multidimensional, scanning: Multiscanning. (line 11) -* arrays, names of, and names of functions/variables: Arrays. (line 18) * arrays, numeric subscripts: Numeric Array Subscripts. (line 6) * arrays, referencing elements: Reference to Elements. @@ -31420,12 +31747,12 @@ Index * ASCII: Ordinal Functions. (line 45) * asort <1>: Array Sorting Functions. (line 6) -* asort: String Functions. (line 42) +* asort: String Functions. (line 41) * asort() function (gawk), arrays, sorting: Array Sorting Functions. (line 6) * asorti <1>: Array Sorting Functions. (line 6) -* asorti: String Functions. (line 42) +* asorti: String Functions. (line 41) * asorti() function (gawk), arrays, sorting: Array Sorting Functions. (line 6) * assert() function (C library): Assert Function. (line 6) @@ -31442,8 +31769,8 @@ Index (line 55) * asterisk (*), * operator, as regexp operator: Regexp Operators. (line 89) -* asterisk (*), * operator, null strings, matching: Gory Details. - (line 143) +* asterisk (*), * operator, null strings, matching: String Functions. + (line 535) * asterisk (*), ** operator <1>: Precedence. (line 49) * asterisk (*), ** operator: Arithmetic Ops. (line 81) * asterisk (*), **= operator <1>: Precedence. (line 95) @@ -31455,7 +31782,7 @@ Index * awf (amazingly workable formatter) program: Glossary. (line 24) * awk debugging, enabling: Options. (line 108) * awk language, POSIX version: Assignment Ops. (line 137) -* awk profiling, enabling: Options. (line 240) +* awk profiling, enabling: Options. (line 242) * awk programs <1>: Two Rules. (line 6) * awk programs <2>: Executable Scripts. (line 6) * awk programs: Getting Started. (line 12) @@ -31481,7 +31808,7 @@ Index * awk, gawk and <1>: This Manual. (line 14) * awk, gawk and: Preface. (line 21) * awk, history of: History. (line 17) -* awk, implementation issues, pipes: Redirection. (line 135) +* awk, implementation issues, pipes: Redirection. (line 129) * awk, implementations: Other Versions. (line 6) * awk, implementations, limits: Getline Notes. (line 14) * awk, invoking: Command Line. (line 6) @@ -31490,7 +31817,7 @@ Index * awk, POSIX and: Preface. (line 21) * awk, POSIX and, See Also POSIX awk: Preface. (line 21) * awk, regexp constants and: Comparison Operators. - (line 102) + (line 103) * awk, See Also gawk: Preface. (line 34) * awk, terms describing: This Manual. (line 6) * awk, uses for <1>: When. (line 6) @@ -31513,10 +31840,10 @@ Index * awkvars.out file: Options. (line 93) * b debugger command (alias for break): Breakpoint Control. (line 11) * backslash (\): Comments. (line 50) -* backslash (\), \" escape sequence: Escape Sequences. (line 84) +* backslash (\), \" escape sequence: Escape Sequences. (line 85) * backslash (\), \' operator (gawk): GNU Regexp Operators. (line 56) -* backslash (\), \/ escape sequence: Escape Sequences. (line 75) +* backslash (\), \/ escape sequence: Escape Sequences. (line 76) * backslash (\), \< operator (gawk): GNU Regexp Operators. (line 30) * backslash (\), \> operator (gawk): GNU Regexp Operators. @@ -31545,7 +31872,7 @@ Index * backslash (\), \y operator (gawk): GNU Regexp Operators. (line 38) * backslash (\), as field separator: Command Line Field Separator. - (line 27) + (line 24) * backslash (\), continuing lines and: Statements/Lines. (line 19) * backslash (\), continuing lines and, comments and: Statements/Lines. (line 76) @@ -31556,7 +31883,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 120) + (line 121) * backslash (\), in regexp constants: Computed Regexps. (line 29) * backslash (\), in shell commands: Quoting. (line 48) * backslash (\), regexp operator: Regexp Operators. (line 18) @@ -31576,18 +31903,18 @@ Index * BEGIN pattern, next/nextfile statements and <1>: Next Statement. (line 44) * BEGIN pattern, next/nextfile statements and: I/O And BEGIN/END. - (line 36) + (line 37) * BEGIN pattern, OFS/ORS variables, assigning values to: Output Separators. (line 20) * BEGIN pattern, operators and: Using BEGIN/END. (line 17) * BEGIN pattern, print statement and: I/O And BEGIN/END. (line 16) * BEGIN pattern, pwcat program: Passwd Functions. (line 143) -* BEGIN pattern, running awk programs and: Cut Program. (line 68) +* BEGIN pattern, running awk programs and: Cut Program. (line 63) * BEGIN pattern, TEXTDOMAIN variable and: Programmer i18n. (line 60) * BEGINFILE pattern: BEGINFILE/ENDFILE. (line 6) * BEGINFILE pattern, Boolean patterns and: Expression Patterns. (line 70) -* beginfile() user-defined function: Filetrans Function. (line 62) +* beginfile() user-defined function: Filetrans Function. (line 61) * Bentley, Jon: Glossary. (line 143) * Benzinger, Michael: Contributors. (line 97) * Berry, Karl <1>: Ranges and Locales. (line 74) @@ -31601,11 +31928,11 @@ Index * BINMODE variable <1>: PC Using. (line 33) * BINMODE variable: User-modified. (line 15) * bit-manipulation functions: Bitwise Functions. (line 6) -* bits2str() user-defined function: Bitwise Functions. (line 70) -* bitwise AND: Bitwise Functions. (line 39) -* bitwise complement: Bitwise Functions. (line 43) -* bitwise OR: Bitwise Functions. (line 49) -* bitwise XOR: Bitwise Functions. (line 55) +* bits2str() user-defined function: Bitwise Functions. (line 71) +* bitwise AND: Bitwise Functions. (line 40) +* bitwise complement: Bitwise Functions. (line 44) +* bitwise OR: Bitwise Functions. (line 50) +* bitwise XOR: Bitwise Functions. (line 56) * bitwise, complement: Bitwise Functions. (line 25) * bitwise, operations: Bitwise Functions. (line 6) * bitwise, shift: Bitwise Functions. (line 32) @@ -31645,12 +31972,13 @@ Index * Brennan, Michael <1>: Other Versions. (line 6) * Brennan, Michael <2>: Simple Sed. (line 25) * Brennan, Michael <3>: Delete. (line 56) -* Brennan, Michael <4>: Acknowledgments. (line 76) -* Brennan, Michael: Foreword. (line 83) +* Brennan, Michael <4>: Acknowledgments. (line 78) +* Brennan, Michael <5>: Foreword4. (line 30) +* Brennan, Michael: Foreword3. (line 83) * 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 490) -* Brian Kernighan's awk <4>: Delete. (line 48) +* Brian Kernighan's awk <3>: String Functions. (line 491) +* 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) * Brian Kernighan's awk <7>: Break Statement. (line 51) @@ -31661,7 +31989,7 @@ Index (line 67) * Brian Kernighan's awk <12>: GNU Regexp Operators. (line 83) -* Brian Kernighan's awk <13>: Escape Sequences. (line 124) +* Brian Kernighan's awk <13>: Escape Sequences. (line 125) * 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) @@ -31671,12 +31999,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 71) +* Buening, Andreas <1>: Bugs. (line 72) * 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 140) -* buffering, interactive vs. noninteractive: I/O Functions. (line 109) +* buffering, input/output: I/O Functions. (line 139) +* buffering, interactive vs. noninteractive: I/O Functions. (line 108) * buffers, flushing: I/O Functions. (line 32) * buffers, operators for: GNU Regexp Operators. (line 48) @@ -31684,10 +32012,6 @@ Index * bug-gawk@gnu.org bug reporting address: Bugs. (line 30) * built-in functions: Functions. (line 6) * built-in functions, evaluation order: Calling Built-in. (line 30) -* built-in variables: Built-in Variables. (line 6) -* built-in variables, -v option, setting with: Options. (line 40) -* built-in variables, conveying information: Auto-set. (line 6) -* built-in variables, user-modifiable: User-modified. (line 6) * Busybox Awk: Other Versions. (line 88) * c.e., See common extensions: Conventions. (line 51) * call by reference: Pass By Value/Reference. @@ -31706,7 +32030,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 520) +* case sensitivity, converting case: String Functions. (line 521) * case sensitivity, example programs: Library Functions. (line 53) * case sensitivity, gawk: Case-sensitivity. (line 26) * case sensitivity, regexps and: Case-sensitivity. (line 6) @@ -31742,14 +32066,14 @@ Index * close() function, portability: Close Files And Pipes. (line 81) * close() function, return value: Close Files And Pipes. - (line 131) + (line 132) * close() function, two-way pipes and: Two-way I/O. (line 59) * Close, Diane <1>: Contributors. (line 20) * Close, Diane: Manual History. (line 34) * Collado, Manuel: Acknowledgments. (line 60) * collating elements: Bracket Expressions. (line 79) * collating symbols: Bracket Expressions. (line 86) -* Colombo, Antonio <1>: Contributors. (line 137) +* Colombo, Antonio <1>: Contributors. (line 140) * Colombo, Antonio: Acknowledgments. (line 60) * columns, aligning: Print Examples. (line 70) * columns, cutting: Cut Program. (line 6) @@ -31778,15 +32102,15 @@ Index * commenting, backslash continuation and: Statements/Lines. (line 76) * common extensions, ** operator: Arithmetic Ops. (line 30) * common extensions, **= operator: Assignment Ops. (line 137) -* common extensions, /dev/stderr special file: Special FD. (line 46) -* common extensions, /dev/stdin special file: Special FD. (line 46) -* common extensions, /dev/stdout special file: Special FD. (line 46) +* common extensions, /dev/stderr special file: Special FD. (line 48) +* common extensions, /dev/stdin special file: Special FD. (line 48) +* common extensions, /dev/stdout special file: Special FD. (line 48) * common extensions, \x escape sequence: Escape Sequences. (line 61) * common extensions, BINMODE variable: PC Using. (line 33) * 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 197) + (line 200) * common extensions, RS as a regexp: gawk split records. (line 6) * common extensions, single character fields: Single Character Fields. (line 6) @@ -31795,7 +32119,7 @@ Index (line 9) * comparison expressions, as patterns: Expression Patterns. (line 14) * comparison expressions, string vs. regexp: Comparison Operators. - (line 78) + (line 79) * compatibility mode (gawk), extensions: POSIX/GNU. (line 6) * compatibility mode (gawk), file names: Special Caveats. (line 9) * compatibility mode (gawk), hexadecimal numbers: Nondecimal-numbers. @@ -31809,7 +32133,7 @@ Index * compiling gawk for MS-DOS and MS-Windows: PC Compiling. (line 13) * compiling gawk for VMS: VMS Compilation. (line 6) * compiling gawk with EMX for OS/2: PC Compiling. (line 28) -* compl: Bitwise Functions. (line 43) +* compl: Bitwise Functions. (line 44) * complement, bitwise: Bitwise Functions. (line 25) * compound statements, control statements and: Statements. (line 10) * concatenating: Concatenation. (line 8) @@ -31835,15 +32159,15 @@ Index * control statements: Statements. (line 6) * controlling array scanning order: Controlling Scanning. (line 14) -* convert string to lower case: String Functions. (line 521) -* convert string to number: String Functions. (line 388) -* convert string to upper case: String Functions. (line 527) +* 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) * converting integer array subscripts: Numeric Array Subscripts. (line 31) * converting, dates to timestamps: Time Functions. (line 76) -* converting, numbers to strings <1>: Bitwise Functions. (line 109) +* converting, numbers to strings <1>: Bitwise Functions. (line 110) * converting, numbers to strings: Strings And Numbers. (line 6) -* converting, strings to numbers <1>: Bitwise Functions. (line 109) +* converting, strings to numbers <1>: Bitwise Functions. (line 110) * converting, strings to numbers: Strings And Numbers. (line 6) * CONVFMT variable <1>: User-modified. (line 30) * CONVFMT variable: Strings And Numbers. (line 29) @@ -31851,7 +32175,7 @@ Index (line 6) * cookie: Glossary. (line 149) * coprocesses <1>: Two-way I/O. (line 25) -* coprocesses: Redirection. (line 102) +* coprocesses: Redirection. (line 96) * coprocesses, closing: Close Files And Pipes. (line 6) * coprocesses, getline from: Getline/Coprocess. (line 6) @@ -31859,7 +32183,7 @@ Index * cosine: Numeric Functions. (line 15) * counting: Wc Program. (line 6) * csh utility: Statements/Lines. (line 44) -* csh utility, POSIXLY_CORRECT environment variable: Options. (line 351) +* csh utility, POSIXLY_CORRECT environment variable: Options. (line 354) * csh utility, |& operator, comparison with: Two-way I/O. (line 25) * ctime() user-defined function: Function Example. (line 74) * currency symbols, localization: Explaining gettext. (line 104) @@ -31884,37 +32208,39 @@ Index (line 43) * dark corner, break statement: Break Statement. (line 51) * dark corner, close() function: Close Files And Pipes. - (line 131) + (line 132) * 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) -* dark corner, escape sequences: Other Arguments. (line 35) +* dark corner, escape sequences: Other Arguments. (line 38) * dark corner, escape sequences, for metacharacters: Escape Sequences. - (line 142) + (line 143) * dark corner, exit statement: Exit Statement. (line 30) * dark corner, field separators: Field Splitting Summary. (line 46) * 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 316) +* dark corner, FNR/NR variables: Auto-set. (line 321) * 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 110) +* dark corner, input files: awk split records. (line 111) * dark corner, invoking awk: Command Line. (line 16) -* dark corner, length() function: String Functions. (line 183) +* dark corner, length() function: String Functions. (line 186) * 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) * 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 359) +* dark corner, split() function: String Functions. (line 360) * 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) @@ -31928,7 +32254,7 @@ Index (line 112) * Davies, Stephen <1>: Contributors. (line 74) * Davies, Stephen: Acknowledgments. (line 60) -* Day, Robert P.J.: Acknowledgments. (line 76) +* Day, Robert P.J.: Acknowledgments. (line 78) * dcgettext <1>: Programmer i18n. (line 19) * dcgettext: I18N Functions. (line 22) * dcgettext() function (gawk), portability and: I18N Portability. @@ -31955,7 +32281,7 @@ Index * debugger commands, disable: Breakpoint Control. (line 69) * debugger commands, display: Viewing And Changing Data. (line 8) -* debugger commands, down: Execution Stack. (line 21) +* debugger commands, down: Execution Stack. (line 23) * debugger commands, dump: Miscellaneous Debugger Commands. (line 9) * debugger commands, e (enable): Breakpoint Control. (line 73) @@ -31964,10 +32290,10 @@ Index (line 10) * debugger commands, eval: Viewing And Changing Data. (line 23) -* debugger commands, f (frame): Execution Stack. (line 25) +* debugger commands, f (frame): Execution Stack. (line 27) * debugger commands, finish: Debugger Execution Control. (line 39) -* debugger commands, frame: Execution Stack. (line 25) +* debugger commands, frame: Execution Stack. (line 27) * debugger commands, h (help): Miscellaneous Debugger Commands. (line 66) * debugger commands, help: Miscellaneous Debugger Commands. @@ -32029,11 +32355,12 @@ Index (line 83) * debugger commands, unwatch: Viewing And Changing Data. (line 84) -* debugger commands, up: Execution Stack. (line 34) +* debugger commands, up: Execution Stack. (line 36) * debugger commands, w (watch): Viewing And Changing Data. (line 67) * debugger commands, watch: Viewing And Changing Data. (line 67) +* debugger commands, where (backtrace): Execution Stack. (line 13) * debugger default list amount: Debugger Info. (line 69) * debugger history file: Debugger Info. (line 80) * debugger history size: Debugger Info. (line 65) @@ -32043,10 +32370,10 @@ Index * debugger, read commands from a file: Debugger Info. (line 96) * debugging awk programs: Debugger. (line 6) * debugging gawk, bug reports: Bugs. (line 9) -* decimal point character, locale specific: Options. (line 268) +* 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 71) +* Deifik, Scott <1>: Bugs. (line 72) * Deifik, Scott <2>: Contributors. (line 53) * Deifik, Scott: Acknowledgments. (line 60) * delete ARRAY: Delete. (line 39) @@ -32060,7 +32387,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 197) +* differences between gawk and awk: String Functions. (line 200) * differences in awk and gawk, ARGC/ARGV variables: ARGC and ARGV. (line 90) * differences in awk and gawk, ARGIND variable: Auto-set. (line 44) @@ -32083,7 +32410,7 @@ Index * differences in awk and gawk, command-line directories: Command-line directories. (line 6) * differences in awk and gawk, ERRNO variable: Auto-set. (line 82) -* differences in awk and gawk, error messages: Special FD. (line 16) +* differences in awk and gawk, error messages: Special FD. (line 19) * differences in awk and gawk, FIELDWIDTHS variable: User-modified. (line 37) * differences in awk and gawk, FPAT variable: User-modified. (line 43) @@ -32094,26 +32421,26 @@ Index * differences in awk and gawk, IGNORECASE variable: User-modified. (line 76) * differences in awk and gawk, implementation limitations <1>: Redirection. - (line 135) + (line 129) * differences in awk and gawk, implementation limitations: Getline Notes. (line 14) * differences in awk and gawk, indirect function calls: Indirect Calls. (line 6) * differences in awk and gawk, input/output operators <1>: Redirection. - (line 102) + (line 96) * differences in awk and gawk, input/output operators: Getline/Coprocess. (line 6) * differences in awk and gawk, line continuations: Conditional Exp. (line 34) * differences in awk and gawk, LINT variable: User-modified. (line 88) * differences in awk and gawk, match() function: String Functions. - (line 260) + (line 262) * 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, read timeouts: Read Timeout. (line 6) * differences in awk and gawk, record separators: awk split records. - (line 124) + (line 125) * differences in awk and gawk, regexp constants: Using Constant Regexps. (line 43) * differences in awk and gawk, regular expressions: Case-sensitivity. @@ -32124,13 +32451,13 @@ Index * differences in awk and gawk, single-character fields: Single Character Fields. (line 6) * differences in awk and gawk, split() function: String Functions. - (line 347) + (line 348) * 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, TEXTDOMAIN variable: User-modified. - (line 152) + (line 151) * differences in awk and gawk, trunc-mod operation: Arithmetic Ops. (line 66) * directories, command-line: Command-line directories. @@ -32158,13 +32485,14 @@ Index * dollar sign ($), regexp operator: Regexp Operators. (line 35) * double quote ("), in regexp constants: Computed Regexps. (line 29) * double quote ("), in shell commands: Quoting. (line 54) -* down debugger command: Execution Stack. (line 21) +* down debugger command: Execution Stack. (line 23) * Drepper, Ulrich: Acknowledgments. (line 52) +* Duman, Patrice: Acknowledgments. (line 74) * dump all variables of a program: Options. (line 93) * dump debugger command: Miscellaneous Debugger Commands. (line 9) * dupword.awk program: Dupword Program. (line 31) -* dynamic profiling: Profiling. (line 179) +* dynamic profiling: Profiling. (line 178) * dynamically loaded extensions: Dynamic Extensions. (line 6) * e debugger command (alias for enable): Breakpoint Control. (line 73) * EBCDIC: Ordinal Functions. (line 45) @@ -32185,7 +32513,7 @@ Index * empty array elements: Reference to Elements. (line 18) * empty pattern: Empty. (line 6) -* empty strings: awk split records. (line 114) +* empty strings: awk split records. (line 115) * empty strings, See null strings: Regexp Field Splitting. (line 43) * enable breakpoint: Breakpoint Control. (line 73) @@ -32202,16 +32530,16 @@ Index * END pattern, next/nextfile statements and <1>: Next Statement. (line 44) * END pattern, next/nextfile statements and: I/O And BEGIN/END. - (line 36) + (line 37) * END pattern, operators and: Using BEGIN/END. (line 17) * END pattern, print statement and: I/O And BEGIN/END. (line 16) * ENDFILE pattern: BEGINFILE/ENDFILE. (line 6) * ENDFILE pattern, Boolean patterns and: Expression Patterns. (line 70) -* endfile() user-defined function: Filetrans Function. (line 62) -* endgrent() function (C library): Group Functions. (line 212) -* endgrent() user-defined function: Group Functions. (line 215) -* endpwent() function (C library): Passwd Functions. (line 210) -* endpwent() user-defined function: Passwd Functions. (line 213) +* endfile() user-defined function: Filetrans Function. (line 61) +* endgrent() function (C library): Group Functions. (line 211) +* endgrent() user-defined function: Group Functions. (line 214) +* endpwent() function (C library): Passwd Functions. (line 207) +* endpwent() user-defined function: Passwd Functions. (line 210) * English, Steve: Advanced Features. (line 6) * ENVIRON array: Auto-set. (line 60) * environment variables used by gawk: Environment Variables. @@ -32227,9 +32555,9 @@ 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 139) + (line 140) * ERRNO variable, with getline command: Getline. (line 19) -* error handling: Special FD. (line 16) +* error handling: Special FD. (line 19) * error handling, ERRNO variable and: Auto-set. (line 82) * error output: Special FD. (line 6) * escape processing, gsub()/gensub()/sub() functions: Gory Details. @@ -32245,7 +32573,7 @@ Index * examining fields: Fields. (line 6) * exclamation point (!), ! operator <1>: Egrep Program. (line 175) * exclamation point (!), ! operator <2>: Precedence. (line 52) -* exclamation point (!), ! operator: Boolean Ops. (line 67) +* exclamation point (!), ! operator: Boolean Ops. (line 69) * exclamation point (!), != operator <1>: Precedence. (line 65) * exclamation point (!), != operator: Comparison Operators. (line 11) @@ -32265,7 +32593,7 @@ Index (line 99) * exp: Numeric Functions. (line 33) * expand utility: Very Simple. (line 72) -* Expat XML parser library: gawkextlib. (line 35) +* Expat XML parser library: gawkextlib. (line 31) * exponent: Numeric Functions. (line 33) * expressions: Expressions. (line 6) * expressions, as patterns: Expression Patterns. (line 6) @@ -32296,16 +32624,16 @@ Index * extensions, Brian Kernighan's awk: BTL. (line 6) * extensions, common, ** operator: Arithmetic Ops. (line 30) * extensions, common, **= operator: Assignment Ops. (line 137) -* extensions, common, /dev/stderr special file: Special FD. (line 46) -* extensions, common, /dev/stdin special file: Special FD. (line 46) -* extensions, common, /dev/stdout special file: Special FD. (line 46) +* extensions, common, /dev/stderr special file: Special FD. (line 48) +* extensions, common, /dev/stdin special file: Special FD. (line 48) +* extensions, common, /dev/stdout special file: Special FD. (line 48) * extensions, common, \x escape sequence: Escape Sequences. (line 61) * extensions, common, BINMODE variable: PC Using. (line 33) * extensions, common, delete to delete entire arrays: Delete. (line 39) * 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 197) + (line 200) * extensions, common, RS as a regexp: gawk split records. (line 6) * extensions, common, single character fields: Single Character Fields. (line 6) @@ -32317,7 +32645,7 @@ Index * extract.awk program: Extract Program. (line 79) * extraction, of marked strings (internationalization): String Extraction. (line 6) -* f debugger command (alias for frame): Execution Stack. (line 25) +* f debugger command (alias for frame): Execution Stack. (line 27) * false, logical: Truth Values. (line 6) * FDL (Free Documentation License): GNU Free Documentation License. (line 7) @@ -32345,7 +32673,7 @@ Index (line 6) * field separators, regular expressions as: Field Separators. (line 51) * field separators, See Also OFS: Changing Fields. (line 64) -* field separators, spaces as: Cut Program. (line 108) +* field separators, spaces as: Cut Program. (line 103) * fields <1>: Basic High Level. (line 73) * fields <2>: Fields. (line 6) * fields: Reading Files. (line 14) @@ -32365,7 +32693,7 @@ Index * file inclusion, @include directive: Include Files. (line 8) * file names, distinguishing: Auto-set. (line 56) * file names, in compatibility mode: Special Caveats. (line 9) -* file names, standard streams in gawk: Special FD. (line 46) +* file names, standard streams in gawk: Special FD. (line 48) * FILENAME variable <1>: Auto-set. (line 98) * FILENAME variable: Reading Files. (line 6) * FILENAME variable, getline, setting with: Getline Notes. (line 19) @@ -32373,12 +32701,12 @@ Index * files, .gmo: Explaining gettext. (line 42) * files, .gmo, specifying directory of <1>: Programmer i18n. (line 47) * files, .gmo, specifying directory of: Explaining gettext. (line 54) -* files, .mo, converting from .po: I18N Example. (line 63) +* files, .mo, converting from .po: I18N Example. (line 64) * files, .po <1>: Translator i18n. (line 6) * files, .po: Explaining gettext. (line 37) -* files, .po, converting to .mo: I18N Example. (line 63) +* files, .po, converting to .mo: I18N Example. (line 64) * files, .pot: Explaining gettext. (line 31) -* files, /dev/... special files: Special FD. (line 46) +* files, /dev/... special files: Special FD. (line 48) * files, /inet/... (gawk): TCP/IP Networking. (line 6) * files, /inet4/... (gawk): TCP/IP Networking. (line 6) * files, /inet6/... (gawk): TCP/IP Networking. (line 6) @@ -32396,12 +32724,12 @@ Index * files, managing, data file boundaries: Filetrans Function. (line 6) * files, message object: Explaining gettext. (line 42) * files, message object, converting from portable object files: I18N Example. - (line 63) + (line 64) * files, message object, specifying directory of <1>: Programmer i18n. (line 47) * files, message object, specifying directory of: Explaining gettext. (line 54) -* files, multiple passes over: Other Arguments. (line 53) +* files, multiple passes over: Other Arguments. (line 56) * files, multiple, duplicating output into: Tee Program. (line 6) * files, output, See output files: Close Files And Pipes. (line 6) @@ -32410,7 +32738,7 @@ Index * files, portable object: Explaining gettext. (line 37) * files, portable object template: Explaining gettext. (line 31) * files, portable object, converting to message object files: I18N Example. - (line 63) + (line 64) * files, portable object, generating: Options. (line 147) * files, processing, ARGIND variable and: Auto-set. (line 51) * files, reading: Rewind Function. (line 6) @@ -32427,7 +32755,7 @@ Index * Fish, Fred: Contributors. (line 50) * fixed-width data: Constant Size. (line 10) * flag variables <1>: Tee Program. (line 20) -* flag variables: Boolean Ops. (line 67) +* flag variables: Boolean Ops. (line 69) * floating-point, numbers, arbitrary precision: Arbitrary Precision Arithmetic. (line 6) * floating-point, VAX/VMS: VMS Running. (line 51) @@ -32436,7 +32764,7 @@ Index (line 12) * FNR variable <1>: Auto-set. (line 107) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 316) +* FNR variable, changing: Auto-set. (line 321) * for statement: For Statement. (line 6) * for statement, looping over arrays: Scanning an Array. (line 20) * fork() extension function: Extension Sample Fork. @@ -32450,7 +32778,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 381) +* formatting strings: String Functions. (line 382) * forward slash (/) to enclose regular expressions: Regexp. (line 10) * forward slash (/), / operator: Precedence. (line 55) * forward slash (/), /= operator <1>: Precedence. (line 95) @@ -32461,7 +32789,7 @@ Index * FPAT variable <1>: User-modified. (line 43) * FPAT variable: Splitting By Content. (line 27) -* frame debugger command: Execution Stack. (line 25) +* frame debugger command: Execution Stack. (line 27) * Free Documentation License (FDL): GNU Free Documentation License. (line 7) * Free Software Foundation (FSF) <1>: Glossary. (line 296) @@ -32473,9 +32801,9 @@ Index * FS variable, --field-separator option and: Options. (line 21) * FS variable, as null string: Single Character Fields. (line 20) -* FS variable, as TAB character: Options. (line 264) +* FS variable, as TAB character: Options. (line 266) * FS variable, changing value of: Field Separators. (line 35) -* FS variable, running awk programs and: Cut Program. (line 68) +* FS variable, running awk programs and: Cut Program. (line 63) * FS variable, setting from command line: Command Line Field Separator. (line 6) * FS, containing ^: Regexp Field Splitting. @@ -32500,7 +32828,7 @@ Index * functions, defining: Definition Syntax. (line 9) * functions, library: Library Functions. (line 6) * functions, library, assertions: Assert Function. (line 6) -* functions, library, associative arrays and: Library Names. (line 57) +* functions, library, associative arrays and: Library Names. (line 58) * functions, library, C library: Getopt Function. (line 6) * functions, library, character values as numbers: Ordinal Functions. (line 6) @@ -32520,8 +32848,7 @@ Index * functions, library, rounding numbers: Round Function. (line 6) * functions, library, user database, reading: Passwd Functions. (line 6) -* functions, names of <1>: Definition Syntax. (line 23) -* functions, names of: Arrays. (line 18) +* functions, names of: Definition Syntax. (line 23) * functions, recursive: Definition Syntax. (line 83) * functions, string-translation: I18N Functions. (line 6) * functions, undefined: Pass By Value/Reference. @@ -32534,22 +32861,19 @@ Index (line 47) * functions, user-defined, next/nextfile statements and: Next Statement. (line 44) -* G-d: Acknowledgments. (line 92) +* G-d: Acknowledgments. (line 94) * Garfinkle, Scott: Contributors. (line 34) -* gawk program, dynamic profiling: Profiling. (line 179) +* gawk program, dynamic profiling: Profiling. (line 178) * gawk version: Auto-set. (line 214) -* gawk, ARGIND variable in: Other Arguments. (line 12) +* 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 39) +* gawk, bitwise operations in: Bitwise Functions. (line 40) * gawk, break statement in: Break Statement. (line 51) -* gawk, built-in variables and: Built-in Variables. (line 14) * gawk, character classes and: Bracket Expressions. (line 100) * gawk, coding style in: Adding Code. (line 39) * gawk, command-line options, and regular expressions: GNU Regexp Operators. (line 70) -* gawk, comparison operators and: Comparison Operators. - (line 50) * gawk, configuring: Configuration Philosophy. (line 6) * gawk, configuring, options: Additional Configuration Options. @@ -32561,10 +32885,10 @@ 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 139) + (line 140) * gawk, ERRNO variable in: Getline. (line 19) -* gawk, escape sequences: Escape Sequences. (line 132) -* gawk, extensions, disabling: Options. (line 252) +* gawk, escape sequences: Escape Sequences. (line 133) +* 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) @@ -32580,7 +32904,7 @@ Index * 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 58) +* gawk, IGNORECASE variable in <2>: String Functions. (line 57) * 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) @@ -32589,7 +32913,7 @@ Index * gawk, implementation issues, downward compatibility: Compatibility Mode. (line 6) * gawk, implementation issues, limits: Getline Notes. (line 14) -* gawk, implementation issues, pipes: Redirection. (line 135) +* gawk, implementation issues, pipes: Redirection. (line 129) * gawk, installing: Installation. (line 6) * gawk, internationalization and, See internationalization: Internationalization. (line 13) @@ -32604,6 +32928,7 @@ Index * gawk, newlines in: Statements/Lines. (line 12) * gawk, octal numbers and: Nondecimal-numbers. (line 42) * gawk, OS/2 version of: PC Using. (line 16) +* gawk, predefined variables and: Built-in Variables. (line 14) * gawk, PROCINFO array in <1>: Two-way I/O. (line 99) * gawk, PROCINFO array in <2>: Time Functions. (line 47) * gawk, PROCINFO array in: Auto-set. (line 137) @@ -32616,21 +32941,27 @@ Index * gawk, regular expressions, precedence: Regexp Operators. (line 161) * gawk, RT variable in <1>: Auto-set. (line 272) * gawk, RT variable in <2>: Multiple Line. (line 129) -* gawk, RT variable in: awk split records. (line 124) +* 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, string-translation functions: I18N Functions. (line 6) * gawk, SYMTAB array in: Auto-set. (line 276) -* gawk, TEXTDOMAIN variable in: User-modified. (line 152) +* gawk, TEXTDOMAIN variable in: User-modified. (line 151) * gawk, timestamps: Time Functions. (line 6) * gawk, uses for: Preface. (line 34) -* gawk, versions of, information about, printing: Options. (line 298) +* gawk, versions of, information about, printing: Options. (line 300) * gawk, VMS version of: VMS Installation. (line 6) * gawk, word-boundary operator: GNU Regexp Operators. (line 63) * gawkextlib: gawkextlib. (line 6) * gawkextlib project: gawkextlib. (line 6) +* gawklibpath_append shell function: Shell Startup Files. (line 29) +* gawklibpath_default shell function: Shell Startup Files. (line 22) +* gawklibpath_prepend shell function: Shell Startup Files. (line 25) +* gawkpath_append shell function: Shell Startup Files. (line 19) +* gawkpath_default shell function: Shell Startup Files. (line 12) +* gawkpath_prepend shell function: Shell Startup Files. (line 15) * General Public License (GPL): Glossary. (line 305) * General Public License, See GPL: Manual History. (line 11) * generate time values: Time Functions. (line 25) @@ -32641,12 +32972,12 @@ Index * getaddrinfo() function (C library): TCP/IP Networking. (line 38) * getgrent() function (C library): Group Functions. (line 6) * getgrent() user-defined function: Group Functions. (line 6) -* getgrgid() function (C library): Group Functions. (line 183) -* getgrgid() user-defined function: Group Functions. (line 186) -* getgrnam() function (C library): Group Functions. (line 172) -* getgrnam() user-defined function: Group Functions. (line 177) -* getgruser() function (C library): Group Functions. (line 192) -* getgruser() function, user-defined: Group Functions. (line 195) +* getgrgid() function (C library): Group Functions. (line 182) +* getgrgid() user-defined function: Group Functions. (line 185) +* getgrnam() function (C library): Group Functions. (line 171) +* getgrnam() user-defined function: Group Functions. (line 176) +* getgruser() function (C library): Group Functions. (line 191) +* getgruser() function, user-defined: Group Functions. (line 194) * getline command: Reading Files. (line 20) * getline command, _gr_init() user-defined function: Group Functions. (line 83) @@ -32670,10 +33001,10 @@ Index * getopt() user-defined function: Getopt Function. (line 108) * getpwent() function (C library): Passwd Functions. (line 16) * getpwent() user-defined function: Passwd Functions. (line 16) -* getpwnam() function (C library): Passwd Functions. (line 177) -* getpwnam() user-defined function: Passwd Functions. (line 182) -* getpwuid() function (C library): Passwd Functions. (line 188) -* getpwuid() user-defined function: Passwd Functions. (line 192) +* getpwnam() function (C library): Passwd Functions. (line 174) +* getpwnam() user-defined function: Passwd Functions. (line 179) +* getpwuid() function (C library): Passwd Functions. (line 185) +* getpwuid() user-defined function: Passwd Functions. (line 189) * gettext library: Explaining gettext. (line 6) * gettext library, locale categories: Explaining gettext. (line 81) * gettext() function (C library): Explaining gettext. (line 63) @@ -32683,7 +33014,7 @@ Index * git utility <2>: Accessing The Source. (line 10) * git utility <3>: Other Versions. (line 29) -* git utility: gawkextlib. (line 29) +* git utility: gawkextlib. (line 25) * Git, use of for gawk source code: Derived Files. (line 6) * GNITS mailing list: Acknowledgments. (line 52) * GNU awk, See gawk: Preface. (line 51) @@ -32712,7 +33043,7 @@ Index * gsub <1>: String Functions. (line 139) * gsub: Using Constant Regexps. (line 43) -* gsub() function, arguments of: String Functions. (line 460) +* gsub() function, arguments of: String Functions. (line 461) * gsub() function, escape processing: Gory Details. (line 6) * h debugger command (alias for help): Miscellaneous Debugger Commands. (line 66) @@ -32729,7 +33060,7 @@ Index * history expansion, in debugger: Readline Support. (line 6) * histsort.awk program: History Sorting. (line 25) * Hughes, Phil: Acknowledgments. (line 43) -* HUP signal, for dynamic profiling: Profiling. (line 211) +* HUP signal, for dynamic profiling: Profiling. (line 210) * hyphen (-), - operator: Precedence. (line 52) * hyphen (-), -- operator <1>: Precedence. (line 46) * hyphen (-), -- operator: Increment Ops. (line 48) @@ -32758,9 +33089,9 @@ Index * Illumos, POSIX-compliant awk: Other Versions. (line 105) * implementation issues, gawk: Notes. (line 6) * implementation issues, gawk, debugging: Compatibility Mode. (line 6) -* implementation issues, gawk, limits <1>: Redirection. (line 135) +* implementation issues, gawk, limits <1>: Redirection. (line 129) * implementation issues, gawk, limits: Getline Notes. (line 14) -* in operator <1>: For Statement. (line 75) +* in operator <1>: For Statement. (line 76) * in operator <2>: Precedence. (line 83) * in operator: Comparison Operators. (line 11) @@ -32789,9 +33120,9 @@ Index * input files, examples: Sample Data Files. (line 6) * input files, reading: Reading Files. (line 6) * input files, running awk without: Read Terminal. (line 6) -* input files, variable assignments and: Other Arguments. (line 23) +* input files, variable assignments and: Other Arguments. (line 26) * input pipeline: Getline/Pipe. (line 9) -* input record, length of: String Functions. (line 174) +* input record, length of: String Functions. (line 177) * input redirection: Getline/File. (line 6) * input, data, nondecimal: Nondecimal Data. (line 6) * input, explicit: Getline. (line 6) @@ -32809,18 +33140,18 @@ Index * installing gawk: Installation. (line 6) * instruction tracing, in debugger: Debugger Info. (line 89) * int: Numeric Functions. (line 38) -* INT signal (MS-Windows): Profiling. (line 214) +* INT signal (MS-Windows): Profiling. (line 213) * integer array indices: Numeric Array Subscripts. (line 31) * integers, arbitrary precision: Arbitrary Precision Integers. (line 6) * integers, unsigned: Computer Arithmetic. (line 41) -* interacting with other programs: I/O Functions. (line 75) +* interacting with other programs: I/O Functions. (line 74) * internationalization <1>: I18N and L10N. (line 6) * internationalization: I18N Functions. (line 6) * internationalization, localization <1>: Internationalization. (line 13) -* internationalization, localization: User-modified. (line 152) +* internationalization, localization: User-modified. (line 151) * internationalization, localization, character classes: Bracket Expressions. (line 100) * internationalization, localization, gawk and: Internationalization. @@ -32836,7 +33167,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 75) +* invoke shell command: I/O Functions. (line 74) * isarray: Type Functions. (line 11) * ISO: Glossary. (line 367) * ISO 8859-1: Glossary. (line 133) @@ -32862,10 +33193,10 @@ Index * Kernighan, Brian <6>: Library Functions. (line 12) * Kernighan, Brian <7>: Concatenation. (line 6) * Kernighan, Brian <8>: Getline/Pipe. (line 6) -* Kernighan, Brian <9>: Acknowledgments. (line 76) +* Kernighan, Brian <9>: Acknowledgments. (line 78) * Kernighan, Brian <10>: Conventions. (line 38) * Kernighan, Brian: History. (line 17) -* kill command, dynamic profiling: Profiling. (line 188) +* kill command, dynamic profiling: Profiling. (line 187) * Knights, jedi: Undocumented. (line 6) * Kwok, Conrad: Contributors. (line 34) * l debugger command (alias for list): Miscellaneous Debugger Commands. @@ -32878,7 +33209,7 @@ Index * LC_CTYPE locale category: Explaining gettext. (line 98) * LC_MESSAGES locale category: Explaining gettext. (line 88) * LC_MESSAGES locale category, bindtextdomain() function (gawk): Programmer i18n. - (line 99) + (line 101) * LC_MONETARY locale category: Explaining gettext. (line 104) * LC_NUMERIC locale category: Explaining gettext. (line 108) * LC_TIME locale category: Explaining gettext. (line 112) @@ -32889,19 +33220,19 @@ Index * left angle bracket (<), <= operator <1>: Precedence. (line 65) * left angle bracket (<), <= operator: Comparison Operators. (line 11) -* left shift: Bitwise Functions. (line 46) +* left shift: Bitwise Functions. (line 47) * left shift, bitwise: Bitwise Functions. (line 32) * leftmost longest match: Multiple Line. (line 26) -* length: String Functions. (line 167) -* length of input record: String Functions. (line 174) -* length of string: String Functions. (line 167) +* length: String Functions. (line 170) +* length of input record: String Functions. (line 177) +* length of string: String Functions. (line 170) * Lesser General Public License (LGPL): Glossary. (line 396) * LGPL (Lesser General Public License): Glossary. (line 396) * libmawk: Other Versions. (line 121) * 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. - (line 57) + (line 58) * libraries of awk functions, character values as numbers: Ordinal Functions. (line 6) * libraries of awk functions, command-line options: Getopt Function. @@ -32921,7 +33252,7 @@ Index * libraries of awk functions, user database, reading: Passwd Functions. (line 6) * line breaks: Statements/Lines. (line 6) -* line continuations: Boolean Ops. (line 62) +* line continuations: Boolean Ops. (line 64) * line continuations, gawk: Conditional Exp. (line 34) * line continuations, in print statement: Print Examples. (line 76) * line continuations, with C shell: More Complex. (line 30) @@ -32937,7 +33268,7 @@ Index * lint checking, empty programs: Command Line. (line 16) * lint checking, issuing warnings: Options. (line 185) * lint checking, POSIXLY_CORRECT environment variable: Options. - (line 336) + (line 339) * lint checking, undefined functions: Pass By Value/Reference. (line 88) * LINT variable: User-modified. (line 88) @@ -32953,7 +33284,7 @@ Index * loading, extensions: Options. (line 173) * local variables, in a function: Variable Scope. (line 6) * locale categories: Explaining gettext. (line 81) -* locale decimal point character: Options. (line 268) +* locale decimal point character: Options. (line 270) * locale, definition of: Locales. (line 6) * localization: I18N and L10N. (line 6) * localization, See internationalization, localization: I18N and L10N. @@ -32967,7 +33298,7 @@ Index * long options: Command Line. (line 13) * loops: While Statement. (line 6) * loops, break statement and: Break Statement. (line 6) -* loops, continue statements and: For Statement. (line 64) +* loops, continue statements and: For Statement. (line 65) * loops, count for header, in a profile: Profiling. (line 131) * loops, do-while: Do Statement. (line 6) * loops, exiting: Break Statement. (line 6) @@ -32976,67 +33307,66 @@ Index * loops, See Also while statement: While Statement. (line 6) * loops, while: While Statement. (line 6) * ls utility: More Complex. (line 15) -* lshift: Bitwise Functions. (line 46) +* lshift: Bitwise Functions. (line 47) * lvalues/rvalues: Assignment Ops. (line 32) * 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 71) +* Malmberg, John <1>: Bugs. (line 72) * Malmberg, John: Acknowledgments. (line 60) +* Malmberg, John E.: Contributors. (line 137) * mark parity: Ordinal Functions. (line 45) * marked string extraction (internationalization): String Extraction. (line 6) * marked strings, extracting: String Extraction. (line 6) * Marx, Groucho: Increment Ops. (line 60) -* match: String Functions. (line 207) -* match regexp in string: String Functions. (line 207) +* match: String Functions. (line 210) +* match regexp in string: String Functions. (line 210) * match() function, RSTART/RLENGTH variables: String Functions. - (line 224) + (line 227) * matching, expressions, See comparison expressions: Typing and Comparison. (line 9) * matching, leftmost longest: Multiple Line. (line 26) -* matching, null strings: Gory Details. (line 143) +* matching, null strings: String Functions. (line 535) * mawk utility <1>: Other Versions. (line 44) * 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 132) +* mawk utility: Escape Sequences. (line 133) * maximum precision supported by MPFR library: Auto-set. (line 228) * McIlroy, Doug: Glossary. (line 149) * McPhee, Patrick: Contributors. (line 100) * message object files: Explaining gettext. (line 42) * message object files, converting from portable object files: I18N Example. - (line 63) + (line 64) * message object files, specifying directory of <1>: Programmer i18n. (line 47) * message object files, specifying directory of: Explaining gettext. (line 54) * messages from extensions: Printing Messages. (line 6) * metacharacters in regular expressions: Regexp Operators. (line 6) -* metacharacters, escape sequences for: Escape Sequences. (line 138) +* metacharacters, escape sequences for: Escape Sequences. (line 139) * minimum precision supported by MPFR library: Auto-set. (line 231) * mktime: Time Functions. (line 25) * modifiers, in format specifiers: Format Modifiers. (line 6) * monetary information, localization: Explaining gettext. (line 104) * Moore, Duncan: Getline Notes. (line 40) -* msgfmt utility: I18N Example. (line 63) +* msgfmt utility: I18N Example. (line 64) * multiple precision: Arbitrary Precision Arithmetic. (line 6) * multiple-line records: Multiple Line. (line 6) * n debugger command (alias for next): Debugger Execution Control. (line 43) -* names, arrays/variables <1>: Library Names. (line 6) -* names, arrays/variables: Arrays. (line 18) +* names, arrays/variables: Library Names. (line 6) * names, functions <1>: Library Names. (line 6) * names, functions: Definition Syntax. (line 23) -* namespace issues <1>: Library Names. (line 6) -* namespace issues: Arrays. (line 18) +* namespace issues: Library Names. (line 6) * namespace issues, functions: Definition Syntax. (line 23) * NetBSD: Glossary. (line 611) * networks, programming: TCP/IP Networking. (line 6) * networks, support for: Special Network. (line 6) -* newlines <1>: Boolean Ops. (line 67) -* newlines <2>: Options. (line 258) +* newlines <1>: Boolean Ops. (line 69) +* newlines <2>: Options. (line 260) * newlines: Statements/Lines. (line 6) * newlines, as field separators: Default Field Splitting. (line 6) @@ -33051,14 +33381,14 @@ Index (line 43) * next file statement: Feature History. (line 169) * next statement <1>: Next Statement. (line 6) -* next statement: Boolean Ops. (line 93) -* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 36) +* next statement: Boolean Ops. (line 95) +* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 37) * next statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. (line 49) * next statement, user-defined functions and: Next Statement. (line 44) * nextfile statement: Nextfile Statement. (line 6) * nextfile statement, BEGIN/END patterns and: I/O And BEGIN/END. - (line 36) + (line 37) * nextfile statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. (line 26) * nextfile statement, user-defined functions and: Nextfile Statement. @@ -33076,21 +33406,21 @@ Index * not Boolean-logic operator: Boolean Ops. (line 6) * NR variable <1>: Auto-set. (line 132) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 316) +* NR variable, changing: Auto-set. (line 321) * null strings <1>: Basic Data Typing. (line 26) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. (line 43) -* null strings: awk split records. (line 114) -* null strings in gawk arguments, quoting and: Quoting. (line 79) +* null strings: awk split records. (line 115) +* null strings in gawk arguments, quoting and: Quoting. (line 82) * null strings, and deleting array elements: Delete. (line 27) * null strings, as array subscripts: Uninitialized Subscripts. (line 43) * null strings, converting numbers to strings: Strings And Numbers. (line 21) -* null strings, matching: Gory Details. (line 143) -* number as string of bits: Bitwise Functions. (line 109) -* number of array elements: String Functions. (line 197) +* null strings, matching: String Functions. (line 535) +* number as string of bits: Bitwise Functions. (line 110) +* number of array elements: String Functions. (line 200) * number sign (#), #! (executable scripts): Executable Scripts. (line 6) * number sign (#), commenting: Comments. (line 6) @@ -33099,7 +33429,7 @@ Index * numbers, as values of characters: Ordinal Functions. (line 6) * numbers, Cliff random: Cliff Random Function. (line 6) -* numbers, converting <1>: Bitwise Functions. (line 109) +* numbers, converting <1>: Bitwise Functions. (line 110) * numbers, converting: Strings And Numbers. (line 6) * numbers, converting, to strings: User-modified. (line 30) * numbers, hexadecimal: Nondecimal-numbers. (line 6) @@ -33117,7 +33447,7 @@ Index * OFMT variable <2>: Strings And Numbers. (line 57) * OFMT variable: OFMT. (line 15) * OFMT variable, POSIX awk and: OFMT. (line 27) -* OFS variable <1>: User-modified. (line 114) +* OFS variable <1>: User-modified. (line 113) * OFS variable <2>: Output Separators. (line 6) * OFS variable: Changing Fields. (line 64) * OpenBSD: Glossary. (line 611) @@ -33147,7 +33477,7 @@ Index * operators, precedence: Increment Ops. (line 60) * operators, relational, See operators, comparison: Typing and Comparison. (line 9) -* operators, short-circuit: Boolean Ops. (line 57) +* operators, short-circuit: Boolean Ops. (line 59) * operators, string: Concatenation. (line 8) * operators, string-matching: Regexp Usage. (line 19) * operators, string-matching, for buffers: GNU Regexp Operators. @@ -33163,14 +33493,14 @@ Index * options, long <1>: Options. (line 6) * options, long: Command Line. (line 13) * options, printing list of: Options. (line 154) -* or: Bitwise Functions. (line 49) +* or: Bitwise Functions. (line 50) * OR bitwise operation: Bitwise Functions. (line 6) * or Boolean-logic operator: Boolean Ops. (line 6) * ord() extension function: Extension Sample Ord. (line 12) * ord() user-defined function: Ordinal Functions. (line 16) * order of evaluation, concatenation: Concatenation. (line 41) -* ORS variable <1>: User-modified. (line 119) +* ORS variable <1>: User-modified. (line 118) * ORS variable: Output Separators. (line 20) * output field separator, See OFS variable: Changing Fields. (line 64) * output record separator, See ORS variable: Output Separators. @@ -33194,7 +33524,7 @@ Index * parentheses (), in a profile: Profiling. (line 146) * parentheses (), regexp operator: Regexp Operators. (line 81) * password file: Passwd Functions. (line 16) -* patsplit: String Functions. (line 294) +* patsplit: String Functions. (line 296) * patterns: Patterns and Actions. (line 6) * patterns, comparison expressions as: Expression Patterns. (line 14) @@ -33221,7 +33551,7 @@ Index (line 6) * pipe, input: Getline/Pipe. (line 9) * pipe, output: Redirection. (line 57) -* Pitts, Dave <1>: Bugs. (line 71) +* Pitts, Dave <1>: Bugs. (line 72) * Pitts, Dave: Acknowledgments. (line 60) * Plauger, P.J.: Library Functions. (line 12) * plug-in: Extension Intro. (line 6) @@ -33232,14 +33562,14 @@ Index * plus sign (+), += operator: Assignment Ops. (line 82) * plus sign (+), regexp operator: Regexp Operators. (line 105) * pointers to functions: Indirect Calls. (line 6) -* portability: Escape Sequences. (line 102) +* portability: Escape Sequences. (line 103) * portability, #! (executable scripts): Executable Scripts. (line 33) * portability, ** operator and: Arithmetic Ops. (line 81) * portability, **= operator and: Assignment Ops. (line 143) * portability, ARGV variable: Executable Scripts. (line 59) * portability, backslash continuation and: Statements/Lines. (line 30) * portability, backslash in escape sequences: Escape Sequences. - (line 120) + (line 121) * portability, close() function and: Close Files And Pipes. (line 81) * portability, data files as single record: gawk split records. @@ -33250,19 +33580,19 @@ 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 176) +* portability, length() function: String Functions. (line 179) * portability, new awk vs. old awk: Strings And Numbers. (line 57) * portability, next statement in user-defined functions: Pass By Value/Reference. (line 91) * 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 356) -* portability, substr() function: String Functions. (line 510) +* portability, POSIXLY_CORRECT environment variable: Options. (line 359) +* portability, substr() function: String Functions. (line 511) * portable object files <1>: Translator i18n. (line 6) * portable object files: Explaining gettext. (line 37) * portable object files, converting to message object files: I18N Example. - (line 63) + (line 64) * portable object files, generating: Options. (line 147) * portable object template files: Explaining gettext. (line 31) * porting gawk: New Ports. (line 6) @@ -33278,7 +33608,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 120) + (line 121) * 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. @@ -33294,7 +33624,7 @@ Index * 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 176) +* POSIX awk, functions and, length(): String Functions. (line 179) * 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) @@ -33302,19 +33632,23 @@ Index * POSIX awk, OFMT variable and <1>: Strings And Numbers. (line 57) * POSIX awk, OFMT variable and: OFMT. (line 27) * POSIX awk, period (.), using: Regexp Operators. (line 51) -* POSIX awk, printf format strings and: Format Modifiers. (line 159) +* POSIX awk, printf format strings and: Format Modifiers. (line 158) * POSIX awk, regular expressions and: Regexp Operators. (line 161) * POSIX awk, timestamps and: Time Functions. (line 6) * POSIX awk, | I/O operator and: Getline/Pipe. (line 55) -* POSIX mode: Options. (line 252) +* POSIX mode: Options. (line 254) * POSIX, awk and: Preface. (line 21) * POSIX, gawk extensions not included in: POSIX/GNU. (line 6) * POSIX, programs, implementing in awk: Clones. (line 6) -* POSIXLY_CORRECT environment variable: Options. (line 336) -* PREC variable: User-modified. (line 124) +* POSIXLY_CORRECT environment variable: Options. (line 339) +* PREC variable: User-modified. (line 123) * precedence <1>: Precedence. (line 6) * precedence: Increment Ops. (line 60) * precedence, regexp operators: Regexp Operators. (line 156) +* predefined variables: Built-in Variables. (line 6) +* predefined variables, -v option, setting with: Options. (line 40) +* predefined variables, conveying information: Auto-set. (line 6) +* predefined variables, user-modifiable: User-modified. (line 6) * print debugger command: Viewing And Changing Data. (line 36) * print statement: Printing. (line 16) @@ -33322,7 +33656,7 @@ Index * print statement, commas, omitting: Print Examples. (line 31) * print statement, I/O operators in: Precedence. (line 71) * print statement, line continuations and: Print Examples. (line 76) -* print statement, OFMT variable and: User-modified. (line 114) +* print statement, OFMT variable and: User-modified. (line 113) * print statement, See Also redirection, of output: Redirection. (line 17) * print statement, sprintf() function and: Round Function. (line 6) @@ -33364,16 +33698,16 @@ Index * PROCINFO array, and group membership: Group Functions. (line 6) * PROCINFO array, and user and group ID numbers: Id Program. (line 15) * PROCINFO array, testing the field splitting: Passwd Functions. - (line 161) + (line 154) * PROCINFO array, uses: Auto-set. (line 249) * PROCINFO, values of sorted_in: Controlling Scanning. (line 26) * profiling awk programs: Profiling. (line 6) -* profiling awk programs, dynamically: Profiling. (line 179) +* profiling awk programs, dynamically: Profiling. (line 178) * program identifiers: Auto-set. (line 155) * program, definition of: Getting Started. (line 21) * programming conventions, --non-decimal-data option: Nondecimal Data. - (line 36) + (line 35) * programming conventions, ARGC/ARGV variables: Auto-set. (line 35) * programming conventions, exit statement: Exit Statement. (line 38) * programming conventions, function parameters: Return Statement. @@ -33405,9 +33739,9 @@ Index * QuikTrim Awk: Other Versions. (line 135) * quit debugger command: Miscellaneous Debugger Commands. (line 99) -* QUIT signal (MS-Windows): Profiling. (line 214) +* QUIT signal (MS-Windows): Profiling. (line 213) * quoting in gawk command lines: Long. (line 26) -* quoting in gawk command lines, tricks for: Quoting. (line 88) +* quoting in gawk command lines, tricks for: Quoting. (line 91) * quoting, for small awk programs: Comments. (line 27) * r debugger command (alias for run): Debugger Execution Control. (line 62) @@ -33423,12 +33757,11 @@ Index * range expressions (regexps): Bracket Expressions. (line 6) * range patterns: Ranges. (line 6) * range patterns, line continuation and: Ranges. (line 65) -* Rankin, Pat <1>: Bugs. (line 71) -* Rankin, Pat <2>: Contributors. (line 37) -* Rankin, Pat <3>: Assignment Ops. (line 100) +* Rankin, Pat <1>: Contributors. (line 37) +* Rankin, Pat <2>: Assignment Ops. (line 100) * Rankin, Pat: Acknowledgments. (line 60) * reada() extension function: Extension Sample Read write array. - (line 15) + (line 18) * readable data files, checking: File Checking. (line 6) * readable.awk program: File Checking. (line 11) * readdir extension: Extension Sample Readdir. @@ -33438,19 +33771,19 @@ Index * readfile() user-defined function: Readfile Function. (line 30) * reading input files: Reading Files. (line 6) * recipe for a programming language: History. (line 6) -* record separators <1>: User-modified. (line 133) +* record separators <1>: User-modified. (line 132) * record separators: awk split records. (line 6) * record separators, changing: awk split records. (line 85) * record separators, regular expressions as: awk split records. - (line 124) + (line 125) * record separators, with multiline records: Multiple Line. (line 10) * records <1>: Basic High Level. (line 73) * records: Reading Files. (line 14) * records, multiline: Multiple Line. (line 6) * records, printing: Print. (line 22) * records, splitting input into: Records. (line 6) -* records, terminating: awk split records. (line 124) -* records, treating files as: gawk split records. (line 92) +* records, terminating: awk split records. (line 125) +* records, treating files as: gawk split records. (line 93) * recursive functions: Definition Syntax. (line 83) * redirect gawk output, in debugger: Debugger Info. (line 72) * redirection of input: Getline/File. (line 6) @@ -33459,7 +33792,7 @@ Index (line 77) * regexp: Regexp. (line 6) * regexp constants <1>: Comparison Operators. - (line 102) + (line 103) * regexp constants <2>: Regexp Constants. (line 6) * regexp constants: Regexp Usage. (line 57) * regexp constants, /=.../, /= operator and: Assignment Ops. (line 148) @@ -33478,7 +33811,7 @@ Index * regular expressions, as patterns <1>: Regexp Patterns. (line 6) * regular expressions, as patterns: Regexp Usage. (line 6) * regular expressions, as record separators: awk split records. - (line 124) + (line 125) * regular expressions, case sensitivity <1>: User-modified. (line 76) * regular expressions, case sensitivity: Case-sensitivity. (line 6) * regular expressions, computed: Computed Regexps. (line 6) @@ -33489,7 +33822,7 @@ Index (line 59) * regular expressions, gawk, command-line options: GNU Regexp Operators. (line 70) -* regular expressions, interval expressions and: Options. (line 277) +* regular expressions, interval expressions and: Options. (line 279) * regular expressions, leftmost longest match: Leftmost Longest. (line 6) * regular expressions, operators <1>: Regexp Operators. (line 6) @@ -33505,12 +33838,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 406) +* replace in string: String Functions. (line 407) * 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 131) + (line 132) * rev() user-defined function: Function Example. (line 54) * revoutput extension: Extension Sample Revout. (line 11) @@ -33526,40 +33859,40 @@ Index (line 11) * right angle bracket (>), >> operator (I/O) <1>: Precedence. (line 65) * right angle bracket (>), >> operator (I/O): Redirection. (line 50) -* right shift: Bitwise Functions. (line 52) +* 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 224) +* RLENGTH variable, match() function and: String Functions. (line 227) * Robbins, Arnold <1>: Future Extensions. (line 6) -* Robbins, Arnold <2>: Bugs. (line 32) -* Robbins, Arnold <3>: Contributors. (line 141) +* Robbins, Arnold <2>: Bugs. (line 72) +* Robbins, Arnold <3>: Contributors. (line 144) * Robbins, Arnold <4>: General Data Types. (line 6) * Robbins, Arnold <5>: Alarm Program. (line 6) * Robbins, Arnold <6>: Passwd Functions. (line 90) * Robbins, Arnold <7>: Getline/Pipe. (line 39) * Robbins, Arnold: Command Line Field Separator. - (line 74) + (line 71) * Robbins, Bill: Getline/Pipe. (line 39) -* Robbins, Harry: Acknowledgments. (line 92) -* Robbins, Jean: Acknowledgments. (line 92) +* Robbins, Harry: Acknowledgments. (line 94) +* Robbins, Jean: Acknowledgments. (line 94) * Robbins, Miriam <1>: Passwd Functions. (line 90) * Robbins, Miriam <2>: Getline/Pipe. (line 39) -* Robbins, Miriam: Acknowledgments. (line 92) +* Robbins, Miriam: Acknowledgments. (line 94) * Rommel, Kai Uwe: Contributors. (line 42) * round to nearest integer: Numeric Functions. (line 38) * round() user-defined function: Round Function. (line 16) * rounding numbers: Round Function. (line 6) -* ROUNDMODE variable: User-modified. (line 128) -* RS variable <1>: User-modified. (line 133) +* ROUNDMODE variable: User-modified. (line 127) +* RS variable <1>: User-modified. (line 132) * RS variable: awk split records. (line 12) * RS variable, multiline records and: Multiple Line. (line 17) -* rshift: Bitwise Functions. (line 52) +* rshift: Bitwise Functions. (line 53) * RSTART variable: Auto-set. (line 265) -* RSTART variable, match() function and: String Functions. (line 224) +* RSTART variable, match() function and: String Functions. (line 227) * RT variable <1>: Auto-set. (line 272) * RT variable <2>: Multiple Line. (line 129) -* RT variable: awk split records. (line 124) +* RT variable: awk split records. (line 125) * Rubin, Paul <1>: Contributors. (line 15) * Rubin, Paul: History. (line 30) * rule, definition of: Getting Started. (line 21) @@ -33570,14 +33903,14 @@ Index (line 68) * sample debugging session: Sample Debugging Session. (line 6) -* sandbox mode: Options. (line 284) +* sandbox mode: Options. (line 286) * save debugger options: Debugger Info. (line 84) * scalar or array: Type Functions. (line 11) * scalar values: Basic Data Typing. (line 13) * 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 299) +* Schorr, Andrew <2>: Auto-set. (line 304) * Schorr, Andrew: Acknowledgments. (line 60) * Schreiber, Bert: Acknowledgments. (line 38) * Schreiber, Rita: Acknowledgments. (line 38) @@ -33609,12 +33942,12 @@ Index * separators, field, FIELDWIDTHS variable and: User-modified. (line 37) * separators, field, FPAT variable and: User-modified. (line 43) * separators, field, POSIX and: Fields. (line 6) -* separators, for records <1>: User-modified. (line 133) +* separators, for records <1>: User-modified. (line 132) * separators, for records: awk split records. (line 6) * separators, for records, regular expressions as: awk split records. - (line 124) + (line 125) * separators, for statements in actions: Action Overview. (line 19) -* separators, subscript: User-modified. (line 146) +* separators, subscript: User-modified. (line 145) * set breakpoint: Breakpoint Control. (line 11) * set debugger command: Viewing And Changing Data. (line 59) @@ -33623,7 +33956,7 @@ Index (line 67) * shadowing of variable values: Definition Syntax. (line 71) * shell quoting, rules for: Quoting. (line 6) -* shells, piping commands into: Redirection. (line 142) +* shells, piping commands into: Redirection. (line 136) * shells, quoting: Using Shell Variables. (line 12) * shells, quoting, rules for: Quoting. (line 18) @@ -33632,7 +33965,7 @@ Index * shells, variables: Using Shell Variables. (line 6) * shift, bitwise: Bitwise Functions. (line 32) -* short-circuit operators: Boolean Ops. (line 57) +* short-circuit operators: Boolean Ops. (line 59) * show all source files, in debugger: Debugger Info. (line 45) * show breakpoints: Debugger Info. (line 21) * show function arguments, in debugger: Debugger Info. (line 18) @@ -33658,27 +33991,27 @@ Index * sidebar, A Constant's Base Does Not Affect Its Value: Nondecimal-numbers. (line 64) * sidebar, Backslash Before Regular Characters: Escape Sequences. - (line 118) + (line 119) * sidebar, Changing FS Does Not Affect the Fields: Field Splitting Summary. (line 38) -* sidebar, Changing NR and FNR: Auto-set. (line 314) +* sidebar, Changing NR and FNR: Auto-set. (line 319) * sidebar, Controlling Output Buffering with system(): I/O Functions. - (line 138) + (line 137) * sidebar, Escape Sequences for Metacharacters: Escape Sequences. - (line 136) + (line 137) * sidebar, FS and IGNORECASE: Field Splitting Summary. (line 64) * sidebar, Interactive Versus Noninteractive Buffering: I/O Functions. - (line 107) -* sidebar, Matching the Null String: Gory Details. (line 141) + (line 106) +* sidebar, Matching the Null String: String Functions. (line 533) * sidebar, Operator Evaluation Order: Increment Ops. (line 58) -* sidebar, Piping into sh: Redirection. (line 140) +* sidebar, Piping into sh: Redirection. (line 134) * sidebar, Pre-POSIX awk Used OFMT For String Conversion: Strings And Numbers. (line 55) * 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. - (line 83) + (line 82) * sidebar, Syntactic Ambiguities Between /= and Regular Expressions: Assignment Ops. (line 146) * sidebar, Understanding #!: Executable Scripts. (line 31) @@ -33686,25 +34019,25 @@ 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 129) -* SIGHUP signal, for dynamic profiling: Profiling. (line 211) -* SIGINT signal (MS-Windows): Profiling. (line 214) -* signals, HUP/SIGHUP, for profiling: Profiling. (line 211) -* signals, INT/SIGINT (MS-Windows): Profiling. (line 214) -* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 214) -* signals, USR1/SIGUSR1, for profiling: Profiling. (line 188) + (line 130) +* SIGHUP signal, for dynamic profiling: Profiling. (line 210) +* SIGINT signal (MS-Windows): Profiling. (line 213) +* signals, HUP/SIGHUP, for profiling: Profiling. (line 210) +* signals, INT/SIGINT (MS-Windows): Profiling. (line 213) +* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 213) +* signals, USR1/SIGUSR1, for profiling: Profiling. (line 187) * signature program: Signature Program. (line 6) -* SIGQUIT signal (MS-Windows): Profiling. (line 214) -* SIGUSR1 signal, for dynamic profiling: Profiling. (line 188) +* SIGQUIT signal (MS-Windows): Profiling. (line 213) +* 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) * single quote ('): One-shot. (line 15) -* single quote (') in gawk command lines: Long. (line 33) +* single quote (') in gawk command lines: Long. (line 35) * single quote ('), in shell commands: Quoting. (line 48) * single quote ('), vs. apostrophe: Comments. (line 27) -* single quote ('), with double quotes: Quoting. (line 70) +* single quote ('), with double quotes: Quoting. (line 73) * single-character fields: Single Character Fields. (line 6) * single-step execution, in the debugger: Debugger Execution Control. @@ -33714,8 +34047,8 @@ Index * sleep() extension function: Extension Sample Time. (line 22) * Solaris, POSIX-compliant awk: Other Versions. (line 96) -* sort array: String Functions. (line 42) -* sort array indices: String Functions. (line 42) +* sort array: String Functions. (line 41) +* sort array indices: String Functions. (line 41) * sort function, arrays, sorting: Array Sorting Functions. (line 6) * sort utility: Word Sorting. (line 50) @@ -33739,14 +34072,14 @@ Index * source files, search path for: Programs Exercises. (line 70) * sparse arrays: Array Intro. (line 72) * Spencer, Henry: Glossary. (line 11) -* split: String Functions. (line 313) -* split string into array: String Functions. (line 294) +* split: String Functions. (line 315) +* split string into array: String Functions. (line 296) * 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 381) +* sprintf <1>: String Functions. (line 382) * sprintf: OFMT. (line 15) -* sprintf() function, OFMT variable and: User-modified. (line 114) +* sprintf() function, OFMT variable and: User-modified. (line 113) * sprintf() function, print/printf statements and: Round Function. (line 6) * sqrt: Numeric Functions. (line 94) @@ -33782,18 +34115,18 @@ Index * string constants, vs. regexp constants: Computed Regexps. (line 39) * string extraction (internationalization): String Extraction. (line 6) -* string length: String Functions. (line 167) +* string length: String Functions. (line 170) * string operators: Concatenation. (line 8) -* string, regular expression match: String Functions. (line 207) +* string, regular expression match: String Functions. (line 210) * 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 333) -* strings, converting <1>: Bitwise Functions. (line 109) +* strings splitting, example: String Functions. (line 334) +* strings, converting <1>: Bitwise Functions. (line 110) * strings, converting: Strings And Numbers. (line 6) -* strings, converting letter case: String Functions. (line 520) +* strings, converting letter case: String Functions. (line 521) * strings, converting, numbers to: User-modified. (line 30) -* strings, empty, See null strings: awk split records. (line 114) +* strings, empty, See null strings: awk split records. (line 115) * strings, extracting: String Extraction. (line 6) * strings, for localization: Programmer i18n. (line 14) * strings, length limitations: Scalar Constants. (line 20) @@ -33801,15 +34134,15 @@ Index * strings, null: Regexp Field Splitting. (line 43) * strings, numeric: Variable Typing. (line 6) -* strtonum: String Functions. (line 388) +* strtonum: String Functions. (line 389) * strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data. - (line 36) -* sub <1>: String Functions. (line 406) + (line 35) +* sub <1>: String Functions. (line 407) * sub: Using Constant Regexps. (line 43) -* sub() function, arguments of: String Functions. (line 460) +* sub() function, arguments of: String Functions. (line 461) * sub() function, escape processing: Gory Details. (line 6) -* subscript separators: User-modified. (line 146) +* subscript separators: User-modified. (line 145) * subscripts in arrays, multidimensional: Multidimensional. (line 10) * subscripts in arrays, multidimensional, scanning: Multiscanning. (line 11) @@ -33817,30 +34150,30 @@ Index (line 6) * subscripts in arrays, uninitialized variables as: Uninitialized Subscripts. (line 6) -* SUBSEP variable: User-modified. (line 146) +* 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 479) -* substring: String Functions. (line 479) +* 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) * switch statement: Switch Statement. (line 6) * SYMTAB array: Auto-set. (line 276) * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) -* system: I/O Functions. (line 75) +* system: I/O Functions. (line 74) * systime: Time Functions. (line 66) * t debugger command (alias for tbreak): Breakpoint Control. (line 90) * tbreak debugger command: Breakpoint Control. (line 90) -* Tcl: Library Names. (line 57) +* Tcl: Library Names. (line 58) * TCP/IP: TCP/IP Networking. (line 6) * TCP/IP, support for: Special Network. (line 6) * tee utility: Tee Program. (line 6) * tee.awk program: Tee Program. (line 26) * temporary breakpoint: Breakpoint Control. (line 90) -* terminating records: awk split records. (line 124) -* testbits.awk program: Bitwise Functions. (line 70) +* terminating records: awk split records. (line 125) +* testbits.awk program: Bitwise Functions. (line 71) * testext extension: Extension Sample API Tests. (line 6) * Texinfo <1>: Adding Code. (line 100) @@ -33856,7 +34189,7 @@ Index * text, printing: Print. (line 22) * text, printing, unduplicated lines of: Uniq Program. (line 6) * TEXTDOMAIN variable <1>: Programmer i18n. (line 9) -* TEXTDOMAIN variable: User-modified. (line 152) +* TEXTDOMAIN variable: User-modified. (line 151) * TEXTDOMAIN variable, BEGIN pattern and: Programmer i18n. (line 60) * TEXTDOMAIN variable, portability and: I18N Portability. (line 20) * textdomain() function (C library): Explaining gettext. (line 28) @@ -33879,45 +34212,45 @@ Index * timestamps, converting dates to: Time Functions. (line 76) * timestamps, formatted: Getlocaltime Function. (line 6) -* tolower: String Functions. (line 521) -* toupper: String Functions. (line 527) +* tolower: String Functions. (line 522) +* toupper: String Functions. (line 528) * tr utility: Translate Program. (line 6) * trace debugger command: Miscellaneous Debugger Commands. (line 108) * traceback, display in debugger: Execution Stack. (line 13) * translate string: I18N Functions. (line 22) * translate.awk program: Translate Program. (line 55) -* treating files, as single records: gawk split records. (line 92) +* treating files, as single records: gawk split records. (line 93) * troubleshooting, --non-decimal-data option: Options. (line 211) * troubleshooting, == operator: Comparison Operators. (line 37) * troubleshooting, awk uses FS not IFS: Field Separators. (line 30) * troubleshooting, backslash before nonspecial character: Escape Sequences. - (line 120) + (line 121) * troubleshooting, division: Arithmetic Ops. (line 44) * troubleshooting, fatal errors, field widths, specifying: Constant Size. (line 23) * troubleshooting, fatal errors, printf format strings: Format Modifiers. - (line 159) -* troubleshooting, fflush() function: I/O Functions. (line 63) + (line 158) +* troubleshooting, fflush() function: I/O Functions. (line 62) * troubleshooting, function call syntax: Function Calls. (line 30) * troubleshooting, gawk: Compatibility Mode. (line 6) * troubleshooting, gawk, bug reports: Bugs. (line 9) * 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 470) -* troubleshooting, match() function: String Functions. (line 289) +* troubleshooting, gsub()/sub() functions: String Functions. (line 471) +* troubleshooting, match() function: String Functions. (line 291) * troubleshooting, print statement, omitting commas: Print Examples. (line 31) -* troubleshooting, printing: Redirection. (line 118) -* troubleshooting, quotes with file names: Special FD. (line 68) +* troubleshooting, printing: Redirection. (line 112) +* troubleshooting, quotes with file names: Special FD. (line 62) * troubleshooting, readable data files: File Checking. (line 6) * troubleshooting, regexp constants vs. string constants: Computed Regexps. (line 39) * troubleshooting, string concatenation: Concatenation. (line 26) -* troubleshooting, substr() function: String Functions. (line 497) -* troubleshooting, system() function: I/O Functions. (line 97) +* troubleshooting, substr() function: String Functions. (line 498) +* troubleshooting, system() function: I/O Functions. (line 96) * troubleshooting, typographical errors, global variables: Options. (line 98) * true, logical: Truth Values. (line 6) @@ -33949,11 +34282,11 @@ Index * uniq.awk program: Uniq Program. (line 65) * Unix: Glossary. (line 611) * Unix awk, backslashes in escape sequences: Escape Sequences. - (line 132) + (line 133) * Unix awk, close() function and: Close Files And Pipes. - (line 131) + (line 132) * Unix awk, password files, field separators and: Command Line Field Separator. - (line 65) + (line 62) * Unix, awk scripts and: Executable Scripts. (line 6) * UNIXROOT variable, on OS/2 systems: PC Using. (line 16) * unsigned integers: Computer Arithmetic. (line 41) @@ -33961,7 +34294,7 @@ Index (line 83) * unwatch debugger command: Viewing And Changing Data. (line 84) -* up debugger command: Execution Stack. (line 34) +* up debugger command: Execution Stack. (line 36) * user database, reading: Passwd Functions. (line 6) * user-defined functions: User-defined. (line 6) * user-defined, functions, counts, in a profile: Profiling. (line 137) @@ -33969,20 +34302,17 @@ Index * user-modifiable variables: User-modified. (line 6) * users, information about, printing: Id Program. (line 6) * users, information about, retrieving: Passwd Functions. (line 16) -* USR1 signal, for dynamic profiling: Profiling. (line 188) +* USR1 signal, for dynamic profiling: Profiling. (line 187) * values, numeric: Basic Data Typing. (line 13) * values, string: Basic Data Typing. (line 13) -* variable assignments and input files: Other Arguments. (line 23) +* variable assignments and input files: Other Arguments. (line 26) * variable typing: Typing and Comparison. (line 9) * variables <1>: Basic Data Typing. (line 6) * variables: Other Features. (line 6) * variables, assigning on command line: Assignment Options. (line 6) -* variables, built-in <1>: Built-in Variables. (line 6) * variables, built-in: Using Variables. (line 23) -* variables, built-in, -v option, setting with: Options. (line 40) -* variables, built-in, conveying information: Auto-set. (line 6) -* variables, flag: Boolean Ops. (line 67) +* variables, flag: Boolean Ops. (line 69) * variables, getline command into, using <1>: Getline/Variable/Coprocess. (line 6) * variables, getline command into, using <2>: Getline/Variable/Pipe. @@ -33994,7 +34324,9 @@ Index * variables, global, printing list of: Options. (line 93) * variables, initializing: Using Variables. (line 23) * variables, local to a function: Variable Scope. (line 6) -* variables, names of: Arrays. (line 18) +* variables, predefined: Built-in Variables. (line 6) +* variables, predefined -v option, setting with: Options. (line 40) +* variables, predefined conveying information: Auto-set. (line 6) * variables, private: Library Names. (line 11) * variables, setting: Options. (line 32) * variables, shadowing: Definition Syntax. (line 71) @@ -34015,7 +34347,7 @@ Index * vertical bar (|), |& operator (I/O) <2>: Precedence. (line 65) * vertical bar (|), |& operator (I/O): Getline/Coprocess. (line 6) * vertical bar (|), || operator <1>: Precedence. (line 89) -* vertical bar (|), || operator: Boolean Ops. (line 57) +* vertical bar (|), || operator: Boolean Ops. (line 59) * Vinschen, Corinna: Acknowledgments. (line 60) * w debugger command (alias for watch): Viewing And Changing Data. (line 67) @@ -34036,12 +34368,15 @@ Index * wc.awk program: Wc Program. (line 46) * Weinberger, Peter <1>: Contributors. (line 11) * Weinberger, Peter: History. (line 17) +* where debugger command: Execution Stack. (line 13) +* where debugger command (alias for backtrace): Execution Stack. + (line 13) * while statement: While Statement. (line 6) * while statement, use of regexps in: Regexp Usage. (line 19) * whitespace, as field separators: Default Field Splitting. (line 6) * whitespace, functions, calling: Calling Built-in. (line 10) -* whitespace, newlines as: Options. (line 258) +* whitespace, newlines as: Options. (line 260) * Williams, Kent: Contributors. (line 34) * Woehlke, Matthew: Contributors. (line 79) * Woods, John: Contributors. (line 27) @@ -34056,12 +34391,12 @@ Index * words, duplicate, searching for: Dupword Program. (line 6) * words, usage counts, generating: Word Sorting. (line 6) * writea() extension function: Extension Sample Read write array. - (line 9) + (line 12) * xgettext utility: String Extraction. (line 13) -* xor: Bitwise Functions. (line 55) +* xor: Bitwise Functions. (line 56) * XOR bitwise operation: Bitwise Functions. (line 6) * Yawitz, Efraim: Contributors. (line 131) -* Zaretskii, Eli <1>: Bugs. (line 71) +* Zaretskii, Eli <1>: Bugs. (line 72) * Zaretskii, Eli <2>: Contributors. (line 55) * Zaretskii, Eli: Acknowledgments. (line 60) * zerofile.awk program: Empty Files. (line 21) @@ -34075,12 +34410,12 @@ Index * | (vertical bar), | operator (I/O): Getline/Pipe. (line 9) * | (vertical bar), |& operator (I/O) <1>: Two-way I/O. (line 25) * | (vertical bar), |& operator (I/O) <2>: Precedence. (line 65) -* | (vertical bar), |& operator (I/O) <3>: Redirection. (line 102) +* | (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 119) + (line 120) * | (vertical bar), || operator <1>: Precedence. (line 89) -* | (vertical bar), || operator: Boolean Ops. (line 57) +* | (vertical bar), || operator: Boolean Ops. (line 59) * ~ (tilde), ~ operator <1>: Expression Patterns. (line 24) * ~ (tilde), ~ operator <2>: Precedence. (line 80) * ~ (tilde), ~ operator <3>: Comparison Operators. @@ -34094,553 +34429,559 @@ Index Tag Table: Node: Top1204 -Node: Foreword41858 -Node: Preface46203 -Ref: Preface-Footnote-149226 -Ref: Preface-Footnote-249333 -Node: History49565 -Node: Names51939 -Ref: Names-Footnote-153033 -Node: This Manual53179 -Ref: This Manual-Footnote-158958 -Node: Conventions59058 -Node: Manual History61403 -Ref: Manual History-Footnote-164479 -Ref: Manual History-Footnote-264520 -Node: How To Contribute64594 -Node: Acknowledgments65833 -Node: Getting Started70581 -Node: Running gawk73015 -Node: One-shot74205 -Node: Read Terminal75430 -Node: Long77455 -Node: Executable Scripts78849 -Ref: Executable Scripts-Footnote-181650 -Node: Comments81752 -Node: Quoting84225 -Node: DOS Quoting89538 -Node: Sample Data Files90213 -Node: Very Simple92820 -Node: Two Rules97705 -Node: More Complex99599 -Ref: More Complex-Footnote-1102513 -Node: Statements/Lines102598 -Ref: Statements/Lines-Footnote-1107054 -Node: Other Features107319 -Node: When108250 -Ref: When-Footnote-1110006 -Node: Intro Summary110071 -Node: Invoking Gawk110954 -Node: Command Line112469 -Node: Options113260 -Ref: Options-Footnote-1128907 -Node: Other Arguments128932 -Node: Naming Standard Input131760 -Node: Environment Variables132853 -Node: AWKPATH Variable133411 -Ref: AWKPATH Variable-Footnote-1136277 -Ref: AWKPATH Variable-Footnote-2136322 -Node: AWKLIBPATH Variable136582 -Node: Other Environment Variables137341 -Node: Exit Status140793 -Node: Include Files141468 -Node: Loading Shared Libraries145046 -Node: Obsolete146430 -Node: Undocumented147127 -Node: Invoking Summary147394 -Node: Regexp148994 -Node: Regexp Usage150453 -Node: Escape Sequences152486 -Node: Regexp Operators158557 -Ref: Regexp Operators-Footnote-1165988 -Ref: Regexp Operators-Footnote-2166135 -Node: Bracket Expressions166233 -Ref: table-char-classes168251 -Node: Leftmost Longest171191 -Node: Computed Regexps172395 -Node: GNU Regexp Operators175773 -Node: Case-sensitivity179479 -Ref: Case-sensitivity-Footnote-1182369 -Ref: Case-sensitivity-Footnote-2182604 -Node: Regexp Summary182712 -Node: Reading Files184181 -Node: Records186273 -Node: awk split records186995 -Node: gawk split records191853 -Ref: gawk split records-Footnote-1196374 -Node: Fields196411 -Ref: Fields-Footnote-1199375 -Node: Nonconstant Fields199461 -Ref: Nonconstant Fields-Footnote-1201691 -Node: Changing Fields201893 -Node: Field Separators207847 -Node: Default Field Splitting210549 -Node: Regexp Field Splitting211666 -Node: Single Character Fields214993 -Node: Command Line Field Separator216052 -Node: Full Line Fields219478 -Ref: Full Line Fields-Footnote-1219986 -Node: Field Splitting Summary220032 -Ref: Field Splitting Summary-Footnote-1223164 -Node: Constant Size223265 -Node: Splitting By Content227871 -Ref: Splitting By Content-Footnote-1231944 -Node: Multiple Line231984 -Ref: Multiple Line-Footnote-1237840 -Node: Getline238019 -Node: Plain Getline240230 -Node: Getline/Variable242936 -Node: Getline/File244083 -Node: Getline/Variable/File245467 -Ref: Getline/Variable/File-Footnote-1247066 -Node: Getline/Pipe247153 -Node: Getline/Variable/Pipe249839 -Node: Getline/Coprocess250946 -Node: Getline/Variable/Coprocess252198 -Node: Getline Notes252935 -Node: Getline Summary255739 -Ref: table-getline-variants256147 -Node: Read Timeout257059 -Ref: Read Timeout-Footnote-1260886 -Node: Command-line directories260944 -Node: Input Summary261848 -Node: Input Exercises264985 -Node: Printing265713 -Node: Print267435 -Node: Print Examples268928 -Node: Output Separators271707 -Node: OFMT273723 -Node: Printf275081 -Node: Basic Printf275987 -Node: Control Letters277526 -Node: Format Modifiers281517 -Node: Printf Examples287544 -Node: Redirection290008 -Node: Special Files296980 -Node: Special FD297513 -Ref: Special FD-Footnote-1301110 -Node: Special Network301184 -Node: Special Caveats302034 -Node: Close Files And Pipes302830 -Ref: Close Files And Pipes-Footnote-1309991 -Ref: Close Files And Pipes-Footnote-2310139 -Node: Output Summary310289 -Node: Output Exercises311286 -Node: Expressions311966 -Node: Values313151 -Node: Constants313827 -Node: Scalar Constants314507 -Ref: Scalar Constants-Footnote-1315366 -Node: Nondecimal-numbers315616 -Node: Regexp Constants318616 -Node: Using Constant Regexps319141 -Node: Variables322213 -Node: Using Variables322868 -Node: Assignment Options324774 -Node: Conversion326649 -Node: Strings And Numbers327173 -Ref: Strings And Numbers-Footnote-1330235 -Node: Locale influences conversions330344 -Ref: table-locale-affects333061 -Node: All Operators333649 -Node: Arithmetic Ops334279 -Node: Concatenation336784 -Ref: Concatenation-Footnote-1339603 -Node: Assignment Ops339709 -Ref: table-assign-ops344692 -Node: Increment Ops345995 -Node: Truth Values and Conditions349433 -Node: Truth Values350516 -Node: Typing and Comparison351565 -Node: Variable Typing352358 -Node: Comparison Operators356010 -Ref: table-relational-ops356420 -Node: POSIX String Comparison359970 -Ref: POSIX String Comparison-Footnote-1361054 -Node: Boolean Ops361192 -Ref: Boolean Ops-Footnote-1365531 -Node: Conditional Exp365622 -Node: Function Calls367349 -Node: Precedence371229 -Node: Locales374898 -Node: Expressions Summary376529 -Node: Patterns and Actions379070 -Node: Pattern Overview380186 -Node: Regexp Patterns381863 -Node: Expression Patterns382406 -Node: Ranges386186 -Node: BEGIN/END389292 -Node: Using BEGIN/END390054 -Ref: Using BEGIN/END-Footnote-1392790 -Node: I/O And BEGIN/END392896 -Node: BEGINFILE/ENDFILE395167 -Node: Empty398098 -Node: Using Shell Variables398415 -Node: Action Overview400698 -Node: Statements403025 -Node: If Statement404873 -Node: While Statement406371 -Node: Do Statement408415 -Node: For Statement409571 -Node: Switch Statement412723 -Node: Break Statement415111 -Node: Continue Statement417152 -Node: Next Statement418977 -Node: Nextfile Statement421347 -Node: Exit Statement424004 -Node: Built-in Variables426408 -Node: User-modified427535 -Ref: User-modified-Footnote-1435224 -Node: Auto-set435286 -Ref: Auto-set-Footnote-1448475 -Ref: Auto-set-Footnote-2448680 -Node: ARGC and ARGV448736 -Node: Pattern Action Summary452640 -Node: Arrays454863 -Node: Array Basics456412 -Node: Array Intro457238 -Ref: figure-array-elements459211 -Ref: Array Intro-Footnote-1461735 -Node: Reference to Elements461863 -Node: Assigning Elements464313 -Node: Array Example464804 -Node: Scanning an Array466536 -Node: Controlling Scanning469537 -Ref: Controlling Scanning-Footnote-1474710 -Node: Delete475026 -Ref: Delete-Footnote-1477777 -Node: Numeric Array Subscripts477834 -Node: Uninitialized Subscripts480017 -Node: Multidimensional481644 -Node: Multiscanning484757 -Node: Arrays of Arrays486346 -Node: Arrays Summary491009 -Node: Functions493114 -Node: Built-in493987 -Node: Calling Built-in495065 -Node: Numeric Functions497053 -Ref: Numeric Functions-Footnote-1501889 -Ref: Numeric Functions-Footnote-2502246 -Ref: Numeric Functions-Footnote-3502294 -Node: String Functions502563 -Ref: String Functions-Footnote-1525560 -Ref: String Functions-Footnote-2525689 -Ref: String Functions-Footnote-3525937 -Node: Gory Details526024 -Ref: table-sub-escapes527797 -Ref: table-sub-proposed529317 -Ref: table-posix-sub530681 -Ref: table-gensub-escapes532221 -Ref: Gory Details-Footnote-1533397 -Node: I/O Functions533548 -Ref: I/O Functions-Footnote-1540658 -Node: Time Functions540805 -Ref: Time Functions-Footnote-1551269 -Ref: Time Functions-Footnote-2551337 -Ref: Time Functions-Footnote-3551495 -Ref: Time Functions-Footnote-4551606 -Ref: Time Functions-Footnote-5551718 -Ref: Time Functions-Footnote-6551945 -Node: Bitwise Functions552211 -Ref: table-bitwise-ops552773 -Ref: Bitwise Functions-Footnote-1557018 -Node: Type Functions557202 -Node: I18N Functions558344 -Node: User-defined559989 -Node: Definition Syntax560793 -Ref: Definition Syntax-Footnote-1566197 -Node: Function Example566266 -Ref: Function Example-Footnote-1568906 -Node: Function Caveats568928 -Node: Calling A Function569446 -Node: Variable Scope570401 -Node: Pass By Value/Reference573389 -Node: Return Statement576899 -Node: Dynamic Typing579883 -Node: Indirect Calls580812 -Ref: Indirect Calls-Footnote-1590528 -Node: Functions Summary590656 -Node: Library Functions593306 -Ref: Library Functions-Footnote-1596924 -Ref: Library Functions-Footnote-2597067 -Node: Library Names597238 -Ref: Library Names-Footnote-1600711 -Ref: Library Names-Footnote-2600931 -Node: General Functions601017 -Node: Strtonum Function602045 -Node: Assert Function604947 -Node: Round Function608273 -Node: Cliff Random Function609814 -Node: Ordinal Functions610830 -Ref: Ordinal Functions-Footnote-1613895 -Ref: Ordinal Functions-Footnote-2614147 -Node: Join Function614358 -Ref: Join Function-Footnote-1616129 -Node: Getlocaltime Function616329 -Node: Readfile Function620065 -Node: Data File Management621904 -Node: Filetrans Function622536 -Node: Rewind Function626605 -Node: File Checking628163 -Ref: File Checking-Footnote-1629295 -Node: Empty Files629496 -Node: Ignoring Assigns631475 -Node: Getopt Function633029 -Ref: Getopt Function-Footnote-1644293 -Node: Passwd Functions644496 -Ref: Passwd Functions-Footnote-1653475 -Node: Group Functions653563 -Ref: Group Functions-Footnote-1661494 -Node: Walking Arrays661707 -Node: Library Functions Summary663310 -Node: Library Exercises664698 -Node: Sample Programs665978 -Node: Running Examples666748 -Node: Clones667476 -Node: Cut Program668700 -Node: Egrep Program678558 -Ref: Egrep Program-Footnote-1686145 -Node: Id Program686255 -Node: Split Program689909 -Ref: Split Program-Footnote-1693447 -Node: Tee Program693575 -Node: Uniq Program696362 -Node: Wc Program703785 -Ref: Wc Program-Footnote-1708050 -Node: Miscellaneous Programs708142 -Node: Dupword Program709355 -Node: Alarm Program711386 -Node: Translate Program716190 -Ref: Translate Program-Footnote-1720763 -Ref: Translate Program-Footnote-2721033 -Node: Labels Program721172 -Ref: Labels Program-Footnote-1724533 -Node: Word Sorting724617 -Node: History Sorting728660 -Node: Extract Program730496 -Node: Simple Sed738032 -Node: Igawk Program741094 -Ref: Igawk Program-Footnote-1755398 -Ref: Igawk Program-Footnote-2755599 -Node: Anagram Program755737 -Node: Signature Program758805 -Node: Programs Summary760052 -Node: Programs Exercises761267 -Ref: Programs Exercises-Footnote-1765398 -Node: Advanced Features765489 -Node: Nondecimal Data767437 -Node: Array Sorting769014 -Node: Controlling Array Traversal769711 -Node: Array Sorting Functions777991 -Ref: Array Sorting Functions-Footnote-1781898 -Node: Two-way I/O782092 -Ref: Two-way I/O-Footnote-1787036 -Ref: Two-way I/O-Footnote-2787215 -Node: TCP/IP Networking787297 -Node: Profiling790139 -Node: Advanced Features Summary797690 -Node: Internationalization799554 -Node: I18N and L10N801034 -Node: Explaining gettext801720 -Ref: Explaining gettext-Footnote-1806746 -Ref: Explaining gettext-Footnote-2806930 -Node: Programmer i18n807095 -Ref: Programmer i18n-Footnote-1811889 -Node: Translator i18n811938 -Node: String Extraction812732 -Ref: String Extraction-Footnote-1813865 -Node: Printf Ordering813951 -Ref: Printf Ordering-Footnote-1816733 -Node: I18N Portability816797 -Ref: I18N Portability-Footnote-1819246 -Node: I18N Example819309 -Ref: I18N Example-Footnote-1822015 -Node: Gawk I18N822087 -Node: I18N Summary822725 -Node: Debugger824064 -Node: Debugging825086 -Node: Debugging Concepts825527 -Node: Debugging Terms827383 -Node: Awk Debugging829980 -Node: Sample Debugging Session830872 -Node: Debugger Invocation831392 -Node: Finding The Bug832728 -Node: List of Debugger Commands839207 -Node: Breakpoint Control840539 -Node: Debugger Execution Control844203 -Node: Viewing And Changing Data847563 -Node: Execution Stack850921 -Node: Debugger Info852434 -Node: Miscellaneous Debugger Commands856428 -Node: Readline Support861612 -Node: Limitations862504 -Node: Debugging Summary864777 -Node: Arbitrary Precision Arithmetic865945 -Node: Computer Arithmetic867432 -Ref: Computer Arithmetic-Footnote-1871819 -Node: Math Definitions871876 -Ref: table-ieee-formats875165 -Ref: Math Definitions-Footnote-1875705 -Node: MPFR features875808 -Node: FP Math Caution877425 -Ref: FP Math Caution-Footnote-1878475 -Node: Inexactness of computations878844 -Node: Inexact representation879792 -Node: Comparing FP Values881147 -Node: Errors accumulate882111 -Node: Getting Accuracy883544 -Node: Try To Round886203 -Node: Setting precision887102 -Ref: table-predefined-precision-strings887784 -Node: Setting the rounding mode889577 -Ref: table-gawk-rounding-modes889941 -Ref: Setting the rounding mode-Footnote-1893395 -Node: Arbitrary Precision Integers893574 -Ref: Arbitrary Precision Integers-Footnote-1897347 -Node: POSIX Floating Point Problems897496 -Ref: POSIX Floating Point Problems-Footnote-1901372 -Node: Floating point summary901410 -Node: Dynamic Extensions903614 -Node: Extension Intro905166 -Node: Plugin License906431 -Node: Extension Mechanism Outline907116 -Ref: figure-load-extension907540 -Ref: figure-load-new-function909025 -Ref: figure-call-new-function910027 -Node: Extension API Description912011 -Node: Extension API Functions Introduction913461 -Node: General Data Types918328 -Ref: General Data Types-Footnote-1924021 -Node: Requesting Values924320 -Ref: table-value-types-returned925057 -Node: Memory Allocation Functions926015 -Ref: Memory Allocation Functions-Footnote-1928762 -Node: Constructor Functions928858 -Node: Registration Functions930616 -Node: Extension Functions931301 -Node: Exit Callback Functions933603 -Node: Extension Version String934851 -Node: Input Parsers935501 -Node: Output Wrappers945315 -Node: Two-way processors949831 -Node: Printing Messages952035 -Ref: Printing Messages-Footnote-1953112 -Node: Updating `ERRNO'953264 -Node: Accessing Parameters954003 -Node: Symbol Table Access955233 -Node: Symbol table by name955747 -Node: Symbol table by cookie957723 -Ref: Symbol table by cookie-Footnote-1961856 -Node: Cached values961919 -Ref: Cached values-Footnote-1965423 -Node: Array Manipulation965514 -Ref: Array Manipulation-Footnote-1966612 -Node: Array Data Types966651 -Ref: Array Data Types-Footnote-1969354 -Node: Array Functions969446 -Node: Flattening Arrays973320 -Node: Creating Arrays980172 -Node: Extension API Variables984903 -Node: Extension Versioning985539 -Node: Extension API Informational Variables987440 -Node: Extension API Boilerplate988526 -Node: Finding Extensions992330 -Node: Extension Example992890 -Node: Internal File Description993620 -Node: Internal File Ops997711 -Ref: Internal File Ops-Footnote-11009143 -Node: Using Internal File Ops1009283 -Ref: Using Internal File Ops-Footnote-11011630 -Node: Extension Samples1011898 -Node: Extension Sample File Functions1013422 -Node: Extension Sample Fnmatch1020990 -Node: Extension Sample Fork1022472 -Node: Extension Sample Inplace1023685 -Node: Extension Sample Ord1025360 -Node: Extension Sample Readdir1026196 -Ref: table-readdir-file-types1027052 -Node: Extension Sample Revout1027851 -Node: Extension Sample Rev2way1028442 -Node: Extension Sample Read write array1029183 -Node: Extension Sample Readfile1031062 -Node: Extension Sample API Tests1032162 -Node: Extension Sample Time1032687 -Node: gawkextlib1034002 -Node: Extension summary1036815 -Node: Extension Exercises1040508 -Node: Language History1041230 -Node: V7/SVR3.11042873 -Node: SVR41045193 -Node: POSIX1046635 -Node: BTL1048021 -Node: POSIX/GNU1048755 -Node: Feature History1054531 -Node: Common Extensions1067622 -Node: Ranges and Locales1068934 -Ref: Ranges and Locales-Footnote-11073551 -Ref: Ranges and Locales-Footnote-21073578 -Ref: Ranges and Locales-Footnote-31073812 -Node: Contributors1074033 -Node: History summary1079458 -Node: Installation1080827 -Node: Gawk Distribution1081778 -Node: Getting1082262 -Node: Extracting1083086 -Node: Distribution contents1084728 -Node: Unix Installation1090498 -Node: Quick Installation1091115 -Node: Additional Configuration Options1093557 -Node: Configuration Philosophy1095295 -Node: Non-Unix Installation1097646 -Node: PC Installation1098104 -Node: PC Binary Installation1099415 -Node: PC Compiling1101263 -Ref: PC Compiling-Footnote-11104262 -Node: PC Testing1104367 -Node: PC Using1105543 -Node: Cygwin1109695 -Node: MSYS1110504 -Node: VMS Installation1111018 -Node: VMS Compilation1111814 -Ref: VMS Compilation-Footnote-11113036 -Node: VMS Dynamic Extensions1113094 -Node: VMS Installation Details1114467 -Node: VMS Running1116719 -Node: VMS GNV1119553 -Node: VMS Old Gawk1120276 -Node: Bugs1120746 -Node: Other Versions1124750 -Node: Installation summary1130974 -Node: Notes1132030 -Node: Compatibility Mode1132895 -Node: Additions1133677 -Node: Accessing The Source1134602 -Node: Adding Code1136038 -Node: New Ports1142216 -Node: Derived Files1146697 -Ref: Derived Files-Footnote-11152172 -Ref: Derived Files-Footnote-21152206 -Ref: Derived Files-Footnote-31152802 -Node: Future Extensions1152916 -Node: Implementation Limitations1153522 -Node: Extension Design1154770 -Node: Old Extension Problems1155924 -Ref: Old Extension Problems-Footnote-11157441 -Node: Extension New Mechanism Goals1157498 -Ref: Extension New Mechanism Goals-Footnote-11160858 -Node: Extension Other Design Decisions1161047 -Node: Extension Future Growth1163153 -Node: Old Extension Mechanism1163989 -Node: Notes summary1165751 -Node: Basic Concepts1166937 -Node: Basic High Level1167618 -Ref: figure-general-flow1167890 -Ref: figure-process-flow1168489 -Ref: Basic High Level-Footnote-11171718 -Node: Basic Data Typing1171903 -Node: Glossary1175231 -Node: Copying1200383 -Node: GNU Free Documentation License1237939 -Node: Index1263075 +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 End Tag Table |