diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2021-06-22 13:45:25 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2021-06-22 13:45:25 -0400 |
commit | 1bf8a67c114568b307c1df6dfe2042e2a3eab49b (patch) | |
tree | d02018ca12bf82104f90804df4b056d44b823a4f | |
parent | e7706feed9aac915db7307ad59d3908a8952eaf0 (diff) | |
download | egawk-1bf8a67c114568b307c1df6dfe2042e2a3eab49b.tar.gz egawk-1bf8a67c114568b307c1df6dfe2042e2a3eab49b.tar.bz2 egawk-1bf8a67c114568b307c1df6dfe2042e2a3eab49b.zip |
Add isnumeric function.
-rw-r--r-- | awklib/eg/lib/isnumeric.awk | 14 | ||||
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 1232 | ||||
-rw-r--r-- | doc/gawk.texi | 32 | ||||
-rw-r--r-- | doc/gawktexi.in | 32 |
5 files changed, 714 insertions, 600 deletions
diff --git a/awklib/eg/lib/isnumeric.awk b/awklib/eg/lib/isnumeric.awk new file mode 100644 index 00000000..6309e76a --- /dev/null +++ b/awklib/eg/lib/isnumeric.awk @@ -0,0 +1,14 @@ +# isnumeric --- check whether a value is numeric + +function isnumeric(x, f) +{ + switch (typeof(x)) { + case "strnum": + case "number": + return 1 + case "string": + return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum") + default: + return 0 + } +} diff --git a/doc/ChangeLog b/doc/ChangeLog index 5c8d469b..9ffc67d0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2021-06-22 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in (Isnumeric Function): New node. + 2021-06-21 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in (Performance bugs): New section. diff --git a/doc/gawk.info b/doc/gawk.info index 5eef11f6..1820528d 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -435,6 +435,8 @@ in (a) below. A copy of the license is included in the section entitled once. * Shell Quoting:: A function to quote strings for the shell. +* Isnumeric Function:: A function to test whether a value + is numeric. * Data File Management:: Functions for managing command-line data files. * Filetrans Function:: A function for handling data file @@ -15711,6 +15713,7 @@ programming use. * Getlocaltime Function:: A function to get formatted times. * Readfile Function:: A function to read an entire file at once. * Shell Quoting:: A function to quote strings for the shell. +* Isnumeric Function:: A function to test whether a value is numeric. File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions @@ -16246,7 +16249,7 @@ test would be 'contents == ""'. reads an entire file into memory. -File: gawk.info, Node: Shell Quoting, Prev: Readfile Function, Up: General Functions +File: gawk.info, Node: Shell Quoting, Next: Isnumeric Function, Prev: Readfile Function, Up: General Functions 10.2.9 Quoting Strings to Pass to the Shell ------------------------------------------- @@ -16298,6 +16301,32 @@ three-character string '"\"'\""': } +File: gawk.info, Node: Isnumeric Function, Prev: Shell Quoting, Up: General Functions + +10.2.10 Checking whether a value is numeric +------------------------------------------- + +A frequent programming question is how to ascertain whether a value is +numeric. This can be solved by using this example function +'isnumeric()', which employs the trick of converting a string value to +user input by using the 'split()' function: + + # isnumeric --- check whether a value is numeric + + function isnumeric(x, f) + { + switch (typeof(x)) { + case "strnum": + case "number": + return 1 + case "string": + return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum") + default: + return 0 + } + } + + File: gawk.info, Node: Data File Management, Next: Getopt Function, Prev: General Functions, Up: Library Functions 10.3 Data file Management @@ -36784,6 +36813,7 @@ Index * inventory-shipped file: Sample Data Files. (line 32) * invoke shell command: I/O Functions. (line 106) * isarray: Type Functions. (line 11) +* isnumeric() user-defined function: Isnumeric Function. (line 11) * ISO, ISO 8601 date and time standard: Time Functions. (line 186) * ISO, ISO 8859-1 character set: Glossary. (line 194) * ISO, ISO Latin-1 character set: Glossary. (line 194) @@ -38062,6 +38092,7 @@ Index * user-defined, function, getlocaltime(): Getlocaltime Function. (line 16) * user-defined, function, readfile(): Readfile Function. (line 30) +* user-defined, function, isnumeric(): Isnumeric Function. (line 11) * user-defined, function, beginfile(): Filetrans Function. (line 62) * user-defined, function, endfile(): Filetrans Function. (line 62) * user-defined, function, rewind(): Rewind Function. (line 15) @@ -38192,605 +38223,606 @@ Index Tag Table: Node: Top1200 -Node: Foreword344934 -Node: Foreword449376 -Node: Preface50908 -Ref: Preface-Footnote-153767 -Ref: Preface-Footnote-253876 -Ref: Preface-Footnote-354110 -Node: History54252 -Node: Names56604 -Ref: Names-Footnote-157708 -Node: This Manual57855 -Ref: This Manual-Footnote-164494 -Node: Conventions64594 -Node: Manual History66963 -Ref: Manual History-Footnote-169960 -Ref: Manual History-Footnote-270001 -Node: How To Contribute70075 -Node: Acknowledgments71001 -Node: Getting Started75938 -Node: Running gawk78377 -Node: One-shot79567 -Node: Read Terminal80830 -Node: Long82823 -Node: Executable Scripts84336 -Ref: Executable Scripts-Footnote-186969 -Node: Comments87072 -Node: Quoting89556 -Node: DOS Quoting95082 -Node: Sample Data Files97138 -Node: Very Simple99733 -Node: Two Rules105835 -Node: More Complex107720 -Node: Statements/Lines110052 -Ref: Statements/Lines-Footnote-1114536 -Node: Other Features114801 -Node: When115737 -Ref: When-Footnote-1117491 -Node: Intro Summary117556 -Node: Invoking Gawk118440 -Node: Command Line119954 -Node: Options120752 -Ref: Options-Footnote-1138666 -Ref: Options-Footnote-2138897 -Node: Other Arguments138922 -Node: Naming Standard Input142933 -Node: Environment Variables144143 -Node: AWKPATH Variable144701 -Ref: AWKPATH Variable-Footnote-1148113 -Ref: AWKPATH Variable-Footnote-2148147 -Node: AWKLIBPATH Variable148518 -Ref: AWKLIBPATH Variable-Footnote-1150215 -Node: Other Environment Variables150590 -Node: Exit Status154411 -Node: Include Files155088 -Node: Loading Shared Libraries158778 -Node: Obsolete160206 -Node: Undocumented160898 -Node: Invoking Summary161195 -Node: Regexp164036 -Node: Regexp Usage165490 -Node: Escape Sequences167527 -Node: Regexp Operators173768 -Node: Regexp Operator Details174253 -Ref: Regexp Operator Details-Footnote-1181617 -Node: Interval Expressions181764 -Ref: Interval Expressions-Footnote-1183185 -Node: Bracket Expressions183283 -Ref: table-char-classes185759 -Node: Leftmost Longest189085 -Node: Computed Regexps190388 -Node: GNU Regexp Operators193815 -Node: Case-sensitivity197552 -Ref: Case-sensitivity-Footnote-1200418 -Ref: Case-sensitivity-Footnote-2200653 -Node: Regexp Summary200761 -Node: Reading Files202227 -Node: Records204496 -Node: awk split records205571 -Node: gawk split records210271 -Ref: gawk split records-Footnote-1215345 -Node: Fields215382 -Node: Nonconstant Fields218123 -Ref: Nonconstant Fields-Footnote-1220359 -Node: Changing Fields220563 -Node: Field Separators226594 -Node: Default Field Splitting229292 -Node: Regexp Field Splitting230410 -Node: Single Character Fields234087 -Node: Command Line Field Separator235147 -Node: Full Line Fields238365 -Ref: Full Line Fields-Footnote-1239887 -Ref: Full Line Fields-Footnote-2239933 -Node: Field Splitting Summary240034 -Node: Constant Size242108 -Node: Fixed width data242840 -Node: Skipping intervening246307 -Node: Allowing trailing data247105 -Node: Fields with fixed data248142 -Node: Splitting By Content249660 -Ref: Splitting By Content-Footnote-1253443 -Node: More CSV253606 -Node: Testing field creation255198 -Node: Multiple Line256823 -Node: Getline263100 -Node: Plain Getline265569 -Node: Getline/Variable268142 -Node: Getline/File269293 -Node: Getline/Variable/File270681 -Ref: Getline/Variable/File-Footnote-1272286 -Node: Getline/Pipe272374 -Node: Getline/Variable/Pipe275078 -Node: Getline/Coprocess276213 -Node: Getline/Variable/Coprocess277480 -Node: Getline Notes278222 -Node: Getline Summary281019 -Ref: table-getline-variants281443 -Node: Read Timeout282191 -Ref: Read Timeout-Footnote-1286097 -Node: Retrying Input286155 -Node: Command-line directories287354 -Node: Input Summary288260 -Node: Input Exercises291432 -Node: Printing291866 -Node: Print293700 -Node: Print Examples295157 -Node: Output Separators297937 -Node: OFMT299954 -Node: Printf301310 -Node: Basic Printf302095 -Node: Control Letters303669 -Node: Format Modifiers308833 -Node: Printf Examples314848 -Node: Redirection317334 -Node: Special FD324175 -Ref: Special FD-Footnote-1327343 -Node: Special Files327417 -Node: Other Inherited Files328034 -Node: Special Network329035 -Node: Special Caveats329895 -Node: Close Files And Pipes330844 -Ref: table-close-pipe-return-values337751 -Ref: Close Files And Pipes-Footnote-1338564 -Ref: Close Files And Pipes-Footnote-2338712 -Node: Nonfatal338864 -Node: Output Summary341202 -Node: Output Exercises342424 -Node: Expressions343103 -Node: Values344291 -Node: Constants344969 -Node: Scalar Constants345660 -Ref: Scalar Constants-Footnote-1348170 -Node: Nondecimal-numbers348420 -Node: Regexp Constants351421 -Node: Using Constant Regexps351947 -Node: Standard Regexp Constants352569 -Node: Strong Regexp Constants355757 -Node: Variables358769 -Node: Using Variables359426 -Node: Assignment Options361336 -Node: Conversion363807 -Node: Strings And Numbers364331 -Ref: Strings And Numbers-Footnote-1367394 -Node: Locale influences conversions367503 -Ref: table-locale-affects370261 -Node: All Operators370879 -Node: Arithmetic Ops371508 -Node: Concatenation374224 -Ref: Concatenation-Footnote-1377071 -Node: Assignment Ops377178 -Ref: table-assign-ops382169 -Node: Increment Ops383482 -Node: Truth Values and Conditions386942 -Node: Truth Values388016 -Node: Typing and Comparison389064 -Node: Variable Typing389884 -Ref: Variable Typing-Footnote-1396347 -Ref: Variable Typing-Footnote-2396419 -Node: Comparison Operators396496 -Ref: table-relational-ops396915 -Node: POSIX String Comparison400410 -Ref: POSIX String Comparison-Footnote-1402105 -Ref: POSIX String Comparison-Footnote-2402244 -Node: Boolean Ops402328 -Ref: Boolean Ops-Footnote-1406810 -Node: Conditional Exp406902 -Node: Function Calls408638 -Node: Precedence412515 -Node: Locales416174 -Node: Expressions Summary417806 -Node: Patterns and Actions420379 -Node: Pattern Overview421499 -Node: Regexp Patterns423176 -Node: Expression Patterns423718 -Node: Ranges427499 -Node: BEGIN/END430607 -Node: Using BEGIN/END431368 -Ref: Using BEGIN/END-Footnote-1434122 -Node: I/O And BEGIN/END434228 -Node: BEGINFILE/ENDFILE436541 -Node: Empty439772 -Node: Using Shell Variables440089 -Node: Action Overview442363 -Node: Statements444688 -Node: If Statement446536 -Node: While Statement448031 -Node: Do Statement450059 -Node: For Statement451207 -Node: Switch Statement454378 -Node: Break Statement456819 -Node: Continue Statement458911 -Node: Next Statement460738 -Node: Nextfile Statement463121 -Node: Exit Statement465810 -Node: Built-in Variables468213 -Node: User-modified469346 -Node: Auto-set477113 -Ref: Auto-set-Footnote-1493920 -Ref: Auto-set-Footnote-2494126 -Node: ARGC and ARGV494182 -Node: Pattern Action Summary498395 -Node: Arrays500825 -Node: Array Basics502154 -Node: Array Intro502998 -Ref: figure-array-elements504973 -Ref: Array Intro-Footnote-1507677 -Node: Reference to Elements507805 -Node: Assigning Elements510269 -Node: Array Example510760 -Node: Scanning an Array512519 -Node: Controlling Scanning515541 -Ref: Controlling Scanning-Footnote-1521997 -Node: Numeric Array Subscripts522313 -Node: Uninitialized Subscripts524497 -Node: Delete526116 -Ref: Delete-Footnote-1528868 -Node: Multidimensional528925 -Node: Multiscanning532020 -Node: Arrays of Arrays533611 -Node: Arrays Summary538379 -Node: Functions540472 -Node: Built-in541510 -Node: Calling Built-in542591 -Node: Numeric Functions544587 -Ref: Numeric Functions-Footnote-1548615 -Ref: Numeric Functions-Footnote-2549263 -Ref: Numeric Functions-Footnote-3549311 -Node: String Functions549583 -Ref: String Functions-Footnote-1573724 -Ref: String Functions-Footnote-2573852 -Ref: String Functions-Footnote-3574100 -Node: Gory Details574187 -Ref: table-sub-escapes575978 -Ref: table-sub-proposed577497 -Ref: table-posix-sub578860 -Ref: table-gensub-escapes580401 -Ref: Gory Details-Footnote-1581224 -Node: I/O Functions581378 -Ref: table-system-return-values587832 -Ref: I/O Functions-Footnote-1589912 -Ref: I/O Functions-Footnote-2590060 -Node: Time Functions590180 -Ref: Time Functions-Footnote-1600851 -Ref: Time Functions-Footnote-2600919 -Ref: Time Functions-Footnote-3601077 -Ref: Time Functions-Footnote-4601188 -Ref: Time Functions-Footnote-5601300 -Ref: Time Functions-Footnote-6601527 -Node: Bitwise Functions601793 -Ref: table-bitwise-ops602387 -Ref: Bitwise Functions-Footnote-1608450 -Ref: Bitwise Functions-Footnote-2608623 -Node: Type Functions608814 -Node: I18N Functions611677 -Node: User-defined613328 -Node: Definition Syntax614140 -Ref: Definition Syntax-Footnote-1619834 -Node: Function Example619905 -Ref: Function Example-Footnote-1622827 -Node: Function Calling622849 -Node: Calling A Function623437 -Node: Variable Scope624395 -Node: Pass By Value/Reference627389 -Node: Function Caveats630033 -Ref: Function Caveats-Footnote-1632080 -Node: Return Statement632200 -Node: Dynamic Typing635179 -Node: Indirect Calls636109 -Ref: Indirect Calls-Footnote-1646361 -Node: Functions Summary646489 -Node: Library Functions649194 -Ref: Library Functions-Footnote-1652801 -Ref: Library Functions-Footnote-2652944 -Node: Library Names653115 -Ref: Library Names-Footnote-1656782 -Ref: Library Names-Footnote-2657005 -Node: General Functions657091 -Node: Strtonum Function658194 -Node: Assert Function661216 -Node: Round Function664542 -Node: Cliff Random Function666082 -Node: Ordinal Functions667098 -Ref: Ordinal Functions-Footnote-1670161 -Ref: Ordinal Functions-Footnote-2670413 -Node: Join Function670623 -Ref: Join Function-Footnote-1672393 -Node: Getlocaltime Function672593 -Node: Readfile Function676335 -Node: Shell Quoting678312 -Node: Data File Management679713 -Node: Filetrans Function680345 -Node: Rewind Function684441 -Node: File Checking686350 -Ref: File Checking-Footnote-1687684 -Node: Empty Files687885 -Node: Ignoring Assigns689864 -Node: Getopt Function691414 -Ref: Getopt Function-Footnote-1706625 -Node: Passwd Functions706825 -Ref: Passwd Functions-Footnote-1715664 -Node: Group Functions715752 -Ref: Group Functions-Footnote-1723650 -Node: Walking Arrays723857 -Node: Library Functions Summary726865 -Node: Library Exercises728271 -Node: Sample Programs728736 -Node: Running Examples729506 -Node: Clones730234 -Node: Cut Program731458 -Node: Egrep Program741598 -Node: Id Program750599 -Node: Split Program760546 -Ref: Split Program-Footnote-1770436 -Node: Tee Program770609 -Node: Uniq Program773399 -Node: Wc Program780987 -Node: Bytes vs. Characters781374 -Node: Using extensions782922 -Node: wc program783676 -Node: Miscellaneous Programs788541 -Node: Dupword Program789754 -Node: Alarm Program791784 -Node: Translate Program796639 -Ref: Translate Program-Footnote-1801204 -Node: Labels Program801474 -Ref: Labels Program-Footnote-1804825 -Node: Word Sorting804909 -Node: History Sorting808981 -Node: Extract Program811206 -Node: Simple Sed819260 -Node: Igawk Program822334 -Ref: Igawk Program-Footnote-1836665 -Ref: Igawk Program-Footnote-2836867 -Ref: Igawk Program-Footnote-3836989 -Node: Anagram Program837104 -Node: Signature Program840166 -Node: Programs Summary841413 -Node: Programs Exercises842627 -Ref: Programs Exercises-Footnote-1846757 -Node: Advanced Features846843 -Node: Nondecimal Data848910 -Node: Array Sorting850501 -Node: Controlling Array Traversal851201 -Ref: Controlling Array Traversal-Footnote-1859569 -Node: Array Sorting Functions859687 -Ref: Array Sorting Functions-Footnote-1864778 -Node: Two-way I/O864974 -Ref: Two-way I/O-Footnote-1872695 -Ref: Two-way I/O-Footnote-2872882 -Node: TCP/IP Networking872964 -Node: Profiling876082 -Node: Extension Philosophy885391 -Node: Advanced Features Summary886870 -Node: Internationalization888885 -Node: I18N and L10N890559 -Node: Explaining gettext891246 -Ref: Explaining gettext-Footnote-1897138 -Ref: Explaining gettext-Footnote-2897323 -Node: Programmer i18n897488 -Ref: Programmer i18n-Footnote-1902437 -Node: Translator i18n902486 -Node: String Extraction903280 -Ref: String Extraction-Footnote-1904412 -Node: Printf Ordering904498 -Ref: Printf Ordering-Footnote-1907284 -Node: I18N Portability907348 -Ref: I18N Portability-Footnote-1909804 -Node: I18N Example909867 -Ref: I18N Example-Footnote-1913142 -Ref: I18N Example-Footnote-2913215 -Node: Gawk I18N913324 -Node: I18N Summary913973 -Node: Debugger915314 -Node: Debugging916314 -Node: Debugging Concepts916755 -Node: Debugging Terms918564 -Node: Awk Debugging921139 -Ref: Awk Debugging-Footnote-1922084 -Node: Sample Debugging Session922216 -Node: Debugger Invocation922750 -Node: Finding The Bug924136 -Node: List of Debugger Commands930610 -Node: Breakpoint Control931943 -Node: Debugger Execution Control935637 -Node: Viewing And Changing Data938999 -Node: Execution Stack942540 -Node: Debugger Info944177 -Node: Miscellaneous Debugger Commands948248 -Node: Readline Support953310 -Node: Limitations954206 -Node: Debugging Summary956760 -Node: Namespaces958039 -Node: Global Namespace959150 -Node: Qualified Names960548 -Node: Default Namespace961547 -Node: Changing The Namespace962288 -Node: Naming Rules963902 -Node: Internal Name Management965750 -Node: Namespace Example966792 -Node: Namespace And Features969354 -Node: Namespace Summary970789 -Node: Arbitrary Precision Arithmetic972266 -Node: Computer Arithmetic973753 -Ref: table-numeric-ranges977519 -Ref: table-floating-point-ranges978012 -Ref: Computer Arithmetic-Footnote-1978670 -Node: Math Definitions978727 -Ref: table-ieee-formats982043 -Ref: Math Definitions-Footnote-1982646 -Node: MPFR features982751 -Node: FP Math Caution984469 -Ref: FP Math Caution-Footnote-1985541 -Node: Inexactness of computations985910 -Node: Inexact representation986870 -Node: Comparing FP Values988230 -Node: Errors accumulate989471 -Node: Getting Accuracy990904 -Node: Try To Round993614 -Node: Setting precision994513 -Ref: table-predefined-precision-strings995210 -Node: Setting the rounding mode997040 -Ref: table-gawk-rounding-modes997414 -Ref: Setting the rounding mode-Footnote-11001345 -Node: Arbitrary Precision Integers1001524 -Ref: Arbitrary Precision Integers-Footnote-11004699 -Node: Checking for MPFR1004848 -Node: POSIX Floating Point Problems1006322 -Ref: POSIX Floating Point Problems-Footnote-11010607 -Node: Floating point summary1010645 -Node: Dynamic Extensions1012835 -Node: Extension Intro1014388 -Node: Plugin License1015654 -Node: Extension Mechanism Outline1016451 -Ref: figure-load-extension1016890 -Ref: figure-register-new-function1018455 -Ref: figure-call-new-function1019547 -Node: Extension API Description1021609 -Node: Extension API Functions Introduction1023322 -Ref: table-api-std-headers1025158 -Node: General Data Types1029407 -Ref: General Data Types-Footnote-11038037 -Node: Memory Allocation Functions1038336 -Ref: Memory Allocation Functions-Footnote-11042837 -Node: Constructor Functions1042936 -Node: API Ownership of MPFR and GMP Values1046402 -Node: Registration Functions1047715 -Node: Extension Functions1048415 -Node: Exit Callback Functions1053737 -Node: Extension Version String1054987 -Node: Input Parsers1055650 -Node: Output Wrappers1068371 -Node: Two-way processors1072883 -Node: Printing Messages1075148 -Ref: Printing Messages-Footnote-11076319 -Node: Updating ERRNO1076472 -Node: Requesting Values1077211 -Ref: table-value-types-returned1077948 -Node: Accessing Parameters1078884 -Node: Symbol Table Access1080121 -Node: Symbol table by name1080633 -Ref: Symbol table by name-Footnote-11083657 -Node: Symbol table by cookie1083785 -Ref: Symbol table by cookie-Footnote-11087970 -Node: Cached values1088034 -Ref: Cached values-Footnote-11091570 -Node: Array Manipulation1091723 -Ref: Array Manipulation-Footnote-11092814 -Node: Array Data Types1092851 -Ref: Array Data Types-Footnote-11095509 -Node: Array Functions1095601 -Node: Flattening Arrays1100099 -Node: Creating Arrays1107075 -Node: Redirection API1111842 -Node: Extension API Variables1114675 -Node: Extension Versioning1115386 -Ref: gawk-api-version1115815 -Node: Extension GMP/MPFR Versioning1117546 -Node: Extension API Informational Variables1119174 -Node: Extension API Boilerplate1120247 -Node: Changes from API V11124221 -Node: Finding Extensions1125793 -Node: Extension Example1126352 -Node: Internal File Description1127150 -Node: Internal File Ops1131230 -Ref: Internal File Ops-Footnote-11142580 -Node: Using Internal File Ops1142720 -Ref: Using Internal File Ops-Footnote-11145103 -Node: Extension Samples1145377 -Node: Extension Sample File Functions1146906 -Node: Extension Sample Fnmatch1154555 -Node: Extension Sample Fork1156042 -Node: Extension Sample Inplace1157260 -Node: Extension Sample Ord1160886 -Node: Extension Sample Readdir1161722 -Ref: table-readdir-file-types1162611 -Node: Extension Sample Revout1163678 -Node: Extension Sample Rev2way1164267 -Node: Extension Sample Read write array1165007 -Node: Extension Sample Readfile1166949 -Node: Extension Sample Time1168044 -Node: Extension Sample API Tests1169796 -Node: gawkextlib1170288 -Node: Extension summary1173206 -Node: Extension Exercises1176908 -Node: Language History1178150 -Node: V7/SVR3.11179806 -Node: SVR41181958 -Node: POSIX1183392 -Node: BTL1184773 -Node: POSIX/GNU1185502 -Node: Feature History1191280 -Node: Common Extensions1208455 -Node: Ranges and Locales1209738 -Ref: Ranges and Locales-Footnote-11214354 -Ref: Ranges and Locales-Footnote-21214381 -Ref: Ranges and Locales-Footnote-31214616 -Node: Contributors1214839 -Node: History summary1220836 -Node: Installation1222216 -Node: Gawk Distribution1223160 -Node: Getting1223644 -Node: Extracting1224607 -Node: Distribution contents1226245 -Node: Unix Installation1232725 -Node: Quick Installation1233407 -Node: Compiling with MPFR1235888 -Node: Shell Startup Files1236580 -Node: Additional Configuration Options1237669 -Node: Configuration Philosophy1239984 -Node: Non-Unix Installation1242353 -Node: PC Installation1242813 -Node: PC Binary Installation1243651 -Node: PC Compiling1244086 -Node: PC Using1245203 -Node: Cygwin1248756 -Node: MSYS1249980 -Node: VMS Installation1250582 -Node: VMS Compilation1251373 -Ref: VMS Compilation-Footnote-11252602 -Node: VMS Dynamic Extensions1252660 -Node: VMS Installation Details1254345 -Node: VMS Running1256598 -Node: VMS GNV1260877 -Node: VMS Old Gawk1261612 -Node: Bugs1262083 -Node: Bug address1262832 -Node: Usenet1265814 -Node: Performance bugs1266823 -Node: Maintainers1269680 -Node: Other Versions1270875 -Node: Installation summary1278740 -Node: Notes1279949 -Node: Compatibility Mode1280743 -Node: Additions1281525 -Node: Accessing The Source1282450 -Node: Adding Code1283887 -Node: New Ports1290106 -Node: Derived Files1294481 -Ref: Derived Files-Footnote-11300141 -Ref: Derived Files-Footnote-21300176 -Ref: Derived Files-Footnote-31300774 -Node: Future Extensions1300888 -Node: Implementation Limitations1301546 -Node: Extension Design1302756 -Node: Old Extension Problems1303900 -Ref: Old Extension Problems-Footnote-11305418 -Node: Extension New Mechanism Goals1305475 -Ref: Extension New Mechanism Goals-Footnote-11308839 -Node: Extension Other Design Decisions1309028 -Node: Extension Future Growth1311141 -Node: Notes summary1311747 -Node: Basic Concepts1312905 -Node: Basic High Level1313586 -Ref: figure-general-flow1313868 -Ref: figure-process-flow1314553 -Ref: Basic High Level-Footnote-11317854 -Node: Basic Data Typing1318039 -Node: Glossary1321367 -Node: Copying1353252 -Node: GNU Free Documentation License1390795 -Node: Index1415915 +Node: Foreword345061 +Node: Foreword449503 +Node: Preface51035 +Ref: Preface-Footnote-153894 +Ref: Preface-Footnote-254003 +Ref: Preface-Footnote-354237 +Node: History54379 +Node: Names56731 +Ref: Names-Footnote-157835 +Node: This Manual57982 +Ref: This Manual-Footnote-164621 +Node: Conventions64721 +Node: Manual History67090 +Ref: Manual History-Footnote-170087 +Ref: Manual History-Footnote-270128 +Node: How To Contribute70202 +Node: Acknowledgments71128 +Node: Getting Started76065 +Node: Running gawk78504 +Node: One-shot79694 +Node: Read Terminal80957 +Node: Long82950 +Node: Executable Scripts84463 +Ref: Executable Scripts-Footnote-187096 +Node: Comments87199 +Node: Quoting89683 +Node: DOS Quoting95209 +Node: Sample Data Files97265 +Node: Very Simple99860 +Node: Two Rules105962 +Node: More Complex107847 +Node: Statements/Lines110179 +Ref: Statements/Lines-Footnote-1114663 +Node: Other Features114928 +Node: When115864 +Ref: When-Footnote-1117618 +Node: Intro Summary117683 +Node: Invoking Gawk118567 +Node: Command Line120081 +Node: Options120879 +Ref: Options-Footnote-1138793 +Ref: Options-Footnote-2139024 +Node: Other Arguments139049 +Node: Naming Standard Input143060 +Node: Environment Variables144270 +Node: AWKPATH Variable144828 +Ref: AWKPATH Variable-Footnote-1148240 +Ref: AWKPATH Variable-Footnote-2148274 +Node: AWKLIBPATH Variable148645 +Ref: AWKLIBPATH Variable-Footnote-1150342 +Node: Other Environment Variables150717 +Node: Exit Status154538 +Node: Include Files155215 +Node: Loading Shared Libraries158905 +Node: Obsolete160333 +Node: Undocumented161025 +Node: Invoking Summary161322 +Node: Regexp164163 +Node: Regexp Usage165617 +Node: Escape Sequences167654 +Node: Regexp Operators173895 +Node: Regexp Operator Details174380 +Ref: Regexp Operator Details-Footnote-1181744 +Node: Interval Expressions181891 +Ref: Interval Expressions-Footnote-1183312 +Node: Bracket Expressions183410 +Ref: table-char-classes185886 +Node: Leftmost Longest189212 +Node: Computed Regexps190515 +Node: GNU Regexp Operators193942 +Node: Case-sensitivity197679 +Ref: Case-sensitivity-Footnote-1200545 +Ref: Case-sensitivity-Footnote-2200780 +Node: Regexp Summary200888 +Node: Reading Files202354 +Node: Records204623 +Node: awk split records205698 +Node: gawk split records210398 +Ref: gawk split records-Footnote-1215472 +Node: Fields215509 +Node: Nonconstant Fields218250 +Ref: Nonconstant Fields-Footnote-1220486 +Node: Changing Fields220690 +Node: Field Separators226721 +Node: Default Field Splitting229419 +Node: Regexp Field Splitting230537 +Node: Single Character Fields234214 +Node: Command Line Field Separator235274 +Node: Full Line Fields238492 +Ref: Full Line Fields-Footnote-1240014 +Ref: Full Line Fields-Footnote-2240060 +Node: Field Splitting Summary240161 +Node: Constant Size242235 +Node: Fixed width data242967 +Node: Skipping intervening246434 +Node: Allowing trailing data247232 +Node: Fields with fixed data248269 +Node: Splitting By Content249787 +Ref: Splitting By Content-Footnote-1253570 +Node: More CSV253733 +Node: Testing field creation255325 +Node: Multiple Line256950 +Node: Getline263227 +Node: Plain Getline265696 +Node: Getline/Variable268269 +Node: Getline/File269420 +Node: Getline/Variable/File270808 +Ref: Getline/Variable/File-Footnote-1272413 +Node: Getline/Pipe272501 +Node: Getline/Variable/Pipe275205 +Node: Getline/Coprocess276340 +Node: Getline/Variable/Coprocess277607 +Node: Getline Notes278349 +Node: Getline Summary281146 +Ref: table-getline-variants281570 +Node: Read Timeout282318 +Ref: Read Timeout-Footnote-1286224 +Node: Retrying Input286282 +Node: Command-line directories287481 +Node: Input Summary288387 +Node: Input Exercises291559 +Node: Printing291993 +Node: Print293827 +Node: Print Examples295284 +Node: Output Separators298064 +Node: OFMT300081 +Node: Printf301437 +Node: Basic Printf302222 +Node: Control Letters303796 +Node: Format Modifiers308960 +Node: Printf Examples314975 +Node: Redirection317461 +Node: Special FD324302 +Ref: Special FD-Footnote-1327470 +Node: Special Files327544 +Node: Other Inherited Files328161 +Node: Special Network329162 +Node: Special Caveats330022 +Node: Close Files And Pipes330971 +Ref: table-close-pipe-return-values337878 +Ref: Close Files And Pipes-Footnote-1338691 +Ref: Close Files And Pipes-Footnote-2338839 +Node: Nonfatal338991 +Node: Output Summary341329 +Node: Output Exercises342551 +Node: Expressions343230 +Node: Values344418 +Node: Constants345096 +Node: Scalar Constants345787 +Ref: Scalar Constants-Footnote-1348297 +Node: Nondecimal-numbers348547 +Node: Regexp Constants351548 +Node: Using Constant Regexps352074 +Node: Standard Regexp Constants352696 +Node: Strong Regexp Constants355884 +Node: Variables358896 +Node: Using Variables359553 +Node: Assignment Options361463 +Node: Conversion363934 +Node: Strings And Numbers364458 +Ref: Strings And Numbers-Footnote-1367521 +Node: Locale influences conversions367630 +Ref: table-locale-affects370388 +Node: All Operators371006 +Node: Arithmetic Ops371635 +Node: Concatenation374351 +Ref: Concatenation-Footnote-1377198 +Node: Assignment Ops377305 +Ref: table-assign-ops382296 +Node: Increment Ops383609 +Node: Truth Values and Conditions387069 +Node: Truth Values388143 +Node: Typing and Comparison389191 +Node: Variable Typing390011 +Ref: Variable Typing-Footnote-1396474 +Ref: Variable Typing-Footnote-2396546 +Node: Comparison Operators396623 +Ref: table-relational-ops397042 +Node: POSIX String Comparison400537 +Ref: POSIX String Comparison-Footnote-1402232 +Ref: POSIX String Comparison-Footnote-2402371 +Node: Boolean Ops402455 +Ref: Boolean Ops-Footnote-1406937 +Node: Conditional Exp407029 +Node: Function Calls408765 +Node: Precedence412642 +Node: Locales416301 +Node: Expressions Summary417933 +Node: Patterns and Actions420506 +Node: Pattern Overview421626 +Node: Regexp Patterns423303 +Node: Expression Patterns423845 +Node: Ranges427626 +Node: BEGIN/END430734 +Node: Using BEGIN/END431495 +Ref: Using BEGIN/END-Footnote-1434249 +Node: I/O And BEGIN/END434355 +Node: BEGINFILE/ENDFILE436668 +Node: Empty439899 +Node: Using Shell Variables440216 +Node: Action Overview442490 +Node: Statements444815 +Node: If Statement446663 +Node: While Statement448158 +Node: Do Statement450186 +Node: For Statement451334 +Node: Switch Statement454505 +Node: Break Statement456946 +Node: Continue Statement459038 +Node: Next Statement460865 +Node: Nextfile Statement463248 +Node: Exit Statement465937 +Node: Built-in Variables468340 +Node: User-modified469473 +Node: Auto-set477240 +Ref: Auto-set-Footnote-1494047 +Ref: Auto-set-Footnote-2494253 +Node: ARGC and ARGV494309 +Node: Pattern Action Summary498522 +Node: Arrays500952 +Node: Array Basics502281 +Node: Array Intro503125 +Ref: figure-array-elements505100 +Ref: Array Intro-Footnote-1507804 +Node: Reference to Elements507932 +Node: Assigning Elements510396 +Node: Array Example510887 +Node: Scanning an Array512646 +Node: Controlling Scanning515668 +Ref: Controlling Scanning-Footnote-1522124 +Node: Numeric Array Subscripts522440 +Node: Uninitialized Subscripts524624 +Node: Delete526243 +Ref: Delete-Footnote-1528995 +Node: Multidimensional529052 +Node: Multiscanning532147 +Node: Arrays of Arrays533738 +Node: Arrays Summary538506 +Node: Functions540599 +Node: Built-in541637 +Node: Calling Built-in542718 +Node: Numeric Functions544714 +Ref: Numeric Functions-Footnote-1548742 +Ref: Numeric Functions-Footnote-2549390 +Ref: Numeric Functions-Footnote-3549438 +Node: String Functions549710 +Ref: String Functions-Footnote-1573851 +Ref: String Functions-Footnote-2573979 +Ref: String Functions-Footnote-3574227 +Node: Gory Details574314 +Ref: table-sub-escapes576105 +Ref: table-sub-proposed577624 +Ref: table-posix-sub578987 +Ref: table-gensub-escapes580528 +Ref: Gory Details-Footnote-1581351 +Node: I/O Functions581505 +Ref: table-system-return-values587959 +Ref: I/O Functions-Footnote-1590039 +Ref: I/O Functions-Footnote-2590187 +Node: Time Functions590307 +Ref: Time Functions-Footnote-1600978 +Ref: Time Functions-Footnote-2601046 +Ref: Time Functions-Footnote-3601204 +Ref: Time Functions-Footnote-4601315 +Ref: Time Functions-Footnote-5601427 +Ref: Time Functions-Footnote-6601654 +Node: Bitwise Functions601920 +Ref: table-bitwise-ops602514 +Ref: Bitwise Functions-Footnote-1608577 +Ref: Bitwise Functions-Footnote-2608750 +Node: Type Functions608941 +Node: I18N Functions611804 +Node: User-defined613455 +Node: Definition Syntax614267 +Ref: Definition Syntax-Footnote-1619961 +Node: Function Example620032 +Ref: Function Example-Footnote-1622954 +Node: Function Calling622976 +Node: Calling A Function623564 +Node: Variable Scope624522 +Node: Pass By Value/Reference627516 +Node: Function Caveats630160 +Ref: Function Caveats-Footnote-1632207 +Node: Return Statement632327 +Node: Dynamic Typing635306 +Node: Indirect Calls636236 +Ref: Indirect Calls-Footnote-1646488 +Node: Functions Summary646616 +Node: Library Functions649321 +Ref: Library Functions-Footnote-1652928 +Ref: Library Functions-Footnote-2653071 +Node: Library Names653242 +Ref: Library Names-Footnote-1656909 +Ref: Library Names-Footnote-2657132 +Node: General Functions657218 +Node: Strtonum Function658400 +Node: Assert Function661422 +Node: Round Function664748 +Node: Cliff Random Function666288 +Node: Ordinal Functions667304 +Ref: Ordinal Functions-Footnote-1670367 +Ref: Ordinal Functions-Footnote-2670619 +Node: Join Function670829 +Ref: Join Function-Footnote-1672599 +Node: Getlocaltime Function672799 +Node: Readfile Function676541 +Node: Shell Quoting678518 +Node: Isnumeric Function679946 +Node: Data File Management680688 +Node: Filetrans Function681320 +Node: Rewind Function685416 +Node: File Checking687325 +Ref: File Checking-Footnote-1688659 +Node: Empty Files688860 +Node: Ignoring Assigns690839 +Node: Getopt Function692389 +Ref: Getopt Function-Footnote-1707600 +Node: Passwd Functions707800 +Ref: Passwd Functions-Footnote-1716639 +Node: Group Functions716727 +Ref: Group Functions-Footnote-1724625 +Node: Walking Arrays724832 +Node: Library Functions Summary727840 +Node: Library Exercises729246 +Node: Sample Programs729711 +Node: Running Examples730481 +Node: Clones731209 +Node: Cut Program732433 +Node: Egrep Program742573 +Node: Id Program751574 +Node: Split Program761521 +Ref: Split Program-Footnote-1771411 +Node: Tee Program771584 +Node: Uniq Program774374 +Node: Wc Program781962 +Node: Bytes vs. Characters782349 +Node: Using extensions783897 +Node: wc program784651 +Node: Miscellaneous Programs789516 +Node: Dupword Program790729 +Node: Alarm Program792759 +Node: Translate Program797614 +Ref: Translate Program-Footnote-1802179 +Node: Labels Program802449 +Ref: Labels Program-Footnote-1805800 +Node: Word Sorting805884 +Node: History Sorting809956 +Node: Extract Program812181 +Node: Simple Sed820235 +Node: Igawk Program823309 +Ref: Igawk Program-Footnote-1837640 +Ref: Igawk Program-Footnote-2837842 +Ref: Igawk Program-Footnote-3837964 +Node: Anagram Program838079 +Node: Signature Program841141 +Node: Programs Summary842388 +Node: Programs Exercises843602 +Ref: Programs Exercises-Footnote-1847732 +Node: Advanced Features847818 +Node: Nondecimal Data849885 +Node: Array Sorting851476 +Node: Controlling Array Traversal852176 +Ref: Controlling Array Traversal-Footnote-1860544 +Node: Array Sorting Functions860662 +Ref: Array Sorting Functions-Footnote-1865753 +Node: Two-way I/O865949 +Ref: Two-way I/O-Footnote-1873670 +Ref: Two-way I/O-Footnote-2873857 +Node: TCP/IP Networking873939 +Node: Profiling877057 +Node: Extension Philosophy886366 +Node: Advanced Features Summary887845 +Node: Internationalization889860 +Node: I18N and L10N891534 +Node: Explaining gettext892221 +Ref: Explaining gettext-Footnote-1898113 +Ref: Explaining gettext-Footnote-2898298 +Node: Programmer i18n898463 +Ref: Programmer i18n-Footnote-1903412 +Node: Translator i18n903461 +Node: String Extraction904255 +Ref: String Extraction-Footnote-1905387 +Node: Printf Ordering905473 +Ref: Printf Ordering-Footnote-1908259 +Node: I18N Portability908323 +Ref: I18N Portability-Footnote-1910779 +Node: I18N Example910842 +Ref: I18N Example-Footnote-1914117 +Ref: I18N Example-Footnote-2914190 +Node: Gawk I18N914299 +Node: I18N Summary914948 +Node: Debugger916289 +Node: Debugging917289 +Node: Debugging Concepts917730 +Node: Debugging Terms919539 +Node: Awk Debugging922114 +Ref: Awk Debugging-Footnote-1923059 +Node: Sample Debugging Session923191 +Node: Debugger Invocation923725 +Node: Finding The Bug925111 +Node: List of Debugger Commands931585 +Node: Breakpoint Control932918 +Node: Debugger Execution Control936612 +Node: Viewing And Changing Data939974 +Node: Execution Stack943515 +Node: Debugger Info945152 +Node: Miscellaneous Debugger Commands949223 +Node: Readline Support954285 +Node: Limitations955181 +Node: Debugging Summary957735 +Node: Namespaces959014 +Node: Global Namespace960125 +Node: Qualified Names961523 +Node: Default Namespace962522 +Node: Changing The Namespace963263 +Node: Naming Rules964877 +Node: Internal Name Management966725 +Node: Namespace Example967767 +Node: Namespace And Features970329 +Node: Namespace Summary971764 +Node: Arbitrary Precision Arithmetic973241 +Node: Computer Arithmetic974728 +Ref: table-numeric-ranges978494 +Ref: table-floating-point-ranges978987 +Ref: Computer Arithmetic-Footnote-1979645 +Node: Math Definitions979702 +Ref: table-ieee-formats983018 +Ref: Math Definitions-Footnote-1983621 +Node: MPFR features983726 +Node: FP Math Caution985444 +Ref: FP Math Caution-Footnote-1986516 +Node: Inexactness of computations986885 +Node: Inexact representation987845 +Node: Comparing FP Values989205 +Node: Errors accumulate990446 +Node: Getting Accuracy991879 +Node: Try To Round994589 +Node: Setting precision995488 +Ref: table-predefined-precision-strings996185 +Node: Setting the rounding mode998015 +Ref: table-gawk-rounding-modes998389 +Ref: Setting the rounding mode-Footnote-11002320 +Node: Arbitrary Precision Integers1002499 +Ref: Arbitrary Precision Integers-Footnote-11005674 +Node: Checking for MPFR1005823 +Node: POSIX Floating Point Problems1007297 +Ref: POSIX Floating Point Problems-Footnote-11011582 +Node: Floating point summary1011620 +Node: Dynamic Extensions1013810 +Node: Extension Intro1015363 +Node: Plugin License1016629 +Node: Extension Mechanism Outline1017426 +Ref: figure-load-extension1017865 +Ref: figure-register-new-function1019430 +Ref: figure-call-new-function1020522 +Node: Extension API Description1022584 +Node: Extension API Functions Introduction1024297 +Ref: table-api-std-headers1026133 +Node: General Data Types1030382 +Ref: General Data Types-Footnote-11039012 +Node: Memory Allocation Functions1039311 +Ref: Memory Allocation Functions-Footnote-11043812 +Node: Constructor Functions1043911 +Node: API Ownership of MPFR and GMP Values1047377 +Node: Registration Functions1048690 +Node: Extension Functions1049390 +Node: Exit Callback Functions1054712 +Node: Extension Version String1055962 +Node: Input Parsers1056625 +Node: Output Wrappers1069346 +Node: Two-way processors1073858 +Node: Printing Messages1076123 +Ref: Printing Messages-Footnote-11077294 +Node: Updating ERRNO1077447 +Node: Requesting Values1078186 +Ref: table-value-types-returned1078923 +Node: Accessing Parameters1079859 +Node: Symbol Table Access1081096 +Node: Symbol table by name1081608 +Ref: Symbol table by name-Footnote-11084632 +Node: Symbol table by cookie1084760 +Ref: Symbol table by cookie-Footnote-11088945 +Node: Cached values1089009 +Ref: Cached values-Footnote-11092545 +Node: Array Manipulation1092698 +Ref: Array Manipulation-Footnote-11093789 +Node: Array Data Types1093826 +Ref: Array Data Types-Footnote-11096484 +Node: Array Functions1096576 +Node: Flattening Arrays1101074 +Node: Creating Arrays1108050 +Node: Redirection API1112817 +Node: Extension API Variables1115650 +Node: Extension Versioning1116361 +Ref: gawk-api-version1116790 +Node: Extension GMP/MPFR Versioning1118521 +Node: Extension API Informational Variables1120149 +Node: Extension API Boilerplate1121222 +Node: Changes from API V11125196 +Node: Finding Extensions1126768 +Node: Extension Example1127327 +Node: Internal File Description1128125 +Node: Internal File Ops1132205 +Ref: Internal File Ops-Footnote-11143555 +Node: Using Internal File Ops1143695 +Ref: Using Internal File Ops-Footnote-11146078 +Node: Extension Samples1146352 +Node: Extension Sample File Functions1147881 +Node: Extension Sample Fnmatch1155530 +Node: Extension Sample Fork1157017 +Node: Extension Sample Inplace1158235 +Node: Extension Sample Ord1161861 +Node: Extension Sample Readdir1162697 +Ref: table-readdir-file-types1163586 +Node: Extension Sample Revout1164653 +Node: Extension Sample Rev2way1165242 +Node: Extension Sample Read write array1165982 +Node: Extension Sample Readfile1167924 +Node: Extension Sample Time1169019 +Node: Extension Sample API Tests1170771 +Node: gawkextlib1171263 +Node: Extension summary1174181 +Node: Extension Exercises1177883 +Node: Language History1179125 +Node: V7/SVR3.11180781 +Node: SVR41182933 +Node: POSIX1184367 +Node: BTL1185748 +Node: POSIX/GNU1186477 +Node: Feature History1192255 +Node: Common Extensions1209430 +Node: Ranges and Locales1210713 +Ref: Ranges and Locales-Footnote-11215329 +Ref: Ranges and Locales-Footnote-21215356 +Ref: Ranges and Locales-Footnote-31215591 +Node: Contributors1215814 +Node: History summary1221811 +Node: Installation1223191 +Node: Gawk Distribution1224135 +Node: Getting1224619 +Node: Extracting1225582 +Node: Distribution contents1227220 +Node: Unix Installation1233700 +Node: Quick Installation1234382 +Node: Compiling with MPFR1236863 +Node: Shell Startup Files1237555 +Node: Additional Configuration Options1238644 +Node: Configuration Philosophy1240959 +Node: Non-Unix Installation1243328 +Node: PC Installation1243788 +Node: PC Binary Installation1244626 +Node: PC Compiling1245061 +Node: PC Using1246178 +Node: Cygwin1249731 +Node: MSYS1250955 +Node: VMS Installation1251557 +Node: VMS Compilation1252348 +Ref: VMS Compilation-Footnote-11253577 +Node: VMS Dynamic Extensions1253635 +Node: VMS Installation Details1255320 +Node: VMS Running1257573 +Node: VMS GNV1261852 +Node: VMS Old Gawk1262587 +Node: Bugs1263058 +Node: Bug address1263807 +Node: Usenet1266789 +Node: Performance bugs1267798 +Node: Maintainers1270655 +Node: Other Versions1271850 +Node: Installation summary1279715 +Node: Notes1280924 +Node: Compatibility Mode1281718 +Node: Additions1282500 +Node: Accessing The Source1283425 +Node: Adding Code1284862 +Node: New Ports1291081 +Node: Derived Files1295456 +Ref: Derived Files-Footnote-11301116 +Ref: Derived Files-Footnote-21301151 +Ref: Derived Files-Footnote-31301749 +Node: Future Extensions1301863 +Node: Implementation Limitations1302521 +Node: Extension Design1303731 +Node: Old Extension Problems1304875 +Ref: Old Extension Problems-Footnote-11306393 +Node: Extension New Mechanism Goals1306450 +Ref: Extension New Mechanism Goals-Footnote-11309814 +Node: Extension Other Design Decisions1310003 +Node: Extension Future Growth1312116 +Node: Notes summary1312722 +Node: Basic Concepts1313880 +Node: Basic High Level1314561 +Ref: figure-general-flow1314843 +Ref: figure-process-flow1315528 +Ref: Basic High Level-Footnote-11318829 +Node: Basic Data Typing1319014 +Node: Glossary1322342 +Node: Copying1354227 +Node: GNU Free Documentation License1391770 +Node: Index1416890 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 2478cf98..fb71bb68 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -808,6 +808,8 @@ particular records in a file and perform operations upon them. once. * Shell Quoting:: A function to quote strings for the shell. +* Isnumeric Function:: A function to test whether a value + is numeric. * Data File Management:: Functions for managing command-line data files. * Filetrans Function:: A function for handling data file @@ -22462,6 +22464,7 @@ programming use. * Getlocaltime Function:: A function to get formatted times. * Readfile Function:: A function to read an entire file at once. * Shell Quoting:: A function to quote strings for the shell. +* Isnumeric Function:: A function to test whether a value is numeric. @end menu @node Strtonum Function @@ -23252,6 +23255,35 @@ function shell_quote(s, # parameter @c endfile @end example +@node Isnumeric Function +@subsection Checking whether a value is numeric + +A frequent programming question is how to ascertain whether a value is numeric. +This can be solved by using this example function @code{isnumeric()}, which +employs the trick of converting a string value to user input by using the +@code{split()} function: + +@cindex @code{isnumeric()} user-defined function +@cindex user-defined @subentry function @subentry @code{isnumeric()} +@example +@c file eg/lib/isnumeric.awk +# isnumeric --- check whether a value is numeric + +function isnumeric(x, f) +@{ + switch (typeof(x)) @{ + case "strnum": + case "number": + return 1 + case "string": + return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum") + default: + return 0 + @} +@} +@c endfile +@end example + @node Data File Management @section @value{DDF} Management diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 37ecbc9f..81a24079 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -803,6 +803,8 @@ particular records in a file and perform operations upon them. once. * Shell Quoting:: A function to quote strings for the shell. +* Isnumeric Function:: A function to test whether a value + is numeric. * Data File Management:: Functions for managing command-line data files. * Filetrans Function:: A function for handling data file @@ -21374,6 +21376,7 @@ programming use. * Getlocaltime Function:: A function to get formatted times. * Readfile Function:: A function to read an entire file at once. * Shell Quoting:: A function to quote strings for the shell. +* Isnumeric Function:: A function to test whether a value is numeric. @end menu @node Strtonum Function @@ -22164,6 +22167,35 @@ function shell_quote(s, # parameter @c endfile @end example +@node Isnumeric Function +@subsection Checking whether a value is numeric + +A frequent programming question is how to ascertain whether a value is numeric. +This can be solved by using this example function @code{isnumeric()}, which +employs the trick of converting a string value to user input by using the +@code{split()} function: + +@cindex @code{isnumeric()} user-defined function +@cindex user-defined @subentry function @subentry @code{isnumeric()} +@example +@c file eg/lib/isnumeric.awk +# isnumeric --- check whether a value is numeric + +function isnumeric(x, f) +@{ + switch (typeof(x)) @{ + case "strnum": + case "number": + return 1 + case "string": + return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum") + default: + return 0 + @} +@} +@c endfile +@end example + @node Data File Management @section @value{DDF} Management |