diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-11 20:30:15 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-11 20:30:15 +0300 |
commit | a09ff78b4fc11a487be7f3dd4cdf75aa34ec54da (patch) | |
tree | 20c10118bb384cfd0ddbf2bd5694d2fc27ee57fd | |
parent | 1d16bc2525dfd1a8191ac4a419b1ca7af6bb0670 (diff) | |
parent | b6c937359a778e40a5d532c2a3aed8b21b89b3be (diff) | |
download | egawk-a09ff78b4fc11a487be7f3dd4cdf75aa34ec54da.tar.gz egawk-a09ff78b4fc11a487be7f3dd4cdf75aa34ec54da.tar.bz2 egawk-a09ff78b4fc11a487be7f3dd4cdf75aa34ec54da.zip |
Merge branch 'gawk-4.1-stable'
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 836 | ||||
-rw-r--r-- | doc/gawk.texi | 173 | ||||
-rw-r--r-- | doc/gawktexi.in | 173 |
4 files changed, 838 insertions, 348 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index c2bb54c8..28cad6e0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-06-11 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: More "Summary" sections. Through chapter 10. + 2014-06-10 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Update docbook figure markup. diff --git a/doc/gawk.info b/doc/gawk.info index 4c422294..7c7af5eb 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -10530,6 +10530,7 @@ cannot have a variable and an array with the same name in the same * Multidimensional:: Emulating multidimensional arrays in `awk'. * Arrays of Arrays:: True multidimensional arrays. +* Arrays Summary:: Summary of arrays. File: gawk.info, Node: Array Basics, Next: Delete, Up: Arrays @@ -11320,7 +11321,7 @@ The result is to set `separate[1]' to `"1"' and `separate[2]' to recovered. -File: gawk.info, Node: Arrays of Arrays, Prev: Multidimensional, Up: Arrays +File: gawk.info, Node: Arrays of Arrays, Next: Arrays Summary, Prev: Multidimensional, Up: Arrays 8.6 Arrays of Arrays ==================== @@ -11442,6 +11443,54 @@ by creating an arbitrary index: -| a +File: gawk.info, Node: Arrays Summary, Prev: Arrays of Arrays, Up: Arrays + +8.7 Summary +=========== + + * Standard `awk' provides one-dimensional associative arrays (arrays + indexed by string values). All arrays are associative; numeric + indices are converted automatically to strings. + + * Array elements are referenced as `ARRAY[INDX]'. Referencing an + element creates it if it did not exist previously. + + * The proper way to see if an array has an element with a given index + is to use the `in' operator: `INDX in ARRAY'. + + * Use `for (INDX in ARRAY) ...' to scan through all the individual + elements of an array. In the body of the loop, INDX takes on the + value of each element's index in turn. + + * The order in which a `for (INDX in ARRAY)' loop traverses an array + is undefined in POSIX `awk' and varies among implementations. + `gawk' lets you control the order by assigning special predefined + values to `PROCINFO["sorted_in"]'. + + * Use `delete ARRAY[INDX]' to delete an individual element. You may + also use `delete ARRAY' to delete all of the elements in the + array. This latter feature has been a common extension for many + years and is now standard, but may not be supported by all + commercial versions of `awk'. + + * Standard `awk' simulates multidimensional arrays by separating + subscript values with a comma. 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 + changing `SUBSEP' may have unexpected consequences. You can use + `(SUB1, SUB2, ...) in ARRAY' to see if such a multidimensional + subscript exists in ARRAY. + + * `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. + + * Use the `isarray()' built-in function to determine if an array + element is itself a subarray. + + + File: gawk.info, Node: Functions, Next: Library Functions, Prev: Arrays, Up: Top 9 Functions @@ -11461,6 +11510,7 @@ major node describes these "user-defined" functions. * Built-in:: Summarizes the built-in functions. * User-defined:: Describes User-defined functions in detail. * Indirect Calls:: Choosing the function to call at runtime. +* Functions Summary:: Summary of functions. File: gawk.info, Node: Built-in, Next: User-defined, Up: Functions @@ -13660,7 +13710,7 @@ call, though, then `awk' does report the second error. of them. -File: gawk.info, Node: Indirect Calls, Prev: User-defined, Up: Functions +File: gawk.info, Node: Indirect Calls, Next: Functions Summary, Prev: User-defined, Up: Functions 9.3 Indirect Function Calls =========================== @@ -13948,6 +13998,63 @@ example, in the following case: `gawk' will look up the actual function to call only once. +File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions + +9.4 Summary +=========== + + * `awk' provides built-in functions and lets you define your own + functions. + + * POSIX `awk' provides three kinds of built-in functions: numeric, + string, and I/O. `gawk' provides functions that work with values + representing time, do bit manipulation, sort arrays, and + internationalize and localize programs. `gawk' also provides + several extensions to some of standard functions, typically in the + form of additional arguments. + + * Functions accept zero or more arguments and return a value. The + expressions that provide the argument values are comnpletely + evaluated before the function is called. Order of evaluation is + not defined. The return value can be ignored. + + * The handling of backslash in `sub()' and `gsub()' is not simple. + It is more straightforward in `gawk''s `gensub()' function, but + that function still requires care in its use. + + * User-defined functions provide important capabilities but come + with some syntactic inelegancies. In a function call, there cannot + be any space between the function name and the opening left + parethesis of the argument list. Also, there is no provision for + local variables, so the convention is to add extra parameters, and + to separate them visually from the real parameters by extra + whitespace. + + * User-defined functions may call other user-defined (and built-in) + functions and may call themselves recursively. Function parameters + "hide" any global variables of the same names. + + * Scalar values are passed to user-defined functions by value. Array + parameters are passed by reference; any changes made by the + function to array parameters are thus visible after the function + has returned. + + * Use the `return' statement to return from a user-defined function. + An optional expression becomes the function's return value. Only + scalar values may be returned by a function. + + * If a variable that has never been used is passed to a user-defined + function, how that function treats the variable can set its + nature: either scalar or array. + + * `gawk' provides indirect function calls using a special syntax. + By setting a variable to the name of a user-defined function, you + can determine at runtime what function will be called at that + point in the program. This is equivalent to function pointers in C + and C++. + + + File: gawk.info, Node: Library Functions, Next: Sample Programs, Prev: Functions, Up: Top 10 A Library of `awk' Functions @@ -14023,6 +14130,7 @@ for different implementations of `awk' is pretty straightforward. * Passwd Functions:: Functions for getting user information. * Group Functions:: Functions for getting group information. * Walking Arrays:: A function to walk arrays of arrays. +* Library Functions Summary:: Summary of library functions. ---------- Footnotes ---------- @@ -14920,8 +15028,8 @@ intervening value in `ARGV' is a variable assignment. File: gawk.info, Node: Ignoring Assigns, Prev: Empty Files, Up: Data File Management -10.3.5 Treating Assignments as File Name ----------------------------------------- +10.3.5 Treating Assignments as File Names +----------------------------------------- Occasionally, you might not want `awk' to process command-line variable assignments (*note Assignment Options::). In particular, if you have a @@ -15735,7 +15843,7 @@ Suppose that the first time there were no names. This code adds the names with a leading comma. It also doesn't check that there is a `$4'. -File: gawk.info, Node: Walking Arrays, Prev: Group Functions, Up: Library Functions +File: gawk.info, Node: Walking Arrays, Next: Library Functions Summary, Prev: Group Functions, Up: Library Functions 10.7 Traversing Arrays of Arrays ================================ @@ -15798,6 +15906,43 @@ user-defined function that expects to receive an index and a value, and then processes the element. +File: gawk.info, Node: Library Functions Summary, Prev: Walking Arrays, Up: Library Functions + +10.8 Summary +============ + + * Reading programs is an excellent way to learn Good Programming. + The functions provided in this major node and the next are intended + to serve that purpose. + + * When writing general-purpose library functions, put some thought + into how to name any global variables so that they won't conflict + with variables from a user's program. + + * The functions presented here fit into the following categories: + + General problems + Number to string conversion, assertions, rounding, random + number generation, converting characters to numbers, joining + strings, getting easily usable time-of-day information, and + reading a whole file in one shot. + + Managing data files + Noting data file boundaries, rereading the current file, + checking for readable files, checking for zero-length files, + and treating assignments as file names. + + Processing command-line options + An `awk' version of the standard C `getopt()' function. + + Reading the user and group databases + Two sets of routines that parallel the C library versions. + + Traversing arrays of arrays + A simple function to traverse an array of arrays to any depth. + + + File: gawk.info, Node: Sample Programs, Next: Advanced Features, Prev: Library Functions, Up: Top 11 Practical `awk' Programs @@ -19876,8 +20021,8 @@ File: gawk.info, Node: Gawk I18N, Prev: I18N Example, Up: Internationalizatio `gawk' itself has been internationalized using the GNU `gettext' package. (GNU `gettext' is described in complete detail in *note (GNU `gettext' utilities)Top:: gettext, GNU gettext tools.) As of this -writing, the latest version of GNU `gettext' is version 0.19 -(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.tar.gz). +writing, the latest version of GNU `gettext' is version 0.19.1 +(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz). If a translation of `gawk''s messages exists, then `gawk' produces usage messages, warnings, and fatal errors in the local language. @@ -33745,342 +33890,345 @@ Ref: Auto-set-Footnote-2442264 Node: ARGC and ARGV442320 Node: Pattern Action Summary446159 Node: Arrays448382 -Node: Array Basics449880 -Node: Array Intro450706 -Ref: figure-array-elements452679 -Node: Reference to Elements455086 -Node: Assigning Elements457359 -Node: Array Example457850 -Node: Scanning an Array459582 -Node: Controlling Scanning462597 -Ref: Controlling Scanning-Footnote-1467770 -Node: Delete468086 -Ref: Delete-Footnote-1470851 -Node: Numeric Array Subscripts470908 -Node: Uninitialized Subscripts473091 -Node: Multidimensional474716 -Node: Multiscanning477809 -Node: Arrays of Arrays479398 -Node: Functions484038 -Node: Built-in484857 -Node: Calling Built-in485935 -Node: Numeric Functions487923 -Ref: Numeric Functions-Footnote-1491757 -Ref: Numeric Functions-Footnote-2492114 -Ref: Numeric Functions-Footnote-3492162 -Node: String Functions492431 -Ref: String Functions-Footnote-1515442 -Ref: String Functions-Footnote-2515571 -Ref: String Functions-Footnote-3515819 -Node: Gory Details515906 -Ref: table-sub-escapes517575 -Ref: table-sub-posix-92518929 -Ref: table-sub-proposed520280 -Ref: table-posix-sub521634 -Ref: table-gensub-escapes523179 -Ref: Gory Details-Footnote-1524355 -Ref: Gory Details-Footnote-2524406 -Node: I/O Functions524557 -Ref: I/O Functions-Footnote-1531680 -Node: Time Functions531827 -Ref: Time Functions-Footnote-1542291 -Ref: Time Functions-Footnote-2542359 -Ref: Time Functions-Footnote-3542517 -Ref: Time Functions-Footnote-4542628 -Ref: Time Functions-Footnote-5542740 -Ref: Time Functions-Footnote-6542967 -Node: Bitwise Functions543233 -Ref: table-bitwise-ops543795 -Ref: Bitwise Functions-Footnote-1548040 -Node: Type Functions548224 -Node: I18N Functions549366 -Node: User-defined551011 -Node: Definition Syntax551815 -Ref: Definition Syntax-Footnote-1556740 -Node: Function Example556809 -Ref: Function Example-Footnote-1559453 -Node: Function Caveats559475 -Node: Calling A Function559993 -Node: Variable Scope560948 -Node: Pass By Value/Reference563936 -Node: Return Statement567444 -Node: Dynamic Typing570428 -Node: Indirect Calls571357 -Node: Library Functions581044 -Ref: Library Functions-Footnote-1584557 -Ref: Library Functions-Footnote-2584700 -Node: Library Names584871 -Ref: Library Names-Footnote-1588344 -Ref: Library Names-Footnote-2588564 -Node: General Functions588650 -Node: Strtonum Function589678 -Node: Assert Function592608 -Node: Round Function595934 -Node: Cliff Random Function597475 -Node: Ordinal Functions598491 -Ref: Ordinal Functions-Footnote-1601568 -Ref: Ordinal Functions-Footnote-2601820 -Node: Join Function602031 -Ref: Join Function-Footnote-1603802 -Node: Getlocaltime Function604002 -Node: Readfile Function607738 -Node: Data File Management609577 -Node: Filetrans Function610209 -Node: Rewind Function614264 -Node: File Checking615651 -Ref: File Checking-Footnote-1616783 -Node: Empty Files616984 -Node: Ignoring Assigns619207 -Node: Getopt Function620738 -Ref: Getopt Function-Footnote-1632034 -Node: Passwd Functions632237 -Ref: Passwd Functions-Footnote-1641216 -Node: Group Functions641304 -Ref: Group Functions-Footnote-1649246 -Node: Walking Arrays649459 -Node: Sample Programs651595 -Node: Running Examples652269 -Node: Clones652997 -Node: Cut Program654221 -Node: Egrep Program664082 -Ref: Egrep Program-Footnote-1672011 -Node: Id Program672121 -Node: Split Program675785 -Ref: Split Program-Footnote-1679316 -Node: Tee Program679444 -Node: Uniq Program682251 -Node: Wc Program689681 -Ref: Wc Program-Footnote-1693949 -Ref: Wc Program-Footnote-2694149 -Node: Miscellaneous Programs694241 -Node: Dupword Program695429 -Node: Alarm Program697460 -Node: Translate Program702274 -Ref: Translate Program-Footnote-1706665 -Ref: Translate Program-Footnote-2706935 -Node: Labels Program707069 -Ref: Labels Program-Footnote-1710440 -Node: Word Sorting710524 -Node: History Sorting714567 -Node: Extract Program716403 -Ref: Extract Program-Footnote-1723978 -Node: Simple Sed724107 -Node: Igawk Program727169 -Ref: Igawk Program-Footnote-1742345 -Ref: Igawk Program-Footnote-2742546 -Node: Anagram Program742684 -Node: Signature Program745752 -Node: Advanced Features746999 -Node: Nondecimal Data748885 -Node: Array Sorting750462 -Node: Controlling Array Traversal751159 -Node: Array Sorting Functions759439 -Ref: Array Sorting Functions-Footnote-1763346 -Node: Two-way I/O763540 -Ref: Two-way I/O-Footnote-1769056 -Node: TCP/IP Networking769138 -Node: Profiling771982 -Node: Internationalization779490 -Node: I18N and L10N780915 -Node: Explaining gettext781601 -Ref: Explaining gettext-Footnote-1786741 -Ref: Explaining gettext-Footnote-2786925 -Node: Programmer i18n787090 -Node: Translator i18n791315 -Node: String Extraction792109 -Ref: String Extraction-Footnote-1793070 -Node: Printf Ordering793156 -Ref: Printf Ordering-Footnote-1795938 -Node: I18N Portability796002 -Ref: I18N Portability-Footnote-1798451 -Node: I18N Example798514 -Ref: I18N Example-Footnote-1801236 -Node: Gawk I18N801308 -Node: Debugger801921 -Node: Debugging802892 -Node: Debugging Concepts803333 -Node: Debugging Terms805189 -Node: Awk Debugging807786 -Node: Sample Debugging Session808678 -Node: Debugger Invocation809198 -Node: Finding The Bug810531 -Node: List of Debugger Commands817013 -Node: Breakpoint Control818345 -Node: Debugger Execution Control822009 -Node: Viewing And Changing Data825369 -Node: Execution Stack828727 -Node: Debugger Info830240 -Node: Miscellaneous Debugger Commands834234 -Node: Readline Support839418 -Node: Limitations840310 -Node: Arbitrary Precision Arithmetic842558 -Ref: Arbitrary Precision Arithmetic-Footnote-1844207 -Node: General Arithmetic844355 -Node: Floating Point Issues846075 -Node: String Conversion Precision846956 -Ref: String Conversion Precision-Footnote-1848661 -Node: Unexpected Results848770 -Node: POSIX Floating Point Problems850923 -Ref: POSIX Floating Point Problems-Footnote-1854744 -Node: Integer Programming854782 -Node: Floating-point Programming856593 -Ref: Floating-point Programming-Footnote-1862921 -Ref: Floating-point Programming-Footnote-2863191 -Node: Floating-point Representation863455 -Node: Floating-point Context864620 -Ref: table-ieee-formats865459 -Node: Rounding Mode866843 -Ref: table-rounding-modes867322 -Ref: Rounding Mode-Footnote-1870337 -Node: Gawk and MPFR870516 -Node: Arbitrary Precision Floats871925 -Ref: Arbitrary Precision Floats-Footnote-1874368 -Node: Setting Precision874689 -Ref: table-predefined-precision-strings875373 -Node: Setting Rounding Mode877518 -Ref: table-gawk-rounding-modes877922 -Node: Floating-point Constants879109 -Node: Changing Precision880561 -Ref: Changing Precision-Footnote-1881953 -Node: Exact Arithmetic882127 -Node: Arbitrary Precision Integers885261 -Ref: Arbitrary Precision Integers-Footnote-1888276 -Node: Dynamic Extensions888423 -Node: Extension Intro889881 -Node: Plugin License891146 -Node: Extension Mechanism Outline891831 -Ref: figure-load-extension892255 -Ref: figure-load-new-function893740 -Ref: figure-call-new-function894742 -Node: Extension API Description896726 -Node: Extension API Functions Introduction898176 -Node: General Data Types903042 -Ref: General Data Types-Footnote-1908735 -Node: Requesting Values909034 -Ref: table-value-types-returned909771 -Node: Memory Allocation Functions910729 -Ref: Memory Allocation Functions-Footnote-1913476 -Node: Constructor Functions913572 -Node: Registration Functions915330 -Node: Extension Functions916015 -Node: Exit Callback Functions918317 -Node: Extension Version String919567 -Node: Input Parsers920217 -Node: Output Wrappers930020 -Node: Two-way processors934536 -Node: Printing Messages936740 -Ref: Printing Messages-Footnote-1937817 -Node: Updating `ERRNO'937969 -Node: Accessing Parameters938708 -Node: Symbol Table Access939938 -Node: Symbol table by name940452 -Node: Symbol table by cookie942428 -Ref: Symbol table by cookie-Footnote-1946561 -Node: Cached values946624 -Ref: Cached values-Footnote-1950129 -Node: Array Manipulation950220 -Ref: Array Manipulation-Footnote-1951318 -Node: Array Data Types951357 -Ref: Array Data Types-Footnote-1954060 -Node: Array Functions954152 -Node: Flattening Arrays958026 -Node: Creating Arrays964878 -Node: Extension API Variables969609 -Node: Extension Versioning970245 -Node: Extension API Informational Variables972146 -Node: Extension API Boilerplate973232 -Node: Finding Extensions977036 -Node: Extension Example977596 -Node: Internal File Description978326 -Node: Internal File Ops982417 -Ref: Internal File Ops-Footnote-1993963 -Node: Using Internal File Ops994103 -Ref: Using Internal File Ops-Footnote-1996450 -Node: Extension Samples996718 -Node: Extension Sample File Functions998242 -Node: Extension Sample Fnmatch1005810 -Node: Extension Sample Fork1007277 -Node: Extension Sample Inplace1008490 -Node: Extension Sample Ord1010256 -Node: Extension Sample Readdir1011092 -Ref: table-readdir-file-types1011941 -Node: Extension Sample Revout1012740 -Node: Extension Sample Rev2way1013331 -Node: Extension Sample Read write array1014072 -Node: Extension Sample Readfile1015951 -Node: Extension Sample API Tests1017051 -Node: Extension Sample Time1017576 -Node: gawkextlib1018891 -Node: Language History1021678 -Node: V7/SVR3.11023272 -Node: SVR41025592 -Node: POSIX1027034 -Node: BTL1028420 -Node: POSIX/GNU1029154 -Node: Feature History1034753 -Node: Common Extensions1047865 -Node: Ranges and Locales1049177 -Ref: Ranges and Locales-Footnote-11053794 -Ref: Ranges and Locales-Footnote-21053821 -Ref: Ranges and Locales-Footnote-31054055 -Node: Contributors1054276 -Node: Installation1059714 -Node: Gawk Distribution1060608 -Node: Getting1061092 -Node: Extracting1061918 -Node: Distribution contents1063560 -Node: Unix Installation1069277 -Node: Quick Installation1069894 -Node: Additional Configuration Options1072336 -Node: Configuration Philosophy1074074 -Node: Non-Unix Installation1076425 -Node: PC Installation1076883 -Node: PC Binary Installation1078194 -Node: PC Compiling1080042 -Ref: PC Compiling-Footnote-11083041 -Node: PC Testing1083146 -Node: PC Using1084322 -Node: Cygwin1088480 -Node: MSYS1089289 -Node: VMS Installation1089803 -Node: VMS Compilation1090599 -Ref: VMS Compilation-Footnote-11091814 -Node: VMS Dynamic Extensions1091872 -Node: VMS Installation Details1093245 -Node: VMS Running1095491 -Node: VMS GNV1098325 -Node: VMS Old Gawk1099048 -Node: Bugs1099518 -Node: Other Versions1103522 -Node: Notes1109747 -Node: Compatibility Mode1110547 -Node: Additions1111329 -Node: Accessing The Source1112254 -Node: Adding Code1113690 -Node: New Ports1119868 -Node: Derived Files1124349 -Ref: Derived Files-Footnote-11129430 -Ref: Derived Files-Footnote-21129464 -Ref: Derived Files-Footnote-31130060 -Node: Future Extensions1130174 -Node: Implementation Limitations1130780 -Node: Extension Design1132028 -Node: Old Extension Problems1133182 -Ref: Old Extension Problems-Footnote-11134699 -Node: Extension New Mechanism Goals1134756 -Ref: Extension New Mechanism Goals-Footnote-11138117 -Node: Extension Other Design Decisions1138306 -Node: Extension Future Growth1140412 -Node: Old Extension Mechanism1141248 -Node: Basic Concepts1142988 -Node: Basic High Level1143669 -Ref: figure-general-flow1143941 -Ref: figure-process-flow1144540 -Ref: Basic High Level-Footnote-11147769 -Node: Basic Data Typing1147954 -Node: Glossary1151281 -Node: Copying1176433 -Node: GNU Free Documentation License1213989 -Node: Index1239125 +Node: Array Basics449931 +Node: Array Intro450757 +Ref: figure-array-elements452730 +Node: Reference to Elements455137 +Node: Assigning Elements457410 +Node: Array Example457901 +Node: Scanning an Array459633 +Node: Controlling Scanning462648 +Ref: Controlling Scanning-Footnote-1467821 +Node: Delete468137 +Ref: Delete-Footnote-1470902 +Node: Numeric Array Subscripts470959 +Node: Uninitialized Subscripts473142 +Node: Multidimensional474767 +Node: Multiscanning477860 +Node: Arrays of Arrays479449 +Node: Arrays Summary484112 +Node: Functions486217 +Node: Built-in487090 +Node: Calling Built-in488168 +Node: Numeric Functions490156 +Ref: Numeric Functions-Footnote-1493990 +Ref: Numeric Functions-Footnote-2494347 +Ref: Numeric Functions-Footnote-3494395 +Node: String Functions494664 +Ref: String Functions-Footnote-1517675 +Ref: String Functions-Footnote-2517804 +Ref: String Functions-Footnote-3518052 +Node: Gory Details518139 +Ref: table-sub-escapes519808 +Ref: table-sub-posix-92521162 +Ref: table-sub-proposed522513 +Ref: table-posix-sub523867 +Ref: table-gensub-escapes525412 +Ref: Gory Details-Footnote-1526588 +Ref: Gory Details-Footnote-2526639 +Node: I/O Functions526790 +Ref: I/O Functions-Footnote-1533913 +Node: Time Functions534060 +Ref: Time Functions-Footnote-1544524 +Ref: Time Functions-Footnote-2544592 +Ref: Time Functions-Footnote-3544750 +Ref: Time Functions-Footnote-4544861 +Ref: Time Functions-Footnote-5544973 +Ref: Time Functions-Footnote-6545200 +Node: Bitwise Functions545466 +Ref: table-bitwise-ops546028 +Ref: Bitwise Functions-Footnote-1550273 +Node: Type Functions550457 +Node: I18N Functions551599 +Node: User-defined553244 +Node: Definition Syntax554048 +Ref: Definition Syntax-Footnote-1558973 +Node: Function Example559042 +Ref: Function Example-Footnote-1561686 +Node: Function Caveats561708 +Node: Calling A Function562226 +Node: Variable Scope563181 +Node: Pass By Value/Reference566169 +Node: Return Statement569677 +Node: Dynamic Typing572661 +Node: Indirect Calls573590 +Node: Functions Summary583303 +Node: Library Functions585842 +Ref: Library Functions-Footnote-1589417 +Ref: Library Functions-Footnote-2589560 +Node: Library Names589731 +Ref: Library Names-Footnote-1593204 +Ref: Library Names-Footnote-2593424 +Node: General Functions593510 +Node: Strtonum Function594538 +Node: Assert Function597468 +Node: Round Function600794 +Node: Cliff Random Function602335 +Node: Ordinal Functions603351 +Ref: Ordinal Functions-Footnote-1606428 +Ref: Ordinal Functions-Footnote-2606680 +Node: Join Function606891 +Ref: Join Function-Footnote-1608662 +Node: Getlocaltime Function608862 +Node: Readfile Function612598 +Node: Data File Management614437 +Node: Filetrans Function615069 +Node: Rewind Function619124 +Node: File Checking620511 +Ref: File Checking-Footnote-1621643 +Node: Empty Files621844 +Node: Ignoring Assigns624067 +Node: Getopt Function625600 +Ref: Getopt Function-Footnote-1636896 +Node: Passwd Functions637099 +Ref: Passwd Functions-Footnote-1646078 +Node: Group Functions646166 +Ref: Group Functions-Footnote-1654108 +Node: Walking Arrays654321 +Node: Library Functions Summary656491 +Node: Sample Programs657853 +Node: Running Examples658527 +Node: Clones659255 +Node: Cut Program660479 +Node: Egrep Program670340 +Ref: Egrep Program-Footnote-1678269 +Node: Id Program678379 +Node: Split Program682043 +Ref: Split Program-Footnote-1685574 +Node: Tee Program685702 +Node: Uniq Program688509 +Node: Wc Program695939 +Ref: Wc Program-Footnote-1700207 +Ref: Wc Program-Footnote-2700407 +Node: Miscellaneous Programs700499 +Node: Dupword Program701687 +Node: Alarm Program703718 +Node: Translate Program708532 +Ref: Translate Program-Footnote-1712923 +Ref: Translate Program-Footnote-2713193 +Node: Labels Program713327 +Ref: Labels Program-Footnote-1716698 +Node: Word Sorting716782 +Node: History Sorting720825 +Node: Extract Program722661 +Ref: Extract Program-Footnote-1730236 +Node: Simple Sed730365 +Node: Igawk Program733427 +Ref: Igawk Program-Footnote-1748603 +Ref: Igawk Program-Footnote-2748804 +Node: Anagram Program748942 +Node: Signature Program752010 +Node: Advanced Features753257 +Node: Nondecimal Data755143 +Node: Array Sorting756720 +Node: Controlling Array Traversal757417 +Node: Array Sorting Functions765697 +Ref: Array Sorting Functions-Footnote-1769604 +Node: Two-way I/O769798 +Ref: Two-way I/O-Footnote-1775314 +Node: TCP/IP Networking775396 +Node: Profiling778240 +Node: Internationalization785748 +Node: I18N and L10N787173 +Node: Explaining gettext787859 +Ref: Explaining gettext-Footnote-1792999 +Ref: Explaining gettext-Footnote-2793183 +Node: Programmer i18n793348 +Node: Translator i18n797573 +Node: String Extraction798367 +Ref: String Extraction-Footnote-1799328 +Node: Printf Ordering799414 +Ref: Printf Ordering-Footnote-1802196 +Node: I18N Portability802260 +Ref: I18N Portability-Footnote-1804709 +Node: I18N Example804772 +Ref: I18N Example-Footnote-1807494 +Node: Gawk I18N807566 +Node: Debugger808183 +Node: Debugging809154 +Node: Debugging Concepts809595 +Node: Debugging Terms811451 +Node: Awk Debugging814048 +Node: Sample Debugging Session814940 +Node: Debugger Invocation815460 +Node: Finding The Bug816793 +Node: List of Debugger Commands823275 +Node: Breakpoint Control824607 +Node: Debugger Execution Control828271 +Node: Viewing And Changing Data831631 +Node: Execution Stack834989 +Node: Debugger Info836502 +Node: Miscellaneous Debugger Commands840496 +Node: Readline Support845680 +Node: Limitations846572 +Node: Arbitrary Precision Arithmetic848820 +Ref: Arbitrary Precision Arithmetic-Footnote-1850469 +Node: General Arithmetic850617 +Node: Floating Point Issues852337 +Node: String Conversion Precision853218 +Ref: String Conversion Precision-Footnote-1854923 +Node: Unexpected Results855032 +Node: POSIX Floating Point Problems857185 +Ref: POSIX Floating Point Problems-Footnote-1861006 +Node: Integer Programming861044 +Node: Floating-point Programming862855 +Ref: Floating-point Programming-Footnote-1869183 +Ref: Floating-point Programming-Footnote-2869453 +Node: Floating-point Representation869717 +Node: Floating-point Context870882 +Ref: table-ieee-formats871721 +Node: Rounding Mode873105 +Ref: table-rounding-modes873584 +Ref: Rounding Mode-Footnote-1876599 +Node: Gawk and MPFR876778 +Node: Arbitrary Precision Floats878187 +Ref: Arbitrary Precision Floats-Footnote-1880630 +Node: Setting Precision880951 +Ref: table-predefined-precision-strings881635 +Node: Setting Rounding Mode883780 +Ref: table-gawk-rounding-modes884184 +Node: Floating-point Constants885371 +Node: Changing Precision886823 +Ref: Changing Precision-Footnote-1888215 +Node: Exact Arithmetic888389 +Node: Arbitrary Precision Integers891523 +Ref: Arbitrary Precision Integers-Footnote-1894538 +Node: Dynamic Extensions894685 +Node: Extension Intro896143 +Node: Plugin License897408 +Node: Extension Mechanism Outline898093 +Ref: figure-load-extension898517 +Ref: figure-load-new-function900002 +Ref: figure-call-new-function901004 +Node: Extension API Description902988 +Node: Extension API Functions Introduction904438 +Node: General Data Types909304 +Ref: General Data Types-Footnote-1914997 +Node: Requesting Values915296 +Ref: table-value-types-returned916033 +Node: Memory Allocation Functions916991 +Ref: Memory Allocation Functions-Footnote-1919738 +Node: Constructor Functions919834 +Node: Registration Functions921592 +Node: Extension Functions922277 +Node: Exit Callback Functions924579 +Node: Extension Version String925829 +Node: Input Parsers926479 +Node: Output Wrappers936282 +Node: Two-way processors940798 +Node: Printing Messages943002 +Ref: Printing Messages-Footnote-1944079 +Node: Updating `ERRNO'944231 +Node: Accessing Parameters944970 +Node: Symbol Table Access946200 +Node: Symbol table by name946714 +Node: Symbol table by cookie948690 +Ref: Symbol table by cookie-Footnote-1952823 +Node: Cached values952886 +Ref: Cached values-Footnote-1956391 +Node: Array Manipulation956482 +Ref: Array Manipulation-Footnote-1957580 +Node: Array Data Types957619 +Ref: Array Data Types-Footnote-1960322 +Node: Array Functions960414 +Node: Flattening Arrays964288 +Node: Creating Arrays971140 +Node: Extension API Variables975871 +Node: Extension Versioning976507 +Node: Extension API Informational Variables978408 +Node: Extension API Boilerplate979494 +Node: Finding Extensions983298 +Node: Extension Example983858 +Node: Internal File Description984588 +Node: Internal File Ops988679 +Ref: Internal File Ops-Footnote-11000225 +Node: Using Internal File Ops1000365 +Ref: Using Internal File Ops-Footnote-11002712 +Node: Extension Samples1002980 +Node: Extension Sample File Functions1004504 +Node: Extension Sample Fnmatch1012072 +Node: Extension Sample Fork1013539 +Node: Extension Sample Inplace1014752 +Node: Extension Sample Ord1016518 +Node: Extension Sample Readdir1017354 +Ref: table-readdir-file-types1018203 +Node: Extension Sample Revout1019002 +Node: Extension Sample Rev2way1019593 +Node: Extension Sample Read write array1020334 +Node: Extension Sample Readfile1022213 +Node: Extension Sample API Tests1023313 +Node: Extension Sample Time1023838 +Node: gawkextlib1025153 +Node: Language History1027940 +Node: V7/SVR3.11029534 +Node: SVR41031854 +Node: POSIX1033296 +Node: BTL1034682 +Node: POSIX/GNU1035416 +Node: Feature History1041015 +Node: Common Extensions1054127 +Node: Ranges and Locales1055439 +Ref: Ranges and Locales-Footnote-11060056 +Ref: Ranges and Locales-Footnote-21060083 +Ref: Ranges and Locales-Footnote-31060317 +Node: Contributors1060538 +Node: Installation1065976 +Node: Gawk Distribution1066870 +Node: Getting1067354 +Node: Extracting1068180 +Node: Distribution contents1069822 +Node: Unix Installation1075539 +Node: Quick Installation1076156 +Node: Additional Configuration Options1078598 +Node: Configuration Philosophy1080336 +Node: Non-Unix Installation1082687 +Node: PC Installation1083145 +Node: PC Binary Installation1084456 +Node: PC Compiling1086304 +Ref: PC Compiling-Footnote-11089303 +Node: PC Testing1089408 +Node: PC Using1090584 +Node: Cygwin1094742 +Node: MSYS1095551 +Node: VMS Installation1096065 +Node: VMS Compilation1096861 +Ref: VMS Compilation-Footnote-11098076 +Node: VMS Dynamic Extensions1098134 +Node: VMS Installation Details1099507 +Node: VMS Running1101753 +Node: VMS GNV1104587 +Node: VMS Old Gawk1105310 +Node: Bugs1105780 +Node: Other Versions1109784 +Node: Notes1116009 +Node: Compatibility Mode1116809 +Node: Additions1117591 +Node: Accessing The Source1118516 +Node: Adding Code1119952 +Node: New Ports1126130 +Node: Derived Files1130611 +Ref: Derived Files-Footnote-11135692 +Ref: Derived Files-Footnote-21135726 +Ref: Derived Files-Footnote-31136322 +Node: Future Extensions1136436 +Node: Implementation Limitations1137042 +Node: Extension Design1138290 +Node: Old Extension Problems1139444 +Ref: Old Extension Problems-Footnote-11140961 +Node: Extension New Mechanism Goals1141018 +Ref: Extension New Mechanism Goals-Footnote-11144379 +Node: Extension Other Design Decisions1144568 +Node: Extension Future Growth1146674 +Node: Old Extension Mechanism1147510 +Node: Basic Concepts1149250 +Node: Basic High Level1149931 +Ref: figure-general-flow1150203 +Ref: figure-process-flow1150802 +Ref: Basic High Level-Footnote-11154031 +Node: Basic Data Typing1154216 +Node: Glossary1157543 +Node: Copying1182695 +Node: GNU Free Documentation License1220251 +Node: Index1245387 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index a1bc73b2..9bac7c58 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -15031,6 +15031,7 @@ same @command{awk} program. * Multidimensional:: Emulating multidimensional arrays in @command{awk}. * Arrays of Arrays:: True multidimensional arrays. +* Arrays Summary:: Summary of arrays. @end menu @node Array Basics @@ -16313,6 +16314,64 @@ creating an arbitrary index: $ @kbd{gawk 'BEGIN @{ b[1][1] = ""; split("a b c d", b[1]); print b[1][1] @}'} @print{} a @end example + +@node Arrays Summary +@section Summary + +@itemize @value{BULLET} +@item +Standard @command{awk} provides one-dimensional associative arrays (arrays +indexed by string values). All arrays are associative; numeric indices +are converted automatically to strings. + +@item +Array elements are referenced as @code{@var{array}[@var{indx}]}. +Referencing an element creates it if it did not exist previously. + +@item +The proper way to see if an array has an element with a given index +is to use the @code{in} operator: @samp{@var{indx} in @var{array}}. + +@item +Use @samp{for (@var{indx} in @var{array}) @dots{}} to scan through all the +individual elements of an array. In the body of the loop, @var{indx} takes +on the value of each element's index in turn. + +@item +The order in which a +@samp{for (@var{indx} in @var{array})} loop traverses an array is +undefined in POSIX @command{awk} and varies among implementations. +@command{gawk} lets you control the order by assigning special predefined +values to @code{PROCINFO["sorted_in"]}. + +@item +Use @samp{delete @var{array}[@var{indx}]} to delete an +individual element. You may also use @samp{delete @var{array}} +to delete all of the elements in the array. This latter feature +has been a common extension for many years and is now standard, but +may not be supported by all commercial versions of @command{awk}. + +@item +Standard @command{awk} simulates multidimensional arrays by separating +subscript values with a comma. 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 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}. + +@item +@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. + +@item +Use the @code{isarray()} built-in function to determine if an +array element is itself a subarray. + +@end itemize + @c ENDOFRANGE arrs @node Functions @@ -16337,6 +16396,7 @@ The second half of this @value{CHAPTER} describes these * Built-in:: Summarizes the built-in functions. * User-defined:: Describes User-defined functions in detail. * Indirect Calls:: Choosing the function to call at runtime. +* Functions Summary:: Summary of functions. @end menu @node Built-in @@ -19895,6 +19955,68 @@ for (i = 1; i <= n; i++) @noindent @code{gawk} will look up the actual function to call only once. +@node Functions Summary +@section Summary + +@itemize @value{BULLET} +@item +@command{awk} provides built-in functions and lets you define your own +functions. + +@item +POSIX @command{awk} provides three kinds of built-in functions: numeric, string, +and I/O. @command{gawk} provides functions that work with values +representing time, do bit manipulation, sort arrays, and internationalize +and localize programs. +@command{gawk} also provides several extensions to some of standard functions, +typically in the form of additional arguments. + +@item +Functions accept zero or more arguments and return a value. +The expressions that provide the argument values are comnpletely evaluated +before the function is called. Order of evaluation is not defined. +The return value can be ignored. + +@item +The handling of backslash in @code{sub()} and @code{gsub()} is +not simple. It is more straightforward in @command{gawk}'s @code{gensub()} +function, but that function still requires care in its use. + +@item +User-defined functions provide important capabilities but come with some +syntactic inelegancies. In a function call, there cannot be any space +between the function name and the opening left parethesis of the argument +list. Also, there is no provision for local variables, so the convention +is to add extra parameters, and to separate them visually from the real +parameters by extra whitespace. + +@item +User-defined functions may call other user-defined (and built-in) functions +and may call themselves recursively. Function parameters ``hide'' any global +variables of the same names. + +@item +Scalar values are passed to user-defined functions by value. Array parameters +are passed by reference; any changes made by the function to array parameters +are thus visible after the function has returned. + +@item +Use the @code{return} statement to return from a user-defined function. +An optional expression becomes the function's return value. +Only scalar values may be returned by a function. + +@item +If a variable that has never been used is passed to a user-defined function, +how that function treats the variable can set its nature: either scalar or array. + +@item +@command{gawk} provides indirect function calls using a special syntax. +By setting a variable to the name of a user-defined function, you can +determine at runtime what function will be called at that point in the +program. This is equivalent to function pointers in C and C++. + +@end itemize + @c ENDOFRANGE funcud @ifnotinfo @@ -20020,6 +20142,7 @@ comparisons use only lowercase letters. * Passwd Functions:: Functions for getting user information. * Group Functions:: Functions for getting group information. * Walking Arrays:: A function to walk arrays of arrays. +* Library Functions Summary:: Summary of library functions. @end menu @node Library Names @@ -21223,7 +21346,7 @@ END @{ @end ignore @node Ignoring Assigns -@subsection Treating Assignments as @value{FFN} +@subsection Treating Assignments as @value{FFN}s @cindex assignments as filenames @cindex filenames, assignments as @@ -22430,6 +22553,7 @@ $ @kbd{gawk -f walk_array.awk} @print{} a[3] = 3 @end example +@c exercise! Walking an array and processing each element is a general-purpose operation. You might want to consider generalizing the @code{walk_array()} function by adding an additional parameter named @code{process}. @@ -22448,6 +22572,50 @@ the element. @c ENDOFRANGE flibgdata @c ENDOFRANGE gdatar @c ENDOFRANGE libf + +@node Library Functions Summary +@section Summary + +@itemize @value{BULLET} +@item +Reading programs is an excellent way to learn Good Programming. +The functions provided in this @value{CHAPTER} and the next are intended +to serve that purpose. + +@item +When writing general-purpose library functions, put some thought into +how to name any global variables so that they won't conflict with +variables from a user's program. + +@item +The functions presented here fit into the following categories: + +@c nested list +@table @asis +@item General problems +Number to string conversion, assertions, rounding, random number generation, +converting characters to numbers, joining strings, getting easily usable +time-of-day information, and reading a whole file in one shot. + +@item Managing @value{DF}s +Noting @value{DF} boundaries, rereading the current file, checking for +readable files, checking for zero-length files, and treating assignments +as @value{FN}s. + +@item Processing command-line options +An @command{awk} version of the standard C @code{getopt()} function. + +@item Reading the user and group databases +Two sets of routines that parallel the C library versions. + +@item Traversing arrays of arrays +A simple function to traverse an array of arrays to any depth. +@end table +@c end nested list + +@end itemize + + @c ENDOFRANGE flib @c ENDOFRANGE fudlib @c ENDOFRANGE datagr @@ -27932,7 +28100,8 @@ complete detail in @cite{GNU gettext tools}}.) @end ifnotinfo As of this writing, the latest version of GNU @command{gettext} is -@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.tar.gz, @value{PVERSION} 0.19}. +@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz, +@value{PVERSION} 0.19.1}. If a translation of @command{gawk}'s messages exists, then @command{gawk} produces usage messages, warnings, diff --git a/doc/gawktexi.in b/doc/gawktexi.in index af9c67a9..14638c5e 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -14365,6 +14365,7 @@ same @command{awk} program. * Multidimensional:: Emulating multidimensional arrays in @command{awk}. * Arrays of Arrays:: True multidimensional arrays. +* Arrays Summary:: Summary of arrays. @end menu @node Array Basics @@ -15647,6 +15648,64 @@ creating an arbitrary index: $ @kbd{gawk 'BEGIN @{ b[1][1] = ""; split("a b c d", b[1]); print b[1][1] @}'} @print{} a @end example + +@node Arrays Summary +@section Summary + +@itemize @value{BULLET} +@item +Standard @command{awk} provides one-dimensional associative arrays (arrays +indexed by string values). All arrays are associative; numeric indices +are converted automatically to strings. + +@item +Array elements are referenced as @code{@var{array}[@var{indx}]}. +Referencing an element creates it if it did not exist previously. + +@item +The proper way to see if an array has an element with a given index +is to use the @code{in} operator: @samp{@var{indx} in @var{array}}. + +@item +Use @samp{for (@var{indx} in @var{array}) @dots{}} to scan through all the +individual elements of an array. In the body of the loop, @var{indx} takes +on the value of each element's index in turn. + +@item +The order in which a +@samp{for (@var{indx} in @var{array})} loop traverses an array is +undefined in POSIX @command{awk} and varies among implementations. +@command{gawk} lets you control the order by assigning special predefined +values to @code{PROCINFO["sorted_in"]}. + +@item +Use @samp{delete @var{array}[@var{indx}]} to delete an +individual element. You may also use @samp{delete @var{array}} +to delete all of the elements in the array. This latter feature +has been a common extension for many years and is now standard, but +may not be supported by all commercial versions of @command{awk}. + +@item +Standard @command{awk} simulates multidimensional arrays by separating +subscript values with a comma. 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 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}. + +@item +@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. + +@item +Use the @code{isarray()} built-in function to determine if an +array element is itself a subarray. + +@end itemize + @c ENDOFRANGE arrs @node Functions @@ -15671,6 +15730,7 @@ The second half of this @value{CHAPTER} describes these * Built-in:: Summarizes the built-in functions. * User-defined:: Describes User-defined functions in detail. * Indirect Calls:: Choosing the function to call at runtime. +* Functions Summary:: Summary of functions. @end menu @node Built-in @@ -19068,6 +19128,68 @@ for (i = 1; i <= n; i++) @noindent @code{gawk} will look up the actual function to call only once. +@node Functions Summary +@section Summary + +@itemize @value{BULLET} +@item +@command{awk} provides built-in functions and lets you define your own +functions. + +@item +POSIX @command{awk} provides three kinds of built-in functions: numeric, string, +and I/O. @command{gawk} provides functions that work with values +representing time, do bit manipulation, sort arrays, and internationalize +and localize programs. +@command{gawk} also provides several extensions to some of standard functions, +typically in the form of additional arguments. + +@item +Functions accept zero or more arguments and return a value. +The expressions that provide the argument values are comnpletely evaluated +before the function is called. Order of evaluation is not defined. +The return value can be ignored. + +@item +The handling of backslash in @code{sub()} and @code{gsub()} is +not simple. It is more straightforward in @command{gawk}'s @code{gensub()} +function, but that function still requires care in its use. + +@item +User-defined functions provide important capabilities but come with some +syntactic inelegancies. In a function call, there cannot be any space +between the function name and the opening left parethesis of the argument +list. Also, there is no provision for local variables, so the convention +is to add extra parameters, and to separate them visually from the real +parameters by extra whitespace. + +@item +User-defined functions may call other user-defined (and built-in) functions +and may call themselves recursively. Function parameters ``hide'' any global +variables of the same names. + +@item +Scalar values are passed to user-defined functions by value. Array parameters +are passed by reference; any changes made by the function to array parameters +are thus visible after the function has returned. + +@item +Use the @code{return} statement to return from a user-defined function. +An optional expression becomes the function's return value. +Only scalar values may be returned by a function. + +@item +If a variable that has never been used is passed to a user-defined function, +how that function treats the variable can set its nature: either scalar or array. + +@item +@command{gawk} provides indirect function calls using a special syntax. +By setting a variable to the name of a user-defined function, you can +determine at runtime what function will be called at that point in the +program. This is equivalent to function pointers in C and C++. + +@end itemize + @c ENDOFRANGE funcud @ifnotinfo @@ -19193,6 +19315,7 @@ comparisons use only lowercase letters. * Passwd Functions:: Functions for getting user information. * Group Functions:: Functions for getting group information. * Walking Arrays:: A function to walk arrays of arrays. +* Library Functions Summary:: Summary of library functions. @end menu @node Library Names @@ -20367,7 +20490,7 @@ END @{ @end ignore @node Ignoring Assigns -@subsection Treating Assignments as @value{FFN} +@subsection Treating Assignments as @value{FFN}s @cindex assignments as filenames @cindex filenames, assignments as @@ -21574,6 +21697,7 @@ $ @kbd{gawk -f walk_array.awk} @print{} a[3] = 3 @end example +@c exercise! Walking an array and processing each element is a general-purpose operation. You might want to consider generalizing the @code{walk_array()} function by adding an additional parameter named @code{process}. @@ -21592,6 +21716,50 @@ the element. @c ENDOFRANGE flibgdata @c ENDOFRANGE gdatar @c ENDOFRANGE libf + +@node Library Functions Summary +@section Summary + +@itemize @value{BULLET} +@item +Reading programs is an excellent way to learn Good Programming. +The functions provided in this @value{CHAPTER} and the next are intended +to serve that purpose. + +@item +When writing general-purpose library functions, put some thought into +how to name any global variables so that they won't conflict with +variables from a user's program. + +@item +The functions presented here fit into the following categories: + +@c nested list +@table @asis +@item General problems +Number to string conversion, assertions, rounding, random number generation, +converting characters to numbers, joining strings, getting easily usable +time-of-day information, and reading a whole file in one shot. + +@item Managing @value{DF}s +Noting @value{DF} boundaries, rereading the current file, checking for +readable files, checking for zero-length files, and treating assignments +as @value{FN}s. + +@item Processing command-line options +An @command{awk} version of the standard C @code{getopt()} function. + +@item Reading the user and group databases +Two sets of routines that parallel the C library versions. + +@item Traversing arrays of arrays +A simple function to traverse an array of arrays to any depth. +@end table +@c end nested list + +@end itemize + + @c ENDOFRANGE flib @c ENDOFRANGE fudlib @c ENDOFRANGE datagr @@ -27076,7 +27244,8 @@ complete detail in @cite{GNU gettext tools}}.) @end ifnotinfo As of this writing, the latest version of GNU @command{gettext} is -@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.tar.gz, @value{PVERSION} 0.19}. +@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz, +@value{PVERSION} 0.19.1}. If a translation of @command{gawk}'s messages exists, then @command{gawk} produces usage messages, warnings, |