diff options
-rw-r--r-- | doc/ChangeLog | 1 | ||||
-rw-r--r-- | doc/gawk.info | 1086 | ||||
-rw-r--r-- | doc/gawk.texi | 189 | ||||
-rw-r--r-- | doc/gawktexi.in | 183 |
4 files changed, 735 insertions, 724 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index bd4ca80c..ba31b052 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,7 @@ 2015-01-25 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Fix a bad URL. And another one. + More O'Reilly fixes. 2015-01-23 Arnold D. Robbins <arnold@skeeve.com> diff --git a/doc/gawk.info b/doc/gawk.info index 2af7b429..59ce5ce6 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -7267,9 +7267,9 @@ value to a variable or a field by using an assignment operator. An expression can serve as a pattern or action statement on its own. Most other kinds of statements contain one or more expressions that specify the data on which to operate. As in other languages, -expressions in `awk' include variables, array references, constants, -and function calls, as well as combinations of these with various -operators. +expressions in `awk' can include variables, array references, +constants, and function calls, as well as combinations of these with +various operators. * Menu: @@ -7288,8 +7288,8 @@ File: gawk.info, Node: Values, Next: All Operators, Up: Expressions ========================================= Expressions are built up from values and the operations performed upon -them. This minor node describes the elementary objects which provide -the values used in expressions. +them. This minor node describes the elementary objects that provide the +values used in expressions. * Menu: @@ -7334,14 +7334,14 @@ the same value: 1.05e+2 1050e-1 - A string constant consists of a sequence of characters enclosed in + A "string constant" consists of a sequence of characters enclosed in double quotation marks. For example: "parrot" represents the string whose contents are `parrot'. Strings in `gawk' can be of any length, and they can contain any of the possible -eight-bit ASCII characters including ASCII NUL (character code zero). +eight-bit ASCII characters, including ASCII NUL (character code zero). Other `awk' implementations may have difficulty with some character codes. @@ -7361,14 +7361,14 @@ File: gawk.info, Node: Nondecimal-numbers, Next: Regexp Constants, Prev: Scal In `awk', all numbers are in decimal (i.e., base 10). Many other programming languages allow you to specify numbers in other bases, often octal (base 8) and hexadecimal (base 16). In octal, the numbers go 0, -1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on. Just as `11', in decimal, -is 1 times 10 plus 1, so `11', in octal, is 1 times 8, plus 1. This -equals 9 in decimal. In hexadecimal, there are 16 digits. Because the -everyday decimal number system only has ten digits (`0'-`9'), the -letters `a' through `f' are used to represent the rest. (Case in the -letters is usually irrelevant; hexadecimal `a' and `A' have the same -value.) Thus, `11', in hexadecimal, is 1 times 16 plus 1, which equals -17 in decimal. +1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on. Just as `11' in decimal is +1 times 10 plus 1, so `11' in octal is 1 times 8 plus 1. This equals 9 +in decimal. In hexadecimal, there are 16 digits. Because the everyday +decimal number system only has ten digits (`0'-`9'), the letters `a' +through `f' are used to represent the rest. (Case in the letters is +usually irrelevant; hexadecimal `a' and `A' have the same value.) +Thus, `11' in hexadecimal is 1 times 16 plus 1, which equals 17 in +decimal. Just by looking at plain `11', you can't tell what base it's in. So, in C, C++, and other languages derived from C, there is a special @@ -7376,13 +7376,13 @@ notation to signify the base. Octal numbers start with a leading `0', and hexadecimal numbers start with a leading `0x' or `0X': `11' - Decimal value 11. + Decimal value 11 `011' - Octal 11, decimal value 9. + Octal 11, decimal value 9 `0x11' - Hexadecimal 11, decimal value 17. + Hexadecimal 11, decimal value 17 This example shows the difference: @@ -7401,11 +7401,11 @@ really need to do this, use the `--non-decimal-data' command-line option; *note Nondecimal Data::.) If you have octal or hexadecimal data, you can use the `strtonum()' function (*note String Functions::) to convert the data into a number. Most of the time, you will want to -use octal or hexadecimal constants when working with the built-in bit -manipulation functions; see *note Bitwise Functions::, for more +use octal or hexadecimal constants when working with the built-in +bit-manipulation functions; see *note Bitwise Functions::, for more information. - Unlike some early C implementations, `8' and `9' are not valid in + Unlike in some early C implementations, `8' and `9' are not valid in octal constants. For example, `gawk' treats `018' as decimal 18: $ gawk 'BEGIN { print "021 is", 021 ; print 018 }' @@ -7432,12 +7432,12 @@ File: gawk.info, Node: Regexp Constants, Prev: Nondecimal-numbers, Up: Consta 6.1.1.3 Regular Expression Constants .................................... -A regexp constant is a regular expression description enclosed in +A "regexp constant" is a regular expression description enclosed in slashes, such as `/^beginning and end$/'. Most regexps used in `awk' programs are constant, but the `~' and `!~' matching operators can also match computed or dynamic regexps (which are typically just ordinary -strings or variables that contain a regexp, but could be a more complex -expression). +strings or variables that contain a regexp, but could be more complex +expressions). File: gawk.info, Node: Using Constant Regexps, Next: Variables, Prev: Constants, Up: Values @@ -7489,7 +7489,7 @@ 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.) Because some built-in functions accept regexp constants -as arguments, it can be confusing when attempting to use regexp +as arguments, confusion can arise when attempting to use regexp constants as arguments to user-defined functions (*note User-defined::). For example: @@ -7512,10 +7512,11 @@ User-defined::). For example: In this example, the programmer wants to pass a regexp constant to the user-defined function `mysub()', which in turn passes it on to either `sub()' or `gsub()'. However, what really happens is that the -`pat' parameter is either one or zero, depending upon whether or not -`$0' matches `/hi/'. `gawk' issues a warning when it sees a regexp -constant used as a parameter to a user-defined function, because -passing a truth value in this way is probably not what was intended. +`pat' parameter is assigned a value of either one or zero, depending +upon whether or not `$0' matches `/hi/'. `gawk' issues a warning when +it sees a regexp constant used as a parameter to a user-defined +function, because passing a truth value in this way is probably not +what was intended. File: gawk.info, Node: Variables, Next: Conversion, Prev: Using Constant Regexps, Up: Values @@ -7523,7 +7524,7 @@ File: gawk.info, Node: Variables, Next: Conversion, Prev: Using Constant Rege 6.1.3 Variables --------------- -Variables are ways of storing values at one point in your program for +"Variables" are ways of storing values at one point in your program for use later in another part of your program. They can be manipulated entirely within the program text, and they can also be assigned values on the `awk' command line. @@ -7552,14 +7553,14 @@ variables. A variable name is a valid expression by itself; it represents the variable's current value. Variables are given new values with -"assignment operators", "increment operators", and "decrement -operators". *Note Assignment Ops::. In addition, the `sub()' and -`gsub()' functions can change a variable's value, and the `match()', -`split()', and `patsplit()' functions can change the contents of their -array parameters. *Note String Functions::. +"assignment operators", "increment operators", and "decrement operators" +(*note Assignment Ops::). In addition, the `sub()' and `gsub()' +functions can change a variable's value, and the `match()', `split()', +and `patsplit()' functions can change the contents of their 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 +field separator) and `NF' (the number of fields in the current input 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 @@ -7756,7 +7757,7 @@ point, so the default behavior was restored to use a period as the decimal point character. You can use the `--use-lc-numeric' option (*note Options::) to force `gawk' to use the locale's decimal point character. (`gawk' also uses the locale's decimal point character when -in POSIX mode, either via `--posix', or the `POSIXLY_CORRECT' +in POSIX mode, either via `--posix' or the `POSIXLY_CORRECT' environment variable, as shown previously.) *note table-locale-affects:: describes the cases in which the @@ -7772,10 +7773,10 @@ Input Use period Use locale Table 6.1: Locale decimal point versus a period - Finally, modern day formal standards and IEEE standard floating-point -representation can have an unusual but important effect on the way -`gawk' converts some special string values to numbers. The details are -presented in *note POSIX Floating Point Problems::. + Finally, modern-day formal standards and the IEEE standard +floating-point representation can have an unusual but important effect +on the way `gawk' converts some special string values to numbers. The +details are presented in *note POSIX Floating Point Problems::. File: gawk.info, Node: All Operators, Next: Truth Values and Conditions, Prev: Values, Up: Expressions @@ -7783,7 +7784,7 @@ File: gawk.info, Node: All Operators, Next: Truth Values and Conditions, Prev 6.2 Operators: Doing Something with Values ========================================== -This minor node introduces the "operators" which make use of the values +This minor node introduces the "operators" that make use of the values provided by constants and variables. * Menu: @@ -7964,7 +7965,7 @@ you'll get. ---------- Footnotes ---------- - (1) It happens that BWK `awk', `gawk' and `mawk' all "get it right," + (1) It happens that BWK `awk', `gawk', and `mawk' all "get it right," but you should not rely on this. @@ -8081,7 +8082,7 @@ righthand expression. For example: The indices of `bar' are practically guaranteed to be different, because `rand()' returns different values each time it is called. (Arrays and the `rand()' function haven't been covered yet. *Note Arrays::, and -*note Numeric Functions::, for more information). This example +*note Numeric Functions::, for more information.) This example illustrates an important fact about assignment operators: the lefthand expression is only evaluated _once_. @@ -8099,14 +8100,14 @@ converted to a number. Operator Effect -------------------------------------------------------------------------- -LVALUE `+=' INCREMENT Add INCREMENT to the value of LVALUE -LVALUE `-=' DECREMENT Subtract DECREMENT from the value of LVALUE -LVALUE `*=' Multiply the value of LVALUE by COEFFICIENT +LVALUE `+=' INCREMENT Add INCREMENT to the value of LVALUE. +LVALUE `-=' DECREMENT Subtract DECREMENT from the value of LVALUE. +LVALUE `*=' Multiply the value of LVALUE by COEFFICIENT. COEFFICIENT -LVALUE `/=' DIVISOR Divide the value of LVALUE by DIVISOR -LVALUE `%=' MODULUS Set LVALUE to its remainder by MODULUS -LVALUE `^=' POWER -LVALUE `**=' POWER Raise LVALUE to the power POWER (c.e.) +LVALUE `/=' DIVISOR Divide the value of LVALUE by DIVISOR. +LVALUE `%=' MODULUS Set LVALUE to its remainder by MODULUS. +LVALUE `^=' POWER Raise LVALUE to the power POWER. +LVALUE `**=' POWER Raise LVALUE to the power POWER. (c.e.) Table 6.2: Arithmetic assignment operators @@ -8191,8 +8192,8 @@ is a summary of increment and decrement expressions: Operator Evaluation Order - Doctor, doctor! It hurts when I do this! - So don't do that! -- Groucho Marx + Doctor, it hurts when I do this! + Then don't do that! -- Groucho Marx What happens for something like the following? @@ -8207,7 +8208,7 @@ Or something even stranger? In other words, when do the various side effects prescribed by the postfix operators (`b++') take effect? When side effects happen is -"implementation defined". In other words, it is up to the particular +"implementation-defined". In other words, it is up to the particular version of `awk'. The result for the first example may be 12 or 13, and for the second, it may be 22 or 23. @@ -8222,7 +8223,7 @@ File: gawk.info, Node: Truth Values and Conditions, Next: Function Calls, Pre =============================== In certain contexts, expression values also serve as "truth values"; -(i.e., they determine what should happen next as the program runs). This +i.e., they determine what should happen next as the program runs. This minor node describes how `awk' defines "true" and "false" and how values are compared. @@ -8276,10 +8277,10 @@ File: gawk.info, Node: Typing and Comparison, Next: Boolean Ops, Prev: Truth The Guide is definitive. Reality is frequently inaccurate. -- Douglas Adams, `The Hitchhiker's Guide to the Galaxy' - Unlike other programming languages, `awk' variables do not have a -fixed type. Instead, they can be either a number or a string, depending -upon the value that is assigned to them. We look now at how variables -are typed, and how `awk' compares variables. + Unlike in other programming languages, in `awk' variables do not +have a fixed type. Instead, they can be either a number or a string, +depending upon the value that is assigned to them. We look now at how +variables are typed, and how `awk' compares variables. * Menu: @@ -8300,16 +8301,16 @@ of the variable is important because the types of two variables determine how they are compared. Variable typing follows these rules: * A numeric constant or the result of a numeric operation has the - NUMERIC attribute. + "numeric" attribute. * A string constant or the result of a string operation has the - STRING attribute. + "string" attribute. * Fields, `getline' input, `FILENAME', `ARGV' elements, `ENVIRON' elements, and the elements of an array created by `match()', `split()', and `patsplit()' that are numeric strings have the - STRNUM attribute. Otherwise, they have the STRING attribute. - Uninitialized variables also have the STRNUM attribute. + "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 use. @@ -8351,12 +8352,13 @@ constant, then a string comparison is performed. Otherwise, a numeric comparison is performed. This point bears additional emphasis: All user input is made of -characters, and so is first and foremost of STRING type; input strings -that look numeric are additionally given the STRNUM attribute. Thus, -the six-character input string ` +3.14' receives the STRNUM attribute. +characters, and so is first and foremost of string type; input strings +that look numeric are additionally given the strnum attribute. Thus, +the six-character input string ` +3.14' receives the strnum attribute. 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: +comparison between the two different constants is true, and `0' +otherwise: $ echo ' +3.14' | awk '{ print($0 == " +3.14") }' True -| 1 @@ -8455,7 +8457,7 @@ comparison is: -| false the result is `false' because both `$1' and `$2' are user input. They -are numeric strings--therefore both have the STRNUM attribute, +are numeric strings--therefore both have the strnum attribute, dictating a numeric comparison. The purpose of the comparison rules and the use of numeric strings is to attempt to produce the behavior that is "least surprising," while still "doing the right thing." @@ -8514,7 +8516,7 @@ is an example to illustrate the difference, in an `en_US.UTF-8' locale: ---------- Footnotes ---------- (1) Technically, string comparison is supposed to behave the same -way as if the strings are compared with the C `strcoll()' function. +way as if the strings were compared with the C `strcoll()' function. File: gawk.info, Node: Boolean Ops, Next: Conditional Exp, Prev: Typing and Comparison, Up: Truth Values and Conditions @@ -8577,7 +8579,7 @@ Boolean operators are: The `&&' and `||' operators are called "short-circuit" operators because of the way they work. Evaluation of the full expression is -"short-circuited" if the result can be determined part way through its +"short-circuited" if the result can be determined partway through its evaluation. Statements that end with `&&' or `||' can be continued simply by @@ -8630,15 +8632,15 @@ File: gawk.info, Node: Conditional Exp, Prev: Boolean Ops, Up: Truth Values a A "conditional expression" is a special kind of expression that has three operands. It allows you to use one expression's value to select -one of two other expressions. The conditional expression is the same -as in the C language, as shown here: +one of two other expressions. The conditional expression in `awk' is +the same as in the C language, as shown here: SELECTOR ? IF-TRUE-EXP : IF-FALSE-EXP There are three subexpressions. The first, SELECTOR, is always computed first. If it is "true" (not zero or not null), then -IF-TRUE-EXP is computed next and its value becomes the value of the -whole expression. Otherwise, IF-FALSE-EXP is computed next and its +IF-TRUE-EXP is computed next, and its value becomes the value of the +whole expression. Otherwise, IF-FALSE-EXP is computed next, and its value becomes the value of the whole expression. For example, the following expression produces the absolute value of `x': @@ -8672,7 +8674,7 @@ A "function" is a name for a particular calculation. This enables you to ask for it by name at any point in the program. For example, the function `sqrt()' computes the square root of a number. - A fixed set of functions are "built-in", which means they are + A fixed set of functions are "built in", which means they are available in every `awk' program. The `sqrt()' function is one of these. *Note Built-in::, for a list of built-in functions and their descriptions. In addition, you can define functions for use in your @@ -8807,7 +8809,7 @@ precedence: Increment, decrement. `^ **' - Exponentiation. These operators group right-to-left. + Exponentiation. These operators group right to left. `+ - !' Unary plus, minus, logical "not." @@ -8834,7 +8836,7 @@ String concatenation operand of another operator. As a result, it does not make sense to use a redirection operator near another operator of lower precedence without parentheses. Such combinations (e.g., `print - foo > a ? b : c'), result in syntax errors. The correct way to + foo > a ? b : c') result in syntax errors. The correct way to write this statement is `print foo > (a ? b : c)'. `~ !~' @@ -8844,16 +8846,16 @@ String concatenation Array membership. `&&' - Logical "and". + Logical "and." `||' - Logical "or". + Logical "or." `?:' - Conditional. This operator groups right-to-left. + Conditional. This operator groups right to left. `= += -= *= /= %= ^= **=' - Assignment. These operators group right-to-left. + Assignment. These operators group right to left. NOTE: The `|&', `**', and `**=' operators are not specified by POSIX. For maximum portability, do not use them. @@ -8921,24 +8923,24 @@ 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, 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. + and minus. It also provides comparison operators, Boolean + operators, an array membership testing operator, 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. - * In `awk', a value is considered to be true if it is non-zero _or_ + * In `awk', a value is considered to be true if it is nonzero _or_ non-null. Otherwise, the value is false. * 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 + * Function calls return a value that may be used as part of a larger expression. Expressions used to pass parameter values are fully evaluated before the function is called. `awk' provides built-in and user-defined functions; this is described in *note Functions::. @@ -9112,7 +9114,7 @@ inside Boolean patterns. Likewise, the special patterns `BEGIN', `END', `BEGINFILE', and `ENDFILE', which never match any input record, are not expressions and cannot appear inside Boolean patterns. - The precedence of the different operators which can appear in + The precedence of the different operators that can appear in patterns is described in *note Precedence::. @@ -9132,8 +9134,8 @@ following: prints every record in `myfile' between `on'/`off' pairs, inclusive. A range pattern starts out by matching BEGPAT against every input -record. When a record matches BEGPAT, the range pattern is "turned on" -and the range pattern matches this record as well. As long as the +record. When a record matches BEGPAT, the range pattern is "turned +on", and the range pattern matches this record as well. As long as the range pattern stays turned on, it automatically matches every input record read. The range pattern also matches ENDPAT against every input record; when this succeeds, the range pattern is "turned off" again for @@ -9251,7 +9253,7 @@ for more information on using library functions. *Note Library Functions::, for a number of useful library functions. If an `awk' program has only `BEGIN' rules and no other rules, then -the program exits after the `BEGIN' rule is run.(1) However, if an +the program exits after the `BEGIN' rules are run.(1) However, if an `END' rule exists, then the input is read, even if there are no other rules in the program. This is necessary in case the `END' rule checks the `FNR' and `NR' variables. @@ -9277,7 +9279,7 @@ give `$0' a real value is to execute a `getline' command without a variable (*note Getline::). Another way is simply to assign a value to `$0'. - The second point is similar to the first but from the other + The second point is similar to the first, but from the other direction. Traditionally, due largely to implementation issues, `$0' and `NF' were _undefined_ inside an `END' rule. The POSIX standard specifies that `NF' is available in an `END' rule. It contains the @@ -9338,7 +9340,7 @@ tasks that would otherwise be difficult or impossible to perform: entirely. Otherwise, `gawk' exits with the usual fatal error. * If you have written extensions that modify the record handling (by - inserting an "input parser," *note Input Parsers::), you can invoke + inserting an "input parser"; *note Input Parsers::), you can invoke them at this point, before `gawk' has started processing the file. (This is a _very_ advanced feature, currently used only by the `gawkextlib' project (http://gawkextlib.sourceforge.net).) @@ -9348,16 +9350,15 @@ last record in an input file. For the last input file, it will be called before any `END' rules. The `ENDFILE' rule is executed even for empty input files. - Normally, when an error occurs when reading input in the normal input -processing loop, the error is fatal. However, if an `ENDFILE' rule is -present, the error becomes non-fatal, and instead `ERRNO' is set. This -makes it possible to catch and process I/O errors at the level of the -`awk' program. + Normally, when an error occurs when reading input in the normal +input-processing loop, the error is fatal. However, if an `ENDFILE' +rule is present, the error becomes non-fatal, and instead `ERRNO' is +set. This 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 an `ENDFILE' rule. The `nextfile' statement is -allowed only inside a `BEGINFILE' rule, but not inside an `ENDFILE' -rule. +allowed only inside a `BEGINFILE' rule, not inside an `ENDFILE' rule. The `getline' statement (*note Getline::) is restricted inside both `BEGINFILE' and `ENDFILE': only redirected forms of `getline' are @@ -9402,11 +9403,11 @@ following program: END { print nmatches, "found" }' /path/to/data The `awk' program consists of two pieces of quoted text that are -concatenated together to form the program. The first part is double -quoted, which allows substitution of the `pattern' shell variable -inside the quotes. The second part is single quoted. +concatenated together to form the program. The first part is +double-quoted, which allows substitution of the `pattern' shell +variable inside the quotes. The second part is single-quoted. - Variable substitution via quoting works, but can be potentially + Variable substitution via quoting works, but can potentially be messy. It requires a good understanding of the shell's quoting rules (*note Quoting::), and it's often difficult to correctly match up the quotes when reading the program. @@ -9603,15 +9604,15 @@ The body of this loop is a compound statement enclosed in braces, containing two statements. The loop works in the following manner: first, the value of `i' is set to one. Then, the `while' statement tests whether `i' is less than or equal to three. This is true when -`i' equals one, so the `i'-th field is printed. Then the `i++' +`i' equals one, so the `i'th field is printed. Then the `i++' increments the value of `i' and the loop repeats. The loop terminates when `i' reaches four. A newline is not required between the condition and the body; however, using one makes the program clearer unless the body is a -compound statement or else is very simple. The newline after the -open-brace that begins the compound statement is not required either, -but the program is harder to read without it. +compound statement or else is very simple. The newline after the open +brace that begins the compound statement is not required either, but the +program is harder to read without it. File: gawk.info, Node: Do Statement, Next: For Statement, Prev: While Statement, Up: Statements @@ -9634,7 +9635,7 @@ Contrast this with the corresponding `while' statement: while (CONDITION) BODY -This statement does not execute BODY even once if the CONDITION is +This statement does not execute the BODY even once if the CONDITION is false to begin with. The following is an example of a `do' statement: { @@ -9690,7 +9691,7 @@ loop.) The same is true of the INCREMENT part. Incrementing additional variables requires separate statements at the end of the loop. The C compound expression, using C's comma operator, is useful in this -context but it is not supported in `awk'. +context, but it is not supported in `awk'. Most often, INCREMENT is an increment expression, as in the previous example. But this is not required; it can be any expression @@ -9766,7 +9767,7 @@ statement looks like this: Control flow in the `switch' statement works as it does in C. Once a match to a given case is made, the case statement bodies execute until -a `break', `continue', `next', `nextfile' or `exit' is encountered, or +a `break', `continue', `next', `nextfile', or `exit' is encountered, or the end of the `switch' statement itself. For example: while ((c = getopt(ARGC, ARGV, "aksx")) != -1) { @@ -10009,12 +10010,11 @@ listed in `ARGV'. standard. See the Austin Group website (http://austingroupbugs.net/view.php?id=607). - 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. + 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 @@ -10042,9 +10042,9 @@ record, skips reading any remaining input records, and executes the 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 -variable in the `END' rule. *Note Assert Function::, for an example -that does this. +a variable to a nonzero value before the `exit' statement and check +that variable in the `END' rule. *Note Assert Function::, for an +example that does this. If an argument is supplied to `exit', its value is used as the exit status code for the `awk' process. If no argument is supplied, `exit' @@ -10102,7 +10102,7 @@ of activity. File: gawk.info, Node: User-modified, Next: Auto-set, Up: Built-in Variables -7.5.1 Built-In Variables That Control `awk' +7.5.1 Built-in Variables That Control `awk' ------------------------------------------- The following is an alphabetical list of variables that you can change @@ -33171,7 +33171,7 @@ Index * getline from a file: Getline/File. (line 6) * getline into a variable: Getline/Variable. (line 6) * getline statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. - (line 54) + (line 53) * getlocaltime() user-defined function: Getlocaltime Function. (line 16) * getopt() function (C library): Getopt Function. (line 15) @@ -34739,424 +34739,424 @@ Ref: Close Files And Pipes-Footnote-2315367 Node: Output Summary315517 Node: Output Exercises316515 Node: Expressions317195 -Node: Values318380 -Node: Constants319058 -Node: Scalar Constants319749 -Ref: Scalar Constants-Footnote-1320608 -Node: Nondecimal-numbers320858 -Node: Regexp Constants323876 -Node: Using Constant Regexps324401 -Node: Variables327544 -Node: Using Variables328199 -Node: Assignment Options330110 -Node: Conversion331985 -Node: Strings And Numbers332509 -Ref: Strings And Numbers-Footnote-1335574 -Node: Locale influences conversions335683 -Ref: table-locale-affects338430 -Node: All Operators339018 -Node: Arithmetic Ops339648 -Node: Concatenation342153 -Ref: Concatenation-Footnote-1344972 -Node: Assignment Ops345078 -Ref: table-assign-ops350057 -Node: Increment Ops351329 -Node: Truth Values and Conditions354767 -Node: Truth Values355852 -Node: Typing and Comparison356901 -Node: Variable Typing357711 -Node: Comparison Operators361364 -Ref: table-relational-ops361774 -Node: POSIX String Comparison365269 -Ref: POSIX String Comparison-Footnote-1366341 -Node: Boolean Ops366479 -Ref: Boolean Ops-Footnote-1370958 -Node: Conditional Exp371049 -Node: Function Calls372776 -Node: Precedence376656 -Node: Locales380317 -Node: Expressions Summary381949 -Node: Patterns and Actions384509 -Node: Pattern Overview385629 -Node: Regexp Patterns387308 -Node: Expression Patterns387851 -Node: Ranges391561 -Node: BEGIN/END394667 -Node: Using BEGIN/END395428 -Ref: Using BEGIN/END-Footnote-1398162 -Node: I/O And BEGIN/END398268 -Node: BEGINFILE/ENDFILE400582 -Node: Empty403483 -Node: Using Shell Variables403800 -Node: Action Overview406073 -Node: Statements408399 -Node: If Statement410247 -Node: While Statement411742 -Node: Do Statement413771 -Node: For Statement414915 -Node: Switch Statement418072 -Node: Break Statement420454 -Node: Continue Statement422495 -Node: Next Statement424322 -Node: Nextfile Statement426703 -Node: Exit Statement429333 -Node: Built-in Variables431736 -Node: User-modified432869 -Ref: User-modified-Footnote-1440550 -Node: Auto-set440612 -Ref: Auto-set-Footnote-1454304 -Ref: Auto-set-Footnote-2454509 -Node: ARGC and ARGV454565 -Node: Pattern Action Summary458783 -Node: Arrays461210 -Node: Array Basics462539 -Node: Array Intro463383 -Ref: figure-array-elements465347 -Ref: Array Intro-Footnote-1467873 -Node: Reference to Elements468001 -Node: Assigning Elements470453 -Node: Array Example470944 -Node: Scanning an Array472702 -Node: Controlling Scanning475718 -Ref: Controlling Scanning-Footnote-1480914 -Node: Numeric Array Subscripts481230 -Node: Uninitialized Subscripts483415 -Node: Delete485032 -Ref: Delete-Footnote-1487775 -Node: Multidimensional487832 -Node: Multiscanning490929 -Node: Arrays of Arrays492518 -Node: Arrays Summary497277 -Node: Functions499369 -Node: Built-in500268 -Node: Calling Built-in501346 -Node: Numeric Functions503337 -Ref: Numeric Functions-Footnote-1508156 -Ref: Numeric Functions-Footnote-2508513 -Ref: Numeric Functions-Footnote-3508561 -Node: String Functions508833 -Ref: String Functions-Footnote-1532308 -Ref: String Functions-Footnote-2532437 -Ref: String Functions-Footnote-3532685 -Node: Gory Details532772 -Ref: table-sub-escapes534553 -Ref: table-sub-proposed536073 -Ref: table-posix-sub537437 -Ref: table-gensub-escapes538973 -Ref: Gory Details-Footnote-1539805 -Node: I/O Functions539956 -Ref: I/O Functions-Footnote-1547174 -Node: Time Functions547321 -Ref: Time Functions-Footnote-1557809 -Ref: Time Functions-Footnote-2557877 -Ref: Time Functions-Footnote-3558035 -Ref: Time Functions-Footnote-4558146 -Ref: Time Functions-Footnote-5558258 -Ref: Time Functions-Footnote-6558485 -Node: Bitwise Functions558751 -Ref: table-bitwise-ops559313 -Ref: Bitwise Functions-Footnote-1563622 -Node: Type Functions563791 -Node: I18N Functions564942 -Node: User-defined566587 -Node: Definition Syntax567392 -Ref: Definition Syntax-Footnote-1572799 -Node: Function Example572870 -Ref: Function Example-Footnote-1575789 -Node: Function Caveats575811 -Node: Calling A Function576329 -Node: Variable Scope577287 -Node: Pass By Value/Reference580275 -Node: Return Statement583770 -Node: Dynamic Typing586751 -Node: Indirect Calls587680 -Ref: Indirect Calls-Footnote-1598982 -Node: Functions Summary599110 -Node: Library Functions601812 -Ref: Library Functions-Footnote-1605421 -Ref: Library Functions-Footnote-2605564 -Node: Library Names605735 -Ref: Library Names-Footnote-1609189 -Ref: Library Names-Footnote-2609412 -Node: General Functions609498 -Node: Strtonum Function610601 -Node: Assert Function613623 -Node: Round Function616947 -Node: Cliff Random Function618488 -Node: Ordinal Functions619504 -Ref: Ordinal Functions-Footnote-1622567 -Ref: Ordinal Functions-Footnote-2622819 -Node: Join Function623030 -Ref: Join Function-Footnote-1624799 -Node: Getlocaltime Function624999 -Node: Readfile Function628743 -Node: Shell Quoting630713 -Node: Data File Management632114 -Node: Filetrans Function632746 -Node: Rewind Function636802 -Node: File Checking638189 -Ref: File Checking-Footnote-1639521 -Node: Empty Files639722 -Node: Ignoring Assigns641701 -Node: Getopt Function643252 -Ref: Getopt Function-Footnote-1654714 -Node: Passwd Functions654914 -Ref: Passwd Functions-Footnote-1663751 -Node: Group Functions663839 -Ref: Group Functions-Footnote-1671733 -Node: Walking Arrays671946 -Node: Library Functions Summary673549 -Node: Library Exercises674950 -Node: Sample Programs676230 -Node: Running Examples677000 -Node: Clones677728 -Node: Cut Program678952 -Node: Egrep Program688671 -Ref: Egrep Program-Footnote-1696169 -Node: Id Program696279 -Node: Split Program699924 -Ref: Split Program-Footnote-1703372 -Node: Tee Program703500 -Node: Uniq Program706289 -Node: Wc Program713708 -Ref: Wc Program-Footnote-1717958 -Node: Miscellaneous Programs718052 -Node: Dupword Program719265 -Node: Alarm Program721296 -Node: Translate Program726100 -Ref: Translate Program-Footnote-1730665 -Node: Labels Program730935 -Ref: Labels Program-Footnote-1734286 -Node: Word Sorting734370 -Node: History Sorting738441 -Node: Extract Program740277 -Node: Simple Sed747802 -Node: Igawk Program750870 -Ref: Igawk Program-Footnote-1765194 -Ref: Igawk Program-Footnote-2765395 -Ref: Igawk Program-Footnote-3765517 -Node: Anagram Program765632 -Node: Signature Program768689 -Node: Programs Summary769936 -Node: Programs Exercises771129 -Ref: Programs Exercises-Footnote-1775260 -Node: Advanced Features775351 -Node: Nondecimal Data777299 -Node: Array Sorting778889 -Node: Controlling Array Traversal779586 -Ref: Controlling Array Traversal-Footnote-1787919 -Node: Array Sorting Functions788037 -Ref: Array Sorting Functions-Footnote-1791926 -Node: Two-way I/O792122 -Ref: Two-way I/O-Footnote-1797067 -Ref: Two-way I/O-Footnote-2797253 -Node: TCP/IP Networking797335 -Node: Profiling800208 -Node: Advanced Features Summary808485 -Node: Internationalization810418 -Node: I18N and L10N811898 -Node: Explaining gettext812584 -Ref: Explaining gettext-Footnote-1817609 -Ref: Explaining gettext-Footnote-2817793 -Node: Programmer i18n817958 -Ref: Programmer i18n-Footnote-1822824 -Node: Translator i18n822873 -Node: String Extraction823667 -Ref: String Extraction-Footnote-1824798 -Node: Printf Ordering824884 -Ref: Printf Ordering-Footnote-1827670 -Node: I18N Portability827734 -Ref: I18N Portability-Footnote-1830189 -Node: I18N Example830252 -Ref: I18N Example-Footnote-1833055 -Node: Gawk I18N833127 -Node: I18N Summary833765 -Node: Debugger835104 -Node: Debugging836126 -Node: Debugging Concepts836567 -Node: Debugging Terms838420 -Node: Awk Debugging840992 -Node: Sample Debugging Session841886 -Node: Debugger Invocation842406 -Node: Finding The Bug843790 -Node: List of Debugger Commands850265 -Node: Breakpoint Control851598 -Node: Debugger Execution Control855294 -Node: Viewing And Changing Data858658 -Node: Execution Stack862036 -Node: Debugger Info863673 -Node: Miscellaneous Debugger Commands867690 -Node: Readline Support872719 -Node: Limitations873611 -Node: Debugging Summary875725 -Node: Arbitrary Precision Arithmetic876893 -Node: Computer Arithmetic878309 -Ref: table-numeric-ranges881907 -Ref: Computer Arithmetic-Footnote-1882766 -Node: Math Definitions882823 -Ref: table-ieee-formats886111 -Ref: Math Definitions-Footnote-1886715 -Node: MPFR features886820 -Node: FP Math Caution888491 -Ref: FP Math Caution-Footnote-1889541 -Node: Inexactness of computations889910 -Node: Inexact representation890869 -Node: Comparing FP Values892226 -Node: Errors accumulate893308 -Node: Getting Accuracy894741 -Node: Try To Round897403 -Node: Setting precision898302 -Ref: table-predefined-precision-strings898986 -Node: Setting the rounding mode900775 -Ref: table-gawk-rounding-modes901139 -Ref: Setting the rounding mode-Footnote-1904594 -Node: Arbitrary Precision Integers904773 -Ref: Arbitrary Precision Integers-Footnote-1909673 -Node: POSIX Floating Point Problems909822 -Ref: POSIX Floating Point Problems-Footnote-1913695 -Node: Floating point summary913733 -Node: Dynamic Extensions915927 -Node: Extension Intro917479 -Node: Plugin License918745 -Node: Extension Mechanism Outline919542 -Ref: figure-load-extension919970 -Ref: figure-register-new-function921450 -Ref: figure-call-new-function922454 -Node: Extension API Description924440 -Node: Extension API Functions Introduction925890 -Node: General Data Types930714 -Ref: General Data Types-Footnote-1936453 -Node: Memory Allocation Functions936752 -Ref: Memory Allocation Functions-Footnote-1939591 -Node: Constructor Functions939687 -Node: Registration Functions941421 -Node: Extension Functions942106 -Node: Exit Callback Functions944403 -Node: Extension Version String945651 -Node: Input Parsers946316 -Node: Output Wrappers956195 -Node: Two-way processors960710 -Node: Printing Messages962914 -Ref: Printing Messages-Footnote-1963990 -Node: Updating `ERRNO'964142 -Node: Requesting Values964882 -Ref: table-value-types-returned965610 -Node: Accessing Parameters966567 -Node: Symbol Table Access967798 -Node: Symbol table by name968312 -Node: Symbol table by cookie970293 -Ref: Symbol table by cookie-Footnote-1974437 -Node: Cached values974500 -Ref: Cached values-Footnote-1977999 -Node: Array Manipulation978090 -Ref: Array Manipulation-Footnote-1979188 -Node: Array Data Types979225 -Ref: Array Data Types-Footnote-1981880 -Node: Array Functions981972 -Node: Flattening Arrays985826 -Node: Creating Arrays992718 -Node: Extension API Variables997489 -Node: Extension Versioning998125 -Node: Extension API Informational Variables1000026 -Node: Extension API Boilerplate1001091 -Node: Finding Extensions1004900 -Node: Extension Example1005460 -Node: Internal File Description1006232 -Node: Internal File Ops1010299 -Ref: Internal File Ops-Footnote-11021969 -Node: Using Internal File Ops1022109 -Ref: Using Internal File Ops-Footnote-11024492 -Node: Extension Samples1024765 -Node: Extension Sample File Functions1026291 -Node: Extension Sample Fnmatch1033929 -Node: Extension Sample Fork1035420 -Node: Extension Sample Inplace1036635 -Node: Extension Sample Ord1038310 -Node: Extension Sample Readdir1039146 -Ref: table-readdir-file-types1040022 -Node: Extension Sample Revout1040833 -Node: Extension Sample Rev2way1041423 -Node: Extension Sample Read write array1042163 -Node: Extension Sample Readfile1044103 -Node: Extension Sample Time1045198 -Node: Extension Sample API Tests1046547 -Node: gawkextlib1047038 -Node: Extension summary1049696 -Node: Extension Exercises1053385 -Node: Language History1054107 -Node: V7/SVR3.11055763 -Node: SVR41057944 -Node: POSIX1059389 -Node: BTL1060778 -Node: POSIX/GNU1061512 -Node: Feature History1067136 -Node: Common Extensions1080234 -Node: Ranges and Locales1081558 -Ref: Ranges and Locales-Footnote-11086176 -Ref: Ranges and Locales-Footnote-21086203 -Ref: Ranges and Locales-Footnote-31086437 -Node: Contributors1086658 -Node: History summary1092199 -Node: Installation1093569 -Node: Gawk Distribution1094515 -Node: Getting1094999 -Node: Extracting1095822 -Node: Distribution contents1097457 -Node: Unix Installation1103522 -Node: Quick Installation1104205 -Node: Shell Startup Files1106616 -Node: Additional Configuration Options1107695 -Node: Configuration Philosophy1109434 -Node: Non-Unix Installation1111803 -Node: PC Installation1112261 -Node: PC Binary Installation1113580 -Node: PC Compiling1115428 -Ref: PC Compiling-Footnote-11118449 -Node: PC Testing1118558 -Node: PC Using1119734 -Node: Cygwin1123849 -Node: MSYS1124672 -Node: VMS Installation1125172 -Node: VMS Compilation1125964 -Ref: VMS Compilation-Footnote-11127186 -Node: VMS Dynamic Extensions1127244 -Node: VMS Installation Details1128928 -Node: VMS Running1131180 -Node: VMS GNV1134016 -Node: VMS Old Gawk1134750 -Node: Bugs1135220 -Node: Other Versions1139103 -Node: Installation summary1145527 -Node: Notes1146583 -Node: Compatibility Mode1147448 -Node: Additions1148230 -Node: Accessing The Source1149155 -Node: Adding Code1150590 -Node: New Ports1156747 -Node: Derived Files1161229 -Ref: Derived Files-Footnote-11166704 -Ref: Derived Files-Footnote-21166738 -Ref: Derived Files-Footnote-31167334 -Node: Future Extensions1167448 -Node: Implementation Limitations1168054 -Node: Extension Design1169302 -Node: Old Extension Problems1170456 -Ref: Old Extension Problems-Footnote-11171973 -Node: Extension New Mechanism Goals1172030 -Ref: Extension New Mechanism Goals-Footnote-11175390 -Node: Extension Other Design Decisions1175579 -Node: Extension Future Growth1177687 -Node: Old Extension Mechanism1178523 -Node: Notes summary1180285 -Node: Basic Concepts1181471 -Node: Basic High Level1182152 -Ref: figure-general-flow1182424 -Ref: figure-process-flow1183023 -Ref: Basic High Level-Footnote-11186252 -Node: Basic Data Typing1186437 -Node: Glossary1189765 -Node: Copying1221694 -Node: GNU Free Documentation License1259250 -Node: Index1284386 +Node: Values318384 +Node: Constants319061 +Node: Scalar Constants319752 +Ref: Scalar Constants-Footnote-1320614 +Node: Nondecimal-numbers320864 +Node: Regexp Constants323874 +Node: Using Constant Regexps324400 +Node: Variables327563 +Node: Using Variables328220 +Node: Assignment Options330131 +Node: Conversion332006 +Node: Strings And Numbers332530 +Ref: Strings And Numbers-Footnote-1335595 +Node: Locale influences conversions335704 +Ref: table-locale-affects338450 +Node: All Operators339042 +Node: Arithmetic Ops339671 +Node: Concatenation342176 +Ref: Concatenation-Footnote-1344995 +Node: Assignment Ops345102 +Ref: table-assign-ops350081 +Node: Increment Ops351391 +Node: Truth Values and Conditions354822 +Node: Truth Values355905 +Node: Typing and Comparison356954 +Node: Variable Typing357770 +Node: Comparison Operators361437 +Ref: table-relational-ops361847 +Node: POSIX String Comparison365342 +Ref: POSIX String Comparison-Footnote-1366414 +Node: Boolean Ops366553 +Ref: Boolean Ops-Footnote-1371031 +Node: Conditional Exp371122 +Node: Function Calls372860 +Node: Precedence376740 +Node: Locales380400 +Node: Expressions Summary382032 +Node: Patterns and Actions384603 +Node: Pattern Overview385723 +Node: Regexp Patterns387402 +Node: Expression Patterns387945 +Node: Ranges391654 +Node: BEGIN/END394761 +Node: Using BEGIN/END395522 +Ref: Using BEGIN/END-Footnote-1398258 +Node: I/O And BEGIN/END398364 +Node: BEGINFILE/ENDFILE400679 +Node: Empty403576 +Node: Using Shell Variables403893 +Node: Action Overview406166 +Node: Statements408492 +Node: If Statement410340 +Node: While Statement411835 +Node: Do Statement413863 +Node: For Statement415011 +Node: Switch Statement418169 +Node: Break Statement420551 +Node: Continue Statement422592 +Node: Next Statement424419 +Node: Nextfile Statement426800 +Node: Exit Statement429428 +Node: Built-in Variables431839 +Node: User-modified432972 +Ref: User-modified-Footnote-1440653 +Node: Auto-set440715 +Ref: Auto-set-Footnote-1454407 +Ref: Auto-set-Footnote-2454612 +Node: ARGC and ARGV454668 +Node: Pattern Action Summary458886 +Node: Arrays461313 +Node: Array Basics462642 +Node: Array Intro463486 +Ref: figure-array-elements465450 +Ref: Array Intro-Footnote-1467976 +Node: Reference to Elements468104 +Node: Assigning Elements470556 +Node: Array Example471047 +Node: Scanning an Array472805 +Node: Controlling Scanning475821 +Ref: Controlling Scanning-Footnote-1481017 +Node: Numeric Array Subscripts481333 +Node: Uninitialized Subscripts483518 +Node: Delete485135 +Ref: Delete-Footnote-1487878 +Node: Multidimensional487935 +Node: Multiscanning491032 +Node: Arrays of Arrays492621 +Node: Arrays Summary497380 +Node: Functions499472 +Node: Built-in500371 +Node: Calling Built-in501449 +Node: Numeric Functions503440 +Ref: Numeric Functions-Footnote-1508259 +Ref: Numeric Functions-Footnote-2508616 +Ref: Numeric Functions-Footnote-3508664 +Node: String Functions508936 +Ref: String Functions-Footnote-1532411 +Ref: String Functions-Footnote-2532540 +Ref: String Functions-Footnote-3532788 +Node: Gory Details532875 +Ref: table-sub-escapes534656 +Ref: table-sub-proposed536176 +Ref: table-posix-sub537540 +Ref: table-gensub-escapes539076 +Ref: Gory Details-Footnote-1539908 +Node: I/O Functions540059 +Ref: I/O Functions-Footnote-1547277 +Node: Time Functions547424 +Ref: Time Functions-Footnote-1557912 +Ref: Time Functions-Footnote-2557980 +Ref: Time Functions-Footnote-3558138 +Ref: Time Functions-Footnote-4558249 +Ref: Time Functions-Footnote-5558361 +Ref: Time Functions-Footnote-6558588 +Node: Bitwise Functions558854 +Ref: table-bitwise-ops559416 +Ref: Bitwise Functions-Footnote-1563725 +Node: Type Functions563894 +Node: I18N Functions565045 +Node: User-defined566690 +Node: Definition Syntax567495 +Ref: Definition Syntax-Footnote-1572902 +Node: Function Example572973 +Ref: Function Example-Footnote-1575892 +Node: Function Caveats575914 +Node: Calling A Function576432 +Node: Variable Scope577390 +Node: Pass By Value/Reference580378 +Node: Return Statement583873 +Node: Dynamic Typing586854 +Node: Indirect Calls587783 +Ref: Indirect Calls-Footnote-1599085 +Node: Functions Summary599213 +Node: Library Functions601915 +Ref: Library Functions-Footnote-1605524 +Ref: Library Functions-Footnote-2605667 +Node: Library Names605838 +Ref: Library Names-Footnote-1609292 +Ref: Library Names-Footnote-2609515 +Node: General Functions609601 +Node: Strtonum Function610704 +Node: Assert Function613726 +Node: Round Function617050 +Node: Cliff Random Function618591 +Node: Ordinal Functions619607 +Ref: Ordinal Functions-Footnote-1622670 +Ref: Ordinal Functions-Footnote-2622922 +Node: Join Function623133 +Ref: Join Function-Footnote-1624902 +Node: Getlocaltime Function625102 +Node: Readfile Function628846 +Node: Shell Quoting630816 +Node: Data File Management632217 +Node: Filetrans Function632849 +Node: Rewind Function636905 +Node: File Checking638292 +Ref: File Checking-Footnote-1639624 +Node: Empty Files639825 +Node: Ignoring Assigns641804 +Node: Getopt Function643355 +Ref: Getopt Function-Footnote-1654817 +Node: Passwd Functions655017 +Ref: Passwd Functions-Footnote-1663854 +Node: Group Functions663942 +Ref: Group Functions-Footnote-1671836 +Node: Walking Arrays672049 +Node: Library Functions Summary673652 +Node: Library Exercises675053 +Node: Sample Programs676333 +Node: Running Examples677103 +Node: Clones677831 +Node: Cut Program679055 +Node: Egrep Program688774 +Ref: Egrep Program-Footnote-1696272 +Node: Id Program696382 +Node: Split Program700027 +Ref: Split Program-Footnote-1703475 +Node: Tee Program703603 +Node: Uniq Program706392 +Node: Wc Program713811 +Ref: Wc Program-Footnote-1718061 +Node: Miscellaneous Programs718155 +Node: Dupword Program719368 +Node: Alarm Program721399 +Node: Translate Program726203 +Ref: Translate Program-Footnote-1730768 +Node: Labels Program731038 +Ref: Labels Program-Footnote-1734389 +Node: Word Sorting734473 +Node: History Sorting738544 +Node: Extract Program740380 +Node: Simple Sed747905 +Node: Igawk Program750973 +Ref: Igawk Program-Footnote-1765297 +Ref: Igawk Program-Footnote-2765498 +Ref: Igawk Program-Footnote-3765620 +Node: Anagram Program765735 +Node: Signature Program768792 +Node: Programs Summary770039 +Node: Programs Exercises771232 +Ref: Programs Exercises-Footnote-1775363 +Node: Advanced Features775454 +Node: Nondecimal Data777402 +Node: Array Sorting778992 +Node: Controlling Array Traversal779689 +Ref: Controlling Array Traversal-Footnote-1788022 +Node: Array Sorting Functions788140 +Ref: Array Sorting Functions-Footnote-1792029 +Node: Two-way I/O792225 +Ref: Two-way I/O-Footnote-1797170 +Ref: Two-way I/O-Footnote-2797356 +Node: TCP/IP Networking797438 +Node: Profiling800311 +Node: Advanced Features Summary808588 +Node: Internationalization810521 +Node: I18N and L10N812001 +Node: Explaining gettext812687 +Ref: Explaining gettext-Footnote-1817712 +Ref: Explaining gettext-Footnote-2817896 +Node: Programmer i18n818061 +Ref: Programmer i18n-Footnote-1822927 +Node: Translator i18n822976 +Node: String Extraction823770 +Ref: String Extraction-Footnote-1824901 +Node: Printf Ordering824987 +Ref: Printf Ordering-Footnote-1827773 +Node: I18N Portability827837 +Ref: I18N Portability-Footnote-1830292 +Node: I18N Example830355 +Ref: I18N Example-Footnote-1833158 +Node: Gawk I18N833230 +Node: I18N Summary833868 +Node: Debugger835207 +Node: Debugging836229 +Node: Debugging Concepts836670 +Node: Debugging Terms838523 +Node: Awk Debugging841095 +Node: Sample Debugging Session841989 +Node: Debugger Invocation842509 +Node: Finding The Bug843893 +Node: List of Debugger Commands850368 +Node: Breakpoint Control851701 +Node: Debugger Execution Control855397 +Node: Viewing And Changing Data858761 +Node: Execution Stack862139 +Node: Debugger Info863776 +Node: Miscellaneous Debugger Commands867793 +Node: Readline Support872822 +Node: Limitations873714 +Node: Debugging Summary875828 +Node: Arbitrary Precision Arithmetic876996 +Node: Computer Arithmetic878412 +Ref: table-numeric-ranges882010 +Ref: Computer Arithmetic-Footnote-1882869 +Node: Math Definitions882926 +Ref: table-ieee-formats886214 +Ref: Math Definitions-Footnote-1886818 +Node: MPFR features886923 +Node: FP Math Caution888594 +Ref: FP Math Caution-Footnote-1889644 +Node: Inexactness of computations890013 +Node: Inexact representation890972 +Node: Comparing FP Values892329 +Node: Errors accumulate893411 +Node: Getting Accuracy894844 +Node: Try To Round897506 +Node: Setting precision898405 +Ref: table-predefined-precision-strings899089 +Node: Setting the rounding mode900878 +Ref: table-gawk-rounding-modes901242 +Ref: Setting the rounding mode-Footnote-1904697 +Node: Arbitrary Precision Integers904876 +Ref: Arbitrary Precision Integers-Footnote-1909776 +Node: POSIX Floating Point Problems909925 +Ref: POSIX Floating Point Problems-Footnote-1913798 +Node: Floating point summary913836 +Node: Dynamic Extensions916030 +Node: Extension Intro917582 +Node: Plugin License918848 +Node: Extension Mechanism Outline919645 +Ref: figure-load-extension920073 +Ref: figure-register-new-function921553 +Ref: figure-call-new-function922557 +Node: Extension API Description924543 +Node: Extension API Functions Introduction925993 +Node: General Data Types930817 +Ref: General Data Types-Footnote-1936556 +Node: Memory Allocation Functions936855 +Ref: Memory Allocation Functions-Footnote-1939694 +Node: Constructor Functions939790 +Node: Registration Functions941524 +Node: Extension Functions942209 +Node: Exit Callback Functions944506 +Node: Extension Version String945754 +Node: Input Parsers946419 +Node: Output Wrappers956298 +Node: Two-way processors960813 +Node: Printing Messages963017 +Ref: Printing Messages-Footnote-1964093 +Node: Updating `ERRNO'964245 +Node: Requesting Values964985 +Ref: table-value-types-returned965713 +Node: Accessing Parameters966670 +Node: Symbol Table Access967901 +Node: Symbol table by name968415 +Node: Symbol table by cookie970396 +Ref: Symbol table by cookie-Footnote-1974540 +Node: Cached values974603 +Ref: Cached values-Footnote-1978102 +Node: Array Manipulation978193 +Ref: Array Manipulation-Footnote-1979291 +Node: Array Data Types979328 +Ref: Array Data Types-Footnote-1981983 +Node: Array Functions982075 +Node: Flattening Arrays985929 +Node: Creating Arrays992821 +Node: Extension API Variables997592 +Node: Extension Versioning998228 +Node: Extension API Informational Variables1000129 +Node: Extension API Boilerplate1001194 +Node: Finding Extensions1005003 +Node: Extension Example1005563 +Node: Internal File Description1006335 +Node: Internal File Ops1010402 +Ref: Internal File Ops-Footnote-11022072 +Node: Using Internal File Ops1022212 +Ref: Using Internal File Ops-Footnote-11024595 +Node: Extension Samples1024868 +Node: Extension Sample File Functions1026394 +Node: Extension Sample Fnmatch1034032 +Node: Extension Sample Fork1035523 +Node: Extension Sample Inplace1036738 +Node: Extension Sample Ord1038413 +Node: Extension Sample Readdir1039249 +Ref: table-readdir-file-types1040125 +Node: Extension Sample Revout1040936 +Node: Extension Sample Rev2way1041526 +Node: Extension Sample Read write array1042266 +Node: Extension Sample Readfile1044206 +Node: Extension Sample Time1045301 +Node: Extension Sample API Tests1046650 +Node: gawkextlib1047141 +Node: Extension summary1049799 +Node: Extension Exercises1053488 +Node: Language History1054210 +Node: V7/SVR3.11055866 +Node: SVR41058047 +Node: POSIX1059492 +Node: BTL1060881 +Node: POSIX/GNU1061615 +Node: Feature History1067239 +Node: Common Extensions1080337 +Node: Ranges and Locales1081661 +Ref: Ranges and Locales-Footnote-11086279 +Ref: Ranges and Locales-Footnote-21086306 +Ref: Ranges and Locales-Footnote-31086540 +Node: Contributors1086761 +Node: History summary1092302 +Node: Installation1093672 +Node: Gawk Distribution1094618 +Node: Getting1095102 +Node: Extracting1095925 +Node: Distribution contents1097560 +Node: Unix Installation1103625 +Node: Quick Installation1104308 +Node: Shell Startup Files1106719 +Node: Additional Configuration Options1107798 +Node: Configuration Philosophy1109537 +Node: Non-Unix Installation1111906 +Node: PC Installation1112364 +Node: PC Binary Installation1113683 +Node: PC Compiling1115531 +Ref: PC Compiling-Footnote-11118552 +Node: PC Testing1118661 +Node: PC Using1119837 +Node: Cygwin1123952 +Node: MSYS1124775 +Node: VMS Installation1125275 +Node: VMS Compilation1126067 +Ref: VMS Compilation-Footnote-11127289 +Node: VMS Dynamic Extensions1127347 +Node: VMS Installation Details1129031 +Node: VMS Running1131283 +Node: VMS GNV1134119 +Node: VMS Old Gawk1134853 +Node: Bugs1135323 +Node: Other Versions1139206 +Node: Installation summary1145630 +Node: Notes1146686 +Node: Compatibility Mode1147551 +Node: Additions1148333 +Node: Accessing The Source1149258 +Node: Adding Code1150693 +Node: New Ports1156850 +Node: Derived Files1161332 +Ref: Derived Files-Footnote-11166807 +Ref: Derived Files-Footnote-21166841 +Ref: Derived Files-Footnote-31167437 +Node: Future Extensions1167551 +Node: Implementation Limitations1168157 +Node: Extension Design1169405 +Node: Old Extension Problems1170559 +Ref: Old Extension Problems-Footnote-11172076 +Node: Extension New Mechanism Goals1172133 +Ref: Extension New Mechanism Goals-Footnote-11175493 +Node: Extension Other Design Decisions1175682 +Node: Extension Future Growth1177790 +Node: Old Extension Mechanism1178626 +Node: Notes summary1180388 +Node: Basic Concepts1181574 +Node: Basic High Level1182255 +Ref: figure-general-flow1182527 +Ref: figure-process-flow1183126 +Ref: Basic High Level-Footnote-11186355 +Node: Basic Data Typing1186540 +Node: Glossary1189868 +Node: Copying1221797 +Node: GNU Free Documentation License1259353 +Node: Index1284489 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index a0995368..ac973b9b 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -10510,7 +10510,7 @@ can assign a new value to a variable or a field by using an assignment operator. An expression can serve as a pattern or action statement on its own. Most other kinds of statements contain one or more expressions that specify the data on which to -operate. As in other languages, expressions in @command{awk} include +operate. As in other languages, expressions in @command{awk} can include variables, array references, constants, and function calls, as well as combinations of these with various operators. @@ -10529,7 +10529,7 @@ combinations of these with various operators. Expressions are built up from values and the operations performed upon them. This @value{SECTION} describes the elementary objects -which provide the values used in expressions. +that provide the values used in expressions. @menu * Constants:: String, numeric and regexp constants. @@ -10579,7 +10579,7 @@ have the same value: @end example @cindex string constants -A string constant consists of a sequence of characters enclosed in +A @dfn{string constant} consists of a sequence of characters enclosed in double quotation marks. For example: @example @@ -10591,7 +10591,7 @@ double quotation marks. For example: @cindex strings, length limitations represents the string whose contents are @samp{parrot}. Strings in @command{gawk} can be of any length, and they can contain any of the possible -eight-bit ASCII characters including ASCII @sc{nul} (character code zero). +eight-bit ASCII characters, including ASCII @sc{nul} (character code zero). Other @command{awk} implementations may have difficulty with some character codes. @@ -10606,15 +10606,15 @@ In @command{awk}, all numbers are in decimal (i.e., base 10). Many other programming languages allow you to specify numbers in other bases, often octal (base 8) and hexadecimal (base 16). In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on. -Just as @samp{11}, in decimal, is 1 times 10 plus 1, so -@samp{11}, in octal, is 1 times 8, plus 1. This equals 9 in decimal. +Just as @samp{11} in decimal is 1 times 10 plus 1, so +@samp{11} in octal is 1 times 8 plus 1. This equals 9 in decimal. In hexadecimal, there are 16 digits. Because the everyday decimal number system only has ten digits (@samp{0}--@samp{9}), the letters @samp{a} through @samp{f} are used to represent the rest. (Case in the letters is usually irrelevant; hexadecimal @samp{a} and @samp{A} have the same value.) -Thus, @samp{11}, in -hexadecimal, is 1 times 16 plus 1, which equals 17 in decimal. +Thus, @samp{11} in +hexadecimal is 1 times 16 plus 1, which equals 17 in decimal. Just by looking at plain @samp{11}, you can't tell what base it's in. So, in C, C++, and other languages derived from C, @@ -10625,13 +10625,13 @@ and hexadecimal numbers start with a leading @samp{0x} or @samp{0X}: @table @code @item 11 -Decimal value 11. +Decimal value 11 @item 011 -Octal 11, decimal value 9. +Octal 11, decimal value 9 @item 0x11 -Hexadecimal 11, decimal value 17. +Hexadecimal 11, decimal value 17 @end table This example shows the difference: @@ -10659,11 +10659,11 @@ you can use the @code{strtonum()} function (@pxref{String Functions}) to convert the data into a number. Most of the time, you will want to use octal or hexadecimal constants -when working with the built-in bit manipulation functions; +when working with the built-in bit-manipulation functions; see @DBREF{Bitwise Functions} for more information. -Unlike some early C implementations, @samp{8} and @samp{9} are not +Unlike in some early C implementations, @samp{8} and @samp{9} are not valid in octal constants. For example, @command{gawk} treats @samp{018} as decimal 18: @@ -10732,12 +10732,12 @@ $ @kbd{gawk 'BEGIN @{ printf "0x11 is <%s>\n", 0x11 @}'} @cindex tilde (@code{~}), @code{~} operator @cindex @code{!} (exclamation point), @code{!~} operator @cindex exclamation point (@code{!}), @code{!~} operator -A regexp constant is a regular expression description enclosed in +A @dfn{regexp constant} is a regular expression description enclosed in slashes, such as @code{@w{/^beginning and end$/}}. Most regexps used in @command{awk} programs are constant, but the @samp{~} and @samp{!~} matching operators can also match computed or dynamic regexps (which are typically just ordinary strings or variables that contain a regexp, -but could be a more complex expression). +but could be more complex expressions). @node Using Constant Regexps @subsection Using Regular Expression Constants @@ -10817,7 +10817,7 @@ the third argument of @code{split()} to be a regexp constant, but some older implementations do not. @value{DARKCORNER} Because some built-in functions accept regexp constants as arguments, -it can be confusing when attempting to use regexp constants as arguments +confusion can arise when attempting to use regexp constants as arguments to user-defined functions (@pxref{User-defined}). For example: @example @@ -10843,7 +10843,7 @@ function mysub(pat, repl, str, global) In this example, the programmer wants to pass a regexp constant to the user-defined function @code{mysub()}, which in turn passes it on to either @code{sub()} or @code{gsub()}. However, what really happens is that -the @code{pat} parameter is either one or zero, depending upon whether +the @code{pat} parameter is assigned a value of either one or zero, depending upon whether or not @code{$0} matches @code{/hi/}. @command{gawk} issues a warning when it sees a regexp constant used as a parameter to a user-defined function, because passing a truth value in @@ -10854,7 +10854,7 @@ this way is probably not what was intended. @cindex variables, user-defined @cindex user-defined, variables -Variables are ways of storing values at one point in your program for +@dfn{Variables} are ways of storing values at one point in your program for use later in another part of your program. They can be manipulated entirely within the program text, and they can also be assigned values on the @command{awk} command line. @@ -10882,17 +10882,17 @@ are distinct variables. A variable name is a valid expression by itself; it represents the variable's current value. Variables are given new values with @dfn{assignment operators}, @dfn{increment operators}, and -@dfn{decrement operators}. -@xref{Assignment Ops}. +@dfn{decrement operators} +(@pxref{Assignment Ops}). In addition, the @code{sub()} and @code{gsub()} functions can change a variable's value, and the @code{match()}, @code{split()}, and @code{patsplit()} functions can change the contents of their -array parameters. @xref{String Functions}. +array parameters (@pxref{String Functions}). @cindex variables, built-in @cindex variables, initializing A few variables have special built-in meanings, such as @code{FS} (the -field separator), and @code{NF} (the number of fields in the current input +field separator) and @code{NF} (the number of fields in the current input record). @DBXREF{Built-in Variables} for a list of the predefined variables. These predefined variables can be used and assigned just like all other variables, but their values are also used or changed automatically by @@ -11149,7 +11149,7 @@ point, so the default behavior was restored to use a period as the decimal point character. You can use the @option{--use-lc-numeric} option (@pxref{Options}) to force @command{gawk} to use the locale's decimal point character. (@command{gawk} also uses the locale's decimal -point character when in POSIX mode, either via @option{--posix}, or the +point character when in POSIX mode, either via @option{--posix} or the @env{POSIXLY_CORRECT} environment variable, as shown previously.) @ref{table-locale-affects} describes the cases in which the locale's decimal @@ -11167,7 +11167,7 @@ features have not been described yet. @end multitable @end float -Finally, modern day formal standards and IEEE standard floating-point +Finally, modern-day formal standards and the IEEE standard floating-point representation can have an unusual but important effect on the way @command{gawk} converts some special string values to numbers. The details are presented in @ref{POSIX Floating Point Problems}. @@ -11175,7 +11175,7 @@ are presented in @ref{POSIX Floating Point Problems}. @node All Operators @section Operators: Doing Something with Values -This @value{SECTION} introduces the @dfn{operators} which make use +This @value{SECTION} introduces the @dfn{operators} that make use of the values provided by constants and variables. @menu @@ -11353,7 +11353,7 @@ print "something meaningful" > file name @noindent This produces a syntax error with some versions of Unix @command{awk}.@footnote{It happens that BWK -@command{awk}, @command{gawk} and @command{mawk} all ``get it right,'' +@command{awk}, @command{gawk}, and @command{mawk} all ``get it right,'' but you should not rely on this.} It is necessary to use the following: @@ -11603,7 +11603,7 @@ and @ifdocbook @DBREF{Numeric Functions} @end ifdocbook -for more information). +for more information.) This example illustrates an important fact about assignment operators: the lefthand expression is only evaluated @emph{once}. @@ -11639,17 +11639,17 @@ to a number. @caption{Arithmetic assignment operators} @multitable @columnfractions .30 .70 @headitem Operator @tab Effect -@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue} -@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue} -@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient} -@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor} -@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus} +@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue}. +@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue}. +@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient}. +@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor}. +@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus}. @cindex common extensions, @code{**=} operator @cindex extensions, common@comma{} @code{**=} operator @cindex @command{awk} language, POSIX version @cindex POSIX @command{awk} -@item @var{lvalue} @code{^=} @var{power} @tab -@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power} @value{COMMONEXT} +@item @var{lvalue} @code{^=} @var{power} @tab Raise @var{lvalue} to the power @var{power}. +@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power}. @value{COMMONEXT} @end multitable @end float @@ -11845,8 +11845,8 @@ like @samp{@var{lvalue}++}, but instead of adding, it subtracts.) @cindex evaluation order @cindex Marx, Groucho @quotation -@i{Doctor, doctor! It hurts when I do this!@* -So don't do that!} +@i{Doctor, it hurts when I do this!@* +Then don't do that!} @author Groucho Marx @end quotation @@ -11870,7 +11870,7 @@ print b @cindex side effects In other words, when do the various side effects prescribed by the postfix operators (@samp{b++}) take effect? -When side effects happen is @dfn{implementation defined}. +When side effects happen is @dfn{implementation-defined}. In other words, it is up to the particular version of @command{awk}. The result for the first example may be 12 or 13, and for the second, it may be 22 or 23. @@ -11897,8 +11897,8 @@ You should avoid such things in your own programs. @cindex evaluation order @cindex Marx, Groucho @quotation -@i{Doctor, doctor! It hurts when I do this!@* -So don't do that!} +@i{Doctor, it hurts when I do this!@* +Then don't do that!} @author Groucho Marx @end quotation @@ -11922,7 +11922,7 @@ print b @cindex side effects In other words, when do the various side effects prescribed by the postfix operators (@samp{b++}) take effect? -When side effects happen is @dfn{implementation defined}. +When side effects happen is @dfn{implementation-defined}. In other words, it is up to the particular version of @command{awk}. The result for the first example may be 12 or 13, and for the second, it may be 22 or 23. @@ -11938,8 +11938,8 @@ You should avoid such things in your own programs. @node Truth Values and Conditions @section Truth Values and Conditions -In certain contexts, expression values also serve as ``truth values''; (i.e., -they determine what should happen next as the program runs). This +In certain contexts, expression values also serve as ``truth values''; i.e., +they determine what should happen next as the program runs. This @value{SECTION} describes how @command{awk} defines ``true'' and ``false'' and how values are compared. @@ -12006,7 +12006,7 @@ the string constant @code{"0"} is actually true, because it is non-null. @cindex operators, relational, See operators@comma{} comparison @cindex variable typing @cindex variables, types of, comparison expressions and -Unlike other programming languages, @command{awk} variables do not have a +Unlike in other programming languages, in @command{awk} variables do not have a fixed type. Instead, they can be either a number or a string, depending upon the value that is assigned to them. We look now at how variables are typed, and how @command{awk} @@ -12035,20 +12035,20 @@ Variable typing follows these rules: @itemize @value{BULLET} @item -A numeric constant or the result of a numeric operation has the @var{numeric} +A numeric constant or the result of a numeric operation has the @dfn{numeric} attribute. @item -A string constant or the result of a string operation has the @var{string} +A string constant or the result of a string operation has the @dfn{string} attribute. @item Fields, @code{getline} input, @code{FILENAME}, @code{ARGV} elements, @code{ENVIRON} elements, and the elements of an array created by @code{match()}, @code{split()}, and @code{patsplit()} that are numeric -strings have the @var{strnum} attribute. Otherwise, they have -the @var{string} attribute. Uninitialized variables also have the -@var{strnum} attribute. +strings have the @dfn{strnum} attribute. Otherwise, they have +the @dfn{string} attribute. Uninitialized variables also have the +@dfn{strnum} attribute. @item Attributes propagate across assignments but are not changed by @@ -12192,13 +12192,13 @@ constant, then a string comparison is performed. Otherwise, a numeric comparison is performed. This point bears additional emphasis: All user input is made of characters, -and so is first and foremost of @var{string} type; input strings -that look numeric are additionally given the @var{strnum} attribute. +and so is first and foremost of string type; input strings +that look numeric are additionally given the strnum attribute. Thus, the six-character input string @w{@samp{ +3.14}} receives the -@var{strnum} attribute. In contrast, the eight characters +strnum attribute. In contrast, the eight characters @w{@code{" +3.14"}} appearing in program text comprise a string constant. The following examples print @samp{1} when the comparison between -the two different constants is true, @samp{0} otherwise: +the two different constants is true, and @samp{0} otherwise: @c 22.9.2014: Tested with mawk and BWK awk, got same results. @example @@ -12328,7 +12328,7 @@ $ @kbd{echo 1e2 3 | awk '@{ print ($1 < $2) ? "true" : "false" @}'} @noindent the result is @samp{false} because both @code{$1} and @code{$2} are user input. They are numeric strings---therefore both have -the @var{strnum} attribute, dictating a numeric comparison. +the strnum attribute, dictating a numeric comparison. The purpose of the comparison rules and the use of numeric strings is to attempt to produce the behavior that is ``least surprising,'' while still ``doing the right thing.'' @@ -12387,7 +12387,7 @@ characters sort, as defined by the locale (for more discussion, @pxref{Locales}). This order is usually very different from the results obtained when doing straight character-by-character comparison.@footnote{Technically, string comparison is supposed -to behave the same way as if the strings are compared with the C +to behave the same way as if the strings were compared with the C @code{strcoll()} function.} Because this behavior differs considerably from existing practice, @@ -12494,7 +12494,7 @@ BEGIN @{ if (! ("HOME" in ENVIRON)) @cindex vertical bar (@code{|}), @code{||} operator The @samp{&&} and @samp{||} operators are called @dfn{short-circuit} operators because of the way they work. Evaluation of the full expression -is ``short-circuited'' if the result can be determined part way through +is ``short-circuited'' if the result can be determined partway through its evaluation. @cindex line continuations @@ -12566,8 +12566,8 @@ The reason it's there is to avoid printing the bracketing A @dfn{conditional expression} is a special kind of expression that has three operands. It allows you to use one expression's value to select one of two other expressions. -The conditional expression is the same as in the C language, -as shown here: +The conditional expression in @command{awk} is the same as in the C +language, as shown here: @example @var{selector} ? @var{if-true-exp} : @var{if-false-exp} @@ -12576,8 +12576,8 @@ as shown here: @noindent There are three subexpressions. The first, @var{selector}, is always computed first. If it is ``true'' (not zero or not null), then -@var{if-true-exp} is computed next and its value becomes the value of -the whole expression. Otherwise, @var{if-false-exp} is computed next +@var{if-true-exp} is computed next, and its value becomes the value of +the whole expression. Otherwise, @var{if-false-exp} is computed next, and its value becomes the value of the whole expression. For example, the following expression produces the absolute value of @code{x}: @@ -12625,7 +12625,7 @@ ask for it by name at any point in the program. For example, the function @code{sqrt()} computes the square root of a number. @cindex functions, built-in -A fixed set of functions are @dfn{built-in}, which means they are +A fixed set of functions are @dfn{built in}, which means they are available in every @command{awk} program. The @code{sqrt()} function is one of these. @DBXREF{Built-in} for a list of built-in functions and their descriptions. In addition, you can define @@ -12799,7 +12799,7 @@ Increment, decrement. @cindex @code{*} (asterisk), @code{**} operator @cindex asterisk (@code{*}), @code{**} operator @item @code{^ **} -Exponentiation. These operators group right-to-left. +Exponentiation. These operators group right to left. @cindex @code{+} (plus sign), @code{+} operator @cindex plus sign (@code{+}), @code{+} operator @@ -12865,7 +12865,7 @@ statements belong to the statement level, not to expressions. The redirection does not produce an expression that could be the operand of another operator. As a result, it does not make sense to use a redirection operator near another operator of lower precedence without -parentheses. Such combinations (e.g., @samp{print foo > a ? b : c}), +parentheses. Such combinations (e.g., @samp{print foo > a ? b : c}) result in syntax errors. The correct way to write this statement is @samp{print foo > (a ? b : c)}. @@ -12883,17 +12883,17 @@ Array membership. @cindex @code{&} (ampersand), @code{&&} operator @cindex ampersand (@code{&}), @code{&&} operator @item @code{&&} -Logical ``and''. +Logical ``and.'' @cindex @code{|} (vertical bar), @code{||} operator @cindex vertical bar (@code{|}), @code{||} operator @item @code{||} -Logical ``or''. +Logical ``or.'' @cindex @code{?} (question mark), @code{?:} operator @cindex question mark (@code{?}), @code{?:} operator @item @code{?:} -Conditional. This operator groups right-to-left. +Conditional. This operator groups right to left. @cindex @code{+} (plus sign), @code{+=} operator @cindex plus sign (@code{+}), @code{+=} operator @@ -12910,7 +12910,7 @@ Conditional. This operator groups right-to-left. @cindex @code{^} (caret), @code{^=} operator @cindex caret (@code{^}), @code{^=} operator @item @code{= += -= *= /= %= ^= **=} -Assignment. These operators group right-to-left. +Assignment. These operators group right to left. @end table @cindex POSIX @command{awk}, @code{**} operator and @@ -12984,8 +12984,8 @@ Locales can influence the conversions. @item @command{awk} provides the usual arithmetic operators (addition, subtraction, multiplication, division, modulus), and unary plus and minus. -It also provides comparison operators, boolean operators, array membership -testing, and regexp +It also provides comparison operators, Boolean operators, an array membership +testing operator, and regexp matching operators. String concatenation is accomplished by placing two expressions next to each other; there is no explicit operator. The three-operand @samp{?:} operator provides an ``if-else'' test within @@ -12996,7 +12996,7 @@ Assignment operators provide convenient shorthands for common arithmetic operations. @item -In @command{awk}, a value is considered to be true if it is non-zero +In @command{awk}, a value is considered to be true if it is nonzero @emph{or} non-null. Otherwise, the value is false. @item @@ -13005,7 +13005,7 @@ lifetime. The type determines how it behaves in comparisons (string or numeric). @item -Function calls return a value which may be used as part of a larger +Function calls return a value that may be used as part of a larger expression. Expressions used to pass parameter values are fully evaluated before the function is called. @command{awk} provides built-in and user-defined functions; this is described in @@ -13032,7 +13032,7 @@ a pattern with an associated action. This @value{CHAPTER} describes how you build patterns and actions, what kinds of things you can do within actions, and @command{awk}'s predefined variables. -The pattern-action rules and the statements available for use +The pattern--action rules and the statements available for use within actions form the core of @command{awk} programming. In a sense, everything covered up to here has been the foundation @@ -13223,7 +13223,7 @@ patterns. Likewise, the special patterns @code{BEGIN}, @code{END}, which never match any input record, are not expressions and cannot appear inside Boolean patterns. -The precedence of the different operators which can appear in +The precedence of the different operators that can appear in patterns is described in @ref{Precedence}. @node Ranges @@ -13249,7 +13249,7 @@ prints every record in @file{myfile} between @samp{on}/@samp{off} pairs, inclusi A range pattern starts out by matching @var{begpat} against every input record. When a record matches @var{begpat}, the range pattern is -@dfn{turned on} and the range pattern matches this record as well. As long as +@dfn{turned on}, and the range pattern matches this record as well. As long as the range pattern stays turned on, it automatically matches every input record read. The range pattern also matches @var{endpat} against every input record; when this succeeds, the range pattern is @dfn{turned off} again @@ -13393,7 +13393,7 @@ using library functions. for a number of useful library functions. If an @command{awk} program has only @code{BEGIN} rules and no -other rules, then the program exits after the @code{BEGIN} rule is +other rules, then the program exits after the @code{BEGIN} rules are run.@footnote{The original version of @command{awk} kept reading and ignoring input until the end of the file was seen.} However, if an @code{END} rule exists, then the input is read, even if there are @@ -13421,7 +13421,7 @@ Another way is simply to assign a value to @code{$0}. @cindex @code{print} statement, @code{BEGIN}/@code{END} patterns and @cindex @code{BEGIN} pattern, @code{print} statement and @cindex @code{END} pattern, @code{print} statement and -The second point is similar to the first but from the other direction. +The second point is similar to the first, but from the other direction. Traditionally, due largely to implementation issues, @code{$0} and @code{NF} were @emph{undefined} inside an @code{END} rule. The POSIX standard specifies that @code{NF} is available in an @code{END} @@ -13510,7 +13510,7 @@ fatal error. @item If you have written extensions that modify the record handling (by -inserting an ``input parser,'' @pxref{Input Parsers}), you can invoke +inserting an ``input parser''; @pxref{Input Parsers}), you can invoke them at this point, before @command{gawk} has started processing the file. (This is a @emph{very} advanced feature, currently used only by the @uref{http://gawkextlib.sourceforge.net, @code{gawkextlib} project}.) @@ -13521,8 +13521,8 @@ the last record in an input file. For the last input file, it will be called before any @code{END} rules. The @code{ENDFILE} rule is executed even for empty input files. -Normally, when an error occurs when reading input in the normal input -processing loop, the error is fatal. However, if an @code{ENDFILE} +Normally, when an error occurs when reading input in the normal +input-processing loop, the error is fatal. However, if an @code{ENDFILE} rule is present, the error becomes non-fatal, and instead @code{ERRNO} is set. This makes it possible to catch and process I/O errors at the level of the @command{awk} program. @@ -13531,7 +13531,7 @@ level of the @command{awk} program. The @code{next} statement (@pxref{Next Statement}) is not allowed inside either a @code{BEGINFILE} or an @code{ENDFILE} rule. The @code{nextfile} statement is allowed only inside a -@code{BEGINFILE} rule, but not inside an @code{ENDFILE} rule. +@code{BEGINFILE} rule, not inside an @code{ENDFILE} rule. @cindex @code{getline} statement, @code{BEGINFILE}/@code{ENDFILE} patterns and The @code{getline} statement (@pxref{Getline}) is restricted inside @@ -13607,11 +13607,11 @@ awk "/$pattern/ "'@{ nmatches++ @} @noindent The @command{awk} program consists of two pieces of quoted text that are concatenated together to form the program. -The first part is double quoted, which allows substitution of +The first part is double-quoted, which allows substitution of the @code{pattern} shell variable inside the quotes. -The second part is single quoted. +The second part is single-quoted. -Variable substitution via quoting works, but can be potentially +Variable substitution via quoting works, but can potentially be messy. It requires a good understanding of the shell's quoting rules (@pxref{Quoting}), and it's often difficult to correctly @@ -13870,13 +13870,13 @@ The body of this loop is a compound statement enclosed in braces, containing two statements. The loop works in the following manner: first, the value of @code{i} is set to one. Then, the @code{while} statement tests whether @code{i} is less than or equal to -three. This is true when @code{i} equals one, so the @code{i}-th +three. This is true when @code{i} equals one, so the @code{i}th field is printed. Then the @samp{i++} increments the value of @code{i} and the loop repeats. The loop terminates when @code{i} reaches four. A newline is not required between the condition and the body; however, using one makes the program clearer unless the body is a -compound statement or else is very simple. The newline after the open-brace +compound statement or else is very simple. The newline after the open brace that begins the compound statement is not required either, but the program is harder to read without it. @@ -13906,9 +13906,9 @@ while (@var{condition}) @end example @noindent -This statement does not execute @var{body} even once if the @var{condition} -is false to begin with. -The following is an example of a @code{do} statement: +This statement does not execute the @var{body} even once if the +@var{condition} is false to begin with. The following is an example of +a @code{do} statement: @example @{ @@ -13975,7 +13975,7 @@ their assignments as separate statements preceding the @code{for} loop.) The same is true of the @var{increment} part. Incrementing additional variables requires separate statements at the end of the loop. The C compound expression, using C's comma operator, is useful in -this context but it is not supported in @command{awk}. +this context, but it is not supported in @command{awk}. Most often, @var{increment} is an increment expression, as in the previous example. But this is not required; it can be any expression @@ -14066,7 +14066,7 @@ default: Control flow in the @code{switch} statement works as it does in C. Once a match to a given case is made, the case statement bodies execute until a @code{break}, -@code{continue}, @code{next}, @code{nextfile} or @code{exit} is encountered, +@code{continue}, @code{next}, @code{nextfile}, or @code{exit} is encountered, or the end of the @code{switch} statement itself. For example: @example @@ -14240,7 +14240,12 @@ body of a loop. Historical versions of @command{awk} treated a @code{continue} statement outside a loop the same way they treated a @code{break} statement outside a loop: as if it were a @code{next} statement +@ifset FOR_PRINT +(discussed in the following section). +@end ifset +@ifclear FOR_PRINT (@pxref{Next Statement}). +@end ifclear @value{DARKCORNER} Recent versions of BWK @command{awk} no longer work this way, nor does @command{gawk}. @@ -14368,7 +14373,7 @@ See @uref{http://austingroupbugs.net/view.php?id=607, the Austin Group website}. @cindex @code{nextfile} statement, user-defined functions and @cindex Brian Kernighan's @command{awk} @cindex @command{mawk} utility -The current version of BWK @command{awk}, and @command{mawk} +The current version of BWK @command{awk} and @command{mawk} also support @code{nextfile}. However, they don't allow the @code{nextfile} statement inside function bodies (@pxref{User-defined}). @command{gawk} does; a @code{nextfile} inside a function body reads the @@ -14406,7 +14411,7 @@ any @code{ENDFILE} rules; they do not execute. In such a case, if you don't want the @code{END} rule to do its job, set a variable -to nonzero before the @code{exit} statement and check that variable in +to a nonzero value before the @code{exit} statement and check that variable in the @code{END} rule. @DBXREF{Assert Function} for an example that does this. @@ -14474,7 +14479,7 @@ their areas of activity. @end menu @node User-modified -@subsection Built-In Variables That Control @command{awk} +@subsection Built-in Variables That Control @command{awk} @cindex predefined variables, user-modifiable @cindex user-modifiable variables diff --git a/doc/gawktexi.in b/doc/gawktexi.in index dfa8cc03..9f20f608 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -10006,7 +10006,7 @@ can assign a new value to a variable or a field by using an assignment operator. An expression can serve as a pattern or action statement on its own. Most other kinds of statements contain one or more expressions that specify the data on which to -operate. As in other languages, expressions in @command{awk} include +operate. As in other languages, expressions in @command{awk} can include variables, array references, constants, and function calls, as well as combinations of these with various operators. @@ -10025,7 +10025,7 @@ combinations of these with various operators. Expressions are built up from values and the operations performed upon them. This @value{SECTION} describes the elementary objects -which provide the values used in expressions. +that provide the values used in expressions. @menu * Constants:: String, numeric and regexp constants. @@ -10075,7 +10075,7 @@ have the same value: @end example @cindex string constants -A string constant consists of a sequence of characters enclosed in +A @dfn{string constant} consists of a sequence of characters enclosed in double quotation marks. For example: @example @@ -10087,7 +10087,7 @@ double quotation marks. For example: @cindex strings, length limitations represents the string whose contents are @samp{parrot}. Strings in @command{gawk} can be of any length, and they can contain any of the possible -eight-bit ASCII characters including ASCII @sc{nul} (character code zero). +eight-bit ASCII characters, including ASCII @sc{nul} (character code zero). Other @command{awk} implementations may have difficulty with some character codes. @@ -10102,15 +10102,15 @@ In @command{awk}, all numbers are in decimal (i.e., base 10). Many other programming languages allow you to specify numbers in other bases, often octal (base 8) and hexadecimal (base 16). In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, and so on. -Just as @samp{11}, in decimal, is 1 times 10 plus 1, so -@samp{11}, in octal, is 1 times 8, plus 1. This equals 9 in decimal. +Just as @samp{11} in decimal is 1 times 10 plus 1, so +@samp{11} in octal is 1 times 8 plus 1. This equals 9 in decimal. In hexadecimal, there are 16 digits. Because the everyday decimal number system only has ten digits (@samp{0}--@samp{9}), the letters @samp{a} through @samp{f} are used to represent the rest. (Case in the letters is usually irrelevant; hexadecimal @samp{a} and @samp{A} have the same value.) -Thus, @samp{11}, in -hexadecimal, is 1 times 16 plus 1, which equals 17 in decimal. +Thus, @samp{11} in +hexadecimal is 1 times 16 plus 1, which equals 17 in decimal. Just by looking at plain @samp{11}, you can't tell what base it's in. So, in C, C++, and other languages derived from C, @@ -10121,13 +10121,13 @@ and hexadecimal numbers start with a leading @samp{0x} or @samp{0X}: @table @code @item 11 -Decimal value 11. +Decimal value 11 @item 011 -Octal 11, decimal value 9. +Octal 11, decimal value 9 @item 0x11 -Hexadecimal 11, decimal value 17. +Hexadecimal 11, decimal value 17 @end table This example shows the difference: @@ -10155,11 +10155,11 @@ you can use the @code{strtonum()} function (@pxref{String Functions}) to convert the data into a number. Most of the time, you will want to use octal or hexadecimal constants -when working with the built-in bit manipulation functions; +when working with the built-in bit-manipulation functions; see @DBREF{Bitwise Functions} for more information. -Unlike some early C implementations, @samp{8} and @samp{9} are not +Unlike in some early C implementations, @samp{8} and @samp{9} are not valid in octal constants. For example, @command{gawk} treats @samp{018} as decimal 18: @@ -10199,12 +10199,12 @@ $ @kbd{gawk 'BEGIN @{ printf "0x11 is <%s>\n", 0x11 @}'} @cindex tilde (@code{~}), @code{~} operator @cindex @code{!} (exclamation point), @code{!~} operator @cindex exclamation point (@code{!}), @code{!~} operator -A regexp constant is a regular expression description enclosed in +A @dfn{regexp constant} is a regular expression description enclosed in slashes, such as @code{@w{/^beginning and end$/}}. Most regexps used in @command{awk} programs are constant, but the @samp{~} and @samp{!~} matching operators can also match computed or dynamic regexps (which are typically just ordinary strings or variables that contain a regexp, -but could be a more complex expression). +but could be more complex expressions). @node Using Constant Regexps @subsection Using Regular Expression Constants @@ -10284,7 +10284,7 @@ the third argument of @code{split()} to be a regexp constant, but some older implementations do not. @value{DARKCORNER} Because some built-in functions accept regexp constants as arguments, -it can be confusing when attempting to use regexp constants as arguments +confusion can arise when attempting to use regexp constants as arguments to user-defined functions (@pxref{User-defined}). For example: @example @@ -10310,7 +10310,7 @@ function mysub(pat, repl, str, global) In this example, the programmer wants to pass a regexp constant to the user-defined function @code{mysub()}, which in turn passes it on to either @code{sub()} or @code{gsub()}. However, what really happens is that -the @code{pat} parameter is either one or zero, depending upon whether +the @code{pat} parameter is assigned a value of either one or zero, depending upon whether or not @code{$0} matches @code{/hi/}. @command{gawk} issues a warning when it sees a regexp constant used as a parameter to a user-defined function, because passing a truth value in @@ -10321,7 +10321,7 @@ this way is probably not what was intended. @cindex variables, user-defined @cindex user-defined, variables -Variables are ways of storing values at one point in your program for +@dfn{Variables} are ways of storing values at one point in your program for use later in another part of your program. They can be manipulated entirely within the program text, and they can also be assigned values on the @command{awk} command line. @@ -10349,17 +10349,17 @@ are distinct variables. A variable name is a valid expression by itself; it represents the variable's current value. Variables are given new values with @dfn{assignment operators}, @dfn{increment operators}, and -@dfn{decrement operators}. -@xref{Assignment Ops}. +@dfn{decrement operators} +(@pxref{Assignment Ops}). In addition, the @code{sub()} and @code{gsub()} functions can change a variable's value, and the @code{match()}, @code{split()}, and @code{patsplit()} functions can change the contents of their -array parameters. @xref{String Functions}. +array parameters (@pxref{String Functions}). @cindex variables, built-in @cindex variables, initializing A few variables have special built-in meanings, such as @code{FS} (the -field separator), and @code{NF} (the number of fields in the current input +field separator) and @code{NF} (the number of fields in the current input record). @DBXREF{Built-in Variables} for a list of the predefined variables. These predefined variables can be used and assigned just like all other variables, but their values are also used or changed automatically by @@ -10587,7 +10587,7 @@ point, so the default behavior was restored to use a period as the decimal point character. You can use the @option{--use-lc-numeric} option (@pxref{Options}) to force @command{gawk} to use the locale's decimal point character. (@command{gawk} also uses the locale's decimal -point character when in POSIX mode, either via @option{--posix}, or the +point character when in POSIX mode, either via @option{--posix} or the @env{POSIXLY_CORRECT} environment variable, as shown previously.) @ref{table-locale-affects} describes the cases in which the locale's decimal @@ -10605,7 +10605,7 @@ features have not been described yet. @end multitable @end float -Finally, modern day formal standards and IEEE standard floating-point +Finally, modern-day formal standards and the IEEE standard floating-point representation can have an unusual but important effect on the way @command{gawk} converts some special string values to numbers. The details are presented in @ref{POSIX Floating Point Problems}. @@ -10613,7 +10613,7 @@ are presented in @ref{POSIX Floating Point Problems}. @node All Operators @section Operators: Doing Something with Values -This @value{SECTION} introduces the @dfn{operators} which make use +This @value{SECTION} introduces the @dfn{operators} that make use of the values provided by constants and variables. @menu @@ -10791,7 +10791,7 @@ print "something meaningful" > file name @noindent This produces a syntax error with some versions of Unix @command{awk}.@footnote{It happens that BWK -@command{awk}, @command{gawk} and @command{mawk} all ``get it right,'' +@command{awk}, @command{gawk}, and @command{mawk} all ``get it right,'' but you should not rely on this.} It is necessary to use the following: @@ -11041,7 +11041,7 @@ and @ifdocbook @DBREF{Numeric Functions} @end ifdocbook -for more information). +for more information.) This example illustrates an important fact about assignment operators: the lefthand expression is only evaluated @emph{once}. @@ -11077,17 +11077,17 @@ to a number. @caption{Arithmetic assignment operators} @multitable @columnfractions .30 .70 @headitem Operator @tab Effect -@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue} -@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue} -@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient} -@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor} -@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus} +@item @var{lvalue} @code{+=} @var{increment} @tab Add @var{increment} to the value of @var{lvalue}. +@item @var{lvalue} @code{-=} @var{decrement} @tab Subtract @var{decrement} from the value of @var{lvalue}. +@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiply the value of @var{lvalue} by @var{coefficient}. +@item @var{lvalue} @code{/=} @var{divisor} @tab Divide the value of @var{lvalue} by @var{divisor}. +@item @var{lvalue} @code{%=} @var{modulus} @tab Set @var{lvalue} to its remainder by @var{modulus}. @cindex common extensions, @code{**=} operator @cindex extensions, common@comma{} @code{**=} operator @cindex @command{awk} language, POSIX version @cindex POSIX @command{awk} -@item @var{lvalue} @code{^=} @var{power} @tab -@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power} @value{COMMONEXT} +@item @var{lvalue} @code{^=} @var{power} @tab Raise @var{lvalue} to the power @var{power}. +@item @var{lvalue} @code{**=} @var{power} @tab Raise @var{lvalue} to the power @var{power}. @value{COMMONEXT} @end multitable @end float @@ -11226,8 +11226,8 @@ like @samp{@var{lvalue}++}, but instead of adding, it subtracts.) @cindex evaluation order @cindex Marx, Groucho @quotation -@i{Doctor, doctor! It hurts when I do this!@* -So don't do that!} +@i{Doctor, it hurts when I do this!@* +Then don't do that!} @author Groucho Marx @end quotation @@ -11251,7 +11251,7 @@ print b @cindex side effects In other words, when do the various side effects prescribed by the postfix operators (@samp{b++}) take effect? -When side effects happen is @dfn{implementation defined}. +When side effects happen is @dfn{implementation-defined}. In other words, it is up to the particular version of @command{awk}. The result for the first example may be 12 or 13, and for the second, it may be 22 or 23. @@ -11266,8 +11266,8 @@ You should avoid such things in your own programs. @node Truth Values and Conditions @section Truth Values and Conditions -In certain contexts, expression values also serve as ``truth values''; (i.e., -they determine what should happen next as the program runs). This +In certain contexts, expression values also serve as ``truth values''; i.e., +they determine what should happen next as the program runs. This @value{SECTION} describes how @command{awk} defines ``true'' and ``false'' and how values are compared. @@ -11334,7 +11334,7 @@ the string constant @code{"0"} is actually true, because it is non-null. @cindex operators, relational, See operators@comma{} comparison @cindex variable typing @cindex variables, types of, comparison expressions and -Unlike other programming languages, @command{awk} variables do not have a +Unlike in other programming languages, in @command{awk} variables do not have a fixed type. Instead, they can be either a number or a string, depending upon the value that is assigned to them. We look now at how variables are typed, and how @command{awk} @@ -11363,20 +11363,20 @@ Variable typing follows these rules: @itemize @value{BULLET} @item -A numeric constant or the result of a numeric operation has the @var{numeric} +A numeric constant or the result of a numeric operation has the @dfn{numeric} attribute. @item -A string constant or the result of a string operation has the @var{string} +A string constant or the result of a string operation has the @dfn{string} attribute. @item Fields, @code{getline} input, @code{FILENAME}, @code{ARGV} elements, @code{ENVIRON} elements, and the elements of an array created by @code{match()}, @code{split()}, and @code{patsplit()} that are numeric -strings have the @var{strnum} attribute. Otherwise, they have -the @var{string} attribute. Uninitialized variables also have the -@var{strnum} attribute. +strings have the @dfn{strnum} attribute. Otherwise, they have +the @dfn{string} attribute. Uninitialized variables also have the +@dfn{strnum} attribute. @item Attributes propagate across assignments but are not changed by @@ -11520,13 +11520,13 @@ constant, then a string comparison is performed. Otherwise, a numeric comparison is performed. This point bears additional emphasis: All user input is made of characters, -and so is first and foremost of @var{string} type; input strings -that look numeric are additionally given the @var{strnum} attribute. +and so is first and foremost of string type; input strings +that look numeric are additionally given the strnum attribute. Thus, the six-character input string @w{@samp{ +3.14}} receives the -@var{strnum} attribute. In contrast, the eight characters +strnum attribute. In contrast, the eight characters @w{@code{" +3.14"}} appearing in program text comprise a string constant. The following examples print @samp{1} when the comparison between -the two different constants is true, @samp{0} otherwise: +the two different constants is true, and @samp{0} otherwise: @c 22.9.2014: Tested with mawk and BWK awk, got same results. @example @@ -11656,7 +11656,7 @@ $ @kbd{echo 1e2 3 | awk '@{ print ($1 < $2) ? "true" : "false" @}'} @noindent the result is @samp{false} because both @code{$1} and @code{$2} are user input. They are numeric strings---therefore both have -the @var{strnum} attribute, dictating a numeric comparison. +the strnum attribute, dictating a numeric comparison. The purpose of the comparison rules and the use of numeric strings is to attempt to produce the behavior that is ``least surprising,'' while still ``doing the right thing.'' @@ -11715,7 +11715,7 @@ characters sort, as defined by the locale (for more discussion, @pxref{Locales}). This order is usually very different from the results obtained when doing straight character-by-character comparison.@footnote{Technically, string comparison is supposed -to behave the same way as if the strings are compared with the C +to behave the same way as if the strings were compared with the C @code{strcoll()} function.} Because this behavior differs considerably from existing practice, @@ -11822,7 +11822,7 @@ BEGIN @{ if (! ("HOME" in ENVIRON)) @cindex vertical bar (@code{|}), @code{||} operator The @samp{&&} and @samp{||} operators are called @dfn{short-circuit} operators because of the way they work. Evaluation of the full expression -is ``short-circuited'' if the result can be determined part way through +is ``short-circuited'' if the result can be determined partway through its evaluation. @cindex line continuations @@ -11894,8 +11894,8 @@ The reason it's there is to avoid printing the bracketing A @dfn{conditional expression} is a special kind of expression that has three operands. It allows you to use one expression's value to select one of two other expressions. -The conditional expression is the same as in the C language, -as shown here: +The conditional expression in @command{awk} is the same as in the C +language, as shown here: @example @var{selector} ? @var{if-true-exp} : @var{if-false-exp} @@ -11904,8 +11904,8 @@ as shown here: @noindent There are three subexpressions. The first, @var{selector}, is always computed first. If it is ``true'' (not zero or not null), then -@var{if-true-exp} is computed next and its value becomes the value of -the whole expression. Otherwise, @var{if-false-exp} is computed next +@var{if-true-exp} is computed next, and its value becomes the value of +the whole expression. Otherwise, @var{if-false-exp} is computed next, and its value becomes the value of the whole expression. For example, the following expression produces the absolute value of @code{x}: @@ -11953,7 +11953,7 @@ ask for it by name at any point in the program. For example, the function @code{sqrt()} computes the square root of a number. @cindex functions, built-in -A fixed set of functions are @dfn{built-in}, which means they are +A fixed set of functions are @dfn{built in}, which means they are available in every @command{awk} program. The @code{sqrt()} function is one of these. @DBXREF{Built-in} for a list of built-in functions and their descriptions. In addition, you can define @@ -12127,7 +12127,7 @@ Increment, decrement. @cindex @code{*} (asterisk), @code{**} operator @cindex asterisk (@code{*}), @code{**} operator @item @code{^ **} -Exponentiation. These operators group right-to-left. +Exponentiation. These operators group right to left. @cindex @code{+} (plus sign), @code{+} operator @cindex plus sign (@code{+}), @code{+} operator @@ -12193,7 +12193,7 @@ statements belong to the statement level, not to expressions. The redirection does not produce an expression that could be the operand of another operator. As a result, it does not make sense to use a redirection operator near another operator of lower precedence without -parentheses. Such combinations (e.g., @samp{print foo > a ? b : c}), +parentheses. Such combinations (e.g., @samp{print foo > a ? b : c}) result in syntax errors. The correct way to write this statement is @samp{print foo > (a ? b : c)}. @@ -12211,17 +12211,17 @@ Array membership. @cindex @code{&} (ampersand), @code{&&} operator @cindex ampersand (@code{&}), @code{&&} operator @item @code{&&} -Logical ``and''. +Logical ``and.'' @cindex @code{|} (vertical bar), @code{||} operator @cindex vertical bar (@code{|}), @code{||} operator @item @code{||} -Logical ``or''. +Logical ``or.'' @cindex @code{?} (question mark), @code{?:} operator @cindex question mark (@code{?}), @code{?:} operator @item @code{?:} -Conditional. This operator groups right-to-left. +Conditional. This operator groups right to left. @cindex @code{+} (plus sign), @code{+=} operator @cindex plus sign (@code{+}), @code{+=} operator @@ -12238,7 +12238,7 @@ Conditional. This operator groups right-to-left. @cindex @code{^} (caret), @code{^=} operator @cindex caret (@code{^}), @code{^=} operator @item @code{= += -= *= /= %= ^= **=} -Assignment. These operators group right-to-left. +Assignment. These operators group right to left. @end table @cindex POSIX @command{awk}, @code{**} operator and @@ -12312,8 +12312,8 @@ Locales can influence the conversions. @item @command{awk} provides the usual arithmetic operators (addition, subtraction, multiplication, division, modulus), and unary plus and minus. -It also provides comparison operators, boolean operators, array membership -testing, and regexp +It also provides comparison operators, Boolean operators, an array membership +testing operator, and regexp matching operators. String concatenation is accomplished by placing two expressions next to each other; there is no explicit operator. The three-operand @samp{?:} operator provides an ``if-else'' test within @@ -12324,7 +12324,7 @@ Assignment operators provide convenient shorthands for common arithmetic operations. @item -In @command{awk}, a value is considered to be true if it is non-zero +In @command{awk}, a value is considered to be true if it is nonzero @emph{or} non-null. Otherwise, the value is false. @item @@ -12333,7 +12333,7 @@ lifetime. The type determines how it behaves in comparisons (string or numeric). @item -Function calls return a value which may be used as part of a larger +Function calls return a value that may be used as part of a larger expression. Expressions used to pass parameter values are fully evaluated before the function is called. @command{awk} provides built-in and user-defined functions; this is described in @@ -12360,7 +12360,7 @@ a pattern with an associated action. This @value{CHAPTER} describes how you build patterns and actions, what kinds of things you can do within actions, and @command{awk}'s predefined variables. -The pattern-action rules and the statements available for use +The pattern--action rules and the statements available for use within actions form the core of @command{awk} programming. In a sense, everything covered up to here has been the foundation @@ -12551,7 +12551,7 @@ patterns. Likewise, the special patterns @code{BEGIN}, @code{END}, which never match any input record, are not expressions and cannot appear inside Boolean patterns. -The precedence of the different operators which can appear in +The precedence of the different operators that can appear in patterns is described in @ref{Precedence}. @node Ranges @@ -12577,7 +12577,7 @@ prints every record in @file{myfile} between @samp{on}/@samp{off} pairs, inclusi A range pattern starts out by matching @var{begpat} against every input record. When a record matches @var{begpat}, the range pattern is -@dfn{turned on} and the range pattern matches this record as well. As long as +@dfn{turned on}, and the range pattern matches this record as well. As long as the range pattern stays turned on, it automatically matches every input record read. The range pattern also matches @var{endpat} against every input record; when this succeeds, the range pattern is @dfn{turned off} again @@ -12721,7 +12721,7 @@ using library functions. for a number of useful library functions. If an @command{awk} program has only @code{BEGIN} rules and no -other rules, then the program exits after the @code{BEGIN} rule is +other rules, then the program exits after the @code{BEGIN} rules are run.@footnote{The original version of @command{awk} kept reading and ignoring input until the end of the file was seen.} However, if an @code{END} rule exists, then the input is read, even if there are @@ -12749,7 +12749,7 @@ Another way is simply to assign a value to @code{$0}. @cindex @code{print} statement, @code{BEGIN}/@code{END} patterns and @cindex @code{BEGIN} pattern, @code{print} statement and @cindex @code{END} pattern, @code{print} statement and -The second point is similar to the first but from the other direction. +The second point is similar to the first, but from the other direction. Traditionally, due largely to implementation issues, @code{$0} and @code{NF} were @emph{undefined} inside an @code{END} rule. The POSIX standard specifies that @code{NF} is available in an @code{END} @@ -12838,7 +12838,7 @@ fatal error. @item If you have written extensions that modify the record handling (by -inserting an ``input parser,'' @pxref{Input Parsers}), you can invoke +inserting an ``input parser''; @pxref{Input Parsers}), you can invoke them at this point, before @command{gawk} has started processing the file. (This is a @emph{very} advanced feature, currently used only by the @uref{http://gawkextlib.sourceforge.net, @code{gawkextlib} project}.) @@ -12849,8 +12849,8 @@ the last record in an input file. For the last input file, it will be called before any @code{END} rules. The @code{ENDFILE} rule is executed even for empty input files. -Normally, when an error occurs when reading input in the normal input -processing loop, the error is fatal. However, if an @code{ENDFILE} +Normally, when an error occurs when reading input in the normal +input-processing loop, the error is fatal. However, if an @code{ENDFILE} rule is present, the error becomes non-fatal, and instead @code{ERRNO} is set. This makes it possible to catch and process I/O errors at the level of the @command{awk} program. @@ -12859,7 +12859,7 @@ level of the @command{awk} program. The @code{next} statement (@pxref{Next Statement}) is not allowed inside either a @code{BEGINFILE} or an @code{ENDFILE} rule. The @code{nextfile} statement is allowed only inside a -@code{BEGINFILE} rule, but not inside an @code{ENDFILE} rule. +@code{BEGINFILE} rule, not inside an @code{ENDFILE} rule. @cindex @code{getline} statement, @code{BEGINFILE}/@code{ENDFILE} patterns and The @code{getline} statement (@pxref{Getline}) is restricted inside @@ -12935,11 +12935,11 @@ awk "/$pattern/ "'@{ nmatches++ @} @noindent The @command{awk} program consists of two pieces of quoted text that are concatenated together to form the program. -The first part is double quoted, which allows substitution of +The first part is double-quoted, which allows substitution of the @code{pattern} shell variable inside the quotes. -The second part is single quoted. +The second part is single-quoted. -Variable substitution via quoting works, but can be potentially +Variable substitution via quoting works, but can potentially be messy. It requires a good understanding of the shell's quoting rules (@pxref{Quoting}), and it's often difficult to correctly @@ -13198,13 +13198,13 @@ The body of this loop is a compound statement enclosed in braces, containing two statements. The loop works in the following manner: first, the value of @code{i} is set to one. Then, the @code{while} statement tests whether @code{i} is less than or equal to -three. This is true when @code{i} equals one, so the @code{i}-th +three. This is true when @code{i} equals one, so the @code{i}th field is printed. Then the @samp{i++} increments the value of @code{i} and the loop repeats. The loop terminates when @code{i} reaches four. A newline is not required between the condition and the body; however, using one makes the program clearer unless the body is a -compound statement or else is very simple. The newline after the open-brace +compound statement or else is very simple. The newline after the open brace that begins the compound statement is not required either, but the program is harder to read without it. @@ -13234,9 +13234,9 @@ while (@var{condition}) @end example @noindent -This statement does not execute @var{body} even once if the @var{condition} -is false to begin with. -The following is an example of a @code{do} statement: +This statement does not execute the @var{body} even once if the +@var{condition} is false to begin with. The following is an example of +a @code{do} statement: @example @{ @@ -13303,7 +13303,7 @@ their assignments as separate statements preceding the @code{for} loop.) The same is true of the @var{increment} part. Incrementing additional variables requires separate statements at the end of the loop. The C compound expression, using C's comma operator, is useful in -this context but it is not supported in @command{awk}. +this context, but it is not supported in @command{awk}. Most often, @var{increment} is an increment expression, as in the previous example. But this is not required; it can be any expression @@ -13394,7 +13394,7 @@ default: Control flow in the @code{switch} statement works as it does in C. Once a match to a given case is made, the case statement bodies execute until a @code{break}, -@code{continue}, @code{next}, @code{nextfile} or @code{exit} is encountered, +@code{continue}, @code{next}, @code{nextfile}, or @code{exit} is encountered, or the end of the @code{switch} statement itself. For example: @example @@ -13568,7 +13568,12 @@ body of a loop. Historical versions of @command{awk} treated a @code{continue} statement outside a loop the same way they treated a @code{break} statement outside a loop: as if it were a @code{next} statement +@ifset FOR_PRINT +(discussed in the following section). +@end ifset +@ifclear FOR_PRINT (@pxref{Next Statement}). +@end ifclear @value{DARKCORNER} Recent versions of BWK @command{awk} no longer work this way, nor does @command{gawk}. @@ -13696,7 +13701,7 @@ See @uref{http://austingroupbugs.net/view.php?id=607, the Austin Group website}. @cindex @code{nextfile} statement, user-defined functions and @cindex Brian Kernighan's @command{awk} @cindex @command{mawk} utility -The current version of BWK @command{awk}, and @command{mawk} +The current version of BWK @command{awk} and @command{mawk} also support @code{nextfile}. However, they don't allow the @code{nextfile} statement inside function bodies (@pxref{User-defined}). @command{gawk} does; a @code{nextfile} inside a function body reads the @@ -13734,7 +13739,7 @@ any @code{ENDFILE} rules; they do not execute. In such a case, if you don't want the @code{END} rule to do its job, set a variable -to nonzero before the @code{exit} statement and check that variable in +to a nonzero value before the @code{exit} statement and check that variable in the @code{END} rule. @DBXREF{Assert Function} for an example that does this. @@ -13802,7 +13807,7 @@ their areas of activity. @end menu @node User-modified -@subsection Built-In Variables That Control @command{awk} +@subsection Built-in Variables That Control @command{awk} @cindex predefined variables, user-modifiable @cindex user-modifiable variables |