diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ChangeLog | 10 | ||||
-rw-r--r-- | doc/awkcard.in | 6 | ||||
-rw-r--r-- | doc/gawk.1 | 16 | ||||
-rw-r--r-- | doc/gawk.info | 991 | ||||
-rw-r--r-- | doc/gawk.texi | 96 | ||||
-rw-r--r-- | doc/gawktexi.in | 96 |
6 files changed, 638 insertions, 577 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index f4a6f19b..0e88c869 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,13 @@ +2015-04-02 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in, gawk.1, awkcard.in: Name change: div() --> intdiv(). + +2015-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Update discussion of calling built-in functions + indirectly. Small additional fix relating to rand(). Thanks + to Antonio Colombo. + 2015-03-27 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Minor edits. diff --git a/doc/awkcard.in b/doc/awkcard.in index 556bdc1e..2e455b2d 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -1609,11 +1609,11 @@ expand; l lw(2i). \*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR The arctangent of \*(FIy/x\fP in radians. \*(FCcos(\*(FIexpr\*(FC)\*(FR The cosine of \*(FIexpr\fP, which is in radians. -\*(CB\*(FCdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI res\*(FR\*(FC)\*(FR T{ -Return the result of integer division in \*(FIres\*(FR.\*(CD -T} \*(FCexp(\*(FIexpr\*(FC)\*(FR The exponential function (\*(FIe \*(FC^ \*(FIx\*(FR). \*(FCint(\*(FIexpr\*(FC)\*(FR Truncate to integer. +\*(CB\*(FCintdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI res\*(FR\*(FC)\*(FR T{ +Return the result of integer division in \*(FIres\*(FR.\*(CD +T} \*(FClog(\*(FIexpr\*(FC)\*(FR The natural logarithm function (base \*(FIe\^\*(FR). \*(FCrand()\fP A random number \*(FIN\fP such that 0 \(<= \*(FIN\fP < 1. \*(FCsin(\*(FIexpr\*(FC)\*(FR The sine of \*(FIexpr\fP, which is in radians. @@ -13,7 +13,7 @@ . if \w'\(rq' .ds rq "\(rq . \} .\} -.TH GAWK 1 "Mar 24 2015" "Free Software Foundation" "Utility Commands" +.TH GAWK 1 "Apr 02 2015" "Free Software Foundation" "Utility Commands" .SH NAME gawk \- pattern scanning and processing language .SH SYNOPSIS @@ -2680,7 +2680,13 @@ Return the cosine of .IR expr , which is in radians. .TP -.BI div( num ", " denom ", " result ) +.BI exp( expr ) +The exponential function. +.TP +.BI int( expr ) +Truncate to integer. +.TP +.BI intdiv( num ", " denom ", " result ) Truncate .I num and @@ -2697,12 +2703,6 @@ This is a extension, primarily of value when working with arbitrarily large integers. .TP -.BI exp( expr ) -The exponential function. -.TP -.BI int( expr ) -Truncate to integer. -.TP .BI log( expr ) The natural logarithm function. .TP diff --git a/doc/gawk.info b/doc/gawk.info index d0312ec6..685df45b 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -6005,11 +6005,11 @@ Auto-set::): PROCINFO["INPUT_NAME", "RETRY"] = 1 - When this element exists, `gawk' checks the value of the system -`errno' variable when an I/O error occurs. If `errno' indicates a -subsequent I/O attempt may succeed, `getline' instead returns -2 and -further calls to `getline' may succeed. This applies to the `errno' -values `EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'. + When this element exists, `gawk' checks the value of the system (C +language) `errno' variable when an I/O error occurs. If `errno' +indicates a subsequent I/O attempt may succeed, `getline' instead +returns -2 and further calls to `getline' may succeed. This applies to +the `errno' values `EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'. This feature is useful in conjunction with `PROCINFO["INPUT_NAME", "READ_TIMEOUT"]' or situations where a file descriptor has been @@ -12031,7 +12031,17 @@ brackets ([ ]): `cos(X)' Return the cosine of X, with X in radians. -`div(NUMERATOR, DENOMINATOR, RESULT)' +`exp(X)' + Return the exponential of X (`e ^ X') or report an error if X is + out of range. The range of values X can have depends on your + machine's floating-point representation. + +`int(X)' + Return the nearest integer to X, located between X and zero and + truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is + 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well. + +`intdiv(NUMERATOR, DENOMINATOR, RESULT)' Perform integer division, similar to the standard C function of the same name. First, truncate `numerator' and `denominator' towards zero, creating integer values. Clear the `result' array, and then @@ -12046,16 +12056,6 @@ brackets ([ ]): This function is a `gawk' extension. It is not available in compatibility mode (*note Options::). -`exp(X)' - Return the exponential of X (`e ^ X') or report an error if X is - out of range. The range of values X can have depends on your - machine's floating-point representation. - -`int(X)' - Return the nearest integer to X, located between X and zero and - truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is - 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well. - `log(X)' Return the natural logarithm of X, if X is positive; otherwise, return `NaN' ("not a number") on IEEE 754 systems. Additionally, @@ -12075,9 +12075,9 @@ brackets ([ ]): return int(n * rand()) } - The multiplication produces a random number greater than zero and - less than `n'. Using `int()', this result is made into an integer - between zero and `n' - 1, inclusive. + The multiplication produces a random number greater than or equal + to zero and less than `n'. Using `int()', this result is made into + an integer between zero and `n' - 1, inclusive. The following example uses a similar function to produce random integers between one and N. This program prints a new random @@ -14440,9 +14440,17 @@ function call. Starting with version 4.1.2 of `gawk', indirect function calls may also be used with built-in functions and with extension functions -(*note Dynamic Extensions::). The only thing you cannot do is pass a -regular expression constant to a built-in function through an indirect -function call.(1) +(*note Dynamic Extensions::). There are some limitations when calling +built-in functions indirectly, as follows. + + * You cannot pass a regular expression constant to a built-in + function through an indirect function call.(1) This applies to the + `sub()', `gsub()', `gensub()', `match()', `split()' and + `patsplit()' functions. + + * If calling `sub()' or `gsub()', you may only pass two arguments, + since those functions are unusual in that they update their third + argument. This means that `$0' will be updated. `gawk' does its best to make indirect function calls efficient. For example, in the following case: @@ -22610,14 +22618,15 @@ the following: `%', the result is typically an arbitrary precision floating point value (unless the denominator evenly divides into the numerator). In order to do integer division or remainder with arbitrary precision -integers, use the built-in `div()' function (*note Numeric Functions::). +integers, use the built-in `intdiv()' function (*note Numeric +Functions::). - You can simulate the `div()' function in standard `awk' using this -user-defined function: + You can simulate the `intdiv()' function in standard `awk' using +this user-defined function: - # div --- do integer division + # intdiv --- do integer division - function div(numerator, denominator, result) + function intdiv(numerator, denominator, result) { split("", result) @@ -22630,8 +22639,8 @@ user-defined function: } The following example program, contributed by Katie Wasserman, uses -`div()' to compute the digits of pi to as many places as you choose to -set: +`intdiv()' to compute the digits of pi to as many places as you choose +to set: # pi.awk --- compute the digits of pi @@ -22642,7 +22651,7 @@ set: for (m = digits * 4; m > 0; --m) { d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two } @@ -26259,15 +26268,17 @@ project. * GD graphics library extension + * MPFR library extension (this provides access to a number of MPFR + functions that `gawk''s native MPFR support does not) + * PDF extension * PostgreSQL extension - * MPFR library extension (this provides access to a number of MPFR - functions that `gawk''s native MPFR support does not) - * Redis extension + * Select extension + * XML parser extension, using the Expat (http://expat.sourceforge.net) XML parsing library @@ -26742,8 +26753,8 @@ the current version of `gawk'. - The `bindtextdomain()', `dcgettext()', and `dcngettext()' functions for internationalization (*note Programmer i18n::) - - The `div()' function for doing integer division and remainder - (*note Numeric Functions::) + - The `intdiv()' function for doing integer division and + remainder (*note Numeric Functions::) * Changes and/or additions in the command-line options: @@ -27203,7 +27214,7 @@ in POSIX `awk', in the order they were added to `gawk'. * The `igawk' program and its manual page are no longer installed when `gawk' is built. *Note Igawk Program::. - * The `div()' function. *Note Numeric Functions::. + * The `intdiv()' function. *Note Numeric Functions::. * The maximum number of hexdecimal digits in `\x' escapes is now two. *Note Escape Sequences::. @@ -32931,7 +32942,6 @@ Index * display debugger command: Viewing And Changing Data. (line 8) * display debugger options: Debugger Info. (line 57) -* div: Numeric Functions. (line 18) * division: Arithmetic Ops. (line 44) * do-while statement: Do Statement. (line 6) * do-while statement, use of regexps in: Regexp Usage. (line 19) @@ -33051,10 +33061,10 @@ Index * exit status, of VMS: VMS Running. (line 28) * exit the debugger: Miscellaneous Debugger Commands. (line 99) -* exp: Numeric Functions. (line 33) +* exp: Numeric Functions. (line 18) * expand utility: Very Simple. (line 73) -* Expat XML parser library: gawkextlib. (line 35) -* exponent: Numeric Functions. (line 33) +* Expat XML parser library: gawkextlib. (line 37) +* exponent: Numeric Functions. (line 18) * expressions: Expressions. (line 6) * expressions, as patterns: Expression Patterns. (line 6) * expressions, assignment: Assignment Ops. (line 6) @@ -33473,7 +33483,7 @@ Index * git utility <2>: Accessing The Source. (line 10) * git utility <3>: Other Versions. (line 29) -* git utility: gawkextlib. (line 29) +* git utility: gawkextlib. (line 31) * Git, use of for gawk source code: Derived Files. (line 6) * GNITS mailing list: Acknowledgments. (line 52) * GNU awk, See gawk: Preface. (line 51) @@ -33598,8 +33608,9 @@ Index * installation, VMS: VMS Installation. (line 6) * installing gawk: Installation. (line 6) * instruction tracing, in debugger: Debugger Info. (line 90) -* int: Numeric Functions. (line 38) +* int: Numeric Functions. (line 23) * INT signal (MS-Windows): Profiling. (line 213) +* intdiv: Numeric Functions. (line 28) * integer array indices: Numeric Array Subscripts. (line 31) * integers, arbitrary precision: Arbitrary Precision Integers. @@ -34339,7 +34350,7 @@ Index * Robbins, Miriam <2>: Getline/Pipe. (line 39) * Robbins, Miriam: Acknowledgments. (line 94) * Rommel, Kai Uwe: Contributors. (line 42) -* round to nearest integer: Numeric Functions. (line 38) +* round to nearest integer: Numeric Functions. (line 23) * round() user-defined function: Round Function. (line 16) * rounding numbers: Round Function. (line 6) * ROUNDMODE variable: User-modified. (line 127) @@ -34997,452 +35008,452 @@ Ref: table-getline-variants261262 Node: Read Timeout262091 Ref: Read Timeout-Footnote-1265994 Node: Retrying Input266052 -Node: Command-line directories267238 -Node: Input Summary268145 -Node: Input Exercises271530 -Node: Printing272258 -Node: Print274093 -Node: Print Examples275550 -Node: Output Separators278329 -Node: OFMT280347 -Node: Printf281702 -Node: Basic Printf282487 -Node: Control Letters284059 -Node: Format Modifiers288044 -Node: Printf Examples294050 -Node: Redirection296536 -Node: Special FD303374 -Ref: Special FD-Footnote-1306540 -Node: Special Files306614 -Node: Other Inherited Files307231 -Node: Special Network308231 -Node: Special Caveats309093 -Node: Close Files And Pipes310042 -Ref: Close Files And Pipes-Footnote-1317227 -Ref: Close Files And Pipes-Footnote-2317375 -Node: Nonfatal317525 -Node: Output Summary319850 -Node: Output Exercises321071 -Node: Expressions321751 -Node: Values322940 -Node: Constants323617 -Node: Scalar Constants324308 -Ref: Scalar Constants-Footnote-1325170 -Node: Nondecimal-numbers325420 -Node: Regexp Constants328430 -Node: Using Constant Regexps328956 -Node: Variables332119 -Node: Using Variables332776 -Node: Assignment Options334687 -Node: Conversion336562 -Node: Strings And Numbers337086 -Ref: Strings And Numbers-Footnote-1340151 -Node: Locale influences conversions340260 -Ref: table-locale-affects343006 -Node: All Operators343598 -Node: Arithmetic Ops344227 -Node: Concatenation346732 -Ref: Concatenation-Footnote-1349551 -Node: Assignment Ops349658 -Ref: table-assign-ops354637 -Node: Increment Ops355947 -Node: Truth Values and Conditions359378 -Node: Truth Values360461 -Node: Typing and Comparison361510 -Node: Variable Typing362326 -Node: Comparison Operators365993 -Ref: table-relational-ops366403 -Node: POSIX String Comparison369898 -Ref: POSIX String Comparison-Footnote-1370970 -Node: Boolean Ops371109 -Ref: Boolean Ops-Footnote-1375587 -Node: Conditional Exp375678 -Node: Function Calls377416 -Node: Precedence381296 -Node: Locales384956 -Node: Expressions Summary386588 -Node: Patterns and Actions389159 -Node: Pattern Overview390279 -Node: Regexp Patterns391958 -Node: Expression Patterns392501 -Node: Ranges396281 -Node: BEGIN/END399388 -Node: Using BEGIN/END400149 -Ref: Using BEGIN/END-Footnote-1402885 -Node: I/O And BEGIN/END402991 -Node: BEGINFILE/ENDFILE405306 -Node: Empty408203 -Node: Using Shell Variables408520 -Node: Action Overview410793 -Node: Statements413119 -Node: If Statement414967 -Node: While Statement416462 -Node: Do Statement418490 -Node: For Statement419638 -Node: Switch Statement422796 -Node: Break Statement425178 -Node: Continue Statement427271 -Node: Next Statement429098 -Node: Nextfile Statement431479 -Node: Exit Statement434107 -Node: Built-in Variables436518 -Node: User-modified437651 -Ref: User-modified-Footnote-1445285 -Node: Auto-set445347 -Ref: Auto-set-Footnote-1459580 -Ref: Auto-set-Footnote-2459785 -Node: ARGC and ARGV459841 -Node: Pattern Action Summary464059 -Node: Arrays466492 -Node: Array Basics467821 -Node: Array Intro468665 -Ref: figure-array-elements470602 -Ref: Array Intro-Footnote-1473225 -Node: Reference to Elements473353 -Node: Assigning Elements475815 -Node: Array Example476306 -Node: Scanning an Array478065 -Node: Controlling Scanning481088 -Ref: Controlling Scanning-Footnote-1486482 -Node: Numeric Array Subscripts486798 -Node: Uninitialized Subscripts488983 -Node: Delete490600 -Ref: Delete-Footnote-1493349 -Node: Multidimensional493406 -Node: Multiscanning496503 -Node: Arrays of Arrays498092 -Node: Arrays Summary502846 -Node: Functions504937 -Node: Built-in505976 -Node: Calling Built-in507054 -Node: Numeric Functions509049 -Ref: Numeric Functions-Footnote-1513867 -Ref: Numeric Functions-Footnote-2514224 -Ref: Numeric Functions-Footnote-3514272 -Node: String Functions514544 -Ref: String Functions-Footnote-1538045 -Ref: String Functions-Footnote-2538174 -Ref: String Functions-Footnote-3538422 -Node: Gory Details538509 -Ref: table-sub-escapes540290 -Ref: table-sub-proposed541805 -Ref: table-posix-sub543167 -Ref: table-gensub-escapes544704 -Ref: Gory Details-Footnote-1545537 -Node: I/O Functions545688 -Ref: I/O Functions-Footnote-1552924 -Node: Time Functions553071 -Ref: Time Functions-Footnote-1563580 -Ref: Time Functions-Footnote-2563648 -Ref: Time Functions-Footnote-3563806 -Ref: Time Functions-Footnote-4563917 -Ref: Time Functions-Footnote-5564029 -Ref: Time Functions-Footnote-6564256 -Node: Bitwise Functions564522 -Ref: table-bitwise-ops565084 -Ref: Bitwise Functions-Footnote-1569412 -Node: Type Functions569584 -Node: I18N Functions570736 -Node: User-defined572383 -Node: Definition Syntax573188 -Ref: Definition Syntax-Footnote-1578847 -Node: Function Example578918 -Ref: Function Example-Footnote-1581839 -Node: Function Caveats581861 -Node: Calling A Function582379 -Node: Variable Scope583337 -Node: Pass By Value/Reference586330 -Node: Return Statement589827 -Node: Dynamic Typing592806 -Node: Indirect Calls593735 -Ref: Indirect Calls-Footnote-1603600 -Node: Functions Summary603728 -Node: Library Functions606430 -Ref: Library Functions-Footnote-1610038 -Ref: Library Functions-Footnote-2610181 -Node: Library Names610352 -Ref: Library Names-Footnote-1613810 -Ref: Library Names-Footnote-2614033 -Node: General Functions614119 -Node: Strtonum Function615222 -Node: Assert Function618244 -Node: Round Function621568 -Node: Cliff Random Function623109 -Node: Ordinal Functions624125 -Ref: Ordinal Functions-Footnote-1627188 -Ref: Ordinal Functions-Footnote-2627440 -Node: Join Function627651 -Ref: Join Function-Footnote-1629421 -Node: Getlocaltime Function629621 -Node: Readfile Function633365 -Node: Shell Quoting635337 -Node: Data File Management636738 -Node: Filetrans Function637370 -Node: Rewind Function641466 -Node: File Checking642852 -Ref: File Checking-Footnote-1644185 -Node: Empty Files644386 -Node: Ignoring Assigns646365 -Node: Getopt Function647915 -Ref: Getopt Function-Footnote-1659379 -Node: Passwd Functions659579 -Ref: Passwd Functions-Footnote-1668419 -Node: Group Functions668507 -Ref: Group Functions-Footnote-1676404 -Node: Walking Arrays676609 -Node: Library Functions Summary679615 -Node: Library Exercises681017 -Node: Sample Programs682297 -Node: Running Examples683067 -Node: Clones683795 -Node: Cut Program685019 -Node: Egrep Program694739 -Ref: Egrep Program-Footnote-1702242 -Node: Id Program702352 -Node: Split Program706028 -Ref: Split Program-Footnote-1709482 -Node: Tee Program709610 -Node: Uniq Program712399 -Node: Wc Program719818 -Ref: Wc Program-Footnote-1724068 -Node: Miscellaneous Programs724162 -Node: Dupword Program725375 -Node: Alarm Program727406 -Node: Translate Program732211 -Ref: Translate Program-Footnote-1736774 -Node: Labels Program737044 -Ref: Labels Program-Footnote-1740395 -Node: Word Sorting740479 -Node: History Sorting744549 -Node: Extract Program746384 -Node: Simple Sed753908 -Node: Igawk Program756978 -Ref: Igawk Program-Footnote-1771304 -Ref: Igawk Program-Footnote-2771505 -Ref: Igawk Program-Footnote-3771627 -Node: Anagram Program771742 -Node: Signature Program774803 -Node: Programs Summary776050 -Node: Programs Exercises777271 -Ref: Programs Exercises-Footnote-1781402 -Node: Advanced Features781493 -Node: Nondecimal Data783475 -Node: Array Sorting785065 -Node: Controlling Array Traversal785765 -Ref: Controlling Array Traversal-Footnote-1794131 -Node: Array Sorting Functions794249 -Ref: Array Sorting Functions-Footnote-1798135 -Node: Two-way I/O798331 -Ref: Two-way I/O-Footnote-1803276 -Ref: Two-way I/O-Footnote-2803462 -Node: TCP/IP Networking803544 -Node: Profiling806416 -Node: Advanced Features Summary814687 -Node: Internationalization816620 -Node: I18N and L10N818100 -Node: Explaining gettext818786 -Ref: Explaining gettext-Footnote-1823811 -Ref: Explaining gettext-Footnote-2823995 -Node: Programmer i18n824160 -Ref: Programmer i18n-Footnote-1829036 -Node: Translator i18n829085 -Node: String Extraction829879 -Ref: String Extraction-Footnote-1831010 -Node: Printf Ordering831096 -Ref: Printf Ordering-Footnote-1833882 -Node: I18N Portability833946 -Ref: I18N Portability-Footnote-1836402 -Node: I18N Example836465 -Ref: I18N Example-Footnote-1839268 -Node: Gawk I18N839340 -Node: I18N Summary839984 -Node: Debugger841324 -Node: Debugging842346 -Node: Debugging Concepts842787 -Node: Debugging Terms844597 -Node: Awk Debugging847169 -Node: Sample Debugging Session848075 -Node: Debugger Invocation848609 -Node: Finding The Bug849994 -Node: List of Debugger Commands856473 -Node: Breakpoint Control857805 -Node: Debugger Execution Control861482 -Node: Viewing And Changing Data864841 -Node: Execution Stack868217 -Node: Debugger Info869852 -Node: Miscellaneous Debugger Commands873897 -Node: Readline Support878898 -Node: Limitations879792 -Node: Debugging Summary881907 -Node: Arbitrary Precision Arithmetic883081 -Node: Computer Arithmetic884497 -Ref: table-numeric-ranges888074 -Ref: Computer Arithmetic-Footnote-1888598 -Node: Math Definitions888655 -Ref: table-ieee-formats891950 -Ref: Math Definitions-Footnote-1892554 -Node: MPFR features892659 -Node: FP Math Caution894330 -Ref: FP Math Caution-Footnote-1895380 -Node: Inexactness of computations895749 -Node: Inexact representation896708 -Node: Comparing FP Values898066 -Node: Errors accumulate899148 -Node: Getting Accuracy900580 -Node: Try To Round903284 -Node: Setting precision904183 -Ref: table-predefined-precision-strings904867 -Node: Setting the rounding mode906696 -Ref: table-gawk-rounding-modes907060 -Ref: Setting the rounding mode-Footnote-1910512 -Node: Arbitrary Precision Integers910691 -Ref: Arbitrary Precision Integers-Footnote-1915589 -Node: POSIX Floating Point Problems915738 -Ref: POSIX Floating Point Problems-Footnote-1919617 -Node: Floating point summary919655 -Node: Dynamic Extensions921842 -Node: Extension Intro923394 -Node: Plugin License924659 -Node: Extension Mechanism Outline925456 -Ref: figure-load-extension925884 -Ref: figure-register-new-function927364 -Ref: figure-call-new-function928368 -Node: Extension API Description930355 -Node: Extension API Functions Introduction931889 -Node: General Data Types936758 -Ref: General Data Types-Footnote-1942658 -Node: Memory Allocation Functions942957 -Ref: Memory Allocation Functions-Footnote-1945796 -Node: Constructor Functions945895 -Node: Registration Functions947634 -Node: Extension Functions948319 -Node: Exit Callback Functions950616 -Node: Extension Version String951864 -Node: Input Parsers952527 -Node: Output Wrappers962402 -Node: Two-way processors966915 -Node: Printing Messages969178 -Ref: Printing Messages-Footnote-1970254 -Node: Updating `ERRNO'970406 -Node: Requesting Values971146 -Ref: table-value-types-returned971873 -Node: Accessing Parameters972830 -Node: Symbol Table Access974064 -Node: Symbol table by name974578 -Node: Symbol table by cookie976598 -Ref: Symbol table by cookie-Footnote-1980743 -Node: Cached values980806 -Ref: Cached values-Footnote-1984302 -Node: Array Manipulation984393 -Ref: Array Manipulation-Footnote-1985483 -Node: Array Data Types985520 -Ref: Array Data Types-Footnote-1988175 -Node: Array Functions988267 -Node: Flattening Arrays992126 -Node: Creating Arrays999028 -Node: Redirection API1003799 -Node: Extension API Variables1006624 -Node: Extension Versioning1007257 -Node: Extension API Informational Variables1009148 -Node: Extension API Boilerplate1010213 -Node: Finding Extensions1014022 -Node: Extension Example1014582 -Node: Internal File Description1015354 -Node: Internal File Ops1019421 -Ref: Internal File Ops-Footnote-11031172 -Node: Using Internal File Ops1031312 -Ref: Using Internal File Ops-Footnote-11033695 -Node: Extension Samples1033968 -Node: Extension Sample File Functions1035496 -Node: Extension Sample Fnmatch1043177 -Node: Extension Sample Fork1044665 -Node: Extension Sample Inplace1045880 -Node: Extension Sample Ord1047966 -Node: Extension Sample Readdir1048802 -Ref: table-readdir-file-types1049679 -Node: Extension Sample Revout1050490 -Node: Extension Sample Rev2way1051079 -Node: Extension Sample Read write array1051819 -Node: Extension Sample Readfile1053759 -Node: Extension Sample Time1054854 -Node: Extension Sample API Tests1056202 -Node: gawkextlib1056693 -Node: Extension summary1059371 -Node: Extension Exercises1063060 -Node: Language History1064556 -Node: V7/SVR3.11066212 -Node: SVR41068365 -Node: POSIX1069799 -Node: BTL1071180 -Node: POSIX/GNU1071911 -Node: Feature History1077747 -Node: Common Extensions1091541 -Node: Ranges and Locales1092913 -Ref: Ranges and Locales-Footnote-11097532 -Ref: Ranges and Locales-Footnote-21097559 -Ref: Ranges and Locales-Footnote-31097794 -Node: Contributors1098015 -Node: History summary1103555 -Node: Installation1104934 -Node: Gawk Distribution1105880 -Node: Getting1106364 -Node: Extracting1107187 -Node: Distribution contents1108824 -Node: Unix Installation1114926 -Node: Quick Installation1115609 -Node: Shell Startup Files1118020 -Node: Additional Configuration Options1119099 -Node: Configuration Philosophy1120903 -Node: Non-Unix Installation1123272 -Node: PC Installation1123730 -Node: PC Binary Installation1125050 -Node: PC Compiling1126898 -Ref: PC Compiling-Footnote-11129919 -Node: PC Testing1130028 -Node: PC Using1131204 -Node: Cygwin1135319 -Node: MSYS1136089 -Node: VMS Installation1136590 -Node: VMS Compilation1137382 -Ref: VMS Compilation-Footnote-11138611 -Node: VMS Dynamic Extensions1138669 -Node: VMS Installation Details1140353 -Node: VMS Running1142604 -Node: VMS GNV1145444 -Node: VMS Old Gawk1146179 -Node: Bugs1146649 -Node: Other Versions1150538 -Node: Installation summary1156972 -Node: Notes1158031 -Node: Compatibility Mode1158896 -Node: Additions1159678 -Node: Accessing The Source1160603 -Node: Adding Code1162038 -Node: New Ports1168195 -Node: Derived Files1172677 -Ref: Derived Files-Footnote-11178152 -Ref: Derived Files-Footnote-21178186 -Ref: Derived Files-Footnote-31178782 -Node: Future Extensions1178896 -Node: Implementation Limitations1179502 -Node: Extension Design1180750 -Node: Old Extension Problems1181904 -Ref: Old Extension Problems-Footnote-11183421 -Node: Extension New Mechanism Goals1183478 -Ref: Extension New Mechanism Goals-Footnote-11186838 -Node: Extension Other Design Decisions1187027 -Node: Extension Future Growth1189135 -Node: Old Extension Mechanism1189971 -Node: Notes summary1191733 -Node: Basic Concepts1192919 -Node: Basic High Level1193600 -Ref: figure-general-flow1193872 -Ref: figure-process-flow1194471 -Ref: Basic High Level-Footnote-11197700 -Node: Basic Data Typing1197885 -Node: Glossary1201213 -Node: Copying1233142 -Node: GNU Free Documentation License1270698 -Node: Index1295834 +Node: Command-line directories267251 +Node: Input Summary268158 +Node: Input Exercises271543 +Node: Printing272271 +Node: Print274106 +Node: Print Examples275563 +Node: Output Separators278342 +Node: OFMT280360 +Node: Printf281715 +Node: Basic Printf282500 +Node: Control Letters284072 +Node: Format Modifiers288057 +Node: Printf Examples294063 +Node: Redirection296549 +Node: Special FD303387 +Ref: Special FD-Footnote-1306553 +Node: Special Files306627 +Node: Other Inherited Files307244 +Node: Special Network308244 +Node: Special Caveats309106 +Node: Close Files And Pipes310055 +Ref: Close Files And Pipes-Footnote-1317240 +Ref: Close Files And Pipes-Footnote-2317388 +Node: Nonfatal317538 +Node: Output Summary319863 +Node: Output Exercises321084 +Node: Expressions321764 +Node: Values322953 +Node: Constants323630 +Node: Scalar Constants324321 +Ref: Scalar Constants-Footnote-1325183 +Node: Nondecimal-numbers325433 +Node: Regexp Constants328443 +Node: Using Constant Regexps328969 +Node: Variables332132 +Node: Using Variables332789 +Node: Assignment Options334700 +Node: Conversion336575 +Node: Strings And Numbers337099 +Ref: Strings And Numbers-Footnote-1340164 +Node: Locale influences conversions340273 +Ref: table-locale-affects343019 +Node: All Operators343611 +Node: Arithmetic Ops344240 +Node: Concatenation346745 +Ref: Concatenation-Footnote-1349564 +Node: Assignment Ops349671 +Ref: table-assign-ops354650 +Node: Increment Ops355960 +Node: Truth Values and Conditions359391 +Node: Truth Values360474 +Node: Typing and Comparison361523 +Node: Variable Typing362339 +Node: Comparison Operators366006 +Ref: table-relational-ops366416 +Node: POSIX String Comparison369911 +Ref: POSIX String Comparison-Footnote-1370983 +Node: Boolean Ops371122 +Ref: Boolean Ops-Footnote-1375600 +Node: Conditional Exp375691 +Node: Function Calls377429 +Node: Precedence381309 +Node: Locales384969 +Node: Expressions Summary386601 +Node: Patterns and Actions389172 +Node: Pattern Overview390292 +Node: Regexp Patterns391971 +Node: Expression Patterns392514 +Node: Ranges396294 +Node: BEGIN/END399401 +Node: Using BEGIN/END400162 +Ref: Using BEGIN/END-Footnote-1402898 +Node: I/O And BEGIN/END403004 +Node: BEGINFILE/ENDFILE405319 +Node: Empty408216 +Node: Using Shell Variables408533 +Node: Action Overview410806 +Node: Statements413132 +Node: If Statement414980 +Node: While Statement416475 +Node: Do Statement418503 +Node: For Statement419651 +Node: Switch Statement422809 +Node: Break Statement425191 +Node: Continue Statement427284 +Node: Next Statement429111 +Node: Nextfile Statement431492 +Node: Exit Statement434120 +Node: Built-in Variables436531 +Node: User-modified437664 +Ref: User-modified-Footnote-1445298 +Node: Auto-set445360 +Ref: Auto-set-Footnote-1459593 +Ref: Auto-set-Footnote-2459798 +Node: ARGC and ARGV459854 +Node: Pattern Action Summary464072 +Node: Arrays466505 +Node: Array Basics467834 +Node: Array Intro468678 +Ref: figure-array-elements470615 +Ref: Array Intro-Footnote-1473238 +Node: Reference to Elements473366 +Node: Assigning Elements475828 +Node: Array Example476319 +Node: Scanning an Array478078 +Node: Controlling Scanning481101 +Ref: Controlling Scanning-Footnote-1486495 +Node: Numeric Array Subscripts486811 +Node: Uninitialized Subscripts488996 +Node: Delete490613 +Ref: Delete-Footnote-1493362 +Node: Multidimensional493419 +Node: Multiscanning496516 +Node: Arrays of Arrays498105 +Node: Arrays Summary502859 +Node: Functions504950 +Node: Built-in505989 +Node: Calling Built-in507067 +Node: Numeric Functions509062 +Ref: Numeric Functions-Footnote-1513895 +Ref: Numeric Functions-Footnote-2514252 +Ref: Numeric Functions-Footnote-3514300 +Node: String Functions514572 +Ref: String Functions-Footnote-1538073 +Ref: String Functions-Footnote-2538202 +Ref: String Functions-Footnote-3538450 +Node: Gory Details538537 +Ref: table-sub-escapes540318 +Ref: table-sub-proposed541833 +Ref: table-posix-sub543195 +Ref: table-gensub-escapes544732 +Ref: Gory Details-Footnote-1545565 +Node: I/O Functions545716 +Ref: I/O Functions-Footnote-1552952 +Node: Time Functions553099 +Ref: Time Functions-Footnote-1563608 +Ref: Time Functions-Footnote-2563676 +Ref: Time Functions-Footnote-3563834 +Ref: Time Functions-Footnote-4563945 +Ref: Time Functions-Footnote-5564057 +Ref: Time Functions-Footnote-6564284 +Node: Bitwise Functions564550 +Ref: table-bitwise-ops565112 +Ref: Bitwise Functions-Footnote-1569440 +Node: Type Functions569612 +Node: I18N Functions570764 +Node: User-defined572411 +Node: Definition Syntax573216 +Ref: Definition Syntax-Footnote-1578875 +Node: Function Example578946 +Ref: Function Example-Footnote-1581867 +Node: Function Caveats581889 +Node: Calling A Function582407 +Node: Variable Scope583365 +Node: Pass By Value/Reference586358 +Node: Return Statement589855 +Node: Dynamic Typing592834 +Node: Indirect Calls593763 +Ref: Indirect Calls-Footnote-1604006 +Node: Functions Summary604134 +Node: Library Functions606836 +Ref: Library Functions-Footnote-1610444 +Ref: Library Functions-Footnote-2610587 +Node: Library Names610758 +Ref: Library Names-Footnote-1614216 +Ref: Library Names-Footnote-2614439 +Node: General Functions614525 +Node: Strtonum Function615628 +Node: Assert Function618650 +Node: Round Function621974 +Node: Cliff Random Function623515 +Node: Ordinal Functions624531 +Ref: Ordinal Functions-Footnote-1627594 +Ref: Ordinal Functions-Footnote-2627846 +Node: Join Function628057 +Ref: Join Function-Footnote-1629827 +Node: Getlocaltime Function630027 +Node: Readfile Function633771 +Node: Shell Quoting635743 +Node: Data File Management637144 +Node: Filetrans Function637776 +Node: Rewind Function641872 +Node: File Checking643258 +Ref: File Checking-Footnote-1644591 +Node: Empty Files644792 +Node: Ignoring Assigns646771 +Node: Getopt Function648321 +Ref: Getopt Function-Footnote-1659785 +Node: Passwd Functions659985 +Ref: Passwd Functions-Footnote-1668825 +Node: Group Functions668913 +Ref: Group Functions-Footnote-1676810 +Node: Walking Arrays677015 +Node: Library Functions Summary680021 +Node: Library Exercises681423 +Node: Sample Programs682703 +Node: Running Examples683473 +Node: Clones684201 +Node: Cut Program685425 +Node: Egrep Program695145 +Ref: Egrep Program-Footnote-1702648 +Node: Id Program702758 +Node: Split Program706434 +Ref: Split Program-Footnote-1709888 +Node: Tee Program710016 +Node: Uniq Program712805 +Node: Wc Program720224 +Ref: Wc Program-Footnote-1724474 +Node: Miscellaneous Programs724568 +Node: Dupword Program725781 +Node: Alarm Program727812 +Node: Translate Program732617 +Ref: Translate Program-Footnote-1737180 +Node: Labels Program737450 +Ref: Labels Program-Footnote-1740801 +Node: Word Sorting740885 +Node: History Sorting744955 +Node: Extract Program746790 +Node: Simple Sed754314 +Node: Igawk Program757384 +Ref: Igawk Program-Footnote-1771710 +Ref: Igawk Program-Footnote-2771911 +Ref: Igawk Program-Footnote-3772033 +Node: Anagram Program772148 +Node: Signature Program775209 +Node: Programs Summary776456 +Node: Programs Exercises777677 +Ref: Programs Exercises-Footnote-1781808 +Node: Advanced Features781899 +Node: Nondecimal Data783881 +Node: Array Sorting785471 +Node: Controlling Array Traversal786171 +Ref: Controlling Array Traversal-Footnote-1794537 +Node: Array Sorting Functions794655 +Ref: Array Sorting Functions-Footnote-1798541 +Node: Two-way I/O798737 +Ref: Two-way I/O-Footnote-1803682 +Ref: Two-way I/O-Footnote-2803868 +Node: TCP/IP Networking803950 +Node: Profiling806822 +Node: Advanced Features Summary815093 +Node: Internationalization817026 +Node: I18N and L10N818506 +Node: Explaining gettext819192 +Ref: Explaining gettext-Footnote-1824217 +Ref: Explaining gettext-Footnote-2824401 +Node: Programmer i18n824566 +Ref: Programmer i18n-Footnote-1829442 +Node: Translator i18n829491 +Node: String Extraction830285 +Ref: String Extraction-Footnote-1831416 +Node: Printf Ordering831502 +Ref: Printf Ordering-Footnote-1834288 +Node: I18N Portability834352 +Ref: I18N Portability-Footnote-1836808 +Node: I18N Example836871 +Ref: I18N Example-Footnote-1839674 +Node: Gawk I18N839746 +Node: I18N Summary840390 +Node: Debugger841730 +Node: Debugging842752 +Node: Debugging Concepts843193 +Node: Debugging Terms845003 +Node: Awk Debugging847575 +Node: Sample Debugging Session848481 +Node: Debugger Invocation849015 +Node: Finding The Bug850400 +Node: List of Debugger Commands856879 +Node: Breakpoint Control858211 +Node: Debugger Execution Control861888 +Node: Viewing And Changing Data865247 +Node: Execution Stack868623 +Node: Debugger Info870258 +Node: Miscellaneous Debugger Commands874303 +Node: Readline Support879304 +Node: Limitations880198 +Node: Debugging Summary882313 +Node: Arbitrary Precision Arithmetic883487 +Node: Computer Arithmetic884903 +Ref: table-numeric-ranges888480 +Ref: Computer Arithmetic-Footnote-1889004 +Node: Math Definitions889061 +Ref: table-ieee-formats892356 +Ref: Math Definitions-Footnote-1892960 +Node: MPFR features893065 +Node: FP Math Caution894736 +Ref: FP Math Caution-Footnote-1895786 +Node: Inexactness of computations896155 +Node: Inexact representation897114 +Node: Comparing FP Values898472 +Node: Errors accumulate899554 +Node: Getting Accuracy900986 +Node: Try To Round903690 +Node: Setting precision904589 +Ref: table-predefined-precision-strings905273 +Node: Setting the rounding mode907102 +Ref: table-gawk-rounding-modes907466 +Ref: Setting the rounding mode-Footnote-1910918 +Node: Arbitrary Precision Integers911097 +Ref: Arbitrary Precision Integers-Footnote-1916013 +Node: POSIX Floating Point Problems916162 +Ref: POSIX Floating Point Problems-Footnote-1920041 +Node: Floating point summary920079 +Node: Dynamic Extensions922266 +Node: Extension Intro923818 +Node: Plugin License925083 +Node: Extension Mechanism Outline925880 +Ref: figure-load-extension926308 +Ref: figure-register-new-function927788 +Ref: figure-call-new-function928792 +Node: Extension API Description930779 +Node: Extension API Functions Introduction932313 +Node: General Data Types937182 +Ref: General Data Types-Footnote-1943082 +Node: Memory Allocation Functions943381 +Ref: Memory Allocation Functions-Footnote-1946220 +Node: Constructor Functions946319 +Node: Registration Functions948058 +Node: Extension Functions948743 +Node: Exit Callback Functions951040 +Node: Extension Version String952288 +Node: Input Parsers952951 +Node: Output Wrappers962826 +Node: Two-way processors967339 +Node: Printing Messages969602 +Ref: Printing Messages-Footnote-1970678 +Node: Updating `ERRNO'970830 +Node: Requesting Values971570 +Ref: table-value-types-returned972297 +Node: Accessing Parameters973254 +Node: Symbol Table Access974488 +Node: Symbol table by name975002 +Node: Symbol table by cookie977022 +Ref: Symbol table by cookie-Footnote-1981167 +Node: Cached values981230 +Ref: Cached values-Footnote-1984726 +Node: Array Manipulation984817 +Ref: Array Manipulation-Footnote-1985907 +Node: Array Data Types985944 +Ref: Array Data Types-Footnote-1988599 +Node: Array Functions988691 +Node: Flattening Arrays992550 +Node: Creating Arrays999452 +Node: Redirection API1004223 +Node: Extension API Variables1007048 +Node: Extension Versioning1007681 +Node: Extension API Informational Variables1009572 +Node: Extension API Boilerplate1010637 +Node: Finding Extensions1014446 +Node: Extension Example1015006 +Node: Internal File Description1015778 +Node: Internal File Ops1019845 +Ref: Internal File Ops-Footnote-11031596 +Node: Using Internal File Ops1031736 +Ref: Using Internal File Ops-Footnote-11034119 +Node: Extension Samples1034392 +Node: Extension Sample File Functions1035920 +Node: Extension Sample Fnmatch1043601 +Node: Extension Sample Fork1045089 +Node: Extension Sample Inplace1046304 +Node: Extension Sample Ord1048390 +Node: Extension Sample Readdir1049226 +Ref: table-readdir-file-types1050103 +Node: Extension Sample Revout1050914 +Node: Extension Sample Rev2way1051503 +Node: Extension Sample Read write array1052243 +Node: Extension Sample Readfile1054183 +Node: Extension Sample Time1055278 +Node: Extension Sample API Tests1056626 +Node: gawkextlib1057117 +Node: Extension summary1059818 +Node: Extension Exercises1063507 +Node: Language History1065003 +Node: V7/SVR3.11066659 +Node: SVR41068812 +Node: POSIX1070246 +Node: BTL1071627 +Node: POSIX/GNU1072358 +Node: Feature History1078197 +Node: Common Extensions1091994 +Node: Ranges and Locales1093366 +Ref: Ranges and Locales-Footnote-11097985 +Ref: Ranges and Locales-Footnote-21098012 +Ref: Ranges and Locales-Footnote-31098247 +Node: Contributors1098468 +Node: History summary1104008 +Node: Installation1105387 +Node: Gawk Distribution1106333 +Node: Getting1106817 +Node: Extracting1107640 +Node: Distribution contents1109277 +Node: Unix Installation1115379 +Node: Quick Installation1116062 +Node: Shell Startup Files1118473 +Node: Additional Configuration Options1119552 +Node: Configuration Philosophy1121356 +Node: Non-Unix Installation1123725 +Node: PC Installation1124183 +Node: PC Binary Installation1125503 +Node: PC Compiling1127351 +Ref: PC Compiling-Footnote-11130372 +Node: PC Testing1130481 +Node: PC Using1131657 +Node: Cygwin1135772 +Node: MSYS1136542 +Node: VMS Installation1137043 +Node: VMS Compilation1137835 +Ref: VMS Compilation-Footnote-11139064 +Node: VMS Dynamic Extensions1139122 +Node: VMS Installation Details1140806 +Node: VMS Running1143057 +Node: VMS GNV1145897 +Node: VMS Old Gawk1146632 +Node: Bugs1147102 +Node: Other Versions1150991 +Node: Installation summary1157425 +Node: Notes1158484 +Node: Compatibility Mode1159349 +Node: Additions1160131 +Node: Accessing The Source1161056 +Node: Adding Code1162491 +Node: New Ports1168648 +Node: Derived Files1173130 +Ref: Derived Files-Footnote-11178605 +Ref: Derived Files-Footnote-21178639 +Ref: Derived Files-Footnote-31179235 +Node: Future Extensions1179349 +Node: Implementation Limitations1179955 +Node: Extension Design1181203 +Node: Old Extension Problems1182357 +Ref: Old Extension Problems-Footnote-11183874 +Node: Extension New Mechanism Goals1183931 +Ref: Extension New Mechanism Goals-Footnote-11187291 +Node: Extension Other Design Decisions1187480 +Node: Extension Future Growth1189588 +Node: Old Extension Mechanism1190424 +Node: Notes summary1192186 +Node: Basic Concepts1193372 +Node: Basic High Level1194053 +Ref: figure-general-flow1194325 +Ref: figure-process-flow1194924 +Ref: Basic High Level-Footnote-11198153 +Node: Basic Data Typing1198338 +Node: Glossary1201666 +Node: Copying1233595 +Node: GNU Free Documentation License1271151 +Node: Index1296287 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index e9d987f0..ca378cca 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -8807,6 +8807,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1 @end example When this element exists, @command{gawk} checks the value of the system +(C language) @code{errno} variable when an I/O error occurs. If @code{errno} indicates a subsequent I/O attempt may succeed, @code{getline} instead returns @minus{}2 and @@ -17088,23 +17089,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of @cindex cosine Return the cosine of @var{x}, with @var{x} in radians. -@item @code{div(@var{numerator}, @var{denominator}, @var{result})} -@cindexawkfunc{div} -@cindex div -Perform integer division, similar to the standard C function of the -same name. First, truncate @code{numerator} and @code{denominator} -towards zero, creating integer values. Clear the @code{result} -array, and then set @code{result["quotient"]} to the result of -@samp{numerator / denominator}, truncated towards zero to an integer, -and set @code{result["remainder"]} to the result of @samp{numerator % -denominator}, truncated towards zero to an integer. This function is -primarily intended for use with arbitrary length integers; it avoids -creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary -Precision Integers}). - -This function is a @code{gawk} extension. It is not available in -compatibility mode (@pxref{Options}). - @item @code{exp(@var{x})} @cindexawkfunc{exp} @cindex exponent @@ -17120,6 +17104,23 @@ truncated toward zero. For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} is @minus{}3, and @code{int(-3)} is @minus{}3 as well. +@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})} +@cindexawkfunc{intdiv} +@cindex intdiv +Perform integer division, similar to the standard C function of the +same name. First, truncate @code{numerator} and @code{denominator} +towards zero, creating integer values. Clear the @code{result} +array, and then set @code{result["quotient"]} to the result of +@samp{numerator / denominator}, truncated towards zero to an integer, +and set @code{result["remainder"]} to the result of @samp{numerator % +denominator}, truncated towards zero to an integer. This function is +primarily intended for use with arbitrary length integers; it avoids +creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary +Precision Integers}). + +This function is a @code{gawk} extension. It is not available in +compatibility mode (@pxref{Options}). + @item @code{log(@var{x})} @cindexawkfunc{log} @cindex logarithm @@ -17152,8 +17153,8 @@ function randint(n) @end example @noindent -The multiplication produces a random number greater than zero and less -than @code{n}. Using @code{int()}, this result is made into +The multiplication produces a random number greater than or equal to +zero and less than @code{n}. Using @code{int()}, this result is made into an integer between zero and @code{n} @minus{} 1, inclusive. The following example uses a similar function to produce random integers @@ -20505,10 +20506,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: @@ -31100,27 +31114,30 @@ When dividing two arbitrary precision integers with either precision floating point value (unless the denominator evenly divides into the numerator). In order to do integer division or remainder with arbitrary precision integers, use the built-in -@code{div()} function (@pxref{Numeric Functions}). +@code{intdiv()} function (@pxref{Numeric Functions}). -You can simulate the @code{div()} function in standard @command{awk} +You can simulate the @code{intdiv()} function in standard @command{awk} using this user-defined function: @example -@c file eg/lib/div.awk -# div --- do integer division +@c file eg/lib/intdiv.awk +# intdiv --- do integer division @c endfile @ignore -@c file eg/lib/div.awk +@c file eg/lib/intdiv.awk # # Arnold Robbins, arnold@@skeeve.com, Public Domain # July, 2014 +# +# Name changed from div() to intdiv() +# April, 2015 @c endfile @end ignore -@c file eg/lib/div.awk -function div(numerator, denominator, result) +@c file eg/lib/intdiv.awk +function intdiv(numerator, denominator, result) @{ split("", result) @@ -31135,7 +31152,7 @@ function div(numerator, denominator, result) @end example The following example program, contributed by Katie Wasserman, -uses @code{div()} to +uses @code{intdiv()} to compute the digits of @value{PI} to as many places as you choose to set: @@ -31160,7 +31177,7 @@ BEGIN @{ for (m = digits * 4; m > 0; --m) @{ d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two @} @@ -35285,18 +35302,21 @@ As of this writing, there are seven extensions: GD graphics library extension @item +MPFR library extension +(this provides access to a number of MPFR functions that @command{gawk}'s +native MPFR support does not) + +@item PDF extension @item PostgreSQL extension @item -MPFR library extension -(this provides access to a number of MPFR functions that @command{gawk}'s -native MPFR support does not) +Redis extension @item -Redis extension +Select extension @item XML parser extension, using the @uref{http://expat.sourceforge.net, Expat} @@ -36026,7 +36046,7 @@ functions for internationalization (@pxref{Programmer i18n}) @item -The @code{div()} function for doing integer +The @code{intdiv()} function for doing integer division and remainder (@pxref{Numeric Functions}) @end itemize @@ -36807,7 +36827,7 @@ installed when @command{gawk} is built. @xref{Igawk Program}. @item -The @code{div()} function. +The @code{intdiv()} function. @xref{Numeric Functions}. @item diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 178444a4..4cd04763 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -8407,6 +8407,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1 @end example When this element exists, @command{gawk} checks the value of the system +(C language) @code{errno} variable when an I/O error occurs. If @code{errno} indicates a subsequent I/O attempt may succeed, @code{getline} instead returns @minus{}2 and @@ -16370,23 +16371,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of @cindex cosine Return the cosine of @var{x}, with @var{x} in radians. -@item @code{div(@var{numerator}, @var{denominator}, @var{result})} -@cindexawkfunc{div} -@cindex div -Perform integer division, similar to the standard C function of the -same name. First, truncate @code{numerator} and @code{denominator} -towards zero, creating integer values. Clear the @code{result} -array, and then set @code{result["quotient"]} to the result of -@samp{numerator / denominator}, truncated towards zero to an integer, -and set @code{result["remainder"]} to the result of @samp{numerator % -denominator}, truncated towards zero to an integer. This function is -primarily intended for use with arbitrary length integers; it avoids -creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary -Precision Integers}). - -This function is a @code{gawk} extension. It is not available in -compatibility mode (@pxref{Options}). - @item @code{exp(@var{x})} @cindexawkfunc{exp} @cindex exponent @@ -16402,6 +16386,23 @@ truncated toward zero. For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} is @minus{}3, and @code{int(-3)} is @minus{}3 as well. +@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})} +@cindexawkfunc{intdiv} +@cindex intdiv +Perform integer division, similar to the standard C function of the +same name. First, truncate @code{numerator} and @code{denominator} +towards zero, creating integer values. Clear the @code{result} +array, and then set @code{result["quotient"]} to the result of +@samp{numerator / denominator}, truncated towards zero to an integer, +and set @code{result["remainder"]} to the result of @samp{numerator % +denominator}, truncated towards zero to an integer. This function is +primarily intended for use with arbitrary length integers; it avoids +creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary +Precision Integers}). + +This function is a @code{gawk} extension. It is not available in +compatibility mode (@pxref{Options}). + @item @code{log(@var{x})} @cindexawkfunc{log} @cindex logarithm @@ -16434,8 +16435,8 @@ function randint(n) @end example @noindent -The multiplication produces a random number greater than zero and less -than @code{n}. Using @code{int()}, this result is made into +The multiplication produces a random number greater than or equal to +zero and less than @code{n}. Using @code{int()}, this result is made into an integer between zero and @code{n} @minus{} 1, inclusive. The following example uses a similar function to produce random integers @@ -19626,10 +19627,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: @@ -30191,27 +30205,30 @@ When dividing two arbitrary precision integers with either precision floating point value (unless the denominator evenly divides into the numerator). In order to do integer division or remainder with arbitrary precision integers, use the built-in -@code{div()} function (@pxref{Numeric Functions}). +@code{intdiv()} function (@pxref{Numeric Functions}). -You can simulate the @code{div()} function in standard @command{awk} +You can simulate the @code{intdiv()} function in standard @command{awk} using this user-defined function: @example -@c file eg/lib/div.awk -# div --- do integer division +@c file eg/lib/intdiv.awk +# intdiv --- do integer division @c endfile @ignore -@c file eg/lib/div.awk +@c file eg/lib/intdiv.awk # # Arnold Robbins, arnold@@skeeve.com, Public Domain # July, 2014 +# +# Name changed from div() to intdiv() +# April, 2015 @c endfile @end ignore -@c file eg/lib/div.awk -function div(numerator, denominator, result) +@c file eg/lib/intdiv.awk +function intdiv(numerator, denominator, result) @{ split("", result) @@ -30226,7 +30243,7 @@ function div(numerator, denominator, result) @end example The following example program, contributed by Katie Wasserman, -uses @code{div()} to +uses @code{intdiv()} to compute the digits of @value{PI} to as many places as you choose to set: @@ -30251,7 +30268,7 @@ BEGIN @{ for (m = digits * 4; m > 0; --m) @{ d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two @} @@ -34376,18 +34393,21 @@ As of this writing, there are seven extensions: GD graphics library extension @item +MPFR library extension +(this provides access to a number of MPFR functions that @command{gawk}'s +native MPFR support does not) + +@item PDF extension @item PostgreSQL extension @item -MPFR library extension -(this provides access to a number of MPFR functions that @command{gawk}'s -native MPFR support does not) +Redis extension @item -Redis extension +Select extension @item XML parser extension, using the @uref{http://expat.sourceforge.net, Expat} @@ -35117,7 +35137,7 @@ functions for internationalization (@pxref{Programmer i18n}) @item -The @code{div()} function for doing integer +The @code{intdiv()} function for doing integer division and remainder (@pxref{Numeric Functions}) @end itemize @@ -35898,7 +35918,7 @@ installed when @command{gawk} is built. @xref{Igawk Program}. @item -The @code{div()} function. +The @code{intdiv()} function. @xref{Numeric Functions}. @item |