diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-01-27 06:22:44 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-01-27 06:22:44 +0200 |
commit | 2f80bf28898274324a07d0b0d7c0e955f591c0df (patch) | |
tree | 71a526bc73c43964db48521a12e9606b2a97b1c0 | |
parent | 2b9f0aae3eab5715283e843c66e4f02b221493f1 (diff) | |
parent | 62fe40d1944810a79c13bd519a5f1157c49cefb6 (diff) | |
download | egawk-2f80bf28898274324a07d0b0d7c0e955f591c0df.tar.gz egawk-2f80bf28898274324a07d0b0d7c0e955f591c0df.tar.bz2 egawk-2f80bf28898274324a07d0b0d7c0e955f591c0df.zip |
Merge branch 'gawk-4.1-stable'
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 806 | ||||
-rw-r--r-- | doc/gawk.texi | 120 | ||||
-rw-r--r-- | doc/gawktexi.in | 120 |
4 files changed, 548 insertions, 502 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 7bd533fa..2d924497 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-01-27 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: O'Reilly fixes. + 2015-01-26 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: O'Reilly fixes. diff --git a/doc/gawk.info b/doc/gawk.info index b48319b7..3bcfde12 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -10870,9 +10870,9 @@ languages allow arbitrary starting and ending indices--e.g., `15 .. 27'--but the size of the array is still fixed when the array is declared.) - A contiguous array of four elements might look like the following -example, conceptually, if the element values are 8, `"foo"', `""', and -30 as shown in *note figure-array-elements::: + A contiguous array of four elements might look like *note +figure-array-elements::, conceptually, if the element values are eight, +`"foo"', `""', and 30. +---------+---------+--------+---------+ | 8 | "foo" | "" | 30 | @r{Value} @@ -10881,17 +10881,19 @@ example, conceptually, if the element values are 8, `"foo"', `""', and Figure 8.1: A contiguous array Only the values are stored; the indices are implicit from the order of -the values. Here, 8 is the value at index zero, because 8 appears in the -position with zero elements before it. +the values. Here, eight is the value at index zero, because eight +appears in the position with zero elements before it. Arrays in `awk' are different--they are "associative". This means that each array is a collection of pairs--an index and its corresponding array element value: - Index 3 Value 30 - Index 1 Value "foo" - Index 0 Value 8 - Index 2 Value "" + Index Value +------------------------ + `3' `30' + `1' `"foo"' + `0' `8' + `2' `""' The pairs are shown in jumbled order because their order is irrelevant.(1) @@ -10900,11 +10902,13 @@ irrelevant.(1) at any time. For example, suppose a tenth element is added to the array whose value is `"number ten"'. The result is: - Index 10 Value "number ten" - Index 3 Value 30 - Index 1 Value "foo" - Index 0 Value 8 - Index 2 Value "" + Index Value +------------------------------- + `10' `"number ten"' + `3' `30' + `1' `"foo"' + `0' `8' + `2' `""' Now the array is "sparse", which just means some indices are missing. It has elements 0-3 and 10, but doesn't have elements 4, 5, 6, 7, 8, or @@ -10915,17 +10919,19 @@ have to be positive integers. Any number, or even a string, can be an index. For example, the following is an array that translates words from English to French: - Index "dog" Value "chien" - Index "cat" Value "chat" - Index "one" Value "un" - Index 1 Value "un" + Index Value +------------------------ + `"dog"' `"chien"' + `"cat"' `"chat"' + `"one"' `"un"' + `1' `"un"' Here we decided to translate the number one in both spelled-out and numeric form--thus illustrating that a single array can have both numbers and strings as indices. (In fact, array subscripts are always strings. There are some subtleties to how numbers work when used as array subscripts; this is discussed in more detail in *note Numeric -Array Subscripts::.) Here, the number `1' isn't double quoted, because +Array Subscripts::.) Here, the number `1' isn't double-quoted, because `awk' automatically converts it to a string. The value of `IGNORECASE' has no effect upon array subscripting. @@ -10949,7 +10955,7 @@ File: gawk.info, Node: Reference to Elements, Next: Assigning Elements, Prev: ----------------------------------- The principal way to use an array is to refer to one of its elements. -An array reference is an expression as follows: +An "array reference" is an expression as follows: ARRAY[INDEX-EXPRESSION] @@ -10957,8 +10963,8 @@ Here, ARRAY is the name of an array. The expression INDEX-EXPRESSION is the index of the desired element of the array. The value of the array reference is the current value of that array -element. For example, `foo[4.3]' is an expression for the element of -array `foo' at index `4.3'. +element. For example, `foo[4.3]' is an expression referencing the +element of array `foo' at index `4.3'. A reference to an array element that has no recorded value yields a value of `""', the null string. This includes elements that have not @@ -11025,7 +11031,7 @@ File: gawk.info, Node: Array Example, Next: Scanning an Array, Prev: Assignin The following program takes a list of lines, each beginning with a line number, and prints them out in order of line number. The line numbers -are not in order when they are first read--instead they are scrambled. +are not in order when they are first read--instead, they are scrambled. This program sorts the lines by making an array using the line numbers as subscripts. The program then prints out the lines in sorted order of their numbers. It is a very simple program and gets confused upon @@ -11096,7 +11102,7 @@ has previously used, with the variable VAR set to that index. The following program uses this form of the `for' statement. The first rule scans the input records and notes which words appear (at least once) in the input, by storing a one into the array `used' with -the word as index. The second rule scans the elements of `used' to +the word as the index. The second rule scans the elements of `used' to find all the distinct words that appear in the input. It prints each word that is more than 10 characters long and also prints the number of such words. *Note String Functions::, for more information on the @@ -11179,7 +11185,7 @@ internal implementation of arrays and will vary from one version of Often, though, you may wish to do something simple, such as "traverse the array by comparing the indices in ascending order," or "traverse the array by comparing the values in descending order." -`gawk' provides two mechanisms which give you this control. +`gawk' provides two mechanisms that give you this control: * Set `PROCINFO["sorted_in"]' to one of a set of predefined values. We describe this now. @@ -11227,22 +11233,26 @@ available: which `gawk' uses internally to perform the sorting. `"@ind_str_desc"' - String indices ordered from high to low. + Like `"@ind_str_asc"', but the string indices are ordered from + high to low. `"@ind_num_desc"' - Numeric indices ordered from high to low. + Like `"@ind_num_asc"', but the numeric indices are ordered from + high to low. `"@val_type_desc"' - Element values, based on type, ordered from high to low. - Subarrays, if present, come out first. + Like `"@val_type_asc"', but the element values, based on type, are + ordered from high to low. Subarrays, if present, come out first. `"@val_str_desc"' - Element values, treated as strings, ordered from high to low. - Subarrays, if present, come out first. + Like `"@val_str_asc"', but the element values, treated as strings, + are ordered from high to low. Subarrays, if present, come out + first. `"@val_num_desc"' - Element values, treated as numbers, ordered from high to low. - Subarrays, if present, come out first. + Like `"@val_num_asc"', but the element values, treated as numbers, + are ordered from high to low. Subarrays, if present, come out + first. The array traversal order is determined before the `for' loop starts to run. Changing `PROCINFO["sorted_in"]' in the loop body does not @@ -11428,8 +11438,8 @@ deleting elements in an array: This example removes all the elements from the array `frequencies'. Once an element is deleted, a subsequent `for' statement to scan the -array does not report that element and the `in' operator to check for -the presence of that element returns zero (i.e., false): +array does not report that element and using the `in' operator to check +for the presence of that element returns zero (i.e., false): delete foo[4] if (4 in foo) @@ -11632,7 +11642,7 @@ two-element subarray at index `1' of the main array `a': This simulates a true two-dimensional array. Each subarray element can contain another subarray as a value, which in turn can hold other arrays as well. In this way, you can create arrays of three or more -dimensions. The indices can be any `awk' expression, including scalars +dimensions. The indices can be any `awk' expressions, including scalars separated by commas (i.e., a regular `awk' simulated multidimensional subscript). So the following is valid in `gawk': @@ -11641,7 +11651,7 @@ subscript). So the following is valid in `gawk': Each subarray and the main array can be of different length. In fact, the elements of an array or its subarray do not all have to have the same type. This means that the main array and any of its subarrays -can be non-rectangular, or jagged in structure. You can assign a scalar +can be nonrectangular, or jagged in structure. You can assign a scalar value to the index `4' of the main array `a', even though `a[1]' is itself an array and not a scalar: @@ -11659,8 +11669,8 @@ the element at that index: a[4][5][6][7] = "An element in a four-dimensional array" This removes the scalar value from index `4' and then inserts a -subarray of subarray of subarray containing a scalar. You can also -delete an entire subarray or subarray of subarrays: +three-level nested subarray containing a scalar. You can also delete an +entire subarray or subarray of subarrays: delete a[4][5] a[4][5] = "An element in subarray a[4]" @@ -11668,7 +11678,7 @@ delete an entire subarray or subarray of subarrays: But recall that you can not delete the main array `a' and then use it as a scalar. - The built-in functions which take array arguments can also be used + The built-in functions that take array arguments can also be used with subarrays. For example, the following code fragment uses `length()' (*note String Functions::) to determine the number of elements in the main array `a' and its subarrays: @@ -11689,7 +11699,7 @@ be nested to scan all the elements of an array of arrays if it is rectangular in structure. In order to print the contents (scalar values) of a two-dimensional array of arrays (i.e., in which each first-level element is itself an array, not necessarily of the same -length) you could use the following code: +length), you could use the following code: for (i in array) for (j in array[i]) @@ -11771,9 +11781,9 @@ File: gawk.info, Node: Arrays Summary, Prev: Arrays of Arrays, Up: Arrays of `awk'. * Standard `awk' simulates multidimensional arrays by separating - subscript values with a comma. The values are concatenated into a + subscript values with commas. The values are concatenated into a single string, separated by the value of `SUBSEP'. The fact that - such a subscript was created in this way is not retained; thus + such a subscript was created in this way is not retained; thus, changing `SUBSEP' may have unexpected consequences. You can use `(SUB1, SUB2, ...) in ARRAY' to see if such a multidimensional subscript exists in ARRAY. @@ -11781,7 +11791,7 @@ File: gawk.info, Node: Arrays Summary, Prev: Arrays of Arrays, Up: Arrays * `gawk' provides true arrays of arrays. You use a separate set of square brackets for each dimension in such an array: `data[row][col]', for example. Array elements may thus be either - scalar values (number or string) or another array. + scalar values (number or string) or other arrays. * Use the `isarray()' built-in function to determine if an array element is itself a subarray. @@ -12349,7 +12359,7 @@ Options::): split("cul-de-sac", a, "-", seps) - splits the string `cul-de-sac' into three fields using `-' as the + splits the string `"cul-de-sac"' into three fields using `-' as the separator. It sets the contents of the array `a' as follows: a[1] = "cul" @@ -31889,7 +31899,7 @@ Index * arrays: Arrays. (line 6) * arrays of arrays: Arrays of Arrays. (line 6) * arrays, an example of using: Array Example. (line 6) -* arrays, and IGNORECASE variable: Array Intro. (line 94) +* arrays, and IGNORECASE variable: Array Intro. (line 100) * arrays, as parameters to functions: Pass By Value/Reference. (line 44) * arrays, associative: Array Intro. (line 50) @@ -31916,7 +31926,7 @@ Index (line 6) * arrays, sorting, and IGNORECASE variable: Array Sorting Functions. (line 83) -* arrays, sparse: Array Intro. (line 72) +* arrays, sparse: Array Intro. (line 76) * arrays, subscripts, uninitialized variables as: Uninitialized Subscripts. (line 6) * arrays, unassigned elements: Reference to Elements. @@ -32209,7 +32219,7 @@ Index * case keyword: Switch Statement. (line 6) * case sensitivity, and regexps: User-modified. (line 76) * case sensitivity, and string comparisons: User-modified. (line 76) -* case sensitivity, array indices and: Array Intro. (line 94) +* case sensitivity, array indices and: Array Intro. (line 100) * case sensitivity, converting case: String Functions. (line 522) * case sensitivity, example programs: Library Functions. (line 53) * case sensitivity, gawk: Case-sensitivity. (line 26) @@ -33083,7 +33093,7 @@ Index * gawk, IGNORECASE variable in <1>: Array Sorting Functions. (line 83) * gawk, IGNORECASE variable in <2>: String Functions. (line 58) -* gawk, IGNORECASE variable in <3>: Array Intro. (line 94) +* gawk, IGNORECASE variable in <3>: Array Intro. (line 100) * gawk, IGNORECASE variable in <4>: User-modified. (line 76) * gawk, IGNORECASE variable in: Case-sensitivity. (line 26) * gawk, implementation issues: Notes. (line 6) @@ -33256,7 +33266,7 @@ Index * ignore breakpoint: Breakpoint Control. (line 87) * ignore debugger command: Breakpoint Control. (line 87) * IGNORECASE variable: User-modified. (line 76) -* IGNORECASE variable, and array indices: Array Intro. (line 94) +* IGNORECASE variable, and array indices: Array Intro. (line 100) * IGNORECASE variable, and array sorting functions: Array Sorting Functions. (line 83) * IGNORECASE variable, in example programs: Library Functions. @@ -34246,7 +34256,7 @@ Index * source code, QuikTrim Awk: Other Versions. (line 139) * source code, Solaris awk: Other Versions. (line 100) * source files, search path for: Programs Exercises. (line 70) -* sparse arrays: Array Intro. (line 72) +* sparse arrays: Array Intro. (line 76) * Spencer, Henry: Glossary. (line 16) * split: String Functions. (line 316) * split string into array: String Functions. (line 297) @@ -34812,352 +34822,352 @@ Node: Pattern Action Summary458925 Node: Arrays461358 Node: Array Basics462687 Node: Array Intro463531 -Ref: figure-array-elements465495 -Ref: Array Intro-Footnote-1468021 -Node: Reference to Elements468149 -Node: Assigning Elements470601 -Node: Array Example471092 -Node: Scanning an Array472850 -Node: Controlling Scanning475866 -Ref: Controlling Scanning-Footnote-1481062 -Node: Numeric Array Subscripts481378 -Node: Uninitialized Subscripts483563 -Node: Delete485180 -Ref: Delete-Footnote-1487923 -Node: Multidimensional487980 -Node: Multiscanning491077 -Node: Arrays of Arrays492666 -Node: Arrays Summary497425 -Node: Functions499517 -Node: Built-in500416 -Node: Calling Built-in501494 -Node: Numeric Functions503485 -Ref: Numeric Functions-Footnote-1508304 -Ref: Numeric Functions-Footnote-2508661 -Ref: Numeric Functions-Footnote-3508709 -Node: String Functions508981 -Ref: String Functions-Footnote-1532456 -Ref: String Functions-Footnote-2532585 -Ref: String Functions-Footnote-3532833 -Node: Gory Details532920 -Ref: table-sub-escapes534701 -Ref: table-sub-proposed536221 -Ref: table-posix-sub537585 -Ref: table-gensub-escapes539121 -Ref: Gory Details-Footnote-1539953 -Node: I/O Functions540104 -Ref: I/O Functions-Footnote-1547322 -Node: Time Functions547469 -Ref: Time Functions-Footnote-1557957 -Ref: Time Functions-Footnote-2558025 -Ref: Time Functions-Footnote-3558183 -Ref: Time Functions-Footnote-4558294 -Ref: Time Functions-Footnote-5558406 -Ref: Time Functions-Footnote-6558633 -Node: Bitwise Functions558899 -Ref: table-bitwise-ops559461 -Ref: Bitwise Functions-Footnote-1563770 -Node: Type Functions563939 -Node: I18N Functions565090 -Node: User-defined566735 -Node: Definition Syntax567540 -Ref: Definition Syntax-Footnote-1572947 -Node: Function Example573018 -Ref: Function Example-Footnote-1575937 -Node: Function Caveats575959 -Node: Calling A Function576477 -Node: Variable Scope577435 -Node: Pass By Value/Reference580423 -Node: Return Statement583918 -Node: Dynamic Typing586899 -Node: Indirect Calls587828 -Ref: Indirect Calls-Footnote-1599130 -Node: Functions Summary599258 -Node: Library Functions601960 -Ref: Library Functions-Footnote-1605569 -Ref: Library Functions-Footnote-2605712 -Node: Library Names605883 -Ref: Library Names-Footnote-1609337 -Ref: Library Names-Footnote-2609560 -Node: General Functions609646 -Node: Strtonum Function610749 -Node: Assert Function613771 -Node: Round Function617095 -Node: Cliff Random Function618636 -Node: Ordinal Functions619652 -Ref: Ordinal Functions-Footnote-1622715 -Ref: Ordinal Functions-Footnote-2622967 -Node: Join Function623178 -Ref: Join Function-Footnote-1624947 -Node: Getlocaltime Function625147 -Node: Readfile Function628891 -Node: Shell Quoting630861 -Node: Data File Management632262 -Node: Filetrans Function632894 -Node: Rewind Function636950 -Node: File Checking638337 -Ref: File Checking-Footnote-1639669 -Node: Empty Files639870 -Node: Ignoring Assigns641849 -Node: Getopt Function643400 -Ref: Getopt Function-Footnote-1654862 -Node: Passwd Functions655062 -Ref: Passwd Functions-Footnote-1663899 -Node: Group Functions663987 -Ref: Group Functions-Footnote-1671881 -Node: Walking Arrays672094 -Node: Library Functions Summary673697 -Node: Library Exercises675098 -Node: Sample Programs676378 -Node: Running Examples677148 -Node: Clones677876 -Node: Cut Program679100 -Node: Egrep Program688819 -Ref: Egrep Program-Footnote-1696317 -Node: Id Program696427 -Node: Split Program700072 -Ref: Split Program-Footnote-1703520 -Node: Tee Program703648 -Node: Uniq Program706437 -Node: Wc Program713856 -Ref: Wc Program-Footnote-1718106 -Node: Miscellaneous Programs718200 -Node: Dupword Program719413 -Node: Alarm Program721444 -Node: Translate Program726248 -Ref: Translate Program-Footnote-1730813 -Node: Labels Program731083 -Ref: Labels Program-Footnote-1734434 -Node: Word Sorting734518 -Node: History Sorting738589 -Node: Extract Program740425 -Node: Simple Sed747950 -Node: Igawk Program751018 -Ref: Igawk Program-Footnote-1765342 -Ref: Igawk Program-Footnote-2765543 -Ref: Igawk Program-Footnote-3765665 -Node: Anagram Program765780 -Node: Signature Program768837 -Node: Programs Summary770084 -Node: Programs Exercises771277 -Ref: Programs Exercises-Footnote-1775408 -Node: Advanced Features775499 -Node: Nondecimal Data777447 -Node: Array Sorting779037 -Node: Controlling Array Traversal779734 -Ref: Controlling Array Traversal-Footnote-1788067 -Node: Array Sorting Functions788185 -Ref: Array Sorting Functions-Footnote-1792074 -Node: Two-way I/O792270 -Ref: Two-way I/O-Footnote-1797215 -Ref: Two-way I/O-Footnote-2797401 -Node: TCP/IP Networking797483 -Node: Profiling800356 -Node: Advanced Features Summary808633 -Node: Internationalization810566 -Node: I18N and L10N812046 -Node: Explaining gettext812732 -Ref: Explaining gettext-Footnote-1817757 -Ref: Explaining gettext-Footnote-2817941 -Node: Programmer i18n818106 -Ref: Programmer i18n-Footnote-1822972 -Node: Translator i18n823021 -Node: String Extraction823815 -Ref: String Extraction-Footnote-1824946 -Node: Printf Ordering825032 -Ref: Printf Ordering-Footnote-1827818 -Node: I18N Portability827882 -Ref: I18N Portability-Footnote-1830337 -Node: I18N Example830400 -Ref: I18N Example-Footnote-1833203 -Node: Gawk I18N833275 -Node: I18N Summary833913 -Node: Debugger835252 -Node: Debugging836274 -Node: Debugging Concepts836715 -Node: Debugging Terms838568 -Node: Awk Debugging841140 -Node: Sample Debugging Session842034 -Node: Debugger Invocation842554 -Node: Finding The Bug843938 -Node: List of Debugger Commands850413 -Node: Breakpoint Control851746 -Node: Debugger Execution Control855442 -Node: Viewing And Changing Data858806 -Node: Execution Stack862184 -Node: Debugger Info863821 -Node: Miscellaneous Debugger Commands867838 -Node: Readline Support872867 -Node: Limitations873759 -Node: Debugging Summary875873 -Node: Arbitrary Precision Arithmetic877041 -Node: Computer Arithmetic878457 -Ref: table-numeric-ranges882055 -Ref: Computer Arithmetic-Footnote-1882914 -Node: Math Definitions882971 -Ref: table-ieee-formats886259 -Ref: Math Definitions-Footnote-1886863 -Node: MPFR features886968 -Node: FP Math Caution888639 -Ref: FP Math Caution-Footnote-1889689 -Node: Inexactness of computations890058 -Node: Inexact representation891017 -Node: Comparing FP Values892374 -Node: Errors accumulate893456 -Node: Getting Accuracy894889 -Node: Try To Round897551 -Node: Setting precision898450 -Ref: table-predefined-precision-strings899134 -Node: Setting the rounding mode900923 -Ref: table-gawk-rounding-modes901287 -Ref: Setting the rounding mode-Footnote-1904742 -Node: Arbitrary Precision Integers904921 -Ref: Arbitrary Precision Integers-Footnote-1909821 -Node: POSIX Floating Point Problems909970 -Ref: POSIX Floating Point Problems-Footnote-1913843 -Node: Floating point summary913881 -Node: Dynamic Extensions916075 -Node: Extension Intro917627 -Node: Plugin License918893 -Node: Extension Mechanism Outline919690 -Ref: figure-load-extension920118 -Ref: figure-register-new-function921598 -Ref: figure-call-new-function922602 -Node: Extension API Description924588 -Node: Extension API Functions Introduction926038 -Node: General Data Types930862 -Ref: General Data Types-Footnote-1936601 -Node: Memory Allocation Functions936900 -Ref: Memory Allocation Functions-Footnote-1939739 -Node: Constructor Functions939835 -Node: Registration Functions941569 -Node: Extension Functions942254 -Node: Exit Callback Functions944551 -Node: Extension Version String945799 -Node: Input Parsers946464 -Node: Output Wrappers956343 -Node: Two-way processors960858 -Node: Printing Messages963062 -Ref: Printing Messages-Footnote-1964138 -Node: Updating `ERRNO'964290 -Node: Requesting Values965030 -Ref: table-value-types-returned965758 -Node: Accessing Parameters966715 -Node: Symbol Table Access967946 -Node: Symbol table by name968460 -Node: Symbol table by cookie970441 -Ref: Symbol table by cookie-Footnote-1974585 -Node: Cached values974648 -Ref: Cached values-Footnote-1978147 -Node: Array Manipulation978238 -Ref: Array Manipulation-Footnote-1979336 -Node: Array Data Types979373 -Ref: Array Data Types-Footnote-1982028 -Node: Array Functions982120 -Node: Flattening Arrays985974 -Node: Creating Arrays992866 -Node: Extension API Variables997637 -Node: Extension Versioning998273 -Node: Extension API Informational Variables1000174 -Node: Extension API Boilerplate1001239 -Node: Finding Extensions1005048 -Node: Extension Example1005608 -Node: Internal File Description1006380 -Node: Internal File Ops1010447 -Ref: Internal File Ops-Footnote-11022117 -Node: Using Internal File Ops1022257 -Ref: Using Internal File Ops-Footnote-11024640 -Node: Extension Samples1024913 -Node: Extension Sample File Functions1026439 -Node: Extension Sample Fnmatch1034077 -Node: Extension Sample Fork1035568 -Node: Extension Sample Inplace1036783 -Node: Extension Sample Ord1038458 -Node: Extension Sample Readdir1039294 -Ref: table-readdir-file-types1040170 -Node: Extension Sample Revout1040981 -Node: Extension Sample Rev2way1041571 -Node: Extension Sample Read write array1042311 -Node: Extension Sample Readfile1044251 -Node: Extension Sample Time1045346 -Node: Extension Sample API Tests1046695 -Node: gawkextlib1047186 -Node: Extension summary1049844 -Node: Extension Exercises1053533 -Node: Language History1054255 -Node: V7/SVR3.11055911 -Node: SVR41058092 -Node: POSIX1059537 -Node: BTL1060926 -Node: POSIX/GNU1061660 -Node: Feature History1067284 -Node: Common Extensions1080382 -Node: Ranges and Locales1081706 -Ref: Ranges and Locales-Footnote-11086324 -Ref: Ranges and Locales-Footnote-21086351 -Ref: Ranges and Locales-Footnote-31086585 -Node: Contributors1086806 -Node: History summary1092347 -Node: Installation1093717 -Node: Gawk Distribution1094663 -Node: Getting1095147 -Node: Extracting1095970 -Node: Distribution contents1097605 -Node: Unix Installation1103670 -Node: Quick Installation1104353 -Node: Shell Startup Files1106764 -Node: Additional Configuration Options1107843 -Node: Configuration Philosophy1109582 -Node: Non-Unix Installation1111951 -Node: PC Installation1112409 -Node: PC Binary Installation1113728 -Node: PC Compiling1115576 -Ref: PC Compiling-Footnote-11118597 -Node: PC Testing1118706 -Node: PC Using1119882 -Node: Cygwin1123997 -Node: MSYS1124820 -Node: VMS Installation1125320 -Node: VMS Compilation1126112 -Ref: VMS Compilation-Footnote-11127334 -Node: VMS Dynamic Extensions1127392 -Node: VMS Installation Details1129076 -Node: VMS Running1131328 -Node: VMS GNV1134164 -Node: VMS Old Gawk1134898 -Node: Bugs1135368 -Node: Other Versions1139251 -Node: Installation summary1145675 -Node: Notes1146731 -Node: Compatibility Mode1147596 -Node: Additions1148378 -Node: Accessing The Source1149303 -Node: Adding Code1150738 -Node: New Ports1156895 -Node: Derived Files1161377 -Ref: Derived Files-Footnote-11166852 -Ref: Derived Files-Footnote-21166886 -Ref: Derived Files-Footnote-31167482 -Node: Future Extensions1167596 -Node: Implementation Limitations1168202 -Node: Extension Design1169450 -Node: Old Extension Problems1170604 -Ref: Old Extension Problems-Footnote-11172121 -Node: Extension New Mechanism Goals1172178 -Ref: Extension New Mechanism Goals-Footnote-11175538 -Node: Extension Other Design Decisions1175727 -Node: Extension Future Growth1177835 -Node: Old Extension Mechanism1178671 -Node: Notes summary1180433 -Node: Basic Concepts1181619 -Node: Basic High Level1182300 -Ref: figure-general-flow1182572 -Ref: figure-process-flow1183171 -Ref: Basic High Level-Footnote-11186400 -Node: Basic Data Typing1186585 -Node: Glossary1189913 -Node: Copying1221842 -Node: GNU Free Documentation License1259398 -Node: Index1284534 +Ref: figure-array-elements465465 +Ref: Array Intro-Footnote-1468085 +Node: Reference to Elements468213 +Node: Assigning Elements470675 +Node: Array Example471166 +Node: Scanning an Array472925 +Node: Controlling Scanning475945 +Ref: Controlling Scanning-Footnote-1481339 +Node: Numeric Array Subscripts481655 +Node: Uninitialized Subscripts483840 +Node: Delete485457 +Ref: Delete-Footnote-1488206 +Node: Multidimensional488263 +Node: Multiscanning491360 +Node: Arrays of Arrays492949 +Node: Arrays Summary497703 +Node: Functions499794 +Node: Built-in500693 +Node: Calling Built-in501771 +Node: Numeric Functions503762 +Ref: Numeric Functions-Footnote-1508581 +Ref: Numeric Functions-Footnote-2508938 +Ref: Numeric Functions-Footnote-3508986 +Node: String Functions509258 +Ref: String Functions-Footnote-1532735 +Ref: String Functions-Footnote-2532864 +Ref: String Functions-Footnote-3533112 +Node: Gory Details533199 +Ref: table-sub-escapes534980 +Ref: table-sub-proposed536500 +Ref: table-posix-sub537864 +Ref: table-gensub-escapes539400 +Ref: Gory Details-Footnote-1540232 +Node: I/O Functions540383 +Ref: I/O Functions-Footnote-1547601 +Node: Time Functions547748 +Ref: Time Functions-Footnote-1558236 +Ref: Time Functions-Footnote-2558304 +Ref: Time Functions-Footnote-3558462 +Ref: Time Functions-Footnote-4558573 +Ref: Time Functions-Footnote-5558685 +Ref: Time Functions-Footnote-6558912 +Node: Bitwise Functions559178 +Ref: table-bitwise-ops559740 +Ref: Bitwise Functions-Footnote-1564049 +Node: Type Functions564218 +Node: I18N Functions565369 +Node: User-defined567014 +Node: Definition Syntax567819 +Ref: Definition Syntax-Footnote-1573226 +Node: Function Example573297 +Ref: Function Example-Footnote-1576216 +Node: Function Caveats576238 +Node: Calling A Function576756 +Node: Variable Scope577714 +Node: Pass By Value/Reference580702 +Node: Return Statement584197 +Node: Dynamic Typing587178 +Node: Indirect Calls588107 +Ref: Indirect Calls-Footnote-1599409 +Node: Functions Summary599537 +Node: Library Functions602239 +Ref: Library Functions-Footnote-1605848 +Ref: Library Functions-Footnote-2605991 +Node: Library Names606162 +Ref: Library Names-Footnote-1609616 +Ref: Library Names-Footnote-2609839 +Node: General Functions609925 +Node: Strtonum Function611028 +Node: Assert Function614050 +Node: Round Function617374 +Node: Cliff Random Function618915 +Node: Ordinal Functions619931 +Ref: Ordinal Functions-Footnote-1622994 +Ref: Ordinal Functions-Footnote-2623246 +Node: Join Function623457 +Ref: Join Function-Footnote-1625226 +Node: Getlocaltime Function625426 +Node: Readfile Function629170 +Node: Shell Quoting631140 +Node: Data File Management632541 +Node: Filetrans Function633173 +Node: Rewind Function637229 +Node: File Checking638616 +Ref: File Checking-Footnote-1639948 +Node: Empty Files640149 +Node: Ignoring Assigns642128 +Node: Getopt Function643679 +Ref: Getopt Function-Footnote-1655141 +Node: Passwd Functions655341 +Ref: Passwd Functions-Footnote-1664178 +Node: Group Functions664266 +Ref: Group Functions-Footnote-1672160 +Node: Walking Arrays672373 +Node: Library Functions Summary673976 +Node: Library Exercises675377 +Node: Sample Programs676657 +Node: Running Examples677427 +Node: Clones678155 +Node: Cut Program679379 +Node: Egrep Program689098 +Ref: Egrep Program-Footnote-1696596 +Node: Id Program696706 +Node: Split Program700351 +Ref: Split Program-Footnote-1703799 +Node: Tee Program703927 +Node: Uniq Program706716 +Node: Wc Program714135 +Ref: Wc Program-Footnote-1718385 +Node: Miscellaneous Programs718479 +Node: Dupword Program719692 +Node: Alarm Program721723 +Node: Translate Program726527 +Ref: Translate Program-Footnote-1731092 +Node: Labels Program731362 +Ref: Labels Program-Footnote-1734713 +Node: Word Sorting734797 +Node: History Sorting738868 +Node: Extract Program740704 +Node: Simple Sed748229 +Node: Igawk Program751297 +Ref: Igawk Program-Footnote-1765621 +Ref: Igawk Program-Footnote-2765822 +Ref: Igawk Program-Footnote-3765944 +Node: Anagram Program766059 +Node: Signature Program769116 +Node: Programs Summary770363 +Node: Programs Exercises771556 +Ref: Programs Exercises-Footnote-1775687 +Node: Advanced Features775778 +Node: Nondecimal Data777726 +Node: Array Sorting779316 +Node: Controlling Array Traversal780013 +Ref: Controlling Array Traversal-Footnote-1788346 +Node: Array Sorting Functions788464 +Ref: Array Sorting Functions-Footnote-1792353 +Node: Two-way I/O792549 +Ref: Two-way I/O-Footnote-1797494 +Ref: Two-way I/O-Footnote-2797680 +Node: TCP/IP Networking797762 +Node: Profiling800635 +Node: Advanced Features Summary808912 +Node: Internationalization810845 +Node: I18N and L10N812325 +Node: Explaining gettext813011 +Ref: Explaining gettext-Footnote-1818036 +Ref: Explaining gettext-Footnote-2818220 +Node: Programmer i18n818385 +Ref: Programmer i18n-Footnote-1823251 +Node: Translator i18n823300 +Node: String Extraction824094 +Ref: String Extraction-Footnote-1825225 +Node: Printf Ordering825311 +Ref: Printf Ordering-Footnote-1828097 +Node: I18N Portability828161 +Ref: I18N Portability-Footnote-1830616 +Node: I18N Example830679 +Ref: I18N Example-Footnote-1833482 +Node: Gawk I18N833554 +Node: I18N Summary834192 +Node: Debugger835531 +Node: Debugging836553 +Node: Debugging Concepts836994 +Node: Debugging Terms838847 +Node: Awk Debugging841419 +Node: Sample Debugging Session842313 +Node: Debugger Invocation842833 +Node: Finding The Bug844217 +Node: List of Debugger Commands850692 +Node: Breakpoint Control852025 +Node: Debugger Execution Control855721 +Node: Viewing And Changing Data859085 +Node: Execution Stack862463 +Node: Debugger Info864100 +Node: Miscellaneous Debugger Commands868117 +Node: Readline Support873146 +Node: Limitations874038 +Node: Debugging Summary876152 +Node: Arbitrary Precision Arithmetic877320 +Node: Computer Arithmetic878736 +Ref: table-numeric-ranges882334 +Ref: Computer Arithmetic-Footnote-1883193 +Node: Math Definitions883250 +Ref: table-ieee-formats886538 +Ref: Math Definitions-Footnote-1887142 +Node: MPFR features887247 +Node: FP Math Caution888918 +Ref: FP Math Caution-Footnote-1889968 +Node: Inexactness of computations890337 +Node: Inexact representation891296 +Node: Comparing FP Values892653 +Node: Errors accumulate893735 +Node: Getting Accuracy895168 +Node: Try To Round897830 +Node: Setting precision898729 +Ref: table-predefined-precision-strings899413 +Node: Setting the rounding mode901202 +Ref: table-gawk-rounding-modes901566 +Ref: Setting the rounding mode-Footnote-1905021 +Node: Arbitrary Precision Integers905200 +Ref: Arbitrary Precision Integers-Footnote-1910100 +Node: POSIX Floating Point Problems910249 +Ref: POSIX Floating Point Problems-Footnote-1914122 +Node: Floating point summary914160 +Node: Dynamic Extensions916354 +Node: Extension Intro917906 +Node: Plugin License919172 +Node: Extension Mechanism Outline919969 +Ref: figure-load-extension920397 +Ref: figure-register-new-function921877 +Ref: figure-call-new-function922881 +Node: Extension API Description924867 +Node: Extension API Functions Introduction926317 +Node: General Data Types931141 +Ref: General Data Types-Footnote-1936880 +Node: Memory Allocation Functions937179 +Ref: Memory Allocation Functions-Footnote-1940018 +Node: Constructor Functions940114 +Node: Registration Functions941848 +Node: Extension Functions942533 +Node: Exit Callback Functions944830 +Node: Extension Version String946078 +Node: Input Parsers946743 +Node: Output Wrappers956622 +Node: Two-way processors961137 +Node: Printing Messages963341 +Ref: Printing Messages-Footnote-1964417 +Node: Updating `ERRNO'964569 +Node: Requesting Values965309 +Ref: table-value-types-returned966037 +Node: Accessing Parameters966994 +Node: Symbol Table Access968225 +Node: Symbol table by name968739 +Node: Symbol table by cookie970720 +Ref: Symbol table by cookie-Footnote-1974864 +Node: Cached values974927 +Ref: Cached values-Footnote-1978426 +Node: Array Manipulation978517 +Ref: Array Manipulation-Footnote-1979615 +Node: Array Data Types979652 +Ref: Array Data Types-Footnote-1982307 +Node: Array Functions982399 +Node: Flattening Arrays986253 +Node: Creating Arrays993145 +Node: Extension API Variables997916 +Node: Extension Versioning998552 +Node: Extension API Informational Variables1000453 +Node: Extension API Boilerplate1001518 +Node: Finding Extensions1005327 +Node: Extension Example1005887 +Node: Internal File Description1006659 +Node: Internal File Ops1010726 +Ref: Internal File Ops-Footnote-11022396 +Node: Using Internal File Ops1022536 +Ref: Using Internal File Ops-Footnote-11024919 +Node: Extension Samples1025192 +Node: Extension Sample File Functions1026718 +Node: Extension Sample Fnmatch1034356 +Node: Extension Sample Fork1035847 +Node: Extension Sample Inplace1037062 +Node: Extension Sample Ord1038737 +Node: Extension Sample Readdir1039573 +Ref: table-readdir-file-types1040449 +Node: Extension Sample Revout1041260 +Node: Extension Sample Rev2way1041850 +Node: Extension Sample Read write array1042590 +Node: Extension Sample Readfile1044530 +Node: Extension Sample Time1045625 +Node: Extension Sample API Tests1046974 +Node: gawkextlib1047465 +Node: Extension summary1050123 +Node: Extension Exercises1053812 +Node: Language History1054534 +Node: V7/SVR3.11056190 +Node: SVR41058371 +Node: POSIX1059816 +Node: BTL1061205 +Node: POSIX/GNU1061939 +Node: Feature History1067563 +Node: Common Extensions1080661 +Node: Ranges and Locales1081985 +Ref: Ranges and Locales-Footnote-11086603 +Ref: Ranges and Locales-Footnote-21086630 +Ref: Ranges and Locales-Footnote-31086864 +Node: Contributors1087085 +Node: History summary1092626 +Node: Installation1093996 +Node: Gawk Distribution1094942 +Node: Getting1095426 +Node: Extracting1096249 +Node: Distribution contents1097884 +Node: Unix Installation1103949 +Node: Quick Installation1104632 +Node: Shell Startup Files1107043 +Node: Additional Configuration Options1108122 +Node: Configuration Philosophy1109861 +Node: Non-Unix Installation1112230 +Node: PC Installation1112688 +Node: PC Binary Installation1114007 +Node: PC Compiling1115855 +Ref: PC Compiling-Footnote-11118876 +Node: PC Testing1118985 +Node: PC Using1120161 +Node: Cygwin1124276 +Node: MSYS1125099 +Node: VMS Installation1125599 +Node: VMS Compilation1126391 +Ref: VMS Compilation-Footnote-11127613 +Node: VMS Dynamic Extensions1127671 +Node: VMS Installation Details1129355 +Node: VMS Running1131607 +Node: VMS GNV1134443 +Node: VMS Old Gawk1135177 +Node: Bugs1135647 +Node: Other Versions1139530 +Node: Installation summary1145954 +Node: Notes1147010 +Node: Compatibility Mode1147875 +Node: Additions1148657 +Node: Accessing The Source1149582 +Node: Adding Code1151017 +Node: New Ports1157174 +Node: Derived Files1161656 +Ref: Derived Files-Footnote-11167131 +Ref: Derived Files-Footnote-21167165 +Ref: Derived Files-Footnote-31167761 +Node: Future Extensions1167875 +Node: Implementation Limitations1168481 +Node: Extension Design1169729 +Node: Old Extension Problems1170883 +Ref: Old Extension Problems-Footnote-11172400 +Node: Extension New Mechanism Goals1172457 +Ref: Extension New Mechanism Goals-Footnote-11175817 +Node: Extension Other Design Decisions1176006 +Node: Extension Future Growth1178114 +Node: Old Extension Mechanism1178950 +Node: Notes summary1180712 +Node: Basic Concepts1181898 +Node: Basic High Level1182579 +Ref: figure-general-flow1182851 +Ref: figure-process-flow1183450 +Ref: Basic High Level-Footnote-11186679 +Node: Basic Data Typing1186864 +Node: Glossary1190192 +Node: Copying1222121 +Node: GNU Free Documentation License1259677 +Node: Index1284813 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index ab1e1a28..a5243277 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -15510,15 +15510,17 @@ the declaration. indices---e.g., @samp{15 .. 27}---but the size of the array is still fixed when the array is declared.) -A contiguous array of four elements might look like the following example, -conceptually, if the element values are 8, @code{"foo"}, -@code{""}, and 30 +@c 1/2015: Do not put the numeric values into @code. Array element +@c values are no different than scalar variable values. +A contiguous array of four elements might look like @ifnotdocbook -as shown in @ref{figure-array-elements}: +@ref{figure-array-elements}, @end ifnotdocbook @ifdocbook -as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}: +@inlineraw{docbook, <xref linkend="figure-array-elements"/>}, @end ifdocbook +conceptually, if the element values are eight, @code{"foo"}, +@code{""}, and 30. @ifnotdocbook @float Figure,figure-array-elements @@ -15543,7 +15545,7 @@ as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}: @noindent Only the values are stored; the indices are implicit from the order of -the values. Here, 8 is the value at index zero, because 8 appears in the +the values. Here, eight is the value at index zero, because eight appears in the position with zero elements before it. @cindex arrays, indexing @@ -15555,19 +15557,21 @@ that each array is a collection of pairs---an index and its corresponding array element value: @ifnotdocbook -@example -@r{Index} 3 @r{Value} 30 -@r{Index} 1 @r{Value} "foo" -@r{Index} 0 @r{Value} 8 -@r{Index} 2 @r{Value} "" -@end example +@c extra empty column to indent it right +@multitable @columnfractions .1 .1 .1 +@headitem @tab Index @tab Value +@item @tab @code{3} @tab @code{30} +@item @tab @code{1} @tab @code{"foo"} +@item @tab @code{0} @tab @code{8} +@item @tab @code{2} @tab @code{""} +@end multitable @end ifnotdocbook @docbook <informaltable> <tgroup cols="2"> -<colspec colname="1" align="center"/> -<colspec colname="2" align="center"/> +<colspec colname="1" align="left"/> +<colspec colname="2" align="left"/> <thead> <row> <entry>Index</entry> @@ -15613,20 +15617,22 @@ at any time. For example, suppose a tenth element is added to the array whose value is @w{@code{"number ten"}}. The result is: @ifnotdocbook -@example -@r{Index} 10 @r{Value} "number ten" -@r{Index} 3 @r{Value} 30 -@r{Index} 1 @r{Value} "foo" -@r{Index} 0 @r{Value} 8 -@r{Index} 2 @r{Value} "" -@end example +@c extra empty column to indent it right +@multitable @columnfractions .1 .1 .2 +@headitem @tab Index @tab Value +@item @tab @code{10} @tab @code{"number ten"} +@item @tab @code{3} @tab @code{30} +@item @tab @code{1} @tab @code{"foo"} +@item @tab @code{0} @tab @code{8} +@item @tab @code{2} @tab @code{""} +@end multitable @end ifnotdocbook @docbook <informaltable> <tgroup cols="2"> -<colspec colname="1" align="center"/> -<colspec colname="2" align="center"/> +<colspec colname="1" align="left"/> +<colspec colname="2" align="left"/> <thead> <row> <entry>Index</entry> @@ -15678,19 +15684,20 @@ an index. For example, the following is an array that translates words from English to French: @ifnotdocbook -@example -@r{Index} "dog" @r{Value} "chien" -@r{Index} "cat" @r{Value} "chat" -@r{Index} "one" @r{Value} "un" -@r{Index} 1 @r{Value} "un" -@end example +@multitable @columnfractions .1 .1 .1 +@headitem @tab Index @tab Value +@item @tab @code{"dog"} @tab @code{"chien"} +@item @tab @code{"cat"} @tab @code{"chat"} +@item @tab @code{"one"} @tab @code{"un"} +@item @tab @code{1} @tab @code{"un"} +@end multitable @end ifnotdocbook @docbook <informaltable> <tgroup cols="2"> -<colspec colname="1" align="center"/> -<colspec colname="2" align="center"/> +<colspec colname="1" align="left"/> +<colspec colname="2" align="left"/> <thead> <row> <entry>Index</entry> @@ -15732,7 +15739,7 @@ numbers and strings as indices. There are some subtleties to how numbers work when used as array subscripts; this is discussed in more detail in @ref{Numeric Array Subscripts}.) -Here, the number @code{1} isn't double quoted, because @command{awk} +Here, the number @code{1} isn't double-quoted, because @command{awk} automatically converts it to a string. @cindex @command{gawk}, @code{IGNORECASE} variable in @@ -15757,7 +15764,7 @@ is independent of the number of elements in the array. @cindex elements of arrays The principal way to use an array is to refer to one of its elements. -An array reference is an expression as follows: +An @dfn{array reference} is an expression as follows: @example @var{array}[@var{index-expression}] @@ -15767,8 +15774,11 @@ An array reference is an expression as follows: Here, @var{array} is the name of an array. The expression @var{index-expression} is the index of the desired element of the array. +@c 1/2015: Having the 4.3 in @samp is a little iffy. It's essentially +@c an expression though, so leave be. It's to early in the discussion +@c to mention that it's really a string. The value of the array reference is the current value of that array -element. For example, @code{foo[4.3]} is an expression for the element +element. For example, @code{foo[4.3]} is an expression referencing the element of array @code{foo} at index @samp{4.3}. @cindex arrays, unassigned elements @@ -15860,7 +15870,7 @@ assign to that element of the array. The following program takes a list of lines, each beginning with a line number, and prints them out in order of line number. The line numbers -are not in order when they are first read---instead they +are not in order when they are first read---instead, they are scrambled. This program sorts the lines by making an array using the line numbers as subscripts. The program then prints out the lines in sorted order of their numbers. It is a very simple program and gets @@ -15954,7 +15964,7 @@ program has previously used, with the variable @var{var} set to that index. The following program uses this form of the @code{for} statement. The first rule scans the input records and notes which words appear (at least once) in the input, by storing a one into the array @code{used} with -the word as index. The second rule scans the elements of @code{used} to +the word as the index. The second rule scans the elements of @code{used} to find all the distinct words that appear in the input. It prints each word that is more than 10 characters long and also prints the number of such words. @@ -16051,7 +16061,7 @@ and will vary from one version of @command{awk} to the next. Often, though, you may wish to do something simple, such as ``traverse the array by comparing the indices in ascending order,'' or ``traverse the array by comparing the values in descending order.'' -@command{gawk} provides two mechanisms which give you this control. +@command{gawk} provides two mechanisms that give you this control: @itemize @value{BULLET} @item @@ -16108,21 +16118,26 @@ across different environments.} which @command{gawk} uses internally to perform the sorting. @item "@@ind_str_desc" -String indices ordered from high to low. +Like @code{"@@ind_str_asc"}, but the +string indices are ordered from high to low. @item "@@ind_num_desc" -Numeric indices ordered from high to low. +Like @code{"@@ind_num_asc"}, but the +numeric indices are ordered from high to low. @item "@@val_type_desc" -Element values, based on type, ordered from high to low. +Like @code{"@@val_type_asc"}, but the +element values, based on type, are ordered from high to low. Subarrays, if present, come out first. @item "@@val_str_desc" -Element values, treated as strings, ordered from high to low. +Like @code{"@@val_str_asc"}, but the +element values, treated as strings, are ordered from high to low. Subarrays, if present, come out first. @item "@@val_num_desc" -Element values, treated as numbers, ordered from high to low. +Like @code{"@@val_num_asc"}, but the +element values, treated as numbers, are ordered from high to low. Subarrays, if present, come out first. @end table @@ -16345,7 +16360,7 @@ for (i in frequencies) @noindent This example removes all the elements from the array @code{frequencies}. Once an element is deleted, a subsequent @code{for} statement to scan the array -does not report that element and the @code{in} operator to check for +does not report that element and using the @code{in} operator to check for the presence of that element returns zero (i.e., false): @example @@ -16605,7 +16620,7 @@ a[1][2] = 2 This simulates a true two-dimensional array. Each subarray element can contain another subarray as a value, which in turn can hold other arrays as well. In this way, you can create arrays of three or more dimensions. -The indices can be any @command{awk} expression, including scalars +The indices can be any @command{awk} expressions, including scalars separated by commas (i.e., a regular @command{awk} simulated multidimensional subscript). So the following is valid in @command{gawk}: @@ -16617,7 +16632,7 @@ a[1][3][1, "name"] = "barney" Each subarray and the main array can be of different length. In fact, the elements of an array or its subarray do not all have to have the same type. This means that the main array and any of its subarrays can be -non-rectangular, or jagged in structure. You can assign a scalar value to +nonrectangular, or jagged in structure. You can assign a scalar value to the index @code{4} of the main array @code{a}, even though @code{a[1]} is itself an array and not a scalar: @@ -16641,7 +16656,8 @@ a[4][5][6][7] = "An element in a four-dimensional array" @noindent This removes the scalar value from index @code{4} and then inserts a -subarray of subarray of subarray containing a scalar. You can also +three-level nested subarray +containing a scalar. You can also delete an entire subarray or subarray of subarrays: @example @@ -16652,7 +16668,7 @@ a[4][5] = "An element in subarray a[4]" But recall that you can not delete the main array @code{a} and then use it as a scalar. -The built-in functions which take array arguments can also be used +The built-in functions that take array arguments can also be used with subarrays. For example, the following code fragment uses @code{length()} (@pxref{String Functions}) to determine the number of elements in the main array @code{a} and @@ -16682,7 +16698,7 @@ can be nested to scan all the elements of an array of arrays if it is rectangular in structure. In order to print the contents (scalar values) of a two-dimensional array of arrays (i.e., in which each first-level element is itself an -array, not necessarily of the same length) +array, not necessarily of the same length), you could use the following code: @example @@ -16782,9 +16798,9 @@ versions of @command{awk}. @item Standard @command{awk} simulates multidimensional arrays by separating -subscript values with a comma. The values are concatenated into a +subscript values with commas. The values are concatenated into a single string, separated by the value of @code{SUBSEP}. The fact -that such a subscript was created in this way is not retained; thus +that such a subscript was created in this way is not retained; thus, changing @code{SUBSEP} may have unexpected consequences. You can use @samp{(@var{sub1}, @var{sub2}, @dots{}) in @var{array}} to see if such a multidimensional subscript exists in @var{array}. @@ -16793,7 +16809,7 @@ a multidimensional subscript exists in @var{array}. @command{gawk} provides true arrays of arrays. You use a separate set of square brackets for each dimension in such an array: @code{data[row][col]}, for example. Array elements may thus be either -scalar values (number or string) or another array. +scalar values (number or string) or other arrays. @item Use the @code{isarray()} built-in function to determine if an array @@ -17531,7 +17547,7 @@ split("cul-de-sac", a, "-", seps) @noindent @cindex strings splitting, example -splits the string @samp{cul-de-sac} into three fields using @samp{-} as the +splits the string @code{"cul-de-sac"} into three fields using @samp{-} as the separator. It sets the contents of the array @code{a} as follows: @example diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 33073ac5..897cfefb 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -14792,15 +14792,17 @@ the declaration. indices---e.g., @samp{15 .. 27}---but the size of the array is still fixed when the array is declared.) -A contiguous array of four elements might look like the following example, -conceptually, if the element values are 8, @code{"foo"}, -@code{""}, and 30 +@c 1/2015: Do not put the numeric values into @code. Array element +@c values are no different than scalar variable values. +A contiguous array of four elements might look like @ifnotdocbook -as shown in @ref{figure-array-elements}: +@ref{figure-array-elements}, @end ifnotdocbook @ifdocbook -as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}: +@inlineraw{docbook, <xref linkend="figure-array-elements"/>}, @end ifdocbook +conceptually, if the element values are eight, @code{"foo"}, +@code{""}, and 30. @ifnotdocbook @float Figure,figure-array-elements @@ -14825,7 +14827,7 @@ as shown in @inlineraw{docbook, <xref linkend="figure-array-elements"/>}: @noindent Only the values are stored; the indices are implicit from the order of -the values. Here, 8 is the value at index zero, because 8 appears in the +the values. Here, eight is the value at index zero, because eight appears in the position with zero elements before it. @cindex arrays, indexing @@ -14837,19 +14839,21 @@ that each array is a collection of pairs---an index and its corresponding array element value: @ifnotdocbook -@example -@r{Index} 3 @r{Value} 30 -@r{Index} 1 @r{Value} "foo" -@r{Index} 0 @r{Value} 8 -@r{Index} 2 @r{Value} "" -@end example +@c extra empty column to indent it right +@multitable @columnfractions .1 .1 .1 +@headitem @tab Index @tab Value +@item @tab @code{3} @tab @code{30} +@item @tab @code{1} @tab @code{"foo"} +@item @tab @code{0} @tab @code{8} +@item @tab @code{2} @tab @code{""} +@end multitable @end ifnotdocbook @docbook <informaltable> <tgroup cols="2"> -<colspec colname="1" align="center"/> -<colspec colname="2" align="center"/> +<colspec colname="1" align="left"/> +<colspec colname="2" align="left"/> <thead> <row> <entry>Index</entry> @@ -14895,20 +14899,22 @@ at any time. For example, suppose a tenth element is added to the array whose value is @w{@code{"number ten"}}. The result is: @ifnotdocbook -@example -@r{Index} 10 @r{Value} "number ten" -@r{Index} 3 @r{Value} 30 -@r{Index} 1 @r{Value} "foo" -@r{Index} 0 @r{Value} 8 -@r{Index} 2 @r{Value} "" -@end example +@c extra empty column to indent it right +@multitable @columnfractions .1 .1 .2 +@headitem @tab Index @tab Value +@item @tab @code{10} @tab @code{"number ten"} +@item @tab @code{3} @tab @code{30} +@item @tab @code{1} @tab @code{"foo"} +@item @tab @code{0} @tab @code{8} +@item @tab @code{2} @tab @code{""} +@end multitable @end ifnotdocbook @docbook <informaltable> <tgroup cols="2"> -<colspec colname="1" align="center"/> -<colspec colname="2" align="center"/> +<colspec colname="1" align="left"/> +<colspec colname="2" align="left"/> <thead> <row> <entry>Index</entry> @@ -14960,19 +14966,20 @@ an index. For example, the following is an array that translates words from English to French: @ifnotdocbook -@example -@r{Index} "dog" @r{Value} "chien" -@r{Index} "cat" @r{Value} "chat" -@r{Index} "one" @r{Value} "un" -@r{Index} 1 @r{Value} "un" -@end example +@multitable @columnfractions .1 .1 .1 +@headitem @tab Index @tab Value +@item @tab @code{"dog"} @tab @code{"chien"} +@item @tab @code{"cat"} @tab @code{"chat"} +@item @tab @code{"one"} @tab @code{"un"} +@item @tab @code{1} @tab @code{"un"} +@end multitable @end ifnotdocbook @docbook <informaltable> <tgroup cols="2"> -<colspec colname="1" align="center"/> -<colspec colname="2" align="center"/> +<colspec colname="1" align="left"/> +<colspec colname="2" align="left"/> <thead> <row> <entry>Index</entry> @@ -15014,7 +15021,7 @@ numbers and strings as indices. There are some subtleties to how numbers work when used as array subscripts; this is discussed in more detail in @ref{Numeric Array Subscripts}.) -Here, the number @code{1} isn't double quoted, because @command{awk} +Here, the number @code{1} isn't double-quoted, because @command{awk} automatically converts it to a string. @cindex @command{gawk}, @code{IGNORECASE} variable in @@ -15039,7 +15046,7 @@ is independent of the number of elements in the array. @cindex elements of arrays The principal way to use an array is to refer to one of its elements. -An array reference is an expression as follows: +An @dfn{array reference} is an expression as follows: @example @var{array}[@var{index-expression}] @@ -15049,8 +15056,11 @@ An array reference is an expression as follows: Here, @var{array} is the name of an array. The expression @var{index-expression} is the index of the desired element of the array. +@c 1/2015: Having the 4.3 in @samp is a little iffy. It's essentially +@c an expression though, so leave be. It's to early in the discussion +@c to mention that it's really a string. The value of the array reference is the current value of that array -element. For example, @code{foo[4.3]} is an expression for the element +element. For example, @code{foo[4.3]} is an expression referencing the element of array @code{foo} at index @samp{4.3}. @cindex arrays, unassigned elements @@ -15142,7 +15152,7 @@ assign to that element of the array. The following program takes a list of lines, each beginning with a line number, and prints them out in order of line number. The line numbers -are not in order when they are first read---instead they +are not in order when they are first read---instead, they are scrambled. This program sorts the lines by making an array using the line numbers as subscripts. The program then prints out the lines in sorted order of their numbers. It is a very simple program and gets @@ -15236,7 +15246,7 @@ program has previously used, with the variable @var{var} set to that index. The following program uses this form of the @code{for} statement. The first rule scans the input records and notes which words appear (at least once) in the input, by storing a one into the array @code{used} with -the word as index. The second rule scans the elements of @code{used} to +the word as the index. The second rule scans the elements of @code{used} to find all the distinct words that appear in the input. It prints each word that is more than 10 characters long and also prints the number of such words. @@ -15333,7 +15343,7 @@ and will vary from one version of @command{awk} to the next. Often, though, you may wish to do something simple, such as ``traverse the array by comparing the indices in ascending order,'' or ``traverse the array by comparing the values in descending order.'' -@command{gawk} provides two mechanisms which give you this control. +@command{gawk} provides two mechanisms that give you this control: @itemize @value{BULLET} @item @@ -15390,21 +15400,26 @@ across different environments.} which @command{gawk} uses internally to perform the sorting. @item "@@ind_str_desc" -String indices ordered from high to low. +Like @code{"@@ind_str_asc"}, but the +string indices are ordered from high to low. @item "@@ind_num_desc" -Numeric indices ordered from high to low. +Like @code{"@@ind_num_asc"}, but the +numeric indices are ordered from high to low. @item "@@val_type_desc" -Element values, based on type, ordered from high to low. +Like @code{"@@val_type_asc"}, but the +element values, based on type, are ordered from high to low. Subarrays, if present, come out first. @item "@@val_str_desc" -Element values, treated as strings, ordered from high to low. +Like @code{"@@val_str_asc"}, but the +element values, treated as strings, are ordered from high to low. Subarrays, if present, come out first. @item "@@val_num_desc" -Element values, treated as numbers, ordered from high to low. +Like @code{"@@val_num_asc"}, but the +element values, treated as numbers, are ordered from high to low. Subarrays, if present, come out first. @end table @@ -15627,7 +15642,7 @@ for (i in frequencies) @noindent This example removes all the elements from the array @code{frequencies}. Once an element is deleted, a subsequent @code{for} statement to scan the array -does not report that element and the @code{in} operator to check for +does not report that element and using the @code{in} operator to check for the presence of that element returns zero (i.e., false): @example @@ -15887,7 +15902,7 @@ a[1][2] = 2 This simulates a true two-dimensional array. Each subarray element can contain another subarray as a value, which in turn can hold other arrays as well. In this way, you can create arrays of three or more dimensions. -The indices can be any @command{awk} expression, including scalars +The indices can be any @command{awk} expressions, including scalars separated by commas (i.e., a regular @command{awk} simulated multidimensional subscript). So the following is valid in @command{gawk}: @@ -15899,7 +15914,7 @@ a[1][3][1, "name"] = "barney" Each subarray and the main array can be of different length. In fact, the elements of an array or its subarray do not all have to have the same type. This means that the main array and any of its subarrays can be -non-rectangular, or jagged in structure. You can assign a scalar value to +nonrectangular, or jagged in structure. You can assign a scalar value to the index @code{4} of the main array @code{a}, even though @code{a[1]} is itself an array and not a scalar: @@ -15923,7 +15938,8 @@ a[4][5][6][7] = "An element in a four-dimensional array" @noindent This removes the scalar value from index @code{4} and then inserts a -subarray of subarray of subarray containing a scalar. You can also +three-level nested subarray +containing a scalar. You can also delete an entire subarray or subarray of subarrays: @example @@ -15934,7 +15950,7 @@ a[4][5] = "An element in subarray a[4]" But recall that you can not delete the main array @code{a} and then use it as a scalar. -The built-in functions which take array arguments can also be used +The built-in functions that take array arguments can also be used with subarrays. For example, the following code fragment uses @code{length()} (@pxref{String Functions}) to determine the number of elements in the main array @code{a} and @@ -15964,7 +15980,7 @@ can be nested to scan all the elements of an array of arrays if it is rectangular in structure. In order to print the contents (scalar values) of a two-dimensional array of arrays (i.e., in which each first-level element is itself an -array, not necessarily of the same length) +array, not necessarily of the same length), you could use the following code: @example @@ -16064,9 +16080,9 @@ versions of @command{awk}. @item Standard @command{awk} simulates multidimensional arrays by separating -subscript values with a comma. The values are concatenated into a +subscript values with commas. The values are concatenated into a single string, separated by the value of @code{SUBSEP}. The fact -that such a subscript was created in this way is not retained; thus +that such a subscript was created in this way is not retained; thus, changing @code{SUBSEP} may have unexpected consequences. You can use @samp{(@var{sub1}, @var{sub2}, @dots{}) in @var{array}} to see if such a multidimensional subscript exists in @var{array}. @@ -16075,7 +16091,7 @@ a multidimensional subscript exists in @var{array}. @command{gawk} provides true arrays of arrays. You use a separate set of square brackets for each dimension in such an array: @code{data[row][col]}, for example. Array elements may thus be either -scalar values (number or string) or another array. +scalar values (number or string) or other arrays. @item Use the @code{isarray()} built-in function to determine if an array @@ -16813,7 +16829,7 @@ split("cul-de-sac", a, "-", seps) @noindent @cindex strings splitting, example -splits the string @samp{cul-de-sac} into three fields using @samp{-} as the +splits the string @code{"cul-de-sac"} into three fields using @samp{-} as the separator. It sets the contents of the array @code{a} as follows: @example |