diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ChangeLog | 22 | ||||
-rw-r--r-- | doc/gawk.1 | 47 | ||||
-rw-r--r-- | doc/gawk.info | 1346 | ||||
-rw-r--r-- | doc/gawk.texi | 128 | ||||
-rw-r--r-- | doc/gawktexi.in | 128 |
5 files changed, 1058 insertions, 613 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index c5ec8e50..679e1bea 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,6 +2,9 @@ * gawktexi.in: Minor fixes from Antonio Colombo and new exercise in chapter 16. + * gawk.1: Minor edits. + * gawktexi.in: Edits in material on errno and retryable and get_file + API. 2015-03-17 Andrew J. Schorr <aschorr@telemetry-investments.com> @@ -143,6 +146,25 @@ * gawktexi.in: Add info that nonfatal I/O works with stdout and stderr. Revise version info and what was added when. +2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in: Improve get_file documentation. + +2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in: Replace "Retrying I/O" with "Retrying Input", since this + feature pertains to input, not output. + +2015-01-04 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in: Document the get_file API function. + +2015-01-04 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawk.1: Document new features PROCINFO["errno"] and + PROCINFO["input", "RETRY"], and new getline return value of -2. + * gawktexi.in: Ditto. + 2014-12-26 Antonio Giovanni Colombo <azc100@gmail.com> * gawktexi.in (Glossary): Really sort the items. @@ -13,7 +13,7 @@ . if \w'\(rq' .ds rq "\(rq . \} .\} -.TH GAWK 1 "Aug 03 2014" "Free Software Foundation" "Utility Commands" +.TH GAWK 1 "Mar 24 2015" "Free Software Foundation" "Utility Commands" .SH NAME gawk \- pattern scanning and processing language .SH SYNOPSIS @@ -942,6 +942,15 @@ then will contain a string describing the error. The value is subject to translation in non-English locales. +If the string in +.B ERRNO +corresponds to a system error in the +.IR errno (3) +variable, then the numeric value can be found in +.B PROCINFO["errno"]. +For non-system errors, +.B PROCINFO["errno"] +will be zero. .TP .B FIELDWIDTHS A whitespace separated list of field widths. When set, @@ -1103,6 +1112,13 @@ system call. The default time format string for .BR strftime() . .TP +\fBPROCINFO["errno"]\fP +The value of +.IR errno (3) +when +.BR ERRNO +is set to the associated error message. +.TP \fBPROCINFO["euid"]\fP The value of the .IR geteuid (2) @@ -1221,6 +1237,28 @@ where is a redirection string or a filename. A value of zero or less than zero means no timeout. .TP +\fBPROCINFO["input", "RETRY"]\fP +If an I/O error that may be retried occurs when reading data from +.IR input , +and this array entry exists, then +.B getline +will return \-2 instead of following the default behavior of returning \-1 +and configuring +.IR input +to return no further data. +An I/O error that may be retried is one where +.IR errno (3) +has the value +.IR EAGAIN , +.IR EWOULDBLOCK , +.IR EINTR , +or +.IR ETIMEDOUT . +This may be useful in conjunction with +\fBPROCINFO["input", "READ_TIMEOUT"]\fP +or situations where a file descriptor has been configured to behave in a +non-blocking fashion. +.TP \fBPROCINFO["mpfr_version"]\fP The version of the GNU MPFR library used for arbitrary precision number support in @@ -2289,6 +2327,13 @@ below.) The .B getline command returns 1 on success, 0 on end of file, and \-1 on an error. +If the +.IR errno (3) +value indicates that the I/O operation may be retried, +and \fBPROCINFO["input", "RETRY"]\fP +is set, then \-2 will be returned instead of \-1, and further calls to +.B getline +may be attempted. Upon an error, .B ERRNO is set to a string describing the problem. diff --git a/doc/gawk.info b/doc/gawk.info index b2b5bb44..6b107344 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -217,6 +217,7 @@ entitled "GNU Free Documentation License". `getline'. * Getline Summary:: Summary of `getline' Variants. * Read Timeout:: Reading input with a timeout. +* Retrying Input:: Retrying input after certain errors. * Command-line directories:: What happens if you put a directory on the command line. * Input Summary:: Input summary. @@ -558,6 +559,7 @@ entitled "GNU Free Documentation License". * Array Functions:: Functions for working with arrays. * Flattening Arrays:: How to flatten arrays. * Creating Arrays:: How to create and populate arrays. +* Redirection API:: How to access and manipulate redirections. * Extension API Variables:: Variables provided by the API. * Extension Versioning:: API Version information. * Extension API Informational Variables:: Variables providing information about @@ -4178,6 +4180,7 @@ have to be named on the `awk' command line (*note Getline::). * Getline:: Reading files under explicit program control using the `getline' function. * Read Timeout:: Reading input with a timeout. +* Retrying Input:: Retrying input after certain errors. * Command-line directories:: What happens if you put a directory on the command line. * Input Summary:: Input summary. @@ -5448,7 +5451,11 @@ how `awk' works. encounters the end of the file. If there is some error in getting a record, such as a file that cannot be opened, then `getline' returns -1. In this case, `gawk' sets the variable `ERRNO' to a string -describing the error that occurred. +describing the error that occurred. If `ERRNO' indicates that the I/O +operation may be retried, and `PROCINFO["input", "RETRY"]' is set, then +-2 will be returned instead of -1, and further calls to `getline' may +be attemped. *Note Retrying Input::, for further information about +this feature. In the following examples, COMMAND stands for a string value that represents a shell command. @@ -5886,7 +5893,7 @@ VAR Table 4.1: `getline' variants and what they set -File: gawk.info, Node: Read Timeout, Next: Command-line directories, Prev: Getline, Up: Reading Files +File: gawk.info, Node: Read Timeout, Next: Retrying Input, Prev: Getline, Up: Reading Files 4.10 Reading Input with a Timeout ================================= @@ -5965,7 +5972,8 @@ a per-command or per-connection basis. `gawk' considers a timeout event to be an error even though the attempt to read from the underlying device may succeed in a later attempt. This is a limitation, and it also means that you cannot use -this to multiplex input from two or more sources. +this to multiplex input from two or more sources. *Note Retrying +Input::, for a way to enable later I/O attempts to succeed. Assigning a timeout value prevents read operations from blocking indefinitely. But bear in mind that there are other ways `gawk' can @@ -5980,9 +5988,36 @@ writing. (1) This assumes that standard input is the keyboard. -File: gawk.info, Node: Command-line directories, Next: Input Summary, Prev: Read Timeout, Up: Reading Files +File: gawk.info, Node: Retrying Input, Next: Command-line directories, Prev: Read Timeout, Up: Reading Files -4.11 Directories on the Command Line +4.11 Retrying Reads After Certain Input Errors +============================================== + +This minor node describes a feature that is specific to `gawk'. + + When `gawk' encounters an error while reading input, by default +`getline' returns -1, and subsequent attempts to read from that file +result in an end-of-file indication. However, you may optionally +instruct `gawk' to allow I/O to be retried when certain errors are +encountered by setting setting a special element in the `PROCINFO' +array (*note Auto-set::): + + PROCINFO["INPUT_NAME", "RETRY"] = 1 + + When this element exists, `gawk' checks the value of the system +`errno' variable when an I/O error occurs. If `errno' indicates a +subsequent I/O attempt may succeed, `getline' instead returns -2 and +further calls to `getline' may succeed. This applies to `errno' values +`EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'. + + This feature is useful in conjunction with `PROCINFO["INPUT_NAME", +"READ_TIMEOUT"]' or situations where a file descriptor has been +configured to behave in a non-blocking fashion. + + +File: gawk.info, Node: Command-line directories, Next: Input Summary, Prev: Retrying Input, Up: Reading Files + +4.12 Directories on the Command Line ==================================== According to the POSIX standard, files named on the `awk' command line @@ -6005,7 +6040,7 @@ usable data from an `awk' program. File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-line directories, Up: Reading Files -4.12 Summary +4.13 Summary ============ * Input is split into records based on the value of `RS'. The @@ -6079,7 +6114,7 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li File: gawk.info, Node: Input Exercises, Prev: Input Summary, Up: Reading Files -4.13 Exercises +4.14 Exercises ============== 1. Using the `FIELDWIDTHS' variable (*note Constant Size::), write a @@ -10440,6 +10475,11 @@ Options::), they are not special: `getline' returning -1. You are, of course, free to clear it yourself before doing an I/O operation. + If the value of `ERRNO' corresponds to a system error in the C + `errno' variable, then `PROCINFO["errno"]' will be set to the value + of `errno'. For non-system errors, `PROCINFO["errno"]' will be + zero. + `FILENAME' The name of the current input file. When no data files are listed on the command line, `awk' reads from the standard input and @@ -10488,6 +10528,10 @@ Options::), they are not special: `PROCINFO["egid"]' The value of the `getegid()' system call. + `PROCINFO["errno"]' + The value of the C `errno' variable when `ERRNO' is set to + the associated error message. + `PROCINFO["euid"]' The value of the `geteuid()' system call. @@ -10598,6 +10642,10 @@ Options::), they are not special: open input file, pipe, or coprocess. *Note Read Timeout::, for more information. + * It may be used to indicate that input may be retried when it + fails due to certain errors. *Note Retrying Input::, 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::. @@ -22973,6 +23021,7 @@ describes the API in detail. * Symbol Table Access:: Functions for accessing global variables. * Array Manipulation:: Functions for working with arrays. +* Redirection API:: How to access and manipulate redirections. * Extension API Variables:: Variables provided by the API. * Extension API Boilerplate:: Boilerplate code for using the API. @@ -23033,6 +23082,9 @@ operations: - Flattening an array for easy C-style looping over all its indices and elements + * Accessing and manipulating redirections. + + Some points about using the API: * The following types, macros, and/or functions are referenced in @@ -24244,7 +24296,7 @@ using `release_value()'. `double' to store. -File: gawk.info, Node: Array Manipulation, Next: Extension API Variables, Prev: Symbol Table Access, Up: Extension API Description +File: gawk.info, Node: Array Manipulation, Next: Redirection API, Prev: Symbol Table Access, Up: Extension API Description 16.4.11 Array Manipulation -------------------------- @@ -24729,9 +24781,78 @@ array: environment variable.) -File: gawk.info, Node: Extension API Variables, Next: Extension API Boilerplate, Prev: Array Manipulation, Up: Extension API Description +File: gawk.info, Node: Redirection API, Next: Extension API Variables, Prev: Array Manipulation, Up: Extension API Description + +16.4.12 Accessing and Manipulating Redirections +----------------------------------------------- -16.4.12 API Variables +The following function allows extensions to access and manipulate +redirections. + +`awk_bool_t get_file(const char *name,' +` size_t name_len,' +` const char *filetype,' +` int fd,' +` const awk_input_buf_t **ibufp,' +` const awk_output_buf_t **obufp);' + Look up a file in `gawk''s internal redirection table. If `name' + is `NULL' or `name_len' is zero, return data for the currently + open input file corresponding to `FILENAME'. (This does not + access the `filetype' argument, so that may be undefined). If the + file is not already open, attempt to open it. The `filetype' + argument must be zero-terminated and should be one of: + + `">"' + A file opened for output. + + `">>"' + A file opened for append. + + `"<"' + A file opened for input. + + `"|>"' + A pipe opened for output. + + `"|<"' + A pipe opened for input. + + `"|&"' + A two-way coprocess. + + On error, return a `false' value. Otherwise, return `true', and + return additional information about the redirection in the `ibufp' + and `obufp' pointers. For input redirections, the `*ibufp' value + should be non-`NULL', and `*obufp' should be `NULL'. For output + redirections, the `*obufp' value should be non-`NULL', and `*ibufp' + should be `NULL'. For two-way coprocesses, both values should be + non-`NULL'. + + In the usual case, the extension is interested in `(*ibufp)->fd' + and/or `fileno((*obufp)->fp)'. If the file is not already open, + and the `fd' argument is non-negative, `gawk' will use that file + descriptor instead of opening the file in the usual way. If `fd' + is non-negative, but the file exists already, `gawk' ignores `fd' + and returns the existing file. It is the caller's responsibility + to notice that neither the `fd' in the returned `awk_input_buf_t' + nor the `fd' in the returned `awk_output_buf_t' matches the + requested value. + + Note that supplying a file descriptor is currently _not_ supported + for pipes. However, supplying a file descriptor should work for + input, output, append, and two-way (coprocess) sockets. If + `filetype' is two-way, `gawk' assumes that it is a socket! Note + that in the two-way case, the input and output file descriptors + may differ. To check for success, you must check whether either + matches. + + It is anticipated that this API function will be used to implement +I/O multiplexing and a socket library. + + +File: gawk.info, Node: Extension API Variables, Next: Extension API Boilerplate, Prev: Redirection API, Up: Extension API Description + +16.4.13 API Variables --------------------- The API provides two sets of variables. The first provides information @@ -24748,7 +24869,7 @@ information about how `gawk' was invoked. File: gawk.info, Node: Extension Versioning, Next: Extension API Informational Variables, Up: Extension API Variables -16.4.12.1 API Version Constants and Variables +16.4.13.1 API Version Constants and Variables ............................................. The API provides both a "major" and a "minor" version number. The API @@ -24797,7 +24918,7 @@ Boilerplate::). File: gawk.info, Node: Extension API Informational Variables, Prev: Extension Versioning, Up: Extension API Variables -16.4.12.2 Informational Variables +16.4.13.2 Informational Variables ................................. The API provides access to several variables that describe whether the @@ -24832,7 +24953,7 @@ not change during execution. File: gawk.info, Node: Extension API Boilerplate, Prev: Extension API Variables, Up: Extension API Description -16.4.13 Boilerplate Code +16.4.14 Boilerplate Code ------------------------ As mentioned earlier (*note Extension Mechanism Outline::), the function @@ -32554,9 +32675,9 @@ Index (line 143) * dark corner, exit statement: Exit Statement. (line 30) * dark corner, field separators: Full Line Fields. (line 22) -* dark corner, FILENAME variable <1>: Auto-set. (line 104) +* dark corner, FILENAME variable <1>: Auto-set. (line 109) * dark corner, FILENAME variable: Getline Notes. (line 19) -* dark corner, FNR/NR variables: Auto-set. (line 328) +* dark corner, FNR/NR variables: Auto-set. (line 341) * dark corner, format-control characters: Control Letters. (line 18) * dark corner, FS as null string: Single Character Fields. (line 20) @@ -32750,7 +32871,7 @@ Index * differences in awk and gawk, FIELDWIDTHS variable: User-modified. (line 37) * differences in awk and gawk, FPAT variable: User-modified. (line 43) -* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 130) +* differences in awk and gawk, FUNCTAB variable: Auto-set. (line 135) * differences in awk and gawk, function arguments (gawk): Calling Built-in. (line 16) * differences in awk and gawk, getline command: Getline. (line 19) @@ -32773,7 +32894,7 @@ Index (line 263) * differences in awk and gawk, print/printf statements: Format Modifiers. (line 13) -* differences in awk and gawk, PROCINFO array: Auto-set. (line 144) +* differences in awk and gawk, PROCINFO array: Auto-set. (line 149) * differences in awk and gawk, read timeouts: Read Timeout. (line 6) * differences in awk and gawk, record separators: awk split records. (line 125) @@ -32781,9 +32902,11 @@ Index (line 43) * differences in awk and gawk, regular expressions: Case-sensitivity. (line 26) +* differences in awk and gawk, retrying input: Retrying Input. + (line 6) * differences in awk and gawk, RS/RT variables: gawk split records. (line 58) -* differences in awk and gawk, RT variable: Auto-set. (line 279) +* differences in awk and gawk, RT variable: Auto-set. (line 292) * differences in awk and gawk, single-character fields: Single Character Fields. (line 6) * differences in awk and gawk, split() function: String Functions. @@ -32791,7 +32914,7 @@ Index * 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 283) +* differences in awk and gawk, SYMTAB variable: Auto-set. (line 296) * differences in awk and gawk, TEXTDOMAIN variable: User-modified. (line 151) * differences in awk and gawk, trunc-mod operation: Arithmetic Ops. @@ -32832,8 +32955,8 @@ Index * dynamically loaded extensions: Dynamic Extensions. (line 6) * e debugger command (alias for enable): Breakpoint Control. (line 73) * EBCDIC: Ordinal Functions. (line 45) -* effective group ID of gawk user: Auto-set. (line 149) -* effective user ID of gawk user: Auto-set. (line 153) +* effective group ID of gawk user: Auto-set. (line 154) +* effective user ID of gawk user: Auto-set. (line 162) * egrep utility <1>: Egrep Program. (line 6) * egrep utility: Bracket Expressions. (line 26) * egrep.awk program: Egrep Program. (line 54) @@ -32948,7 +33071,7 @@ Index (line 6) * extension API version: Extension Versioning. (line 6) -* extension API, version number: Auto-set. (line 246) +* extension API, version number: Auto-set. (line 255) * extension example: Extension Example. (line 6) * extension registration: Registration Functions. (line 6) @@ -33029,7 +33152,7 @@ Index * 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 48) -* FILENAME variable <1>: Auto-set. (line 104) +* FILENAME variable <1>: Auto-set. (line 109) * FILENAME variable: Reading Files. (line 6) * FILENAME variable, getline, setting with: Getline Notes. (line 19) * filenames, assignments as: Ignoring Assigns. (line 6) @@ -33097,9 +33220,9 @@ Index * flush buffered output: I/O Functions. (line 28) * fnmatch() extension function: Extension Sample Fnmatch. (line 12) -* FNR variable <1>: Auto-set. (line 114) +* FNR variable <1>: Auto-set. (line 119) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 328) +* FNR variable, changing: Auto-set. (line 341) * for statement: For Statement. (line 6) * for statement, looping over arrays: Scanning an Array. (line 20) * fork() extension function: Extension Sample Fork. @@ -33149,7 +33272,7 @@ Index * FSF (Free Software Foundation): Manual History. (line 6) * fts() extension function: Extension Sample File Functions. (line 61) -* FUNCTAB array: Auto-set. (line 130) +* FUNCTAB array: Auto-set. (line 135) * function calls: Function Calls. (line 6) * function calls, indirect: Indirect Calls. (line 6) * function calls, indirect, @-notation for: Indirect Calls. (line 47) @@ -33199,7 +33322,7 @@ Index * G-d: Acknowledgments. (line 94) * Garfinkle, Scott: Contributors. (line 34) * gawk program, dynamic profiling: Profiling. (line 178) -* gawk version: Auto-set. (line 221) +* gawk version: Auto-set. (line 230) * gawk, ARGIND variable in: Other Arguments. (line 15) * gawk, awk and <1>: This Manual. (line 14) * gawk, awk and: Preface. (line 21) @@ -33234,7 +33357,7 @@ Index * gawk, FPAT variable in <1>: User-modified. (line 43) * gawk, FPAT variable in: Splitting By Content. (line 25) -* gawk, FUNCTAB array in: Auto-set. (line 130) +* gawk, FUNCTAB array in: Auto-set. (line 135) * gawk, function arguments and: Calling Built-in. (line 16) * gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42) * gawk, IGNORECASE variable in <1>: Array Sorting Functions. @@ -33266,7 +33389,7 @@ Index * gawk, predefined variables and: Built-in Variables. (line 14) * gawk, PROCINFO array in <1>: Two-way I/O. (line 99) * gawk, PROCINFO array in <2>: Time Functions. (line 47) -* gawk, PROCINFO array in: Auto-set. (line 144) +* gawk, PROCINFO array in: Auto-set. (line 149) * gawk, regexp constants and: Using Constant Regexps. (line 28) * gawk, regular expressions, case sensitivity: Case-sensitivity. @@ -33274,14 +33397,14 @@ Index * gawk, regular expressions, operators: GNU Regexp Operators. (line 6) * gawk, regular expressions, precedence: Regexp Operators. (line 161) -* gawk, RT variable in <1>: Auto-set. (line 279) +* gawk, RT variable in <1>: Auto-set. (line 292) * gawk, RT variable in <2>: Multiple Line. (line 129) * gawk, RT variable in: awk split records. (line 125) * gawk, See Also awk: Preface. (line 34) * gawk, source code, obtaining: Getting. (line 6) * gawk, splitting fields and: Constant Size. (line 87) * gawk, string-translation functions: I18N Functions. (line 6) -* gawk, SYMTAB array in: Auto-set. (line 283) +* gawk, SYMTAB array in: Auto-set. (line 296) * gawk, TEXTDOMAIN variable in: User-modified. (line 151) * gawk, timestamps: Time Functions. (line 6) * gawk, uses for: Preface. (line 34) @@ -33373,7 +33496,7 @@ Index * Grigera, Juan: Contributors. (line 57) * group database, reading: Group Functions. (line 6) * group file: Group Functions. (line 6) -* group ID of gawk user: Auto-set. (line 194) +* group ID of gawk user: Auto-set. (line 203) * groups, information about: Group Functions. (line 6) * gsub <1>: String Functions. (line 140) * gsub: Using Constant Regexps. @@ -33668,7 +33791,7 @@ Index * mawk utility <3>: Concatenation. (line 36) * mawk utility <4>: Getline/Pipe. (line 62) * mawk utility: Escape Sequences. (line 120) -* maximum precision supported by MPFR library: Auto-set. (line 235) +* maximum precision supported by MPFR library: Auto-set. (line 244) * McIlroy, Doug: Glossary. (line 258) * McPhee, Patrick: Contributors. (line 100) * message object files: Explaining gettext. (line 42) @@ -33681,7 +33804,7 @@ Index * messages from extensions: Printing Messages. (line 6) * metacharacters in regular expressions: Regexp Operators. (line 6) * metacharacters, escape sequences for: Escape Sequences. (line 139) -* minimum precision required by MPFR library: Auto-set. (line 238) +* minimum precision required by MPFR library: Auto-set. (line 247) * mktime: Time Functions. (line 25) * modifiers, in format specifiers: Format Modifiers. (line 6) * monetary information, localization: Explaining gettext. (line 104) @@ -33730,7 +33853,7 @@ Index (line 47) * nexti debugger command: Debugger Execution Control. (line 49) -* NF variable <1>: Auto-set. (line 119) +* NF variable <1>: Auto-set. (line 124) * NF variable: Fields. (line 33) * NF variable, decrementing: Changing Fields. (line 107) * ni debugger command (alias for nexti): Debugger Execution Control. @@ -33739,9 +33862,9 @@ Index * non-existent array elements: Reference to Elements. (line 23) * not Boolean-logic operator: Boolean Ops. (line 6) -* NR variable <1>: Auto-set. (line 139) +* NR variable <1>: Auto-set. (line 144) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 328) +* NR variable, changing: Auto-set. (line 341) * null strings <1>: Basic Data Typing. (line 26) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. @@ -33855,7 +33978,7 @@ Index * p debugger command (alias for print): Viewing And Changing Data. (line 36) * Papadopoulos, Panos: Contributors. (line 128) -* parent process ID of gawk process: Auto-set. (line 203) +* parent process ID of gawk process: Auto-set. (line 212) * parentheses (), in a profile: Profiling. (line 146) * parentheses (), regexp operator: Regexp Operators. (line 81) * password file: Passwd Functions. (line 16) @@ -34021,24 +34144,24 @@ Index * printing, unduplicated lines of text: Uniq Program. (line 6) * printing, user information: Id Program. (line 6) * private variables: Library Names. (line 11) -* process group ID of gawk process: Auto-set. (line 197) -* process ID of gawk process: Auto-set. (line 200) +* process group ID of gawk process: Auto-set. (line 206) +* process ID of gawk process: Auto-set. (line 209) * processes, two-way communications with: Two-way I/O. (line 6) * processing data: Basic High Level. (line 6) * PROCINFO array <1>: Passwd Functions. (line 6) * PROCINFO array <2>: Time Functions. (line 47) -* PROCINFO array: Auto-set. (line 144) +* PROCINFO array: Auto-set. (line 149) * PROCINFO array, and communications via ptys: Two-way I/O. (line 99) * PROCINFO array, and group membership: Group Functions. (line 6) * PROCINFO array, and user and group ID numbers: Id Program. (line 15) * PROCINFO array, testing the field splitting: Passwd Functions. (line 154) -* PROCINFO array, uses: Auto-set. (line 256) +* PROCINFO array, uses: Auto-set. (line 265) * PROCINFO, values of sorted_in: Controlling Scanning. (line 26) * profiling awk programs: Profiling. (line 6) * profiling awk programs, dynamically: Profiling. (line 178) -* program identifiers: Auto-set. (line 162) +* program identifiers: Auto-set. (line 171) * program, definition of: Getting Started. (line 21) * programming conventions, --non-decimal-data option: Nondecimal Data. (line 35) @@ -34173,6 +34296,7 @@ Index * relational operators, See comparison operators: Typing and Comparison. (line 9) * replace in string: String Functions. (line 409) +* retrying input: Retrying Input. (line 6) * return debugger command: Debugger Execution Control. (line 54) * return statement, user-defined functions: Return Statement. (line 6) @@ -34196,7 +34320,7 @@ Index * right shift: Bitwise Functions. (line 53) * right shift, bitwise: Bitwise Functions. (line 32) * Ritchie, Dennis: Basic Data Typing. (line 54) -* RLENGTH variable: Auto-set. (line 266) +* RLENGTH variable: Auto-set. (line 279) * RLENGTH variable, match() function and: String Functions. (line 228) * Robbins, Arnold <1>: Future Extensions. (line 6) * Robbins, Arnold <2>: Bugs. (line 71) @@ -34222,9 +34346,9 @@ Index * RS variable: awk split records. (line 12) * RS variable, multiline records and: Multiple Line. (line 17) * rshift: Bitwise Functions. (line 53) -* RSTART variable: Auto-set. (line 272) +* RSTART variable: Auto-set. (line 285) * RSTART variable, match() function and: String Functions. (line 228) -* RT variable <1>: Auto-set. (line 279) +* RT variable <1>: Auto-set. (line 292) * RT variable <2>: Multiple Line. (line 129) * RT variable: awk split records. (line 125) * Rubin, Paul <1>: Contributors. (line 15) @@ -34244,7 +34368,7 @@ Index * scanning arrays: Scanning an Array. (line 6) * scanning multidimensional arrays: Multiscanning. (line 11) * Schorr, Andrew <1>: Contributors. (line 133) -* Schorr, Andrew <2>: Auto-set. (line 311) +* Schorr, Andrew <2>: Auto-set. (line 324) * Schorr, Andrew: Acknowledgments. (line 60) * Schreiber, Bert: Acknowledgments. (line 38) * Schreiber, Rita: Acknowledgments. (line 38) @@ -34327,7 +34451,7 @@ Index (line 106) * sidebar, Changing FS Does Not Affect the Fields: Full Line Fields. (line 14) -* sidebar, Changing NR and FNR: Auto-set. (line 326) +* sidebar, Changing NR and FNR: Auto-set. (line 339) * sidebar, Controlling Output Buffering with system(): I/O Functions. (line 139) * sidebar, Escape Sequences for Metacharacters: Escape Sequences. @@ -34489,9 +34613,9 @@ Index * substr: String Functions. (line 482) * substring: String Functions. (line 482) * Sumner, Andrew: Other Versions. (line 68) -* supplementary groups of gawk process: Auto-set. (line 251) +* supplementary groups of gawk process: Auto-set. (line 260) * switch statement: Switch Statement. (line 6) -* SYMTAB array: Auto-set. (line 283) +* SYMTAB array: Auto-set. (line 296) * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) * system: I/O Functions. (line 107) @@ -34668,10 +34792,10 @@ Index * variables, uninitialized, as array subscripts: Uninitialized Subscripts. (line 6) * variables, user-defined: Variables. (line 6) -* version of gawk: Auto-set. (line 221) -* version of gawk extension API: Auto-set. (line 246) -* version of GNU MP library: Auto-set. (line 232) -* version of GNU MPFR library: Auto-set. (line 228) +* version of gawk: Auto-set. (line 230) +* version of gawk extension API: Auto-set. (line 255) +* version of GNU MP library: Auto-set. (line 241) +* version of GNU MPFR library: Auto-set. (line 237) * vertical bar (|): Regexp Operators. (line 70) * vertical bar (|), | operator (I/O) <1>: Precedence. (line 65) * vertical bar (|), | operator (I/O): Getline/Pipe. (line 9) @@ -34761,561 +34885,563 @@ Index Tag Table: Node: Top1204 -Node: Foreword342291 -Node: Foreword446735 -Node: Preface48266 -Ref: Preface-Footnote-151137 -Ref: Preface-Footnote-251244 -Ref: Preface-Footnote-351477 -Node: History51619 -Node: Names53970 -Ref: Names-Footnote-155064 -Node: This Manual55210 -Ref: This Manual-Footnote-161710 -Node: Conventions61810 -Node: Manual History64147 -Ref: Manual History-Footnote-167140 -Ref: Manual History-Footnote-267181 -Node: How To Contribute67255 -Node: Acknowledgments68384 -Node: Getting Started73250 -Node: Running gawk75689 -Node: One-shot76879 -Node: Read Terminal78143 -Node: Long80174 -Node: Executable Scripts81687 -Ref: Executable Scripts-Footnote-184476 -Node: Comments84579 -Node: Quoting87061 -Node: DOS Quoting92579 -Node: Sample Data Files93254 -Node: Very Simple95849 -Node: Two Rules100748 -Node: More Complex102634 -Node: Statements/Lines105496 -Ref: Statements/Lines-Footnote-1109951 -Node: Other Features110216 -Node: When111152 -Ref: When-Footnote-1112906 -Node: Intro Summary112971 -Node: Invoking Gawk113855 -Node: Command Line115369 -Node: Options116167 -Ref: Options-Footnote-1131962 -Ref: Options-Footnote-2132191 -Node: Other Arguments132216 -Node: Naming Standard Input135164 -Node: Environment Variables136257 -Node: AWKPATH Variable136815 -Ref: AWKPATH Variable-Footnote-1140222 -Ref: AWKPATH Variable-Footnote-2140267 -Node: AWKLIBPATH Variable140527 -Node: Other Environment Variables141783 -Node: Exit Status145414 -Node: Include Files146090 -Node: Loading Shared Libraries149679 -Node: Obsolete151106 -Node: Undocumented151798 -Node: Invoking Summary152065 -Node: Regexp153728 -Node: Regexp Usage155182 -Node: Escape Sequences157219 -Node: Regexp Operators163448 -Ref: Regexp Operators-Footnote-1170858 -Ref: Regexp Operators-Footnote-2171005 -Node: Bracket Expressions171103 -Ref: table-char-classes173118 -Node: Leftmost Longest176060 -Node: Computed Regexps177362 -Node: GNU Regexp Operators180791 -Node: Case-sensitivity184463 -Ref: Case-sensitivity-Footnote-1187348 -Ref: Case-sensitivity-Footnote-2187583 -Node: Regexp Summary187691 -Node: Reading Files189158 -Node: Records191251 -Node: awk split records191984 -Node: gawk split records196913 -Ref: gawk split records-Footnote-1201452 -Node: Fields201489 -Ref: Fields-Footnote-1204267 -Node: Nonconstant Fields204353 -Ref: Nonconstant Fields-Footnote-1206591 -Node: Changing Fields206794 -Node: Field Separators212725 -Node: Default Field Splitting215429 -Node: Regexp Field Splitting216546 -Node: Single Character Fields219896 -Node: Command Line Field Separator220955 -Node: Full Line Fields224172 -Ref: Full Line Fields-Footnote-1225693 -Ref: Full Line Fields-Footnote-2225739 -Node: Field Splitting Summary225840 -Node: Constant Size227914 -Node: Splitting By Content232493 -Ref: Splitting By Content-Footnote-1236458 -Node: Multiple Line236621 -Ref: Multiple Line-Footnote-1242502 -Node: Getline242681 -Node: Plain Getline244888 -Node: Getline/Variable247528 -Node: Getline/File248677 -Node: Getline/Variable/File250062 -Ref: Getline/Variable/File-Footnote-1251665 -Node: Getline/Pipe251752 -Node: Getline/Variable/Pipe254430 -Node: Getline/Coprocess255561 -Node: Getline/Variable/Coprocess256825 -Node: Getline Notes257564 -Node: Getline Summary260358 -Ref: table-getline-variants260770 -Node: Read Timeout261599 -Ref: Read Timeout-Footnote-1265436 -Node: Command-line directories265494 -Node: Input Summary266399 -Node: Input Exercises269784 -Node: Printing270512 -Node: Print272347 -Node: Print Examples273804 -Node: Output Separators276583 -Node: OFMT278601 -Node: Printf279956 -Node: Basic Printf280741 -Node: Control Letters282313 -Node: Format Modifiers286298 -Node: Printf Examples292304 -Node: Redirection294790 -Node: Special FD301628 -Ref: Special FD-Footnote-1304794 -Node: Special Files304868 -Node: Other Inherited Files305485 -Node: Special Network306485 -Node: Special Caveats307347 -Node: Close Files And Pipes308296 -Ref: Close Files And Pipes-Footnote-1315481 -Ref: Close Files And Pipes-Footnote-2315629 -Node: Nonfatal315779 -Node: Output Summary318104 -Node: Output Exercises319325 -Node: Expressions320005 -Node: Values321194 -Node: Constants321871 -Node: Scalar Constants322562 -Ref: Scalar Constants-Footnote-1323424 -Node: Nondecimal-numbers323674 -Node: Regexp Constants326684 -Node: Using Constant Regexps327210 -Node: Variables330373 -Node: Using Variables331030 -Node: Assignment Options332941 -Node: Conversion334816 -Node: Strings And Numbers335340 -Ref: Strings And Numbers-Footnote-1338405 -Node: Locale influences conversions338514 -Ref: table-locale-affects341260 -Node: All Operators341852 -Node: Arithmetic Ops342481 -Node: Concatenation344986 -Ref: Concatenation-Footnote-1347805 -Node: Assignment Ops347912 -Ref: table-assign-ops352891 -Node: Increment Ops354201 -Node: Truth Values and Conditions357632 -Node: Truth Values358715 -Node: Typing and Comparison359764 -Node: Variable Typing360580 -Node: Comparison Operators364247 -Ref: table-relational-ops364657 -Node: POSIX String Comparison368152 -Ref: POSIX String Comparison-Footnote-1369224 -Node: Boolean Ops369363 -Ref: Boolean Ops-Footnote-1373841 -Node: Conditional Exp373932 -Node: Function Calls375670 -Node: Precedence379550 -Node: Locales383210 -Node: Expressions Summary384842 -Node: Patterns and Actions387413 -Node: Pattern Overview388533 -Node: Regexp Patterns390212 -Node: Expression Patterns390755 -Node: Ranges394535 -Node: BEGIN/END397642 -Node: Using BEGIN/END398403 -Ref: Using BEGIN/END-Footnote-1401139 -Node: I/O And BEGIN/END401245 -Node: BEGINFILE/ENDFILE403560 -Node: Empty406457 -Node: Using Shell Variables406774 -Node: Action Overview409047 -Node: Statements411373 -Node: If Statement413221 -Node: While Statement414716 -Node: Do Statement416744 -Node: For Statement417892 -Node: Switch Statement421050 -Node: Break Statement423432 -Node: Continue Statement425525 -Node: Next Statement427352 -Node: Nextfile Statement429733 -Node: Exit Statement432361 -Node: Built-in Variables434772 -Node: User-modified435905 -Ref: User-modified-Footnote-1443539 -Node: Auto-set443601 -Ref: Auto-set-Footnote-1457310 -Ref: Auto-set-Footnote-2457515 -Node: ARGC and ARGV457571 -Node: Pattern Action Summary461789 -Node: Arrays464222 -Node: Array Basics465551 -Node: Array Intro466395 -Ref: figure-array-elements468332 -Ref: Array Intro-Footnote-1470955 -Node: Reference to Elements471083 -Node: Assigning Elements473545 -Node: Array Example474036 -Node: Scanning an Array475795 -Node: Controlling Scanning478818 -Ref: Controlling Scanning-Footnote-1484212 -Node: Numeric Array Subscripts484528 -Node: Uninitialized Subscripts486713 -Node: Delete488330 -Ref: Delete-Footnote-1491079 -Node: Multidimensional491136 -Node: Multiscanning494233 -Node: Arrays of Arrays495822 -Node: Arrays Summary500576 -Node: Functions502667 -Node: Built-in503706 -Node: Calling Built-in504784 -Node: Numeric Functions506779 -Ref: Numeric Functions-Footnote-1511597 -Ref: Numeric Functions-Footnote-2511954 -Ref: Numeric Functions-Footnote-3512002 -Node: String Functions512274 -Ref: String Functions-Footnote-1535775 -Ref: String Functions-Footnote-2535904 -Ref: String Functions-Footnote-3536152 -Node: Gory Details536239 -Ref: table-sub-escapes538020 -Ref: table-sub-proposed539535 -Ref: table-posix-sub540897 -Ref: table-gensub-escapes542434 -Ref: Gory Details-Footnote-1543267 -Node: I/O Functions543418 -Ref: I/O Functions-Footnote-1550654 -Node: Time Functions550801 -Ref: Time Functions-Footnote-1561310 -Ref: Time Functions-Footnote-2561378 -Ref: Time Functions-Footnote-3561536 -Ref: Time Functions-Footnote-4561647 -Ref: Time Functions-Footnote-5561759 -Ref: Time Functions-Footnote-6561986 -Node: Bitwise Functions562252 -Ref: table-bitwise-ops562814 -Ref: Bitwise Functions-Footnote-1567142 -Node: Type Functions567314 -Node: I18N Functions568466 -Node: User-defined570113 -Node: Definition Syntax570918 -Ref: Definition Syntax-Footnote-1576577 -Node: Function Example576648 -Ref: Function Example-Footnote-1579569 -Node: Function Caveats579591 -Node: Calling A Function580109 -Node: Variable Scope581067 -Node: Pass By Value/Reference584060 -Node: Return Statement587557 -Node: Dynamic Typing590536 -Node: Indirect Calls591465 -Ref: Indirect Calls-Footnote-1601330 -Node: Functions Summary601458 -Node: Library Functions604160 -Ref: Library Functions-Footnote-1607768 -Ref: Library Functions-Footnote-2607911 -Node: Library Names608082 -Ref: Library Names-Footnote-1611540 -Ref: Library Names-Footnote-2611763 -Node: General Functions611849 -Node: Strtonum Function612952 -Node: Assert Function615974 -Node: Round Function619298 -Node: Cliff Random Function620839 -Node: Ordinal Functions621855 -Ref: Ordinal Functions-Footnote-1624918 -Ref: Ordinal Functions-Footnote-2625170 -Node: Join Function625381 -Ref: Join Function-Footnote-1627151 -Node: Getlocaltime Function627351 -Node: Readfile Function631095 -Node: Shell Quoting633067 -Node: Data File Management634468 -Node: Filetrans Function635100 -Node: Rewind Function639196 -Node: File Checking640582 -Ref: File Checking-Footnote-1641915 -Node: Empty Files642116 -Node: Ignoring Assigns644095 -Node: Getopt Function645645 -Ref: Getopt Function-Footnote-1657109 -Node: Passwd Functions657309 -Ref: Passwd Functions-Footnote-1666149 -Node: Group Functions666237 -Ref: Group Functions-Footnote-1674134 -Node: Walking Arrays674339 -Node: Library Functions Summary677345 -Node: Library Exercises678747 -Node: Sample Programs680027 -Node: Running Examples680797 -Node: Clones681525 -Node: Cut Program682749 -Node: Egrep Program692469 -Ref: Egrep Program-Footnote-1699972 -Node: Id Program700082 -Node: Split Program703758 -Ref: Split Program-Footnote-1707212 -Node: Tee Program707340 -Node: Uniq Program710129 -Node: Wc Program717548 -Ref: Wc Program-Footnote-1721798 -Node: Miscellaneous Programs721892 -Node: Dupword Program723105 -Node: Alarm Program725136 -Node: Translate Program729941 -Ref: Translate Program-Footnote-1734504 -Node: Labels Program734774 -Ref: Labels Program-Footnote-1738125 -Node: Word Sorting738209 -Node: History Sorting742279 -Node: Extract Program744114 -Node: Simple Sed751638 -Node: Igawk Program754708 -Ref: Igawk Program-Footnote-1769034 -Ref: Igawk Program-Footnote-2769235 -Ref: Igawk Program-Footnote-3769357 -Node: Anagram Program769472 -Node: Signature Program772533 -Node: Programs Summary773780 -Node: Programs Exercises775001 -Ref: Programs Exercises-Footnote-1779132 -Node: Advanced Features779223 -Node: Nondecimal Data781205 -Node: Array Sorting782795 -Node: Controlling Array Traversal783495 -Ref: Controlling Array Traversal-Footnote-1791861 -Node: Array Sorting Functions791979 -Ref: Array Sorting Functions-Footnote-1795865 -Node: Two-way I/O796061 -Ref: Two-way I/O-Footnote-1801006 -Ref: Two-way I/O-Footnote-2801192 -Node: TCP/IP Networking801274 -Node: Profiling804146 -Node: Advanced Features Summary812417 -Node: Internationalization814350 -Node: I18N and L10N815830 -Node: Explaining gettext816516 -Ref: Explaining gettext-Footnote-1821541 -Ref: Explaining gettext-Footnote-2821725 -Node: Programmer i18n821890 -Ref: Programmer i18n-Footnote-1826766 -Node: Translator i18n826815 -Node: String Extraction827609 -Ref: String Extraction-Footnote-1828740 -Node: Printf Ordering828826 -Ref: Printf Ordering-Footnote-1831612 -Node: I18N Portability831676 -Ref: I18N Portability-Footnote-1834132 -Node: I18N Example834195 -Ref: I18N Example-Footnote-1836998 -Node: Gawk I18N837070 -Node: I18N Summary837714 -Node: Debugger839054 -Node: Debugging840076 -Node: Debugging Concepts840517 -Node: Debugging Terms842327 -Node: Awk Debugging844899 -Node: Sample Debugging Session845805 -Node: Debugger Invocation846339 -Node: Finding The Bug847724 -Node: List of Debugger Commands854203 -Node: Breakpoint Control855535 -Node: Debugger Execution Control859212 -Node: Viewing And Changing Data862571 -Node: Execution Stack865947 -Node: Debugger Info867582 -Node: Miscellaneous Debugger Commands871627 -Node: Readline Support876628 -Node: Limitations877522 -Node: Debugging Summary879637 -Node: Arbitrary Precision Arithmetic880811 -Node: Computer Arithmetic882227 -Ref: table-numeric-ranges885804 -Ref: Computer Arithmetic-Footnote-1886328 -Node: Math Definitions886385 -Ref: table-ieee-formats889680 -Ref: Math Definitions-Footnote-1890284 -Node: MPFR features890389 -Node: FP Math Caution892060 -Ref: FP Math Caution-Footnote-1893110 -Node: Inexactness of computations893479 -Node: Inexact representation894438 -Node: Comparing FP Values895796 -Node: Errors accumulate896878 -Node: Getting Accuracy898310 -Node: Try To Round901014 -Node: Setting precision901913 -Ref: table-predefined-precision-strings902597 -Node: Setting the rounding mode904426 -Ref: table-gawk-rounding-modes904790 -Ref: Setting the rounding mode-Footnote-1908242 -Node: Arbitrary Precision Integers908421 -Ref: Arbitrary Precision Integers-Footnote-1913319 -Node: POSIX Floating Point Problems913468 -Ref: POSIX Floating Point Problems-Footnote-1917347 -Node: Floating point summary917385 -Node: Dynamic Extensions919572 -Node: Extension Intro921124 -Node: Plugin License922389 -Node: Extension Mechanism Outline923186 -Ref: figure-load-extension923614 -Ref: figure-register-new-function925094 -Ref: figure-call-new-function926098 -Node: Extension API Description928085 -Node: Extension API Functions Introduction929535 -Node: General Data Types934356 -Ref: General Data Types-Footnote-1940256 -Node: Memory Allocation Functions940555 -Ref: Memory Allocation Functions-Footnote-1943394 -Node: Constructor Functions943493 -Node: Registration Functions945232 -Node: Extension Functions945917 -Node: Exit Callback Functions948214 -Node: Extension Version String949462 -Node: Input Parsers950125 -Node: Output Wrappers960000 -Node: Two-way processors964513 -Node: Printing Messages966776 -Ref: Printing Messages-Footnote-1967852 -Node: Updating `ERRNO'968004 -Node: Requesting Values968744 -Ref: table-value-types-returned969471 -Node: Accessing Parameters970428 -Node: Symbol Table Access971662 -Node: Symbol table by name972176 -Node: Symbol table by cookie974196 -Ref: Symbol table by cookie-Footnote-1978341 -Node: Cached values978404 -Ref: Cached values-Footnote-1981900 -Node: Array Manipulation981991 -Ref: Array Manipulation-Footnote-1983089 -Node: Array Data Types983126 -Ref: Array Data Types-Footnote-1985781 -Node: Array Functions985873 -Node: Flattening Arrays989732 -Node: Creating Arrays996634 -Node: Extension API Variables1001405 -Node: Extension Versioning1002041 -Node: Extension API Informational Variables1003932 -Node: Extension API Boilerplate1004997 -Node: Finding Extensions1008806 -Node: Extension Example1009366 -Node: Internal File Description1010138 -Node: Internal File Ops1014205 -Ref: Internal File Ops-Footnote-11025956 -Node: Using Internal File Ops1026096 -Ref: Using Internal File Ops-Footnote-11028479 -Node: Extension Samples1028752 -Node: Extension Sample File Functions1030280 -Node: Extension Sample Fnmatch1037961 -Node: Extension Sample Fork1039449 -Node: Extension Sample Inplace1040664 -Node: Extension Sample Ord1042750 -Node: Extension Sample Readdir1043586 -Ref: table-readdir-file-types1044463 -Node: Extension Sample Revout1045274 -Node: Extension Sample Rev2way1045863 -Node: Extension Sample Read write array1046603 -Node: Extension Sample Readfile1048543 -Node: Extension Sample Time1049638 -Node: Extension Sample API Tests1050986 -Node: gawkextlib1051477 -Node: Extension summary1054155 -Node: Extension Exercises1057844 -Node: Language History1059340 -Node: V7/SVR3.11060996 -Node: SVR41063149 -Node: POSIX1064583 -Node: BTL1065964 -Node: POSIX/GNU1066695 -Node: Feature History1072531 -Node: Common Extensions1086325 -Node: Ranges and Locales1087697 -Ref: Ranges and Locales-Footnote-11092316 -Ref: Ranges and Locales-Footnote-21092343 -Ref: Ranges and Locales-Footnote-31092578 -Node: Contributors1092799 -Node: History summary1098339 -Node: Installation1099718 -Node: Gawk Distribution1100664 -Node: Getting1101148 -Node: Extracting1101971 -Node: Distribution contents1103608 -Node: Unix Installation1109710 -Node: Quick Installation1110393 -Node: Shell Startup Files1112804 -Node: Additional Configuration Options1113883 -Node: Configuration Philosophy1115687 -Node: Non-Unix Installation1118056 -Node: PC Installation1118514 -Node: PC Binary Installation1119834 -Node: PC Compiling1121682 -Ref: PC Compiling-Footnote-11124703 -Node: PC Testing1124812 -Node: PC Using1125988 -Node: Cygwin1130103 -Node: MSYS1130873 -Node: VMS Installation1131374 -Node: VMS Compilation1132166 -Ref: VMS Compilation-Footnote-11133395 -Node: VMS Dynamic Extensions1133453 -Node: VMS Installation Details1135137 -Node: VMS Running1137388 -Node: VMS GNV1140228 -Node: VMS Old Gawk1140963 -Node: Bugs1141433 -Node: Other Versions1145322 -Node: Installation summary1151756 -Node: Notes1152815 -Node: Compatibility Mode1153680 -Node: Additions1154462 -Node: Accessing The Source1155387 -Node: Adding Code1156822 -Node: New Ports1162979 -Node: Derived Files1167461 -Ref: Derived Files-Footnote-11172936 -Ref: Derived Files-Footnote-21172970 -Ref: Derived Files-Footnote-31173566 -Node: Future Extensions1173680 -Node: Implementation Limitations1174286 -Node: Extension Design1175534 -Node: Old Extension Problems1176688 -Ref: Old Extension Problems-Footnote-11178205 -Node: Extension New Mechanism Goals1178262 -Ref: Extension New Mechanism Goals-Footnote-11181622 -Node: Extension Other Design Decisions1181811 -Node: Extension Future Growth1183919 -Node: Old Extension Mechanism1184755 -Node: Notes summary1186517 -Node: Basic Concepts1187703 -Node: Basic High Level1188384 -Ref: figure-general-flow1188656 -Ref: figure-process-flow1189255 -Ref: Basic High Level-Footnote-11192484 -Node: Basic Data Typing1192669 -Node: Glossary1195997 -Node: Copying1227926 -Node: GNU Free Documentation License1265482 -Node: Index1290618 +Node: Foreword342451 +Node: Foreword446895 +Node: Preface48426 +Ref: Preface-Footnote-151297 +Ref: Preface-Footnote-251404 +Ref: Preface-Footnote-351637 +Node: History51779 +Node: Names54130 +Ref: Names-Footnote-155224 +Node: This Manual55370 +Ref: This Manual-Footnote-161870 +Node: Conventions61970 +Node: Manual History64307 +Ref: Manual History-Footnote-167300 +Ref: Manual History-Footnote-267341 +Node: How To Contribute67415 +Node: Acknowledgments68544 +Node: Getting Started73410 +Node: Running gawk75849 +Node: One-shot77039 +Node: Read Terminal78303 +Node: Long80334 +Node: Executable Scripts81847 +Ref: Executable Scripts-Footnote-184636 +Node: Comments84739 +Node: Quoting87221 +Node: DOS Quoting92739 +Node: Sample Data Files93414 +Node: Very Simple96009 +Node: Two Rules100908 +Node: More Complex102794 +Node: Statements/Lines105656 +Ref: Statements/Lines-Footnote-1110111 +Node: Other Features110376 +Node: When111312 +Ref: When-Footnote-1113066 +Node: Intro Summary113131 +Node: Invoking Gawk114015 +Node: Command Line115529 +Node: Options116327 +Ref: Options-Footnote-1132122 +Ref: Options-Footnote-2132351 +Node: Other Arguments132376 +Node: Naming Standard Input135324 +Node: Environment Variables136417 +Node: AWKPATH Variable136975 +Ref: AWKPATH Variable-Footnote-1140382 +Ref: AWKPATH Variable-Footnote-2140427 +Node: AWKLIBPATH Variable140687 +Node: Other Environment Variables141943 +Node: Exit Status145574 +Node: Include Files146250 +Node: Loading Shared Libraries149839 +Node: Obsolete151266 +Node: Undocumented151958 +Node: Invoking Summary152225 +Node: Regexp153888 +Node: Regexp Usage155342 +Node: Escape Sequences157379 +Node: Regexp Operators163608 +Ref: Regexp Operators-Footnote-1171018 +Ref: Regexp Operators-Footnote-2171165 +Node: Bracket Expressions171263 +Ref: table-char-classes173278 +Node: Leftmost Longest176220 +Node: Computed Regexps177522 +Node: GNU Regexp Operators180951 +Node: Case-sensitivity184623 +Ref: Case-sensitivity-Footnote-1187508 +Ref: Case-sensitivity-Footnote-2187743 +Node: Regexp Summary187851 +Node: Reading Files189318 +Node: Records191480 +Node: awk split records192213 +Node: gawk split records197142 +Ref: gawk split records-Footnote-1201681 +Node: Fields201718 +Ref: Fields-Footnote-1204496 +Node: Nonconstant Fields204582 +Ref: Nonconstant Fields-Footnote-1206820 +Node: Changing Fields207023 +Node: Field Separators212954 +Node: Default Field Splitting215658 +Node: Regexp Field Splitting216775 +Node: Single Character Fields220125 +Node: Command Line Field Separator221184 +Node: Full Line Fields224401 +Ref: Full Line Fields-Footnote-1225922 +Ref: Full Line Fields-Footnote-2225968 +Node: Field Splitting Summary226069 +Node: Constant Size228143 +Node: Splitting By Content232722 +Ref: Splitting By Content-Footnote-1236687 +Node: Multiple Line236850 +Ref: Multiple Line-Footnote-1242731 +Node: Getline242910 +Node: Plain Getline245376 +Node: Getline/Variable248016 +Node: Getline/File249165 +Node: Getline/Variable/File250550 +Ref: Getline/Variable/File-Footnote-1252153 +Node: Getline/Pipe252240 +Node: Getline/Variable/Pipe254918 +Node: Getline/Coprocess256049 +Node: Getline/Variable/Coprocess257313 +Node: Getline Notes258052 +Node: Getline Summary260846 +Ref: table-getline-variants261258 +Node: Read Timeout262087 +Ref: Read Timeout-Footnote-1265990 +Node: Retrying Input266048 +Node: Command-line directories267238 +Node: Input Summary268145 +Node: Input Exercises271530 +Node: Printing272258 +Node: Print274093 +Node: Print Examples275550 +Node: Output Separators278329 +Node: OFMT280347 +Node: Printf281702 +Node: Basic Printf282487 +Node: Control Letters284059 +Node: Format Modifiers288044 +Node: Printf Examples294050 +Node: Redirection296536 +Node: Special FD303374 +Ref: Special FD-Footnote-1306540 +Node: Special Files306614 +Node: Other Inherited Files307231 +Node: Special Network308231 +Node: Special Caveats309093 +Node: Close Files And Pipes310042 +Ref: Close Files And Pipes-Footnote-1317227 +Ref: Close Files And Pipes-Footnote-2317375 +Node: Nonfatal317525 +Node: Output Summary319850 +Node: Output Exercises321071 +Node: Expressions321751 +Node: Values322940 +Node: Constants323617 +Node: Scalar Constants324308 +Ref: Scalar Constants-Footnote-1325170 +Node: Nondecimal-numbers325420 +Node: Regexp Constants328430 +Node: Using Constant Regexps328956 +Node: Variables332119 +Node: Using Variables332776 +Node: Assignment Options334687 +Node: Conversion336562 +Node: Strings And Numbers337086 +Ref: Strings And Numbers-Footnote-1340151 +Node: Locale influences conversions340260 +Ref: table-locale-affects343006 +Node: All Operators343598 +Node: Arithmetic Ops344227 +Node: Concatenation346732 +Ref: Concatenation-Footnote-1349551 +Node: Assignment Ops349658 +Ref: table-assign-ops354637 +Node: Increment Ops355947 +Node: Truth Values and Conditions359378 +Node: Truth Values360461 +Node: Typing and Comparison361510 +Node: Variable Typing362326 +Node: Comparison Operators365993 +Ref: table-relational-ops366403 +Node: POSIX String Comparison369898 +Ref: POSIX String Comparison-Footnote-1370970 +Node: Boolean Ops371109 +Ref: Boolean Ops-Footnote-1375587 +Node: Conditional Exp375678 +Node: Function Calls377416 +Node: Precedence381296 +Node: Locales384956 +Node: Expressions Summary386588 +Node: Patterns and Actions389159 +Node: Pattern Overview390279 +Node: Regexp Patterns391958 +Node: Expression Patterns392501 +Node: Ranges396281 +Node: BEGIN/END399388 +Node: Using BEGIN/END400149 +Ref: Using BEGIN/END-Footnote-1402885 +Node: I/O And BEGIN/END402991 +Node: BEGINFILE/ENDFILE405306 +Node: Empty408203 +Node: Using Shell Variables408520 +Node: Action Overview410793 +Node: Statements413119 +Node: If Statement414967 +Node: While Statement416462 +Node: Do Statement418490 +Node: For Statement419638 +Node: Switch Statement422796 +Node: Break Statement425178 +Node: Continue Statement427271 +Node: Next Statement429098 +Node: Nextfile Statement431479 +Node: Exit Statement434107 +Node: Built-in Variables436518 +Node: User-modified437651 +Ref: User-modified-Footnote-1445285 +Node: Auto-set445347 +Ref: Auto-set-Footnote-1459580 +Ref: Auto-set-Footnote-2459785 +Node: ARGC and ARGV459841 +Node: Pattern Action Summary464059 +Node: Arrays466492 +Node: Array Basics467821 +Node: Array Intro468665 +Ref: figure-array-elements470602 +Ref: Array Intro-Footnote-1473225 +Node: Reference to Elements473353 +Node: Assigning Elements475815 +Node: Array Example476306 +Node: Scanning an Array478065 +Node: Controlling Scanning481088 +Ref: Controlling Scanning-Footnote-1486482 +Node: Numeric Array Subscripts486798 +Node: Uninitialized Subscripts488983 +Node: Delete490600 +Ref: Delete-Footnote-1493349 +Node: Multidimensional493406 +Node: Multiscanning496503 +Node: Arrays of Arrays498092 +Node: Arrays Summary502846 +Node: Functions504937 +Node: Built-in505976 +Node: Calling Built-in507054 +Node: Numeric Functions509049 +Ref: Numeric Functions-Footnote-1513867 +Ref: Numeric Functions-Footnote-2514224 +Ref: Numeric Functions-Footnote-3514272 +Node: String Functions514544 +Ref: String Functions-Footnote-1538045 +Ref: String Functions-Footnote-2538174 +Ref: String Functions-Footnote-3538422 +Node: Gory Details538509 +Ref: table-sub-escapes540290 +Ref: table-sub-proposed541805 +Ref: table-posix-sub543167 +Ref: table-gensub-escapes544704 +Ref: Gory Details-Footnote-1545537 +Node: I/O Functions545688 +Ref: I/O Functions-Footnote-1552924 +Node: Time Functions553071 +Ref: Time Functions-Footnote-1563580 +Ref: Time Functions-Footnote-2563648 +Ref: Time Functions-Footnote-3563806 +Ref: Time Functions-Footnote-4563917 +Ref: Time Functions-Footnote-5564029 +Ref: Time Functions-Footnote-6564256 +Node: Bitwise Functions564522 +Ref: table-bitwise-ops565084 +Ref: Bitwise Functions-Footnote-1569412 +Node: Type Functions569584 +Node: I18N Functions570736 +Node: User-defined572383 +Node: Definition Syntax573188 +Ref: Definition Syntax-Footnote-1578847 +Node: Function Example578918 +Ref: Function Example-Footnote-1581839 +Node: Function Caveats581861 +Node: Calling A Function582379 +Node: Variable Scope583337 +Node: Pass By Value/Reference586330 +Node: Return Statement589827 +Node: Dynamic Typing592806 +Node: Indirect Calls593735 +Ref: Indirect Calls-Footnote-1603600 +Node: Functions Summary603728 +Node: Library Functions606430 +Ref: Library Functions-Footnote-1610038 +Ref: Library Functions-Footnote-2610181 +Node: Library Names610352 +Ref: Library Names-Footnote-1613810 +Ref: Library Names-Footnote-2614033 +Node: General Functions614119 +Node: Strtonum Function615222 +Node: Assert Function618244 +Node: Round Function621568 +Node: Cliff Random Function623109 +Node: Ordinal Functions624125 +Ref: Ordinal Functions-Footnote-1627188 +Ref: Ordinal Functions-Footnote-2627440 +Node: Join Function627651 +Ref: Join Function-Footnote-1629421 +Node: Getlocaltime Function629621 +Node: Readfile Function633365 +Node: Shell Quoting635337 +Node: Data File Management636738 +Node: Filetrans Function637370 +Node: Rewind Function641466 +Node: File Checking642852 +Ref: File Checking-Footnote-1644185 +Node: Empty Files644386 +Node: Ignoring Assigns646365 +Node: Getopt Function647915 +Ref: Getopt Function-Footnote-1659379 +Node: Passwd Functions659579 +Ref: Passwd Functions-Footnote-1668419 +Node: Group Functions668507 +Ref: Group Functions-Footnote-1676404 +Node: Walking Arrays676609 +Node: Library Functions Summary679615 +Node: Library Exercises681017 +Node: Sample Programs682297 +Node: Running Examples683067 +Node: Clones683795 +Node: Cut Program685019 +Node: Egrep Program694739 +Ref: Egrep Program-Footnote-1702242 +Node: Id Program702352 +Node: Split Program706028 +Ref: Split Program-Footnote-1709482 +Node: Tee Program709610 +Node: Uniq Program712399 +Node: Wc Program719818 +Ref: Wc Program-Footnote-1724068 +Node: Miscellaneous Programs724162 +Node: Dupword Program725375 +Node: Alarm Program727406 +Node: Translate Program732211 +Ref: Translate Program-Footnote-1736774 +Node: Labels Program737044 +Ref: Labels Program-Footnote-1740395 +Node: Word Sorting740479 +Node: History Sorting744549 +Node: Extract Program746384 +Node: Simple Sed753908 +Node: Igawk Program756978 +Ref: Igawk Program-Footnote-1771304 +Ref: Igawk Program-Footnote-2771505 +Ref: Igawk Program-Footnote-3771627 +Node: Anagram Program771742 +Node: Signature Program774803 +Node: Programs Summary776050 +Node: Programs Exercises777271 +Ref: Programs Exercises-Footnote-1781402 +Node: Advanced Features781493 +Node: Nondecimal Data783475 +Node: Array Sorting785065 +Node: Controlling Array Traversal785765 +Ref: Controlling Array Traversal-Footnote-1794131 +Node: Array Sorting Functions794249 +Ref: Array Sorting Functions-Footnote-1798135 +Node: Two-way I/O798331 +Ref: Two-way I/O-Footnote-1803276 +Ref: Two-way I/O-Footnote-2803462 +Node: TCP/IP Networking803544 +Node: Profiling806416 +Node: Advanced Features Summary814687 +Node: Internationalization816620 +Node: I18N and L10N818100 +Node: Explaining gettext818786 +Ref: Explaining gettext-Footnote-1823811 +Ref: Explaining gettext-Footnote-2823995 +Node: Programmer i18n824160 +Ref: Programmer i18n-Footnote-1829036 +Node: Translator i18n829085 +Node: String Extraction829879 +Ref: String Extraction-Footnote-1831010 +Node: Printf Ordering831096 +Ref: Printf Ordering-Footnote-1833882 +Node: I18N Portability833946 +Ref: I18N Portability-Footnote-1836402 +Node: I18N Example836465 +Ref: I18N Example-Footnote-1839268 +Node: Gawk I18N839340 +Node: I18N Summary839984 +Node: Debugger841324 +Node: Debugging842346 +Node: Debugging Concepts842787 +Node: Debugging Terms844597 +Node: Awk Debugging847169 +Node: Sample Debugging Session848075 +Node: Debugger Invocation848609 +Node: Finding The Bug849994 +Node: List of Debugger Commands856473 +Node: Breakpoint Control857805 +Node: Debugger Execution Control861482 +Node: Viewing And Changing Data864841 +Node: Execution Stack868217 +Node: Debugger Info869852 +Node: Miscellaneous Debugger Commands873897 +Node: Readline Support878898 +Node: Limitations879792 +Node: Debugging Summary881907 +Node: Arbitrary Precision Arithmetic883081 +Node: Computer Arithmetic884497 +Ref: table-numeric-ranges888074 +Ref: Computer Arithmetic-Footnote-1888598 +Node: Math Definitions888655 +Ref: table-ieee-formats891950 +Ref: Math Definitions-Footnote-1892554 +Node: MPFR features892659 +Node: FP Math Caution894330 +Ref: FP Math Caution-Footnote-1895380 +Node: Inexactness of computations895749 +Node: Inexact representation896708 +Node: Comparing FP Values898066 +Node: Errors accumulate899148 +Node: Getting Accuracy900580 +Node: Try To Round903284 +Node: Setting precision904183 +Ref: table-predefined-precision-strings904867 +Node: Setting the rounding mode906696 +Ref: table-gawk-rounding-modes907060 +Ref: Setting the rounding mode-Footnote-1910512 +Node: Arbitrary Precision Integers910691 +Ref: Arbitrary Precision Integers-Footnote-1915589 +Node: POSIX Floating Point Problems915738 +Ref: POSIX Floating Point Problems-Footnote-1919617 +Node: Floating point summary919655 +Node: Dynamic Extensions921842 +Node: Extension Intro923394 +Node: Plugin License924659 +Node: Extension Mechanism Outline925456 +Ref: figure-load-extension925884 +Ref: figure-register-new-function927364 +Ref: figure-call-new-function928368 +Node: Extension API Description930355 +Node: Extension API Functions Introduction931889 +Node: General Data Types936758 +Ref: General Data Types-Footnote-1942658 +Node: Memory Allocation Functions942957 +Ref: Memory Allocation Functions-Footnote-1945796 +Node: Constructor Functions945895 +Node: Registration Functions947634 +Node: Extension Functions948319 +Node: Exit Callback Functions950616 +Node: Extension Version String951864 +Node: Input Parsers952527 +Node: Output Wrappers962402 +Node: Two-way processors966915 +Node: Printing Messages969178 +Ref: Printing Messages-Footnote-1970254 +Node: Updating `ERRNO'970406 +Node: Requesting Values971146 +Ref: table-value-types-returned971873 +Node: Accessing Parameters972830 +Node: Symbol Table Access974064 +Node: Symbol table by name974578 +Node: Symbol table by cookie976598 +Ref: Symbol table by cookie-Footnote-1980743 +Node: Cached values980806 +Ref: Cached values-Footnote-1984302 +Node: Array Manipulation984393 +Ref: Array Manipulation-Footnote-1985483 +Node: Array Data Types985520 +Ref: Array Data Types-Footnote-1988175 +Node: Array Functions988267 +Node: Flattening Arrays992126 +Node: Creating Arrays999028 +Node: Redirection API1003799 +Node: Extension API Variables1006624 +Node: Extension Versioning1007257 +Node: Extension API Informational Variables1009148 +Node: Extension API Boilerplate1010213 +Node: Finding Extensions1014022 +Node: Extension Example1014582 +Node: Internal File Description1015354 +Node: Internal File Ops1019421 +Ref: Internal File Ops-Footnote-11031172 +Node: Using Internal File Ops1031312 +Ref: Using Internal File Ops-Footnote-11033695 +Node: Extension Samples1033968 +Node: Extension Sample File Functions1035496 +Node: Extension Sample Fnmatch1043177 +Node: Extension Sample Fork1044665 +Node: Extension Sample Inplace1045880 +Node: Extension Sample Ord1047966 +Node: Extension Sample Readdir1048802 +Ref: table-readdir-file-types1049679 +Node: Extension Sample Revout1050490 +Node: Extension Sample Rev2way1051079 +Node: Extension Sample Read write array1051819 +Node: Extension Sample Readfile1053759 +Node: Extension Sample Time1054854 +Node: Extension Sample API Tests1056202 +Node: gawkextlib1056693 +Node: Extension summary1059371 +Node: Extension Exercises1063060 +Node: Language History1064556 +Node: V7/SVR3.11066212 +Node: SVR41068365 +Node: POSIX1069799 +Node: BTL1071180 +Node: POSIX/GNU1071911 +Node: Feature History1077747 +Node: Common Extensions1091541 +Node: Ranges and Locales1092913 +Ref: Ranges and Locales-Footnote-11097532 +Ref: Ranges and Locales-Footnote-21097559 +Ref: Ranges and Locales-Footnote-31097794 +Node: Contributors1098015 +Node: History summary1103555 +Node: Installation1104934 +Node: Gawk Distribution1105880 +Node: Getting1106364 +Node: Extracting1107187 +Node: Distribution contents1108824 +Node: Unix Installation1114926 +Node: Quick Installation1115609 +Node: Shell Startup Files1118020 +Node: Additional Configuration Options1119099 +Node: Configuration Philosophy1120903 +Node: Non-Unix Installation1123272 +Node: PC Installation1123730 +Node: PC Binary Installation1125050 +Node: PC Compiling1126898 +Ref: PC Compiling-Footnote-11129919 +Node: PC Testing1130028 +Node: PC Using1131204 +Node: Cygwin1135319 +Node: MSYS1136089 +Node: VMS Installation1136590 +Node: VMS Compilation1137382 +Ref: VMS Compilation-Footnote-11138611 +Node: VMS Dynamic Extensions1138669 +Node: VMS Installation Details1140353 +Node: VMS Running1142604 +Node: VMS GNV1145444 +Node: VMS Old Gawk1146179 +Node: Bugs1146649 +Node: Other Versions1150538 +Node: Installation summary1156972 +Node: Notes1158031 +Node: Compatibility Mode1158896 +Node: Additions1159678 +Node: Accessing The Source1160603 +Node: Adding Code1162038 +Node: New Ports1168195 +Node: Derived Files1172677 +Ref: Derived Files-Footnote-11178152 +Ref: Derived Files-Footnote-21178186 +Ref: Derived Files-Footnote-31178782 +Node: Future Extensions1178896 +Node: Implementation Limitations1179502 +Node: Extension Design1180750 +Node: Old Extension Problems1181904 +Ref: Old Extension Problems-Footnote-11183421 +Node: Extension New Mechanism Goals1183478 +Ref: Extension New Mechanism Goals-Footnote-11186838 +Node: Extension Other Design Decisions1187027 +Node: Extension Future Growth1189135 +Node: Old Extension Mechanism1189971 +Node: Notes summary1191733 +Node: Basic Concepts1192919 +Node: Basic High Level1193600 +Ref: figure-general-flow1193872 +Ref: figure-process-flow1194471 +Ref: Basic High Level-Footnote-11197700 +Node: Basic Data Typing1197885 +Node: Glossary1201213 +Node: Copying1233142 +Node: GNU Free Documentation License1270698 +Node: Index1295834 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 4850da0b..0c21d923 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -604,6 +604,7 @@ particular records in a file and perform operations upon them. @code{getline}. * Getline Summary:: Summary of @code{getline} Variants. * Read Timeout:: Reading input with a timeout. +* Retrying Input:: Retrying input after certain errors. * Command-line directories:: What happens if you put a directory on the command line. * Input Summary:: Input summary. @@ -945,6 +946,7 @@ particular records in a file and perform operations upon them. * Array Functions:: Functions for working with arrays. * Flattening Arrays:: How to flatten arrays. * Creating Arrays:: How to create and populate arrays. +* Redirection API:: How to access and manipulate redirections. * Extension API Variables:: Variables provided by the API. * Extension Versioning:: API Version information. * Extension API Informational Variables:: Variables providing information about @@ -6327,6 +6329,7 @@ used with it do not have to be named on the @command{awk} command line * Getline:: Reading files under explicit program control using the @code{getline} function. * Read Timeout:: Reading input with a timeout. +* Retrying Input:: Retrying input after certain errors. * Command-line directories:: What happens if you put a directory on the command line. * Input Summary:: Input summary. @@ -8112,6 +8115,11 @@ it encounters the end of the file. If there is some error in getting a record, such as a file that cannot be opened, then @code{getline} returns @minus{}1. In this case, @command{gawk} sets the variable @code{ERRNO} to a string describing the error that occurred. +If @code{ERRNO} indicates that the I/O operation may be +retried, and @code{PROCINFO["input", "RETRY"]} is set, then @minus{}2 +will be returned instead of @minus{}1, and further calls to @code{getline} +may be attemped. @DBXREF{Retrying Input} for further information about +this feature. In the following examples, @var{command} stands for a string value that represents a shell command. @@ -8767,7 +8775,8 @@ on a per-command or per-connection basis. the attempt to read from the underlying device may succeed in a later attempt. This is a limitation, and it also means that you cannot use this to multiplex input from -two or more sources. +two or more sources. @DBXREF{Retrying Input} for a way to enable +later I/O attempts to succeed. Assigning a timeout value prevents read operations from blocking indefinitely. But bear in mind that there are other ways @@ -8777,6 +8786,35 @@ a connection before it can start reading any data, or the attempt to open a FIFO special file for reading can block indefinitely until some other process opens it for writing. +@node Retrying Input +@section Retrying Reads After Certain Input Errors +@cindex retrying input + +@cindex differences in @command{awk} and @command{gawk}, retrying input +This @value{SECTION} describes a feature that is specific to @command{gawk}. + +When @command{gawk} encounters an error while reading input, by +default @code{getline} returns @minus{}1, and subsequent attempts to +read from that file result in an end-of-file indication. However, you +may optionally instruct @command{gawk} to allow I/O to be retried when +certain errors are encountered by setting setting a special element in +the @code{PROCINFO} array (@pxref{Auto-set}): + +@example +PROCINFO["@var{input_name}", "RETRY"] = 1 +@end example + +When this element exists, @command{gawk} checks the value of the system +@code{errno} variable when an I/O error occurs. If @code{errno} indicates +a subsequent I/O attempt may succeed, @code{getline} instead returns +@minus{}2 and +further calls to @code{getline} may succeed. This applies to @code{errno} +values @code{EAGAIN}, @code{EWOULDBLOCK}, @code{EINTR}, or @code{ETIMEDOUT}. + +This feature is useful in conjunction with +@code{PROCINFO["@var{input_name}", "READ_TIMEOUT"]} or situations where a file +descriptor has been configured to behave in a non-blocking fashion. + @node Command-line directories @section Directories on the Command Line @cindex differences in @command{awk} and @command{gawk}, command-line directories @@ -14928,6 +14966,11 @@ value to be meaningful when an I/O operation returns a failure value, such as @code{getline} returning @minus{}1. You are, of course, free to clear it yourself before doing an I/O operation. +If the value of @code{ERRNO} corresponds to a system error in the C +@code{errno} variable, then @code{PROCINFO["errno"]} will be set to the value +of @code{errno}. For non-system errors, @code{PROCINFO["errno"]} will +be zero. + @cindex @code{FILENAME} variable @cindex dark corner, @code{FILENAME} variable @item @code{FILENAME} @@ -14996,6 +15039,10 @@ are guaranteed to be available: @item PROCINFO["egid"] The value of the @code{getegid()} system call. +@item PROCINFO["errno"] +The value of the C @code{errno} variable when @code{ERRNO} is set to +the associated error message. + @item PROCINFO["euid"] @cindex effective user ID of @command{gawk} user The value of the @code{geteuid()} system call. @@ -15135,6 +15182,11 @@ open input file, pipe, or coprocess. @DBXREF{Read Timeout} for more information. @item +It may be used to indicate that input may be retried when it fails due to +certain errors. +@DBXREF{Retrying Input} for more information. + +@item It may be used to cause coprocesses to communicate over pseudo-ttys instead of through two-way pipes; this is discussed further in @ref{Two-way I/O}. @@ -31571,6 +31623,7 @@ This (rather large) @value{SECTION} describes the API in detail. * Symbol Table Access:: Functions for accessing global variables. * Array Manipulation:: Functions for working with arrays. +* Redirection API:: How to access and manipulate redirections. * Extension API Variables:: Variables provided by the API. * Extension API Boilerplate:: Boilerplate code for using the API. @end menu @@ -31646,6 +31699,10 @@ Clearing an array @item Flattening an array for easy C-style looping over all its indices and elements @end itemize + +@item +Accessing and manipulating redirections. + @end itemize Some points about using the API: @@ -33616,6 +33673,75 @@ $ @kbd{AWKLIBPATH=$PWD ./gawk -f subarray.awk} (@DBXREF{Finding Extensions} for more information on the @env{AWKLIBPATH} environment variable.) +@node Redirection API +@subsection Accessing and Manipulating Redirections + +The following function allows extensions to access and manipulate redirections. + +@table @code +@item awk_bool_t get_file(const char *name, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ size_t name_len, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const char *filetype, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ int fd, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const awk_input_buf_t **ibufp, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const awk_output_buf_t **obufp); +Look up a file in @command{gawk}'s internal redirection table. +If @code{name} is @code{NULL} or @code{name_len} is zero, return +data for the currently open input file corresponding to @code{FILENAME}. +(This does not access the @code{filetype} argument, so that may be undefined). +If the file is not already open, attempt to open it. +The @code{filetype} argument must be zero-terminated and should be one of: + +@table @code +@item ">" +A file opened for output. + +@item ">>" +A file opened for append. + +@item "<" +A file opened for input. + +@item "|>" +A pipe opened for output. + +@item "|<" +A pipe opened for input. + +@item "|&" +A two-way coprocess. +@end table + +On error, return a @code{false} value. Otherwise, return +@code{true}, and return additional information about the redirection +in the @code{ibufp} and @code{obufp} pointers. For input +redirections, the @code{*ibufp} value should be non-@code{NULL}, +and @code{*obufp} should be @code{NULL}. For output redirections, +the @code{*obufp} value should be non-@code{NULL}, and @code{*ibufp} +should be @code{NULL}. For two-way coprocesses, both values should +be non-@code{NULL}. + +In the usual case, the extension is interested in @code{(*ibufp)->fd} +and/or @code{fileno((*obufp)->fp)}. If the file is not already +open, and the @code{fd} argument is non-negative, @command{gawk} +will use that file descriptor instead of opening the file in the +usual way. If @code{fd} is non-negative, but the file exists already, +@command{gawk} ignores @code{fd} and returns the existing file. It is +the caller's responsibility to notice that neither the @code{fd} in +the returned @code{awk_input_buf_t} nor the @code{fd} in the returned +@code{awk_output_buf_t} matches the requested value. + +Note that supplying a file descriptor is currently @emph{not} supported +for pipes. However, supplying a file descriptor should work for input, +output, append, and two-way (coprocess) sockets. If @code{filetype} +is two-way, @command{gawk} assumes that it is a socket! Note that in +the two-way case, the input and output file descriptors may differ. +To check for success, you must check whether either matches. +@end table + +It is anticipated that this API function will be used to implement I/O +multiplexing and a socket library. + @node Extension API Variables @subsection API Variables diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 697d9107..7aa427aa 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -599,6 +599,7 @@ particular records in a file and perform operations upon them. @code{getline}. * Getline Summary:: Summary of @code{getline} Variants. * Read Timeout:: Reading input with a timeout. +* Retrying Input:: Retrying input after certain errors. * Command-line directories:: What happens if you put a directory on the command line. * Input Summary:: Input summary. @@ -940,6 +941,7 @@ particular records in a file and perform operations upon them. * Array Functions:: Functions for working with arrays. * Flattening Arrays:: How to flatten arrays. * Creating Arrays:: How to create and populate arrays. +* Redirection API:: How to access and manipulate redirections. * Extension API Variables:: Variables provided by the API. * Extension Versioning:: API Version information. * Extension API Informational Variables:: Variables providing information about @@ -6111,6 +6113,7 @@ used with it do not have to be named on the @command{awk} command line * Getline:: Reading files under explicit program control using the @code{getline} function. * Read Timeout:: Reading input with a timeout. +* Retrying Input:: Retrying input after certain errors. * Command-line directories:: What happens if you put a directory on the command line. * Input Summary:: Input summary. @@ -7712,6 +7715,11 @@ it encounters the end of the file. If there is some error in getting a record, such as a file that cannot be opened, then @code{getline} returns @minus{}1. In this case, @command{gawk} sets the variable @code{ERRNO} to a string describing the error that occurred. +If @code{ERRNO} indicates that the I/O operation may be +retried, and @code{PROCINFO["input", "RETRY"]} is set, then @minus{}2 +will be returned instead of @minus{}1, and further calls to @code{getline} +may be attemped. @DBXREF{Retrying Input} for further information about +this feature. In the following examples, @var{command} stands for a string value that represents a shell command. @@ -8367,7 +8375,8 @@ on a per-command or per-connection basis. the attempt to read from the underlying device may succeed in a later attempt. This is a limitation, and it also means that you cannot use this to multiplex input from -two or more sources. +two or more sources. @DBXREF{Retrying Input} for a way to enable +later I/O attempts to succeed. Assigning a timeout value prevents read operations from blocking indefinitely. But bear in mind that there are other ways @@ -8377,6 +8386,35 @@ a connection before it can start reading any data, or the attempt to open a FIFO special file for reading can block indefinitely until some other process opens it for writing. +@node Retrying Input +@section Retrying Reads After Certain Input Errors +@cindex retrying input + +@cindex differences in @command{awk} and @command{gawk}, retrying input +This @value{SECTION} describes a feature that is specific to @command{gawk}. + +When @command{gawk} encounters an error while reading input, by +default @code{getline} returns @minus{}1, and subsequent attempts to +read from that file result in an end-of-file indication. However, you +may optionally instruct @command{gawk} to allow I/O to be retried when +certain errors are encountered by setting setting a special element in +the @code{PROCINFO} array (@pxref{Auto-set}): + +@example +PROCINFO["@var{input_name}", "RETRY"] = 1 +@end example + +When this element exists, @command{gawk} checks the value of the system +@code{errno} variable when an I/O error occurs. If @code{errno} indicates +a subsequent I/O attempt may succeed, @code{getline} instead returns +@minus{}2 and +further calls to @code{getline} may succeed. This applies to @code{errno} +values @code{EAGAIN}, @code{EWOULDBLOCK}, @code{EINTR}, or @code{ETIMEDOUT}. + +This feature is useful in conjunction with +@code{PROCINFO["@var{input_name}", "READ_TIMEOUT"]} or situations where a file +descriptor has been configured to behave in a non-blocking fashion. + @node Command-line directories @section Directories on the Command Line @cindex differences in @command{awk} and @command{gawk}, command-line directories @@ -14256,6 +14294,11 @@ value to be meaningful when an I/O operation returns a failure value, such as @code{getline} returning @minus{}1. You are, of course, free to clear it yourself before doing an I/O operation. +If the value of @code{ERRNO} corresponds to a system error in the C +@code{errno} variable, then @code{PROCINFO["errno"]} will be set to the value +of @code{errno}. For non-system errors, @code{PROCINFO["errno"]} will +be zero. + @cindex @code{FILENAME} variable @cindex dark corner, @code{FILENAME} variable @item @code{FILENAME} @@ -14324,6 +14367,10 @@ are guaranteed to be available: @item PROCINFO["egid"] The value of the @code{getegid()} system call. +@item PROCINFO["errno"] +The value of the C @code{errno} variable when @code{ERRNO} is set to +the associated error message. + @item PROCINFO["euid"] @cindex effective user ID of @command{gawk} user The value of the @code{geteuid()} system call. @@ -14463,6 +14510,11 @@ open input file, pipe, or coprocess. @DBXREF{Read Timeout} for more information. @item +It may be used to indicate that input may be retried when it fails due to +certain errors. +@DBXREF{Retrying Input} for more information. + +@item It may be used to cause coprocesses to communicate over pseudo-ttys instead of through two-way pipes; this is discussed further in @ref{Two-way I/O}. @@ -30662,6 +30714,7 @@ This (rather large) @value{SECTION} describes the API in detail. * Symbol Table Access:: Functions for accessing global variables. * Array Manipulation:: Functions for working with arrays. +* Redirection API:: How to access and manipulate redirections. * Extension API Variables:: Variables provided by the API. * Extension API Boilerplate:: Boilerplate code for using the API. @end menu @@ -30737,6 +30790,10 @@ Clearing an array @item Flattening an array for easy C-style looping over all its indices and elements @end itemize + +@item +Accessing and manipulating redirections. + @end itemize Some points about using the API: @@ -32707,6 +32764,75 @@ $ @kbd{AWKLIBPATH=$PWD ./gawk -f subarray.awk} (@DBXREF{Finding Extensions} for more information on the @env{AWKLIBPATH} environment variable.) +@node Redirection API +@subsection Accessing and Manipulating Redirections + +The following function allows extensions to access and manipulate redirections. + +@table @code +@item awk_bool_t get_file(const char *name, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ size_t name_len, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const char *filetype, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ int fd, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const awk_input_buf_t **ibufp, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const awk_output_buf_t **obufp); +Look up a file in @command{gawk}'s internal redirection table. +If @code{name} is @code{NULL} or @code{name_len} is zero, return +data for the currently open input file corresponding to @code{FILENAME}. +(This does not access the @code{filetype} argument, so that may be undefined). +If the file is not already open, attempt to open it. +The @code{filetype} argument must be zero-terminated and should be one of: + +@table @code +@item ">" +A file opened for output. + +@item ">>" +A file opened for append. + +@item "<" +A file opened for input. + +@item "|>" +A pipe opened for output. + +@item "|<" +A pipe opened for input. + +@item "|&" +A two-way coprocess. +@end table + +On error, return a @code{false} value. Otherwise, return +@code{true}, and return additional information about the redirection +in the @code{ibufp} and @code{obufp} pointers. For input +redirections, the @code{*ibufp} value should be non-@code{NULL}, +and @code{*obufp} should be @code{NULL}. For output redirections, +the @code{*obufp} value should be non-@code{NULL}, and @code{*ibufp} +should be @code{NULL}. For two-way coprocesses, both values should +be non-@code{NULL}. + +In the usual case, the extension is interested in @code{(*ibufp)->fd} +and/or @code{fileno((*obufp)->fp)}. If the file is not already +open, and the @code{fd} argument is non-negative, @command{gawk} +will use that file descriptor instead of opening the file in the +usual way. If @code{fd} is non-negative, but the file exists already, +@command{gawk} ignores @code{fd} and returns the existing file. It is +the caller's responsibility to notice that neither the @code{fd} in +the returned @code{awk_input_buf_t} nor the @code{fd} in the returned +@code{awk_output_buf_t} matches the requested value. + +Note that supplying a file descriptor is currently @emph{not} supported +for pipes. However, supplying a file descriptor should work for input, +output, append, and two-way (coprocess) sockets. If @code{filetype} +is two-way, @command{gawk} assumes that it is a socket! Note that in +the two-way case, the input and output file descriptors may differ. +To check for success, you must check whether either matches. +@end table + +It is anticipated that this API function will be used to implement I/O +multiplexing and a socket library. + @node Extension API Variables @subsection API Variables |