diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2017-08-13 21:20:52 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2017-08-13 21:20:52 +0300 |
commit | a9c174139581f6f23f17d09e2a72f77e5594e166 (patch) | |
tree | 988ae72fe3a707475d046dbc2c166ac06e25c448 /doc | |
parent | d2f829ccb51da24a52c566010fc2e8a650eed116 (diff) | |
download | egawk-a9c174139581f6f23f17d09e2a72f77e5594e166.tar.gz egawk-a9c174139581f6f23f17d09e2a72f77e5594e166.tar.bz2 egawk-a9c174139581f6f23f17d09e2a72f77e5594e166.zip |
Document MPFR/GMP additions to the extension API.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 1314 | ||||
-rw-r--r-- | doc/gawk.texi | 148 | ||||
-rw-r--r-- | doc/gawktexi.in | 148 |
4 files changed, 992 insertions, 623 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index b7d06538..971d0027 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2017-08-13 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Update API chapter with info about additions + for accessing and/or creating MPZ and MPFR values. + 2017-08-04 Arnold D. Robbins <arnold@skeeve.com> * texinfo.tex: Updated. diff --git a/doc/gawk.info b/doc/gawk.info index 2c0f9493..4faa99c6 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -573,6 +573,8 @@ in (a) below. A copy of the license is included in the section entitled redirections. * Extension API Variables:: Variables provided by the API. * Extension Versioning:: API Version information. +* Extension GMP/MPFR Versioning:: Version information about GMP and + MPFR. * Extension API Informational Variables:: Variables providing information about 'gawk''s invocation. * Extension API Boilerplate:: Boilerplate code for using the API. @@ -23689,6 +23691,10 @@ operations: order to keep 'gawkapi.h' clean, instead of becoming a portability hodge-podge as can be seen in some parts of the 'gawk' source code. + * If your extension uses MPFR facilities, and you wish to receive + such values from 'gawk' and/or pass such values to it, you must + include the '<mpfr.h>' header before including '<gawkapi.h>'. + * The 'gawkapi.h' file may be included more than once without ill effect. Doing so, however, is poor coding practice. @@ -23808,7 +23814,7 @@ use them. ' awk_valtype_t val_type;' ' union {' ' awk_string_t s;' -' double d;' +' awknum_t n;' ' awk_array_t a;' ' awk_scalar_t scl;' ' awk_value_cookie_t vc;' @@ -23821,13 +23827,36 @@ use them. '#define str_value u.s' '#define strnum_value str_value' '#define regex_value str_value' -'#define num_value u.d' +'#define num_value u.n.d' +'#define num_type u.n.type' +'#define num_ptr u.n.ptr' '#define array_cookie u.a' '#define scalar_cookie u.scl' '#define value_cookie u.vc' Using these macros makes accessing the fields of the 'awk_value_t' more readable. +'typedef struct awk_number {' +' double d;' +' enum AWK_NUMBER_TYPE {' +' AWK_NUMBER_TYPE_DOUBLE,' +' AWK_NUMBER_TYPE_MPFR,' +' AWK_NUMBER_TYPE_MPZ' +' } type;' +' void *ptr;' +'} awk_number_t;' + This represents a numeric value. Internally, 'gawk' stores every + number as either a C 'double', a GMP integer, or an MPFR + arbitrary-precision floating-point value. In order to allow + extensions to also support GMP and MPFR values, numeric values are + passed in this structure. + + The double-precision 'd' element is always populated in data + received from 'gawk'. In addition, by examining the 'type' member, + an extension can determine if the 'ptr' member is either a GMP + integer (type 'mpz_ptr'), or an MPFR floating-point value (type + 'mpfr_ptr_t'), and cast it appropriately. + 'typedef void *awk_scalar_t;' Scalars can be represented as an opaque type. These values are obtained from 'gawk' and then passed back into it. This is @@ -23991,6 +24020,28 @@ value: 'gawk_malloc()'. The arguments are the same as for the 'emalloc()' macro. + Two additional functions allocate MPFR and GMP objects for use by +extension functions that need to create and then return such values: + +'void *get_mpfr_ptr();' + Allocate and initialize an MPFR object and return a pointer to it. + If the allocation fails, 'gawk' exits with a fatal "out of memory" + error. If 'gawk' was compiled without MPFR support, calling this + function causes a fatal error. + +'void *get_mpz_ptr();' + Allocate and initialize a GMP object and return a pointer to it. + If the allocation fails, 'gawk' exits with a fatal "out of memory" + error. If 'gawk' was compiled without MPFR support, calling this + function causes a fatal error. + + Both of these functions return 'void *', since the 'gawkapi.h' header +file should not have dependency upon '<mpfr.h>' (and '<gmp.h>', which is +included from '<mpfr.h>'). The actual return values are of types +'mpfr_ptr' and 'mpz_ptr' respectively, and you should cast the return +values appropriately before assigning the results to variables of the +correct types. + ---------- Footnotes ---------- (1) This is more common on MS-Windows systems, but it can happen on @@ -24035,6 +24086,18 @@ code would use them: variable pointed to by 'result'. 'static inline awk_value_t *' +'make_number_mpz(void *mpz, awk_value_t *result);' + This function creates a GMP number value in 'result'. The 'mpz' + must be from a call to 'get_mpz_ptr()' (and thus be or real + underlying type 'mpz_ptr'). 'gawk' takes ownership of this memory. + +'static inline awk_value_t *' +'make_number_mpfr(void *mpfr, awk_value_t *result);' + This function creates an MPFR number value in 'result'. The 'mpfr' + must be from a call to 'get_mpfr_ptr()'. (and thus be or real + underlying type 'mpfr_ptr') 'gawk' takes ownership of this memory. + +'static inline awk_value_t *' 'make_const_user_input(const char *string, size_t length, awk_value_t *result);' This function is identical to 'make_const_string()', but the string is flagged as user input that should be treated as a strnum value @@ -24508,10 +24571,10 @@ structure, which looks like this: provide the information for '$1', and so on through the 'fields[nf-1]' element containing the information for '$NF'. - A convenience macro 'awk_fieldwidth_info_size(NF)' is provided to -calculate the appropriate size of a variable-length -'awk_fieldwidth_info_t' structure containing 'NF' fields. This can be -used as an argument to 'malloc()' or in a union to allocate space + A convenience macro 'awk_fieldwidth_info_size(numfields)' is provided +to calculate the appropriate size of a variable-length +'awk_fieldwidth_info_t' structure containing 'numfields' fields. This +can be used as an argument to 'malloc()' or in a union to allocate space statically. Please refer to the 'readdir_test' sample extension for an example. @@ -25047,7 +25110,8 @@ using 'release_value()'. ---------- Footnotes ---------- (1) Numeric values are clearly less problematic, requiring only a C -'double' to store. +'double' to store. But of course, GMP and MPFR values _do_ take up more +memory. File: gawk.info, Node: Array Manipulation, Next: Redirection API, Prev: Symbol Table Access, Up: Extension API Description @@ -25207,7 +25271,10 @@ The following functions relate to individual array elements: array, but after calling this function, it has no elements. This is equivalent to using the 'delete' statement (*note Delete::). -'awk_bool_t flatten_array_typed(awk_array_t a_cookie, awk_flat_array_t **data, awk_valtype_t index_type, awk_valtype_t value_type);' +'awk_bool_t flatten_array_typed(awk_array_t a_cookie,' +' awk_flat_array_t **data,' +' awk_valtype_t index_type,' +' awk_valtype_t value_type);' For the array represented by 'a_cookie', create an 'awk_flat_array_t' structure and fill it in with indices and values of the requested types. Set the pointer whose address is passed as @@ -25323,7 +25390,8 @@ count of elements in the array and print it: double-check that the count in the 'awk_flat_array_t' is the same as the count just retrieved: - if (! flatten_array_typed(value2.array_cookie, & flat_array, AWK_STRING, AWK_UNDEFINED)) { + if (! flatten_array_typed(value2.array_cookie, & flat_array, + AWK_STRING, AWK_UNDEFINED)) { printf("dump_array_and_delete: could not flatten array\n"); goto out; } @@ -25582,13 +25650,14 @@ redirections. '"|&"' A two-way coprocess. - On error, return an 'awk_false' value. Otherwise, return - 'awk_true', and return additional information about the redirection - in the 'ibufp' and 'obufp' pointers. For input redirections, the - '*ibufp' value should be non-'NULL', and '*obufp' should be 'NULL'. - For output redirections, the '*obufp' value should be non-'NULL', - and '*ibufp' should be 'NULL'. For two-way coprocesses, both - values should be non-'NULL'. + On error, return 'awk_false'. Otherwise, return 'awk_true', and + return additional information about the redirection in the 'ibufp' + and 'obufp' pointers. + + For input redirections, the '*ibufp' value should be non-'NULL', + and '*obufp' should be 'NULL'. For output redirections, the + '*obufp' value should be non-'NULL', and '*ibufp' should be 'NULL'. + For two-way coprocesses, both values should be non-'NULL'. In the usual case, the extension is interested in '(*ibufp)->fd' and/or 'fileno((*obufp)->fp)'. If the file is not already open, @@ -25624,12 +25693,13 @@ information about how 'gawk' was invoked. * Menu: -* Extension Versioning:: API Version information. +* Extension Versioning:: API Version information. +* Extension GMP/MPFR Versioning:: Version information about GMP and MPFR. * Extension API Informational Variables:: Variables providing information about - 'gawk''s invocation. + 'gawk''s invocation. -File: gawk.info, Node: Extension Versioning, Next: Extension API Informational Variables, Up: Extension API Variables +File: gawk.info, Node: Extension Versioning, Next: Extension GMP/MPFR Versioning, Up: Extension API Variables 16.4.13.1 API Version Constants and Variables ............................................. @@ -25681,9 +25751,51 @@ provided in 'gawkapi.h' (discussed in *note Extension API Boilerplate::). -File: gawk.info, Node: Extension API Informational Variables, Prev: Extension Versioning, Up: Extension API Variables +File: gawk.info, Node: Extension GMP/MPFR Versioning, Next: Extension API Informational Variables, Prev: Extension Versioning, Up: Extension API Variables + +16.4.13.2 GMP and MPFR Version Information +.......................................... + +The API also includes information about the versions of GMP and MPFR +with which the running 'gawk' was compiled (if any). They are included +in the API 'struct' as read-only constant integers: + +'api->gmp_major_version' + The major version of the GMP library used to compile 'gawk'. + +'api->gmp_minor_version' + The minor version of the GMP library used to compile 'gawk'. + +'api->mpfr_major_version' + The major version of the MPFR library used to compile 'gawk'. + +'api->mpfr_minor_version' + The minor version of the MPFR library used to compile 'gawk'. + + These fields are set to zero if 'gawk' was compiled without MPFR +support. + + You can check if the versions of MPFR and GMP that you are using +match those of 'gawk' with the following macro: + +'check_mpfr_version(extension)' + The 'extension' is the extension id passed to all the other macros + and functions defined in 'gawkapi.h'. If you have not included the + '<mpfr.h>' header file, then this macro will be defined to do + nothing. + + If you have included that file, then this macro compares the MPFR + and GMP major and minor versions against those of the library you + are compiling against. If your libraries are newer than 'gawk''s, + it produces a fatal error message. + + The 'dl_load_func()' macro (*note Extension API Boilerplate::) + calls 'check_mpfr_version()'. + + +File: gawk.info, Node: Extension API Informational Variables, Prev: Extension GMP/MPFR Versioning, Up: Extension API Variables -16.4.13.2 Informational Variables +16.4.13.3 Informational Variables ................................. The API provides access to several variables that describe whether the @@ -25807,13 +25919,16 @@ does the following: match 'gawk''s, or if the extension minor version is greater than 'gawk''s, it prints a fatal error message and exits. - 2. Load the functions defined in 'func_table'. If any of them fails + 2. Check the MPFR and GMP versions. If there is a mismatch, it prints + a fatal error message and exits. + + 3. Load the functions defined in 'func_table'. If any of them fails to load, it prints a warning message but continues on. - 3. If the 'init_func' pointer is not 'NULL', call the function it + 4. If the 'init_func' pointer is not 'NULL', call the function it points to. If it returns 'awk_false', print a warning message. - 4. If 'ext_version' is not 'NULL', register the version string with + 5. If 'ext_version' is not 'NULL', register the version string with 'gawk'. @@ -35682,580 +35797,581 @@ Index Tag Table: Node: Top1200 -Node: Foreword343279 -Node: Foreword447721 -Node: Preface49253 -Ref: Preface-Footnote-152112 -Ref: Preface-Footnote-252219 -Ref: Preface-Footnote-352453 -Node: History52595 -Node: Names54947 -Ref: Names-Footnote-156041 -Node: This Manual56188 -Ref: This Manual-Footnote-162673 -Node: Conventions62773 -Node: Manual History65127 -Ref: Manual History-Footnote-168122 -Ref: Manual History-Footnote-268163 -Node: How To Contribute68237 -Node: Acknowledgments68888 -Node: Getting Started73774 -Node: Running gawk76213 -Node: One-shot77403 -Node: Read Terminal78666 -Node: Long80659 -Node: Executable Scripts82172 -Ref: Executable Scripts-Footnote-184967 -Node: Comments85070 -Node: Quoting87554 -Node: DOS Quoting93071 -Node: Sample Data Files95127 -Node: Very Simple97722 -Node: Two Rules102624 -Node: More Complex104509 -Node: Statements/Lines107375 -Ref: Statements/Lines-Footnote-1111834 -Node: Other Features112099 -Node: When113035 -Ref: When-Footnote-1114789 -Node: Intro Summary114854 -Node: Invoking Gawk115738 -Node: Command Line117252 -Node: Options118050 -Ref: Options-Footnote-1134669 -Ref: Options-Footnote-2134899 -Node: Other Arguments134924 -Node: Naming Standard Input137871 -Node: Environment Variables138964 -Node: AWKPATH Variable139522 -Ref: AWKPATH Variable-Footnote-1142933 -Ref: AWKPATH Variable-Footnote-2142967 -Node: AWKLIBPATH Variable143228 -Node: Other Environment Variables144485 -Node: Exit Status148306 -Node: Include Files148983 -Node: Loading Shared Libraries152578 -Node: Obsolete154006 -Node: Undocumented154698 -Node: Invoking Summary154995 -Node: Regexp156655 -Node: Regexp Usage158109 -Node: Escape Sequences160146 -Node: Regexp Operators166378 -Ref: Regexp Operators-Footnote-1173794 -Ref: Regexp Operators-Footnote-2173941 -Node: Bracket Expressions174039 -Ref: table-char-classes176515 -Node: Leftmost Longest179652 -Node: Computed Regexps180955 -Node: GNU Regexp Operators184382 -Node: Case-sensitivity188061 -Ref: Case-sensitivity-Footnote-1190948 -Ref: Case-sensitivity-Footnote-2191183 -Node: Regexp Summary191291 -Node: Reading Files192757 -Node: Records195026 -Node: awk split records195759 -Node: gawk split records200690 -Ref: gawk split records-Footnote-1205230 -Node: Fields205267 -Node: Nonconstant Fields208008 -Ref: Nonconstant Fields-Footnote-1210244 -Node: Changing Fields210448 -Node: Field Separators216376 -Node: Default Field Splitting219074 -Node: Regexp Field Splitting220192 -Node: Single Character Fields223545 -Node: Command Line Field Separator224605 -Node: Full Line Fields227823 -Ref: Full Line Fields-Footnote-1229345 -Ref: Full Line Fields-Footnote-2229391 -Node: Field Splitting Summary229492 -Node: Constant Size231566 -Node: Fixed width data232298 -Node: Skipping intervening235765 -Node: Allowing trailing data236563 -Node: Fields with fixed data237600 -Node: Splitting By Content239118 -Ref: Splitting By Content-Footnote-1242768 -Node: Testing field creation242931 -Node: Multiple Line244552 -Ref: Multiple Line-Footnote-1250436 -Node: Getline250615 -Node: Plain Getline253084 -Node: Getline/Variable255725 -Node: Getline/File256876 -Node: Getline/Variable/File258264 -Ref: Getline/Variable/File-Footnote-1259869 -Node: Getline/Pipe259957 -Node: Getline/Variable/Pipe262664 -Node: Getline/Coprocess263799 -Node: Getline/Variable/Coprocess265066 -Node: Getline Notes265808 -Node: Getline Summary268605 -Ref: table-getline-variants269029 -Node: Read Timeout269777 -Ref: Read Timeout-Footnote-1273683 -Node: Retrying Input273741 -Node: Command-line directories274940 -Node: Input Summary275846 -Node: Input Exercises279018 -Node: Printing279746 -Node: Print281580 -Node: Print Examples283037 -Node: Output Separators285817 -Node: OFMT287834 -Node: Printf289190 -Node: Basic Printf289975 -Node: Control Letters291549 -Node: Format Modifiers295537 -Node: Printf Examples301552 -Node: Redirection304038 -Node: Special FD310879 -Ref: Special FD-Footnote-1314047 -Node: Special Files314121 -Node: Other Inherited Files314738 -Node: Special Network315739 -Node: Special Caveats316599 -Node: Close Files And Pipes317548 -Ref: table-close-pipe-return-values324455 -Ref: Close Files And Pipes-Footnote-1325238 -Ref: Close Files And Pipes-Footnote-2325386 -Node: Nonfatal325538 -Node: Output Summary327863 -Node: Output Exercises329085 -Node: Expressions329764 -Node: Values330952 -Node: Constants331630 -Node: Scalar Constants332321 -Ref: Scalar Constants-Footnote-1333185 -Node: Nondecimal-numbers333435 -Node: Regexp Constants336436 -Node: Using Constant Regexps336962 -Node: Standard Regexp Constants337584 -Node: Strong Regexp Constants340772 -Node: Variables343730 -Node: Using Variables344387 -Node: Assignment Options346297 -Node: Conversion348170 -Node: Strings And Numbers348694 -Ref: Strings And Numbers-Footnote-1351757 -Node: Locale influences conversions351866 -Ref: table-locale-affects354624 -Node: All Operators355242 -Node: Arithmetic Ops355871 -Node: Concatenation358377 -Ref: Concatenation-Footnote-1361224 -Node: Assignment Ops361331 -Ref: table-assign-ops366322 -Node: Increment Ops367635 -Node: Truth Values and Conditions371095 -Node: Truth Values372169 -Node: Typing and Comparison373217 -Node: Variable Typing374037 -Ref: Variable Typing-Footnote-1380500 -Ref: Variable Typing-Footnote-2380572 -Node: Comparison Operators380649 -Ref: table-relational-ops381068 -Node: POSIX String Comparison384563 -Ref: POSIX String Comparison-Footnote-1386258 -Ref: POSIX String Comparison-Footnote-2386397 -Node: Boolean Ops386481 -Ref: Boolean Ops-Footnote-1390963 -Node: Conditional Exp391055 -Node: Function Calls392791 -Node: Precedence396668 -Node: Locales400327 -Node: Expressions Summary401959 -Node: Patterns and Actions404532 -Node: Pattern Overview405652 -Node: Regexp Patterns407329 -Node: Expression Patterns407871 -Node: Ranges411652 -Node: BEGIN/END414760 -Node: Using BEGIN/END415521 -Ref: Using BEGIN/END-Footnote-1418257 -Node: I/O And BEGIN/END418363 -Node: BEGINFILE/ENDFILE420677 -Node: Empty423584 -Node: Using Shell Variables423901 -Node: Action Overview426175 -Node: Statements428500 -Node: If Statement430348 -Node: While Statement431843 -Node: Do Statement433871 -Node: For Statement435019 -Node: Switch Statement438177 -Node: Break Statement440563 -Node: Continue Statement442655 -Node: Next Statement444482 -Node: Nextfile Statement446865 -Node: Exit Statement449517 -Node: Built-in Variables451920 -Node: User-modified453053 -Node: Auto-set460820 -Ref: Auto-set-Footnote-1476417 -Ref: Auto-set-Footnote-2476623 -Node: ARGC and ARGV476679 -Node: Pattern Action Summary480892 -Node: Arrays483322 -Node: Array Basics484651 -Node: Array Intro485495 -Ref: figure-array-elements487470 -Ref: Array Intro-Footnote-1490174 -Node: Reference to Elements490302 -Node: Assigning Elements492766 -Node: Array Example493257 -Node: Scanning an Array495016 -Node: Controlling Scanning498038 -Ref: Controlling Scanning-Footnote-1503437 -Node: Numeric Array Subscripts503753 -Node: Uninitialized Subscripts505937 -Node: Delete507556 -Ref: Delete-Footnote-1510308 -Node: Multidimensional510365 -Node: Multiscanning513460 -Node: Arrays of Arrays515051 -Node: Arrays Summary519818 -Node: Functions521911 -Node: Built-in522949 -Node: Calling Built-in524030 -Node: Numeric Functions526026 -Ref: Numeric Functions-Footnote-1530054 -Ref: Numeric Functions-Footnote-2530411 -Ref: Numeric Functions-Footnote-3530459 -Node: String Functions530731 -Ref: String Functions-Footnote-1554389 -Ref: String Functions-Footnote-2554517 -Ref: String Functions-Footnote-3554765 -Node: Gory Details554852 -Ref: table-sub-escapes556643 -Ref: table-sub-proposed558162 -Ref: table-posix-sub559525 -Ref: table-gensub-escapes561066 -Ref: Gory Details-Footnote-1561889 -Node: I/O Functions562043 -Ref: table-system-return-values568625 -Ref: I/O Functions-Footnote-1570605 -Ref: I/O Functions-Footnote-2570753 -Node: Time Functions570873 -Ref: Time Functions-Footnote-1581540 -Ref: Time Functions-Footnote-2581608 -Ref: Time Functions-Footnote-3581766 -Ref: Time Functions-Footnote-4581877 -Ref: Time Functions-Footnote-5581989 -Ref: Time Functions-Footnote-6582216 -Node: Bitwise Functions582482 -Ref: table-bitwise-ops583076 -Ref: Bitwise Functions-Footnote-1589109 -Ref: Bitwise Functions-Footnote-2589282 -Node: Type Functions589473 -Node: I18N Functions592390 -Node: User-defined594041 -Node: Definition Syntax594846 -Ref: Definition Syntax-Footnote-1600533 -Node: Function Example600604 -Ref: Function Example-Footnote-1603526 -Node: Function Caveats603548 -Node: Calling A Function604066 -Node: Variable Scope605024 -Node: Pass By Value/Reference608018 -Node: Return Statement611517 -Node: Dynamic Typing614496 -Node: Indirect Calls615426 -Ref: Indirect Calls-Footnote-1625677 -Node: Functions Summary625805 -Node: Library Functions628510 -Ref: Library Functions-Footnote-1632117 -Ref: Library Functions-Footnote-2632260 -Node: Library Names632431 -Ref: Library Names-Footnote-1635891 -Ref: Library Names-Footnote-2636114 -Node: General Functions636200 -Node: Strtonum Function637303 -Node: Assert Function640325 -Node: Round Function643651 -Node: Cliff Random Function645192 -Node: Ordinal Functions646208 -Ref: Ordinal Functions-Footnote-1649271 -Ref: Ordinal Functions-Footnote-2649523 -Node: Join Function649733 -Ref: Join Function-Footnote-1651503 -Node: Getlocaltime Function651703 -Node: Readfile Function655445 -Node: Shell Quoting657417 -Node: Data File Management658818 -Node: Filetrans Function659450 -Node: Rewind Function663546 -Node: File Checking665456 -Ref: File Checking-Footnote-1666790 -Node: Empty Files666991 -Node: Ignoring Assigns668970 -Node: Getopt Function670520 -Ref: Getopt Function-Footnote-1681989 -Node: Passwd Functions682189 -Ref: Passwd Functions-Footnote-1691028 -Node: Group Functions691116 -Ref: Group Functions-Footnote-1699014 -Node: Walking Arrays699221 -Node: Library Functions Summary702229 -Node: Library Exercises703635 -Node: Sample Programs704100 -Node: Running Examples704870 -Node: Clones705598 -Node: Cut Program706822 -Node: Egrep Program716751 -Ref: Egrep Program-Footnote-1724263 -Node: Id Program724373 -Node: Split Program728053 -Ref: Split Program-Footnote-1731512 -Node: Tee Program731641 -Node: Uniq Program734431 -Node: Wc Program741857 -Ref: Wc Program-Footnote-1746112 -Node: Miscellaneous Programs746206 -Node: Dupword Program747419 -Node: Alarm Program749449 -Node: Translate Program754304 -Ref: Translate Program-Footnote-1758869 -Node: Labels Program759139 -Ref: Labels Program-Footnote-1762490 -Node: Word Sorting762574 -Node: History Sorting766646 -Node: Extract Program768481 -Node: Simple Sed776010 -Node: Igawk Program779084 -Ref: Igawk Program-Footnote-1793415 -Ref: Igawk Program-Footnote-2793617 -Ref: Igawk Program-Footnote-3793739 -Node: Anagram Program793854 -Node: Signature Program796916 -Node: Programs Summary798163 -Node: Programs Exercises799377 -Ref: Programs Exercises-Footnote-1803506 -Node: Advanced Features803597 -Node: Nondecimal Data805587 -Node: Array Sorting807178 -Node: Controlling Array Traversal807878 -Ref: Controlling Array Traversal-Footnote-1816245 -Node: Array Sorting Functions816363 -Ref: Array Sorting Functions-Footnote-1821454 -Node: Two-way I/O821650 -Ref: Two-way I/O-Footnote-1828201 -Ref: Two-way I/O-Footnote-2828388 -Node: TCP/IP Networking828470 -Node: Profiling831588 -Ref: Profiling-Footnote-1840260 -Node: Advanced Features Summary840583 -Node: Internationalization842427 -Node: I18N and L10N843907 -Node: Explaining gettext844594 -Ref: Explaining gettext-Footnote-1850486 -Ref: Explaining gettext-Footnote-2850671 -Node: Programmer i18n850836 -Ref: Programmer i18n-Footnote-1855785 -Node: Translator i18n855834 -Node: String Extraction856628 -Ref: String Extraction-Footnote-1857760 -Node: Printf Ordering857846 -Ref: Printf Ordering-Footnote-1860632 -Node: I18N Portability860696 -Ref: I18N Portability-Footnote-1863152 -Node: I18N Example863215 -Ref: I18N Example-Footnote-1866021 -Node: Gawk I18N866094 -Node: I18N Summary866739 -Node: Debugger868080 -Node: Debugging869102 -Node: Debugging Concepts869543 -Node: Debugging Terms871352 -Node: Awk Debugging873927 -Node: Sample Debugging Session874833 -Node: Debugger Invocation875367 -Node: Finding The Bug876753 -Node: List of Debugger Commands883231 -Node: Breakpoint Control884564 -Node: Debugger Execution Control888258 -Node: Viewing And Changing Data891620 -Node: Execution Stack894994 -Node: Debugger Info896631 -Node: Miscellaneous Debugger Commands900702 -Node: Readline Support905790 -Node: Limitations906686 -Node: Debugging Summary908795 -Node: Arbitrary Precision Arithmetic910074 -Node: Computer Arithmetic911559 -Ref: table-numeric-ranges915150 -Ref: Computer Arithmetic-Footnote-1915872 -Node: Math Definitions915929 -Ref: table-ieee-formats919243 -Ref: Math Definitions-Footnote-1919846 -Node: MPFR features919951 -Node: FP Math Caution921668 -Ref: FP Math Caution-Footnote-1922740 -Node: Inexactness of computations923109 -Node: Inexact representation924069 -Node: Comparing FP Values925429 -Node: Errors accumulate926511 -Node: Getting Accuracy927944 -Node: Try To Round930654 -Node: Setting precision931553 -Ref: table-predefined-precision-strings932250 -Node: Setting the rounding mode934080 -Ref: table-gawk-rounding-modes934454 -Ref: Setting the rounding mode-Footnote-1937862 -Node: Arbitrary Precision Integers938041 -Ref: Arbitrary Precision Integers-Footnote-1941216 -Node: Checking for MPFR941365 -Node: POSIX Floating Point Problems942662 -Ref: POSIX Floating Point Problems-Footnote-1946533 -Node: Floating point summary946571 -Node: Dynamic Extensions948761 -Node: Extension Intro950314 -Node: Plugin License951580 -Node: Extension Mechanism Outline952377 -Ref: figure-load-extension952816 -Ref: figure-register-new-function954381 -Ref: figure-call-new-function955473 -Node: Extension API Description957535 -Node: Extension API Functions Introduction959177 -Node: General Data Types964511 -Ref: General Data Types-Footnote-1971716 -Node: Memory Allocation Functions972015 -Ref: Memory Allocation Functions-Footnote-1975167 -Node: Constructor Functions975266 -Node: Registration Functions978265 -Node: Extension Functions978950 -Node: Exit Callback Functions984163 -Node: Extension Version String985413 -Node: Input Parsers986076 -Node: Output Wrappers998783 -Node: Two-way processors1003295 -Node: Printing Messages1005560 -Ref: Printing Messages-Footnote-11006731 -Node: Updating ERRNO1006884 -Node: Requesting Values1007623 -Ref: table-value-types-returned1008360 -Node: Accessing Parameters1009296 -Node: Symbol Table Access1010531 -Node: Symbol table by name1011043 -Node: Symbol table by cookie1012832 -Ref: Symbol table by cookie-Footnote-11017017 -Node: Cached values1017081 -Ref: Cached values-Footnote-11020617 -Node: Array Manipulation1020708 -Ref: Array Manipulation-Footnote-11021799 -Node: Array Data Types1021836 -Ref: Array Data Types-Footnote-11024494 -Node: Array Functions1024586 -Node: Flattening Arrays1028985 -Node: Creating Arrays1035926 -Node: Redirection API1040695 -Node: Extension API Variables1043537 -Node: Extension Versioning1044170 -Ref: gawk-api-version1044607 -Node: Extension API Informational Variables1046335 -Node: Extension API Boilerplate1047399 -Node: Changes from API V11051261 -Node: Finding Extensions1051921 -Node: Extension Example1052480 -Node: Internal File Description1053278 -Node: Internal File Ops1057358 -Ref: Internal File Ops-Footnote-11068758 -Node: Using Internal File Ops1068898 -Ref: Using Internal File Ops-Footnote-11071281 -Node: Extension Samples1071555 -Node: Extension Sample File Functions1073084 -Node: Extension Sample Fnmatch1080733 -Node: Extension Sample Fork1082220 -Node: Extension Sample Inplace1083438 -Node: Extension Sample Ord1086655 -Node: Extension Sample Readdir1087491 -Ref: table-readdir-file-types1088380 -Node: Extension Sample Revout1089185 -Node: Extension Sample Rev2way1089774 -Node: Extension Sample Read write array1090514 -Node: Extension Sample Readfile1092456 -Node: Extension Sample Time1093551 -Node: Extension Sample API Tests1094899 -Node: gawkextlib1095391 -Node: Extension summary1097838 -Node: Extension Exercises1101540 -Node: Language History1103038 -Node: V7/SVR3.11104694 -Node: SVR41106846 -Node: POSIX1108280 -Node: BTL1109659 -Node: POSIX/GNU1110388 -Node: Feature History1116166 -Node: Common Extensions1130531 -Node: Ranges and Locales1131814 -Ref: Ranges and Locales-Footnote-11136430 -Ref: Ranges and Locales-Footnote-21136457 -Ref: Ranges and Locales-Footnote-31136692 -Node: Contributors1136913 -Node: History summary1142541 -Node: Installation1143921 -Node: Gawk Distribution1144865 -Node: Getting1145349 -Node: Extracting1146310 -Node: Distribution contents1147948 -Node: Unix Installation1154290 -Node: Quick Installation1154972 -Node: Shell Startup Files1157386 -Node: Additional Configuration Options1158475 -Node: Configuration Philosophy1160464 -Node: Non-Unix Installation1162833 -Node: PC Installation1163293 -Node: PC Binary Installation1164131 -Node: PC Compiling1164566 -Node: PC Using1165683 -Node: Cygwin1168728 -Node: MSYS1169498 -Node: VMS Installation1169999 -Node: VMS Compilation1170790 -Ref: VMS Compilation-Footnote-11172019 -Node: VMS Dynamic Extensions1172077 -Node: VMS Installation Details1173762 -Node: VMS Running1176015 -Node: VMS GNV1180294 -Node: VMS Old Gawk1181029 -Node: Bugs1181500 -Node: Bug address1182163 -Node: Usenet1184560 -Node: Maintainers1185337 -Node: Other Versions1186598 -Node: Installation summary1193182 -Node: Notes1194217 -Node: Compatibility Mode1195082 -Node: Additions1195864 -Node: Accessing The Source1196789 -Node: Adding Code1198224 -Node: New Ports1204442 -Node: Derived Files1208930 -Ref: Derived Files-Footnote-11214415 -Ref: Derived Files-Footnote-21214450 -Ref: Derived Files-Footnote-31215048 -Node: Future Extensions1215162 -Node: Implementation Limitations1215820 -Node: Extension Design1217003 -Node: Old Extension Problems1218157 -Ref: Old Extension Problems-Footnote-11219675 -Node: Extension New Mechanism Goals1219732 -Ref: Extension New Mechanism Goals-Footnote-11223096 -Node: Extension Other Design Decisions1223285 -Node: Extension Future Growth1225398 -Node: Old Extension Mechanism1226234 -Node: Notes summary1227997 -Node: Basic Concepts1229179 -Node: Basic High Level1229860 -Ref: figure-general-flow1230142 -Ref: figure-process-flow1230827 -Ref: Basic High Level-Footnote-11234128 -Node: Basic Data Typing1234313 -Node: Glossary1237641 -Node: Copying1269588 -Node: GNU Free Documentation License1307127 -Node: Index1332245 +Node: Foreword343399 +Node: Foreword447841 +Node: Preface49373 +Ref: Preface-Footnote-152232 +Ref: Preface-Footnote-252339 +Ref: Preface-Footnote-352573 +Node: History52715 +Node: Names55067 +Ref: Names-Footnote-156161 +Node: This Manual56308 +Ref: This Manual-Footnote-162793 +Node: Conventions62893 +Node: Manual History65247 +Ref: Manual History-Footnote-168242 +Ref: Manual History-Footnote-268283 +Node: How To Contribute68357 +Node: Acknowledgments69008 +Node: Getting Started73894 +Node: Running gawk76333 +Node: One-shot77523 +Node: Read Terminal78786 +Node: Long80779 +Node: Executable Scripts82292 +Ref: Executable Scripts-Footnote-185087 +Node: Comments85190 +Node: Quoting87674 +Node: DOS Quoting93191 +Node: Sample Data Files95247 +Node: Very Simple97842 +Node: Two Rules102744 +Node: More Complex104629 +Node: Statements/Lines107495 +Ref: Statements/Lines-Footnote-1111954 +Node: Other Features112219 +Node: When113155 +Ref: When-Footnote-1114909 +Node: Intro Summary114974 +Node: Invoking Gawk115858 +Node: Command Line117372 +Node: Options118170 +Ref: Options-Footnote-1134789 +Ref: Options-Footnote-2135019 +Node: Other Arguments135044 +Node: Naming Standard Input137991 +Node: Environment Variables139084 +Node: AWKPATH Variable139642 +Ref: AWKPATH Variable-Footnote-1143053 +Ref: AWKPATH Variable-Footnote-2143087 +Node: AWKLIBPATH Variable143348 +Node: Other Environment Variables144605 +Node: Exit Status148426 +Node: Include Files149103 +Node: Loading Shared Libraries152698 +Node: Obsolete154126 +Node: Undocumented154818 +Node: Invoking Summary155115 +Node: Regexp156775 +Node: Regexp Usage158229 +Node: Escape Sequences160266 +Node: Regexp Operators166498 +Ref: Regexp Operators-Footnote-1173914 +Ref: Regexp Operators-Footnote-2174061 +Node: Bracket Expressions174159 +Ref: table-char-classes176635 +Node: Leftmost Longest179772 +Node: Computed Regexps181075 +Node: GNU Regexp Operators184502 +Node: Case-sensitivity188181 +Ref: Case-sensitivity-Footnote-1191068 +Ref: Case-sensitivity-Footnote-2191303 +Node: Regexp Summary191411 +Node: Reading Files192877 +Node: Records195146 +Node: awk split records195879 +Node: gawk split records200810 +Ref: gawk split records-Footnote-1205350 +Node: Fields205387 +Node: Nonconstant Fields208128 +Ref: Nonconstant Fields-Footnote-1210364 +Node: Changing Fields210568 +Node: Field Separators216496 +Node: Default Field Splitting219194 +Node: Regexp Field Splitting220312 +Node: Single Character Fields223665 +Node: Command Line Field Separator224725 +Node: Full Line Fields227943 +Ref: Full Line Fields-Footnote-1229465 +Ref: Full Line Fields-Footnote-2229511 +Node: Field Splitting Summary229612 +Node: Constant Size231686 +Node: Fixed width data232418 +Node: Skipping intervening235885 +Node: Allowing trailing data236683 +Node: Fields with fixed data237720 +Node: Splitting By Content239238 +Ref: Splitting By Content-Footnote-1242888 +Node: Testing field creation243051 +Node: Multiple Line244672 +Ref: Multiple Line-Footnote-1250556 +Node: Getline250735 +Node: Plain Getline253204 +Node: Getline/Variable255845 +Node: Getline/File256996 +Node: Getline/Variable/File258384 +Ref: Getline/Variable/File-Footnote-1259989 +Node: Getline/Pipe260077 +Node: Getline/Variable/Pipe262784 +Node: Getline/Coprocess263919 +Node: Getline/Variable/Coprocess265186 +Node: Getline Notes265928 +Node: Getline Summary268725 +Ref: table-getline-variants269149 +Node: Read Timeout269897 +Ref: Read Timeout-Footnote-1273803 +Node: Retrying Input273861 +Node: Command-line directories275060 +Node: Input Summary275966 +Node: Input Exercises279138 +Node: Printing279866 +Node: Print281700 +Node: Print Examples283157 +Node: Output Separators285937 +Node: OFMT287954 +Node: Printf289310 +Node: Basic Printf290095 +Node: Control Letters291669 +Node: Format Modifiers295657 +Node: Printf Examples301672 +Node: Redirection304158 +Node: Special FD310999 +Ref: Special FD-Footnote-1314167 +Node: Special Files314241 +Node: Other Inherited Files314858 +Node: Special Network315859 +Node: Special Caveats316719 +Node: Close Files And Pipes317668 +Ref: table-close-pipe-return-values324575 +Ref: Close Files And Pipes-Footnote-1325358 +Ref: Close Files And Pipes-Footnote-2325506 +Node: Nonfatal325658 +Node: Output Summary327983 +Node: Output Exercises329205 +Node: Expressions329884 +Node: Values331072 +Node: Constants331750 +Node: Scalar Constants332441 +Ref: Scalar Constants-Footnote-1333305 +Node: Nondecimal-numbers333555 +Node: Regexp Constants336556 +Node: Using Constant Regexps337082 +Node: Standard Regexp Constants337704 +Node: Strong Regexp Constants340892 +Node: Variables343850 +Node: Using Variables344507 +Node: Assignment Options346417 +Node: Conversion348290 +Node: Strings And Numbers348814 +Ref: Strings And Numbers-Footnote-1351877 +Node: Locale influences conversions351986 +Ref: table-locale-affects354744 +Node: All Operators355362 +Node: Arithmetic Ops355991 +Node: Concatenation358497 +Ref: Concatenation-Footnote-1361344 +Node: Assignment Ops361451 +Ref: table-assign-ops366442 +Node: Increment Ops367755 +Node: Truth Values and Conditions371215 +Node: Truth Values372289 +Node: Typing and Comparison373337 +Node: Variable Typing374157 +Ref: Variable Typing-Footnote-1380620 +Ref: Variable Typing-Footnote-2380692 +Node: Comparison Operators380769 +Ref: table-relational-ops381188 +Node: POSIX String Comparison384683 +Ref: POSIX String Comparison-Footnote-1386378 +Ref: POSIX String Comparison-Footnote-2386517 +Node: Boolean Ops386601 +Ref: Boolean Ops-Footnote-1391083 +Node: Conditional Exp391175 +Node: Function Calls392911 +Node: Precedence396788 +Node: Locales400447 +Node: Expressions Summary402079 +Node: Patterns and Actions404652 +Node: Pattern Overview405772 +Node: Regexp Patterns407449 +Node: Expression Patterns407991 +Node: Ranges411772 +Node: BEGIN/END414880 +Node: Using BEGIN/END415641 +Ref: Using BEGIN/END-Footnote-1418377 +Node: I/O And BEGIN/END418483 +Node: BEGINFILE/ENDFILE420797 +Node: Empty423704 +Node: Using Shell Variables424021 +Node: Action Overview426295 +Node: Statements428620 +Node: If Statement430468 +Node: While Statement431963 +Node: Do Statement433991 +Node: For Statement435139 +Node: Switch Statement438297 +Node: Break Statement440683 +Node: Continue Statement442775 +Node: Next Statement444602 +Node: Nextfile Statement446985 +Node: Exit Statement449637 +Node: Built-in Variables452040 +Node: User-modified453173 +Node: Auto-set460940 +Ref: Auto-set-Footnote-1476537 +Ref: Auto-set-Footnote-2476743 +Node: ARGC and ARGV476799 +Node: Pattern Action Summary481012 +Node: Arrays483442 +Node: Array Basics484771 +Node: Array Intro485615 +Ref: figure-array-elements487590 +Ref: Array Intro-Footnote-1490294 +Node: Reference to Elements490422 +Node: Assigning Elements492886 +Node: Array Example493377 +Node: Scanning an Array495136 +Node: Controlling Scanning498158 +Ref: Controlling Scanning-Footnote-1503557 +Node: Numeric Array Subscripts503873 +Node: Uninitialized Subscripts506057 +Node: Delete507676 +Ref: Delete-Footnote-1510428 +Node: Multidimensional510485 +Node: Multiscanning513580 +Node: Arrays of Arrays515171 +Node: Arrays Summary519938 +Node: Functions522031 +Node: Built-in523069 +Node: Calling Built-in524150 +Node: Numeric Functions526146 +Ref: Numeric Functions-Footnote-1530174 +Ref: Numeric Functions-Footnote-2530531 +Ref: Numeric Functions-Footnote-3530579 +Node: String Functions530851 +Ref: String Functions-Footnote-1554509 +Ref: String Functions-Footnote-2554637 +Ref: String Functions-Footnote-3554885 +Node: Gory Details554972 +Ref: table-sub-escapes556763 +Ref: table-sub-proposed558282 +Ref: table-posix-sub559645 +Ref: table-gensub-escapes561186 +Ref: Gory Details-Footnote-1562009 +Node: I/O Functions562163 +Ref: table-system-return-values568745 +Ref: I/O Functions-Footnote-1570725 +Ref: I/O Functions-Footnote-2570873 +Node: Time Functions570993 +Ref: Time Functions-Footnote-1581660 +Ref: Time Functions-Footnote-2581728 +Ref: Time Functions-Footnote-3581886 +Ref: Time Functions-Footnote-4581997 +Ref: Time Functions-Footnote-5582109 +Ref: Time Functions-Footnote-6582336 +Node: Bitwise Functions582602 +Ref: table-bitwise-ops583196 +Ref: Bitwise Functions-Footnote-1589229 +Ref: Bitwise Functions-Footnote-2589402 +Node: Type Functions589593 +Node: I18N Functions592510 +Node: User-defined594161 +Node: Definition Syntax594966 +Ref: Definition Syntax-Footnote-1600653 +Node: Function Example600724 +Ref: Function Example-Footnote-1603646 +Node: Function Caveats603668 +Node: Calling A Function604186 +Node: Variable Scope605144 +Node: Pass By Value/Reference608138 +Node: Return Statement611637 +Node: Dynamic Typing614616 +Node: Indirect Calls615546 +Ref: Indirect Calls-Footnote-1625797 +Node: Functions Summary625925 +Node: Library Functions628630 +Ref: Library Functions-Footnote-1632237 +Ref: Library Functions-Footnote-2632380 +Node: Library Names632551 +Ref: Library Names-Footnote-1636011 +Ref: Library Names-Footnote-2636234 +Node: General Functions636320 +Node: Strtonum Function637423 +Node: Assert Function640445 +Node: Round Function643771 +Node: Cliff Random Function645312 +Node: Ordinal Functions646328 +Ref: Ordinal Functions-Footnote-1649391 +Ref: Ordinal Functions-Footnote-2649643 +Node: Join Function649853 +Ref: Join Function-Footnote-1651623 +Node: Getlocaltime Function651823 +Node: Readfile Function655565 +Node: Shell Quoting657537 +Node: Data File Management658938 +Node: Filetrans Function659570 +Node: Rewind Function663666 +Node: File Checking665576 +Ref: File Checking-Footnote-1666910 +Node: Empty Files667111 +Node: Ignoring Assigns669090 +Node: Getopt Function670640 +Ref: Getopt Function-Footnote-1682109 +Node: Passwd Functions682309 +Ref: Passwd Functions-Footnote-1691148 +Node: Group Functions691236 +Ref: Group Functions-Footnote-1699134 +Node: Walking Arrays699341 +Node: Library Functions Summary702349 +Node: Library Exercises703755 +Node: Sample Programs704220 +Node: Running Examples704990 +Node: Clones705718 +Node: Cut Program706942 +Node: Egrep Program716871 +Ref: Egrep Program-Footnote-1724383 +Node: Id Program724493 +Node: Split Program728173 +Ref: Split Program-Footnote-1731632 +Node: Tee Program731761 +Node: Uniq Program734551 +Node: Wc Program741977 +Ref: Wc Program-Footnote-1746232 +Node: Miscellaneous Programs746326 +Node: Dupword Program747539 +Node: Alarm Program749569 +Node: Translate Program754424 +Ref: Translate Program-Footnote-1758989 +Node: Labels Program759259 +Ref: Labels Program-Footnote-1762610 +Node: Word Sorting762694 +Node: History Sorting766766 +Node: Extract Program768601 +Node: Simple Sed776130 +Node: Igawk Program779204 +Ref: Igawk Program-Footnote-1793535 +Ref: Igawk Program-Footnote-2793737 +Ref: Igawk Program-Footnote-3793859 +Node: Anagram Program793974 +Node: Signature Program797036 +Node: Programs Summary798283 +Node: Programs Exercises799497 +Ref: Programs Exercises-Footnote-1803626 +Node: Advanced Features803717 +Node: Nondecimal Data805707 +Node: Array Sorting807298 +Node: Controlling Array Traversal807998 +Ref: Controlling Array Traversal-Footnote-1816365 +Node: Array Sorting Functions816483 +Ref: Array Sorting Functions-Footnote-1821574 +Node: Two-way I/O821770 +Ref: Two-way I/O-Footnote-1828321 +Ref: Two-way I/O-Footnote-2828508 +Node: TCP/IP Networking828590 +Node: Profiling831708 +Ref: Profiling-Footnote-1840380 +Node: Advanced Features Summary840703 +Node: Internationalization842547 +Node: I18N and L10N844027 +Node: Explaining gettext844714 +Ref: Explaining gettext-Footnote-1850606 +Ref: Explaining gettext-Footnote-2850791 +Node: Programmer i18n850956 +Ref: Programmer i18n-Footnote-1855905 +Node: Translator i18n855954 +Node: String Extraction856748 +Ref: String Extraction-Footnote-1857880 +Node: Printf Ordering857966 +Ref: Printf Ordering-Footnote-1860752 +Node: I18N Portability860816 +Ref: I18N Portability-Footnote-1863272 +Node: I18N Example863335 +Ref: I18N Example-Footnote-1866141 +Node: Gawk I18N866214 +Node: I18N Summary866859 +Node: Debugger868200 +Node: Debugging869222 +Node: Debugging Concepts869663 +Node: Debugging Terms871472 +Node: Awk Debugging874047 +Node: Sample Debugging Session874953 +Node: Debugger Invocation875487 +Node: Finding The Bug876873 +Node: List of Debugger Commands883351 +Node: Breakpoint Control884684 +Node: Debugger Execution Control888378 +Node: Viewing And Changing Data891740 +Node: Execution Stack895114 +Node: Debugger Info896751 +Node: Miscellaneous Debugger Commands900822 +Node: Readline Support905910 +Node: Limitations906806 +Node: Debugging Summary908915 +Node: Arbitrary Precision Arithmetic910194 +Node: Computer Arithmetic911679 +Ref: table-numeric-ranges915270 +Ref: Computer Arithmetic-Footnote-1915992 +Node: Math Definitions916049 +Ref: table-ieee-formats919363 +Ref: Math Definitions-Footnote-1919966 +Node: MPFR features920071 +Node: FP Math Caution921788 +Ref: FP Math Caution-Footnote-1922860 +Node: Inexactness of computations923229 +Node: Inexact representation924189 +Node: Comparing FP Values925549 +Node: Errors accumulate926631 +Node: Getting Accuracy928064 +Node: Try To Round930774 +Node: Setting precision931673 +Ref: table-predefined-precision-strings932370 +Node: Setting the rounding mode934200 +Ref: table-gawk-rounding-modes934574 +Ref: Setting the rounding mode-Footnote-1937982 +Node: Arbitrary Precision Integers938161 +Ref: Arbitrary Precision Integers-Footnote-1941336 +Node: Checking for MPFR941485 +Node: POSIX Floating Point Problems942782 +Ref: POSIX Floating Point Problems-Footnote-1946653 +Node: Floating point summary946691 +Node: Dynamic Extensions948881 +Node: Extension Intro950434 +Node: Plugin License951700 +Node: Extension Mechanism Outline952497 +Ref: figure-load-extension952936 +Ref: figure-register-new-function954501 +Ref: figure-call-new-function955593 +Node: Extension API Description957655 +Node: Extension API Functions Introduction959297 +Node: General Data Types964837 +Ref: General Data Types-Footnote-1972958 +Node: Memory Allocation Functions973257 +Ref: Memory Allocation Functions-Footnote-1977465 +Node: Constructor Functions977564 +Node: Registration Functions981150 +Node: Extension Functions981835 +Node: Exit Callback Functions987048 +Node: Extension Version String988298 +Node: Input Parsers988961 +Node: Output Wrappers1001682 +Node: Two-way processors1006194 +Node: Printing Messages1008459 +Ref: Printing Messages-Footnote-11009630 +Node: Updating ERRNO1009783 +Node: Requesting Values1010522 +Ref: table-value-types-returned1011259 +Node: Accessing Parameters1012195 +Node: Symbol Table Access1013430 +Node: Symbol table by name1013942 +Node: Symbol table by cookie1015731 +Ref: Symbol table by cookie-Footnote-11019916 +Node: Cached values1019980 +Ref: Cached values-Footnote-11023516 +Node: Array Manipulation1023669 +Ref: Array Manipulation-Footnote-11024760 +Node: Array Data Types1024797 +Ref: Array Data Types-Footnote-11027455 +Node: Array Functions1027547 +Node: Flattening Arrays1032045 +Node: Creating Arrays1039021 +Node: Redirection API1043790 +Node: Extension API Variables1046623 +Node: Extension Versioning1047334 +Ref: gawk-api-version1047763 +Node: Extension GMP/MPFR Versioning1049491 +Node: Extension API Informational Variables1051119 +Node: Extension API Boilerplate1052192 +Node: Changes from API V11056166 +Node: Finding Extensions1056826 +Node: Extension Example1057385 +Node: Internal File Description1058183 +Node: Internal File Ops1062263 +Ref: Internal File Ops-Footnote-11073663 +Node: Using Internal File Ops1073803 +Ref: Using Internal File Ops-Footnote-11076186 +Node: Extension Samples1076460 +Node: Extension Sample File Functions1077989 +Node: Extension Sample Fnmatch1085638 +Node: Extension Sample Fork1087125 +Node: Extension Sample Inplace1088343 +Node: Extension Sample Ord1091560 +Node: Extension Sample Readdir1092396 +Ref: table-readdir-file-types1093285 +Node: Extension Sample Revout1094090 +Node: Extension Sample Rev2way1094679 +Node: Extension Sample Read write array1095419 +Node: Extension Sample Readfile1097361 +Node: Extension Sample Time1098456 +Node: Extension Sample API Tests1099804 +Node: gawkextlib1100296 +Node: Extension summary1102743 +Node: Extension Exercises1106445 +Node: Language History1107943 +Node: V7/SVR3.11109599 +Node: SVR41111751 +Node: POSIX1113185 +Node: BTL1114564 +Node: POSIX/GNU1115293 +Node: Feature History1121071 +Node: Common Extensions1135436 +Node: Ranges and Locales1136719 +Ref: Ranges and Locales-Footnote-11141335 +Ref: Ranges and Locales-Footnote-21141362 +Ref: Ranges and Locales-Footnote-31141597 +Node: Contributors1141818 +Node: History summary1147446 +Node: Installation1148826 +Node: Gawk Distribution1149770 +Node: Getting1150254 +Node: Extracting1151215 +Node: Distribution contents1152853 +Node: Unix Installation1159195 +Node: Quick Installation1159877 +Node: Shell Startup Files1162291 +Node: Additional Configuration Options1163380 +Node: Configuration Philosophy1165369 +Node: Non-Unix Installation1167738 +Node: PC Installation1168198 +Node: PC Binary Installation1169036 +Node: PC Compiling1169471 +Node: PC Using1170588 +Node: Cygwin1173633 +Node: MSYS1174403 +Node: VMS Installation1174904 +Node: VMS Compilation1175695 +Ref: VMS Compilation-Footnote-11176924 +Node: VMS Dynamic Extensions1176982 +Node: VMS Installation Details1178667 +Node: VMS Running1180920 +Node: VMS GNV1185199 +Node: VMS Old Gawk1185934 +Node: Bugs1186405 +Node: Bug address1187068 +Node: Usenet1189465 +Node: Maintainers1190242 +Node: Other Versions1191503 +Node: Installation summary1198087 +Node: Notes1199122 +Node: Compatibility Mode1199987 +Node: Additions1200769 +Node: Accessing The Source1201694 +Node: Adding Code1203129 +Node: New Ports1209347 +Node: Derived Files1213835 +Ref: Derived Files-Footnote-11219320 +Ref: Derived Files-Footnote-21219355 +Ref: Derived Files-Footnote-31219953 +Node: Future Extensions1220067 +Node: Implementation Limitations1220725 +Node: Extension Design1221908 +Node: Old Extension Problems1223062 +Ref: Old Extension Problems-Footnote-11224580 +Node: Extension New Mechanism Goals1224637 +Ref: Extension New Mechanism Goals-Footnote-11228001 +Node: Extension Other Design Decisions1228190 +Node: Extension Future Growth1230303 +Node: Old Extension Mechanism1231139 +Node: Notes summary1232902 +Node: Basic Concepts1234084 +Node: Basic High Level1234765 +Ref: figure-general-flow1235047 +Ref: figure-process-flow1235732 +Ref: Basic High Level-Footnote-11239033 +Node: Basic Data Typing1239218 +Node: Glossary1242546 +Node: Copying1274493 +Node: GNU Free Documentation License1312032 +Node: Index1337150 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 3fa98afd..e44abad5 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -945,6 +945,8 @@ particular records in a file and perform operations upon them. redirections. * Extension API Variables:: Variables provided by the API. * Extension Versioning:: API Version information. +* Extension GMP/MPFR Versioning:: Version information about GMP and + MPFR. * Extension API Informational Variables:: Variables providing information about @command{gawk}'s invocation. * Extension API Boilerplate:: Boilerplate code for using the API. @@ -32708,6 +32710,11 @@ a portability hodge-podge as can be seen in some parts of the @command{gawk} source code. @item +If your extension uses MPFR facilities, and you wish to receive such +values from @command{gawk} and/or pass such values to it, you must include the +@code{<mpfr.h>} header before including @code{<gawkapi.h>}. + +@item The @file{gawkapi.h} file may be included more than once without ill effect. Doing so, however, is poor coding practice. @@ -32845,7 +32852,7 @@ It is used in the following @code{struct}. @itemx @ @ @ @ awk_valtype_t val_type; @itemx @ @ @ @ union @{ @itemx @ @ @ @ @ @ @ @ awk_string_t@ @ @ @ @ @ @ s; -@itemx @ @ @ @ @ @ @ @ double@ @ @ @ @ @ @ @ @ @ @ @ @ d; +@itemx @ @ @ @ @ @ @ @ awknum_t@ @ @ @ @ @ @ @ @ @ @ n; @itemx @ @ @ @ @ @ @ @ awk_array_t@ @ @ @ @ @ @ @ a; @itemx @ @ @ @ @ @ @ @ awk_scalar_t@ @ @ @ @ @ @ scl; @itemx @ @ @ @ @ @ @ @ awk_value_cookie_t@ vc; @@ -32858,13 +32865,37 @@ The @code{val_type} member indicates what kind of value the @item #define str_value@ @ @ @ @ @ u.s @itemx #define strnum_value@ @ @ str_value @itemx #define regex_value@ @ @ @ str_value -@itemx #define num_value@ @ @ @ @ @ u.d +@itemx #define num_value@ @ @ @ @ @ u.n.d +@itemx #define num_type@ @ @ @ @ @ @ u.n.type +@itemx #define num_ptr@ @ @ @ @ @ @ @ u.n.ptr @itemx #define array_cookie@ @ @ u.a @itemx #define scalar_cookie@ @ u.scl @itemx #define value_cookie@ @ @ u.vc Using these macros makes accessing the fields of the @code{awk_value_t} more readable. +@item typedef struct awk_number @{ +@itemx @ @ @ @ double d; +@itemx @ @ @ @ enum AWK_NUMBER_TYPE @{ +@itemx @ @ @ @ @ @ @ @ AWK_NUMBER_TYPE_DOUBLE, +@itemx @ @ @ @ @ @ @ @ AWK_NUMBER_TYPE_MPFR, +@itemx @ @ @ @ @ @ @ @ AWK_NUMBER_TYPE_MPZ +@itemx @ @ @ @ @} type; +@itemx @ @ @ @ void *ptr; +@itemx @} awk_number_t; +This represents a numeric value. Internally, @command{gawk} stores +every number as either a C @code{double}, a GMP integer, or an MPFR +arbitrary-precision floating-point value. In order to allow extensions +to also support GMP and MPFR values, numeric values are passed in this +structure. + +The double-precision @code{d} element is always populated +in data received from @command{gawk}. In addition, by examining the +@code{type} member, an extension can determine if the @code{ptr} +member is either a GMP integer (type @code{mpz_ptr}), or an MPFR +floating-point value (type @code{mpfr_ptr_t}), and cast it appropriately. + + @item typedef void *awk_scalar_t; Scalars can be represented as an opaque type. These values are obtained from @command{gawk} and then passed back into it. This is discussed @@ -33045,6 +33076,31 @@ instead of @code{gawk_malloc()}. The arguments are the same as for the @code{emalloc()} macro. @end table +Two additional functions allocate MPFR and GMP objects for use +by extension functions that need to create and then return such +values: + +@table @code +@item void *get_mpfr_ptr(); +Allocate and initialize an MPFR object and return a pointer to it. +If the allocation fails, @command{gawk} exits with a fatal +``out of memory'' error. If @command{gawk} was compiled without +MPFR support, calling this function causes a fatal error. + +@item void *get_mpz_ptr(); +Allocate and initialize a GMP object and return a pointer to it. +If the allocation fails, @command{gawk} exits with a fatal +``out of memory'' error. If @command{gawk} was compiled without +MPFR support, calling this function causes a fatal error. +@end table + +Both of these functions return @samp{void *}, since the @file{gawkapi.h} +header file should not have dependency upon @code{<mpfr.h>} (and @code{<gmp.h>}, +which is included from @code{<mpfr.h>}). The actual return values are of +types @code{mpfr_ptr} and @code{mpz_ptr} respectively, and you should cast +the return values appropriately before assigning the results to variables +of the correct types. + @node Constructor Functions @subsection Constructor Functions @@ -33081,6 +33137,20 @@ This function simply creates a numeric value in the @code{awk_value_t} variable pointed to by @code{result}. @item static inline awk_value_t * +@itemx make_number_mpz(void *mpz, awk_value_t *result); +This function creates a GMP number value in @code{result}. +The @code{mpz} must be from a call to @code{get_mpz_ptr()} +(and thus be or real underlying type @code{mpz_ptr}). +@command{gawk} takes ownership of this memory. + +@item static inline awk_value_t * +@itemx make_number_mpfr(void *mpfr, awk_value_t *result); +This function creates an MPFR number value in @code{result}. +The @code{mpfr} must be from a call to @code{get_mpfr_ptr()}. +(and thus be or real underlying type @code{mpfr_ptr}) +@command{gawk} takes ownership of this memory. + +@item static inline awk_value_t * @itemx make_const_user_input(const char *string, size_t length, awk_value_t *result); This function is identical to @code{make_const_string()}, but the string is flagged as user input that should be treated as a strnum value if the contents @@ -33598,9 +33668,9 @@ the length of the field. The values in @code{fields[0]} provide the information for @code{$1}, and so on through the @code{fields[nf-1]} element containing the information for @code{$NF}. @end table -A convenience macro @code{awk_fieldwidth_info_size(NF)} is provided to +A convenience macro @code{awk_fieldwidth_info_size(numfields)} is provided to calculate the appropriate size of a variable-length -@code{awk_fieldwidth_info_t} structure containing @code{NF} fields. This can +@code{awk_fieldwidth_info_t} structure containing @code{numfields} fields. This can be used as an argument to @code{malloc()} or in a union to allocate space statically. Please refer to the @code{readdir_test} sample extension for an example. @@ -34217,7 +34287,8 @@ However, you can understand the point of cached values if you remember that @code{gawk_calloc()}, or @code{gawk_realloc()}. If you have 20 variables, all of which have the same string value, you must create 20 identical copies of the string.@footnote{Numeric values -are clearly less problematic, requiring only a C @code{double} to store.} +are clearly less problematic, requiring only a C @code{double} to store. +But of course, GMP and MPFR values @emph{do} take up more memory.} It is clearly more efficient, if possible, to create a value once, and then tell @command{gawk} to reuse the value for multiple variables. That @@ -34452,7 +34523,10 @@ The array remains an array, but after calling this function, it has no elements. This is equivalent to using the @code{delete} statement (@pxref{Delete}). -@item awk_bool_t flatten_array_typed(awk_array_t a_cookie, awk_flat_array_t **data, awk_valtype_t index_type, awk_valtype_t value_type); +@item awk_bool_t flatten_array_typed(awk_array_t a_cookie, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_flat_array_t **data, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_valtype_t index_type, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_valtype_t value_type); For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t} structure and fill it in with indices and values of the requested types. Set the pointer whose address is passed as @code{data} @@ -34587,7 +34661,8 @@ to double-check that the count in the @code{awk_flat_array_t} is the same as the count just retrieved: @example - if (! flatten_array_typed(value2.array_cookie, & flat_array, AWK_STRING, AWK_UNDEFINED)) @{ + if (! flatten_array_typed(value2.array_cookie, & flat_array, + AWK_STRING, AWK_UNDEFINED)) @{ printf("dump_array_and_delete: could not flatten array\n"); goto out; @} @@ -34922,10 +34997,11 @@ A pipe opened for input. A two-way coprocess. @end table -On error, return an @code{awk_false} value. Otherwise, return +On error, return @code{awk_false}. Otherwise, return @code{awk_true}, and return additional information about the redirection -in the @code{ibufp} and @code{obufp} pointers. For input -redirections, the @code{*ibufp} value should be non-@code{NULL}, +in the @code{ibufp} and @code{obufp} pointers. + +For input redirections, the @code{*ibufp} value should be non-@code{NULL}, and @code{*obufp} should be @code{NULL}. For output redirections, the @code{*obufp} value should be non-@code{NULL}, and @code{*ibufp} should be @code{NULL}. For two-way coprocesses, both values should @@ -34961,9 +35037,10 @@ and with which @command{gawk} was compiled). The second provides information about how @command{gawk} was invoked. @menu -* Extension Versioning:: API Version information. +* Extension Versioning:: API Version information. +* Extension GMP/MPFR Versioning:: Version information about GMP and MPFR. * Extension API Informational Variables:: Variables providing information about - @command{gawk}'s invocation. + @command{gawk}'s invocation. @end menu @node Extension Versioning @@ -35024,6 +35101,49 @@ Such code is included in the boilerplate @code{dl_load_func()} macro provided in @file{gawkapi.h} (discussed in @ref{Extension API Boilerplate}). +@node Extension GMP/MPFR Versioning +@subsubsection GMP and MPFR Version Information + +The API also includes information about the versions of GMP and MPFR +with which the running @command{gawk} was compiled (if any). +They are included in the API @code{struct} as read-only +constant integers: + +@table @code +@item api->gmp_major_version +The major version of the GMP library used to compile @command{gawk}. + +@item api->gmp_minor_version +The minor version of the GMP library used to compile @command{gawk}. + +@item api->mpfr_major_version +The major version of the MPFR library used to compile @command{gawk}. + +@item api->mpfr_minor_version +The minor version of the MPFR library used to compile @command{gawk}. +@end table + +These fields are set to zero if @command{gawk} was compiled without +MPFR support. + +You can check if the versions of MPFR and GMP that you are using match those +of @command{gawk} with the following macro: + +@table @code +@item check_mpfr_version(extension) +The @code{extension} is the extension id passed to all the other macros +and functions defined in @file{gawkapi.h}. If you have not included +the @code{<mpfr.h>} header file, then this macro will be defined to do nothing. + +If you have included that file, then this macro compares the MPFR +and GMP major and minor versions against those of the library you are +compiling against. If your libraries are newer than @command{gawk}'s, it +produces a fatal error message. + +The @code{dl_load_func()} macro (@pxref{Extension API Boilerplate}) +calls @code{check_mpfr_version()}. +@end table + @node Extension API Informational Variables @subsubsection Informational Variables @cindex API informational variables @@ -35163,6 +35283,10 @@ Check the API versions. If the extension major version does not match @command{gawk}'s, it prints a fatal error message and exits. @item +Check the MPFR and GMP versions. If there is a mismatch, it prints +a fatal error message and exits. + +@item Load the functions defined in @code{func_table}. If any of them fails to load, it prints a warning message but continues on. diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 5b6d56bf..8ad4c72e 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -940,6 +940,8 @@ particular records in a file and perform operations upon them. redirections. * Extension API Variables:: Variables provided by the API. * Extension Versioning:: API Version information. +* Extension GMP/MPFR Versioning:: Version information about GMP and + MPFR. * Extension API Informational Variables:: Variables providing information about @command{gawk}'s invocation. * Extension API Boilerplate:: Boilerplate code for using the API. @@ -31722,6 +31724,11 @@ a portability hodge-podge as can be seen in some parts of the @command{gawk} source code. @item +If your extension uses MPFR facilities, and you wish to receive such +values from @command{gawk} and/or pass such values to it, you must include the +@code{<mpfr.h>} header before including @code{<gawkapi.h>}. + +@item The @file{gawkapi.h} file may be included more than once without ill effect. Doing so, however, is poor coding practice. @@ -31859,7 +31866,7 @@ It is used in the following @code{struct}. @itemx @ @ @ @ awk_valtype_t val_type; @itemx @ @ @ @ union @{ @itemx @ @ @ @ @ @ @ @ awk_string_t@ @ @ @ @ @ @ s; -@itemx @ @ @ @ @ @ @ @ double@ @ @ @ @ @ @ @ @ @ @ @ @ d; +@itemx @ @ @ @ @ @ @ @ awknum_t@ @ @ @ @ @ @ @ @ @ @ n; @itemx @ @ @ @ @ @ @ @ awk_array_t@ @ @ @ @ @ @ @ a; @itemx @ @ @ @ @ @ @ @ awk_scalar_t@ @ @ @ @ @ @ scl; @itemx @ @ @ @ @ @ @ @ awk_value_cookie_t@ vc; @@ -31872,13 +31879,37 @@ The @code{val_type} member indicates what kind of value the @item #define str_value@ @ @ @ @ @ u.s @itemx #define strnum_value@ @ @ str_value @itemx #define regex_value@ @ @ @ str_value -@itemx #define num_value@ @ @ @ @ @ u.d +@itemx #define num_value@ @ @ @ @ @ u.n.d +@itemx #define num_type@ @ @ @ @ @ @ u.n.type +@itemx #define num_ptr@ @ @ @ @ @ @ @ u.n.ptr @itemx #define array_cookie@ @ @ u.a @itemx #define scalar_cookie@ @ u.scl @itemx #define value_cookie@ @ @ u.vc Using these macros makes accessing the fields of the @code{awk_value_t} more readable. +@item typedef struct awk_number @{ +@itemx @ @ @ @ double d; +@itemx @ @ @ @ enum AWK_NUMBER_TYPE @{ +@itemx @ @ @ @ @ @ @ @ AWK_NUMBER_TYPE_DOUBLE, +@itemx @ @ @ @ @ @ @ @ AWK_NUMBER_TYPE_MPFR, +@itemx @ @ @ @ @ @ @ @ AWK_NUMBER_TYPE_MPZ +@itemx @ @ @ @ @} type; +@itemx @ @ @ @ void *ptr; +@itemx @} awk_number_t; +This represents a numeric value. Internally, @command{gawk} stores +every number as either a C @code{double}, a GMP integer, or an MPFR +arbitrary-precision floating-point value. In order to allow extensions +to also support GMP and MPFR values, numeric values are passed in this +structure. + +The double-precision @code{d} element is always populated +in data received from @command{gawk}. In addition, by examining the +@code{type} member, an extension can determine if the @code{ptr} +member is either a GMP integer (type @code{mpz_ptr}), or an MPFR +floating-point value (type @code{mpfr_ptr_t}), and cast it appropriately. + + @item typedef void *awk_scalar_t; Scalars can be represented as an opaque type. These values are obtained from @command{gawk} and then passed back into it. This is discussed @@ -32059,6 +32090,31 @@ instead of @code{gawk_malloc()}. The arguments are the same as for the @code{emalloc()} macro. @end table +Two additional functions allocate MPFR and GMP objects for use +by extension functions that need to create and then return such +values: + +@table @code +@item void *get_mpfr_ptr(); +Allocate and initialize an MPFR object and return a pointer to it. +If the allocation fails, @command{gawk} exits with a fatal +``out of memory'' error. If @command{gawk} was compiled without +MPFR support, calling this function causes a fatal error. + +@item void *get_mpz_ptr(); +Allocate and initialize a GMP object and return a pointer to it. +If the allocation fails, @command{gawk} exits with a fatal +``out of memory'' error. If @command{gawk} was compiled without +MPFR support, calling this function causes a fatal error. +@end table + +Both of these functions return @samp{void *}, since the @file{gawkapi.h} +header file should not have dependency upon @code{<mpfr.h>} (and @code{<gmp.h>}, +which is included from @code{<mpfr.h>}). The actual return values are of +types @code{mpfr_ptr} and @code{mpz_ptr} respectively, and you should cast +the return values appropriately before assigning the results to variables +of the correct types. + @node Constructor Functions @subsection Constructor Functions @@ -32095,6 +32151,20 @@ This function simply creates a numeric value in the @code{awk_value_t} variable pointed to by @code{result}. @item static inline awk_value_t * +@itemx make_number_mpz(void *mpz, awk_value_t *result); +This function creates a GMP number value in @code{result}. +The @code{mpz} must be from a call to @code{get_mpz_ptr()} +(and thus be or real underlying type @code{mpz_ptr}). +@command{gawk} takes ownership of this memory. + +@item static inline awk_value_t * +@itemx make_number_mpfr(void *mpfr, awk_value_t *result); +This function creates an MPFR number value in @code{result}. +The @code{mpfr} must be from a call to @code{get_mpfr_ptr()}. +(and thus be or real underlying type @code{mpfr_ptr}) +@command{gawk} takes ownership of this memory. + +@item static inline awk_value_t * @itemx make_const_user_input(const char *string, size_t length, awk_value_t *result); This function is identical to @code{make_const_string()}, but the string is flagged as user input that should be treated as a strnum value if the contents @@ -32612,9 +32682,9 @@ the length of the field. The values in @code{fields[0]} provide the information for @code{$1}, and so on through the @code{fields[nf-1]} element containing the information for @code{$NF}. @end table -A convenience macro @code{awk_fieldwidth_info_size(NF)} is provided to +A convenience macro @code{awk_fieldwidth_info_size(numfields)} is provided to calculate the appropriate size of a variable-length -@code{awk_fieldwidth_info_t} structure containing @code{NF} fields. This can +@code{awk_fieldwidth_info_t} structure containing @code{numfields} fields. This can be used as an argument to @code{malloc()} or in a union to allocate space statically. Please refer to the @code{readdir_test} sample extension for an example. @@ -33231,7 +33301,8 @@ However, you can understand the point of cached values if you remember that @code{gawk_calloc()}, or @code{gawk_realloc()}. If you have 20 variables, all of which have the same string value, you must create 20 identical copies of the string.@footnote{Numeric values -are clearly less problematic, requiring only a C @code{double} to store.} +are clearly less problematic, requiring only a C @code{double} to store. +But of course, GMP and MPFR values @emph{do} take up more memory.} It is clearly more efficient, if possible, to create a value once, and then tell @command{gawk} to reuse the value for multiple variables. That @@ -33466,7 +33537,10 @@ The array remains an array, but after calling this function, it has no elements. This is equivalent to using the @code{delete} statement (@pxref{Delete}). -@item awk_bool_t flatten_array_typed(awk_array_t a_cookie, awk_flat_array_t **data, awk_valtype_t index_type, awk_valtype_t value_type); +@item awk_bool_t flatten_array_typed(awk_array_t a_cookie, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_flat_array_t **data, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_valtype_t index_type, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ awk_valtype_t value_type); For the array represented by @code{a_cookie}, create an @code{awk_flat_array_t} structure and fill it in with indices and values of the requested types. Set the pointer whose address is passed as @code{data} @@ -33601,7 +33675,8 @@ to double-check that the count in the @code{awk_flat_array_t} is the same as the count just retrieved: @example - if (! flatten_array_typed(value2.array_cookie, & flat_array, AWK_STRING, AWK_UNDEFINED)) @{ + if (! flatten_array_typed(value2.array_cookie, & flat_array, + AWK_STRING, AWK_UNDEFINED)) @{ printf("dump_array_and_delete: could not flatten array\n"); goto out; @} @@ -33936,10 +34011,11 @@ A pipe opened for input. A two-way coprocess. @end table -On error, return an @code{awk_false} value. Otherwise, return +On error, return @code{awk_false}. Otherwise, return @code{awk_true}, and return additional information about the redirection -in the @code{ibufp} and @code{obufp} pointers. For input -redirections, the @code{*ibufp} value should be non-@code{NULL}, +in the @code{ibufp} and @code{obufp} pointers. + +For input redirections, the @code{*ibufp} value should be non-@code{NULL}, and @code{*obufp} should be @code{NULL}. For output redirections, the @code{*obufp} value should be non-@code{NULL}, and @code{*ibufp} should be @code{NULL}. For two-way coprocesses, both values should @@ -33975,9 +34051,10 @@ and with which @command{gawk} was compiled). The second provides information about how @command{gawk} was invoked. @menu -* Extension Versioning:: API Version information. +* Extension Versioning:: API Version information. +* Extension GMP/MPFR Versioning:: Version information about GMP and MPFR. * Extension API Informational Variables:: Variables providing information about - @command{gawk}'s invocation. + @command{gawk}'s invocation. @end menu @node Extension Versioning @@ -34038,6 +34115,49 @@ Such code is included in the boilerplate @code{dl_load_func()} macro provided in @file{gawkapi.h} (discussed in @ref{Extension API Boilerplate}). +@node Extension GMP/MPFR Versioning +@subsubsection GMP and MPFR Version Information + +The API also includes information about the versions of GMP and MPFR +with which the running @command{gawk} was compiled (if any). +They are included in the API @code{struct} as read-only +constant integers: + +@table @code +@item api->gmp_major_version +The major version of the GMP library used to compile @command{gawk}. + +@item api->gmp_minor_version +The minor version of the GMP library used to compile @command{gawk}. + +@item api->mpfr_major_version +The major version of the MPFR library used to compile @command{gawk}. + +@item api->mpfr_minor_version +The minor version of the MPFR library used to compile @command{gawk}. +@end table + +These fields are set to zero if @command{gawk} was compiled without +MPFR support. + +You can check if the versions of MPFR and GMP that you are using match those +of @command{gawk} with the following macro: + +@table @code +@item check_mpfr_version(extension) +The @code{extension} is the extension id passed to all the other macros +and functions defined in @file{gawkapi.h}. If you have not included +the @code{<mpfr.h>} header file, then this macro will be defined to do nothing. + +If you have included that file, then this macro compares the MPFR +and GMP major and minor versions against those of the library you are +compiling against. If your libraries are newer than @command{gawk}'s, it +produces a fatal error message. + +The @code{dl_load_func()} macro (@pxref{Extension API Boilerplate}) +calls @code{check_mpfr_version()}. +@end table + @node Extension API Informational Variables @subsubsection Informational Variables @cindex API informational variables @@ -34177,6 +34297,10 @@ Check the API versions. If the extension major version does not match @command{gawk}'s, it prints a fatal error message and exits. @item +Check the MPFR and GMP versions. If there is a mismatch, it prints +a fatal error message and exits. + +@item Load the functions defined in @code{func_table}. If any of them fails to load, it prints a warning message but continues on. |