diff options
-rw-r--r-- | doc/ChangeLog | 7 | ||||
-rw-r--r-- | doc/gawk.info | 1111 | ||||
-rw-r--r-- | doc/gawk.texi | 94 | ||||
-rw-r--r-- | doc/gawktexi.in | 40 |
4 files changed, 716 insertions, 536 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 3dd82e08..34a0b68c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,10 @@ +2021-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (Regexp Operator Details): Added a sidebar on + matching the empty regexp. Thanks to Arkadiusz Drabczyk + <arkadiusz@drabczyk.org> for pointing out the lack of + documentation. + 2021-03-21 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in (Other Environment Variables): Document "fnv1a" diff --git a/doc/gawk.info b/doc/gawk.info index 445d06dd..76ecc3c5 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -3911,6 +3911,39 @@ themselves when there is nothing in the regexp that precedes them. For example, '/+/' matches a literal plus sign. However, many other versions of 'awk' treat such a usage as a syntax error. + What About The Empty Regexp? + + We describe here an advanced regexp usage. Feel free to skip it upon +first reading. + + You can supply an empty regexp constant ('//') in all places where a +regexp is expected. Is this useful? What does it match? + + It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string between +characters. This is best illustrated with the 'gsub()' function, which +makes global substitutions in a string (*note String Functions::). +Normal usage of 'gsub()' is like so: + + $ awk ' + > BEGIN { + > x = "ABC_CBA" + > gsub(/B/, "bb", x) + > print x + > }' + -| AbbC_CbbA + + We can use 'gsub()' to see where the empty strings are that match the +empty regexp: + + $ awk ' + > BEGIN { + > x = "ABC" + > gsub(//, "x", x) + > print x + > }' + -| xAxBxCx + ---------- Footnotes ---------- (1) In other literature, you may see a bracket expression referred to @@ -35942,6 +35975,8 @@ Index * empty array elements: Reference to Elements. (line 18) * empty pattern: Empty. (line 6) +* empty regexps: Regexp Operator Details. + (line 149) * EMRED: TCP/IP Networking. (line 6) * enable breakpoint: Breakpoint Control. (line 73) * enable debugger command: Breakpoint Control. (line 73) @@ -37393,6 +37428,8 @@ Index * regexp constants <2>: Comparison Operators. (line 103) * regexp constants, as patterns: Expression Patterns. (line 34) +* regexps, empty: Regexp Operator Details. + (line 149) * register loadable extension: Registration Functions. (line 6) * regular expressions, interval expressions and: Options. (line 317) @@ -37604,6 +37641,8 @@ Index (line 106) * sidebar, Escape Sequences for Metacharacters: Escape Sequences. (line 138) +* sidebar, What About The Empty Regexp?: Regexp Operator Details. + (line 147) * sidebar, Using \n in Bracket Expressions of Dynamic Regexps: Computed Regexps. (line 58) * sidebar, Caveats When Using Regular Expressions for RS: gawk split records. @@ -38135,542 +38174,542 @@ Node: Regexp Usage165325 Node: Escape Sequences167362 Node: Regexp Operators173603 Node: Regexp Operator Details174088 -Ref: Regexp Operator Details-Footnote-1180520 -Node: Interval Expressions180667 -Ref: Interval Expressions-Footnote-1182088 -Node: Bracket Expressions182186 -Ref: table-char-classes184662 -Node: Leftmost Longest187988 -Node: Computed Regexps189291 -Node: GNU Regexp Operators192718 -Node: Case-sensitivity196455 -Ref: Case-sensitivity-Footnote-1199321 -Ref: Case-sensitivity-Footnote-2199556 -Node: Regexp Summary199664 -Node: Reading Files201130 -Node: Records203399 -Node: awk split records204474 -Node: gawk split records209174 -Ref: gawk split records-Footnote-1214248 -Node: Fields214285 -Node: Nonconstant Fields217026 -Ref: Nonconstant Fields-Footnote-1219262 -Node: Changing Fields219466 -Node: Field Separators225497 -Node: Default Field Splitting228195 -Node: Regexp Field Splitting229313 -Node: Single Character Fields232990 -Node: Command Line Field Separator234050 -Node: Full Line Fields237268 -Ref: Full Line Fields-Footnote-1238790 -Ref: Full Line Fields-Footnote-2238836 -Node: Field Splitting Summary238937 -Node: Constant Size241011 -Node: Fixed width data241743 -Node: Skipping intervening245210 -Node: Allowing trailing data246008 -Node: Fields with fixed data247045 -Node: Splitting By Content248563 -Ref: Splitting By Content-Footnote-1252346 -Node: More CSV252509 -Node: Testing field creation254101 -Node: Multiple Line255726 -Node: Getline262003 -Node: Plain Getline264472 -Node: Getline/Variable267045 -Node: Getline/File268196 -Node: Getline/Variable/File269584 -Ref: Getline/Variable/File-Footnote-1271189 -Node: Getline/Pipe271277 -Node: Getline/Variable/Pipe273981 -Node: Getline/Coprocess275116 -Node: Getline/Variable/Coprocess276383 -Node: Getline Notes277125 -Node: Getline Summary279922 -Ref: table-getline-variants280346 -Node: Read Timeout281094 -Ref: Read Timeout-Footnote-1285000 -Node: Retrying Input285058 -Node: Command-line directories286257 -Node: Input Summary287163 -Node: Input Exercises290335 -Node: Printing290769 -Node: Print292603 -Node: Print Examples294060 -Node: Output Separators296840 -Node: OFMT298857 -Node: Printf300213 -Node: Basic Printf300998 -Node: Control Letters302572 -Node: Format Modifiers307734 -Node: Printf Examples313749 -Node: Redirection316235 -Node: Special FD323076 -Ref: Special FD-Footnote-1326244 -Node: Special Files326318 -Node: Other Inherited Files326935 -Node: Special Network327936 -Node: Special Caveats328796 -Node: Close Files And Pipes329745 -Ref: table-close-pipe-return-values336652 -Ref: Close Files And Pipes-Footnote-1337465 -Ref: Close Files And Pipes-Footnote-2337613 -Node: Nonfatal337765 -Node: Output Summary340103 -Node: Output Exercises341325 -Node: Expressions342004 -Node: Values343192 -Node: Constants343870 -Node: Scalar Constants344561 -Ref: Scalar Constants-Footnote-1347071 -Node: Nondecimal-numbers347321 -Node: Regexp Constants350322 -Node: Using Constant Regexps350848 -Node: Standard Regexp Constants351470 -Node: Strong Regexp Constants354658 -Node: Variables357670 -Node: Using Variables358327 -Node: Assignment Options360237 -Node: Conversion362708 -Node: Strings And Numbers363232 -Ref: Strings And Numbers-Footnote-1366295 -Node: Locale influences conversions366404 -Ref: table-locale-affects369162 -Node: All Operators369780 -Node: Arithmetic Ops370409 -Node: Concatenation373125 -Ref: Concatenation-Footnote-1375972 -Node: Assignment Ops376079 -Ref: table-assign-ops381070 -Node: Increment Ops382383 -Node: Truth Values and Conditions385843 -Node: Truth Values386917 -Node: Typing and Comparison387965 -Node: Variable Typing388785 -Ref: Variable Typing-Footnote-1395248 -Ref: Variable Typing-Footnote-2395320 -Node: Comparison Operators395397 -Ref: table-relational-ops395816 -Node: POSIX String Comparison399311 -Ref: POSIX String Comparison-Footnote-1401006 -Ref: POSIX String Comparison-Footnote-2401145 -Node: Boolean Ops401229 -Ref: Boolean Ops-Footnote-1405711 -Node: Conditional Exp405803 -Node: Function Calls407539 -Node: Precedence411416 -Node: Locales415075 -Node: Expressions Summary416707 -Node: Patterns and Actions419280 -Node: Pattern Overview420400 -Node: Regexp Patterns422077 -Node: Expression Patterns422619 -Node: Ranges426400 -Node: BEGIN/END429508 -Node: Using BEGIN/END430269 -Ref: Using BEGIN/END-Footnote-1433023 -Node: I/O And BEGIN/END433129 -Node: BEGINFILE/ENDFILE435442 -Node: Empty438673 -Node: Using Shell Variables438990 -Node: Action Overview441264 -Node: Statements443589 -Node: If Statement445437 -Node: While Statement446932 -Node: Do Statement448960 -Node: For Statement450108 -Node: Switch Statement453279 -Node: Break Statement455720 -Node: Continue Statement457812 -Node: Next Statement459639 -Node: Nextfile Statement462022 -Node: Exit Statement464711 -Node: Built-in Variables467114 -Node: User-modified468247 -Node: Auto-set476014 -Ref: Auto-set-Footnote-1492821 -Ref: Auto-set-Footnote-2493027 -Node: ARGC and ARGV493083 -Node: Pattern Action Summary497296 -Node: Arrays499726 -Node: Array Basics501055 -Node: Array Intro501899 -Ref: figure-array-elements503874 -Ref: Array Intro-Footnote-1506578 -Node: Reference to Elements506706 -Node: Assigning Elements509170 -Node: Array Example509661 -Node: Scanning an Array511420 -Node: Controlling Scanning514442 -Ref: Controlling Scanning-Footnote-1520898 -Node: Numeric Array Subscripts521214 -Node: Uninitialized Subscripts523398 -Node: Delete525017 -Ref: Delete-Footnote-1527769 -Node: Multidimensional527826 -Node: Multiscanning530921 -Node: Arrays of Arrays532512 -Node: Arrays Summary537280 -Node: Functions539373 -Node: Built-in540411 -Node: Calling Built-in541492 -Node: Numeric Functions543488 -Ref: Numeric Functions-Footnote-1547514 -Ref: Numeric Functions-Footnote-2548162 -Ref: Numeric Functions-Footnote-3548210 -Node: String Functions548482 -Ref: String Functions-Footnote-1572623 -Ref: String Functions-Footnote-2572751 -Ref: String Functions-Footnote-3572999 -Node: Gory Details573086 -Ref: table-sub-escapes574877 -Ref: table-sub-proposed576396 -Ref: table-posix-sub577759 -Ref: table-gensub-escapes579300 -Ref: Gory Details-Footnote-1580123 -Node: I/O Functions580277 -Ref: table-system-return-values586731 -Ref: I/O Functions-Footnote-1588811 -Ref: I/O Functions-Footnote-2588959 -Node: Time Functions589079 -Ref: Time Functions-Footnote-1599750 -Ref: Time Functions-Footnote-2599818 -Ref: Time Functions-Footnote-3599976 -Ref: Time Functions-Footnote-4600087 -Ref: Time Functions-Footnote-5600199 -Ref: Time Functions-Footnote-6600426 -Node: Bitwise Functions600692 -Ref: table-bitwise-ops601286 -Ref: Bitwise Functions-Footnote-1607349 -Ref: Bitwise Functions-Footnote-2607522 -Node: Type Functions607713 -Node: I18N Functions610576 -Node: User-defined612227 -Node: Definition Syntax613039 -Ref: Definition Syntax-Footnote-1618733 -Node: Function Example618804 -Ref: Function Example-Footnote-1621726 -Node: Function Calling621748 -Node: Calling A Function622336 -Node: Variable Scope623294 -Node: Pass By Value/Reference626288 -Node: Function Caveats628932 -Ref: Function Caveats-Footnote-1630979 -Node: Return Statement631099 -Node: Dynamic Typing634078 -Node: Indirect Calls635008 -Ref: Indirect Calls-Footnote-1645260 -Node: Functions Summary645388 -Node: Library Functions648093 -Ref: Library Functions-Footnote-1651700 -Ref: Library Functions-Footnote-2651843 -Node: Library Names652014 -Ref: Library Names-Footnote-1655681 -Ref: Library Names-Footnote-2655904 -Node: General Functions655990 -Node: Strtonum Function657093 -Node: Assert Function660115 -Node: Round Function663441 -Node: Cliff Random Function664981 -Node: Ordinal Functions665997 -Ref: Ordinal Functions-Footnote-1669060 -Ref: Ordinal Functions-Footnote-2669312 -Node: Join Function669522 -Ref: Join Function-Footnote-1671292 -Node: Getlocaltime Function671492 -Node: Readfile Function675234 -Node: Shell Quoting677211 -Node: Data File Management678612 -Node: Filetrans Function679244 -Node: Rewind Function683340 -Node: File Checking685249 -Ref: File Checking-Footnote-1686583 -Node: Empty Files686784 -Node: Ignoring Assigns688763 -Node: Getopt Function690313 -Ref: Getopt Function-Footnote-1705524 -Node: Passwd Functions705724 -Ref: Passwd Functions-Footnote-1714563 -Node: Group Functions714651 -Ref: Group Functions-Footnote-1722549 -Node: Walking Arrays722756 -Node: Library Functions Summary725764 -Node: Library Exercises727170 -Node: Sample Programs727635 -Node: Running Examples728405 -Node: Clones729133 -Node: Cut Program730357 -Node: Egrep Program740497 -Node: Id Program749498 -Node: Split Program759445 -Ref: Split Program-Footnote-1769335 -Node: Tee Program769508 -Node: Uniq Program772298 -Node: Wc Program779886 -Node: Bytes vs. Characters780283 -Node: Using extensions781831 -Node: wc program782585 -Node: Miscellaneous Programs787450 -Node: Dupword Program788663 -Node: Alarm Program790693 -Node: Translate Program795548 -Ref: Translate Program-Footnote-1800113 -Node: Labels Program800383 -Ref: Labels Program-Footnote-1803734 -Node: Word Sorting803818 -Node: History Sorting807890 -Node: Extract Program810115 -Node: Simple Sed818169 -Node: Igawk Program821243 -Ref: Igawk Program-Footnote-1835574 -Ref: Igawk Program-Footnote-2835776 -Ref: Igawk Program-Footnote-3835898 -Node: Anagram Program836013 -Node: Signature Program839075 -Node: Programs Summary840322 -Node: Programs Exercises841536 -Ref: Programs Exercises-Footnote-1845666 -Node: Advanced Features845752 -Node: Nondecimal Data847819 -Node: Array Sorting849410 -Node: Controlling Array Traversal850110 -Ref: Controlling Array Traversal-Footnote-1858478 -Node: Array Sorting Functions858596 -Ref: Array Sorting Functions-Footnote-1863687 -Node: Two-way I/O863883 -Ref: Two-way I/O-Footnote-1871604 -Ref: Two-way I/O-Footnote-2871791 -Node: TCP/IP Networking871873 -Node: Profiling874991 -Node: Extension Philosophy884300 -Node: Advanced Features Summary885779 -Node: Internationalization887794 -Node: I18N and L10N889274 -Node: Explaining gettext889961 -Ref: Explaining gettext-Footnote-1895853 -Ref: Explaining gettext-Footnote-2896038 -Node: Programmer i18n896203 -Ref: Programmer i18n-Footnote-1901152 -Node: Translator i18n901201 -Node: String Extraction901995 -Ref: String Extraction-Footnote-1903127 -Node: Printf Ordering903213 -Ref: Printf Ordering-Footnote-1905999 -Node: I18N Portability906063 -Ref: I18N Portability-Footnote-1908519 -Node: I18N Example908582 -Ref: I18N Example-Footnote-1911857 -Ref: I18N Example-Footnote-2911930 -Node: Gawk I18N912039 -Node: I18N Summary912688 -Node: Debugger914029 -Node: Debugging915029 -Node: Debugging Concepts915470 -Node: Debugging Terms917279 -Node: Awk Debugging919854 -Ref: Awk Debugging-Footnote-1920799 -Node: Sample Debugging Session920931 -Node: Debugger Invocation921465 -Node: Finding The Bug922851 -Node: List of Debugger Commands929325 -Node: Breakpoint Control930658 -Node: Debugger Execution Control934352 -Node: Viewing And Changing Data937714 -Node: Execution Stack941255 -Node: Debugger Info942892 -Node: Miscellaneous Debugger Commands946963 -Node: Readline Support952025 -Node: Limitations952921 -Node: Debugging Summary955475 -Node: Namespaces956754 -Node: Global Namespace957865 -Node: Qualified Names959263 -Node: Default Namespace960262 -Node: Changing The Namespace961003 -Node: Naming Rules962617 -Node: Internal Name Management964465 -Node: Namespace Example965507 -Node: Namespace And Features968069 -Node: Namespace Summary969504 -Node: Arbitrary Precision Arithmetic970981 -Node: Computer Arithmetic972468 -Ref: table-numeric-ranges976234 -Ref: table-floating-point-ranges976727 -Ref: Computer Arithmetic-Footnote-1977385 -Node: Math Definitions977442 -Ref: table-ieee-formats980418 -Node: MPFR features980985 -Node: FP Math Caution982703 -Ref: FP Math Caution-Footnote-1983775 -Node: Inexactness of computations984144 -Node: Inexact representation985175 -Node: Comparing FP Values986535 -Node: Errors accumulate987776 -Node: Strange values989232 -Ref: Strange values-Footnote-1991820 -Node: Getting Accuracy991925 -Node: Try To Round994635 -Node: Setting precision995534 -Ref: table-predefined-precision-strings996231 -Node: Setting the rounding mode998061 -Ref: table-gawk-rounding-modes998435 -Ref: Setting the rounding mode-Footnote-11002366 -Node: Arbitrary Precision Integers1002545 -Ref: Arbitrary Precision Integers-Footnote-11005720 -Node: Checking for MPFR1005869 -Node: POSIX Floating Point Problems1007343 -Ref: POSIX Floating Point Problems-Footnote-11011628 -Node: Floating point summary1011666 -Node: Dynamic Extensions1013856 -Node: Extension Intro1015409 -Node: Plugin License1016675 -Node: Extension Mechanism Outline1017472 -Ref: figure-load-extension1017911 -Ref: figure-register-new-function1019476 -Ref: figure-call-new-function1020568 -Node: Extension API Description1022630 -Node: Extension API Functions Introduction1024343 -Ref: table-api-std-headers1026179 -Node: General Data Types1030428 -Ref: General Data Types-Footnote-11039058 -Node: Memory Allocation Functions1039357 -Ref: Memory Allocation Functions-Footnote-11043858 -Node: Constructor Functions1043957 -Node: API Ownership of MPFR and GMP Values1047423 -Node: Registration Functions1048736 -Node: Extension Functions1049436 -Node: Exit Callback Functions1054758 -Node: Extension Version String1056008 -Node: Input Parsers1056671 -Node: Output Wrappers1069392 -Node: Two-way processors1073904 -Node: Printing Messages1076169 -Ref: Printing Messages-Footnote-11077340 -Node: Updating ERRNO1077493 -Node: Requesting Values1078232 -Ref: table-value-types-returned1078969 -Node: Accessing Parameters1079905 -Node: Symbol Table Access1081142 -Node: Symbol table by name1081654 -Ref: Symbol table by name-Footnote-11084678 -Node: Symbol table by cookie1084806 -Ref: Symbol table by cookie-Footnote-11088991 -Node: Cached values1089055 -Ref: Cached values-Footnote-11092591 -Node: Array Manipulation1092744 -Ref: Array Manipulation-Footnote-11093835 -Node: Array Data Types1093872 -Ref: Array Data Types-Footnote-11096530 -Node: Array Functions1096622 -Node: Flattening Arrays1101120 -Node: Creating Arrays1108096 -Node: Redirection API1112863 -Node: Extension API Variables1115696 -Node: Extension Versioning1116407 -Ref: gawk-api-version1116836 -Node: Extension GMP/MPFR Versioning1118567 -Node: Extension API Informational Variables1120195 -Node: Extension API Boilerplate1121268 -Node: Changes from API V11125242 -Node: Finding Extensions1126814 -Node: Extension Example1127373 -Node: Internal File Description1128171 -Node: Internal File Ops1132251 -Ref: Internal File Ops-Footnote-11143601 -Node: Using Internal File Ops1143741 -Ref: Using Internal File Ops-Footnote-11146124 -Node: Extension Samples1146398 -Node: Extension Sample File Functions1147927 -Node: Extension Sample Fnmatch1155576 -Node: Extension Sample Fork1157063 -Node: Extension Sample Inplace1158281 -Node: Extension Sample Ord1161907 -Node: Extension Sample Readdir1162743 -Ref: table-readdir-file-types1163632 -Node: Extension Sample Revout1164699 -Node: Extension Sample Rev2way1165288 -Node: Extension Sample Read write array1166028 -Node: Extension Sample Readfile1167970 -Node: Extension Sample Time1169065 -Node: Extension Sample API Tests1170817 -Node: gawkextlib1171309 -Node: Extension summary1174227 -Node: Extension Exercises1177929 -Node: Language History1179171 -Node: V7/SVR3.11180827 -Node: SVR41182979 -Node: POSIX1184413 -Node: BTL1185794 -Node: POSIX/GNU1186523 -Node: Feature History1192301 -Node: Common Extensions1208620 -Node: Ranges and Locales1209903 -Ref: Ranges and Locales-Footnote-11214519 -Ref: Ranges and Locales-Footnote-21214546 -Ref: Ranges and Locales-Footnote-31214781 -Node: Contributors1215004 -Node: History summary1221001 -Node: Installation1222381 -Node: Gawk Distribution1223325 -Node: Getting1223809 -Node: Extracting1224772 -Node: Distribution contents1226410 -Node: Unix Installation1232890 -Node: Quick Installation1233572 -Node: Shell Startup Files1235986 -Node: Additional Configuration Options1237075 -Node: Configuration Philosophy1239390 -Node: Non-Unix Installation1241759 -Node: PC Installation1242219 -Node: PC Binary Installation1243057 -Node: PC Compiling1243492 -Node: PC Using1244609 -Node: Cygwin1248162 -Node: MSYS1249386 -Node: VMS Installation1249988 -Node: VMS Compilation1250779 -Ref: VMS Compilation-Footnote-11252008 -Node: VMS Dynamic Extensions1252066 -Node: VMS Installation Details1253751 -Node: VMS Running1256004 -Node: VMS GNV1260283 -Node: VMS Old Gawk1261018 -Node: Bugs1261489 -Node: Bug address1262152 -Node: Usenet1265134 -Node: Maintainers1266138 -Node: Other Versions1267323 -Node: Installation summary1275188 -Node: Notes1276397 -Node: Compatibility Mode1277191 -Node: Additions1277973 -Node: Accessing The Source1278898 -Node: Adding Code1280335 -Node: New Ports1286554 -Node: Derived Files1290929 -Ref: Derived Files-Footnote-11296589 -Ref: Derived Files-Footnote-21296624 -Ref: Derived Files-Footnote-31297222 -Node: Future Extensions1297336 -Node: Implementation Limitations1297994 -Node: Extension Design1299204 -Node: Old Extension Problems1300348 -Ref: Old Extension Problems-Footnote-11301866 -Node: Extension New Mechanism Goals1301923 -Ref: Extension New Mechanism Goals-Footnote-11305287 -Node: Extension Other Design Decisions1305476 -Node: Extension Future Growth1307589 -Node: Notes summary1308195 -Node: Basic Concepts1309353 -Node: Basic High Level1310034 -Ref: figure-general-flow1310316 -Ref: figure-process-flow1311001 -Ref: Basic High Level-Footnote-11314302 -Node: Basic Data Typing1314487 -Node: Glossary1317815 -Node: Copying1349700 -Node: GNU Free Documentation License1387243 -Node: Index1412363 +Ref: Regexp Operator Details-Footnote-1181452 +Node: Interval Expressions181599 +Ref: Interval Expressions-Footnote-1183020 +Node: Bracket Expressions183118 +Ref: table-char-classes185594 +Node: Leftmost Longest188920 +Node: Computed Regexps190223 +Node: GNU Regexp Operators193650 +Node: Case-sensitivity197387 +Ref: Case-sensitivity-Footnote-1200253 +Ref: Case-sensitivity-Footnote-2200488 +Node: Regexp Summary200596 +Node: Reading Files202062 +Node: Records204331 +Node: awk split records205406 +Node: gawk split records210106 +Ref: gawk split records-Footnote-1215180 +Node: Fields215217 +Node: Nonconstant Fields217958 +Ref: Nonconstant Fields-Footnote-1220194 +Node: Changing Fields220398 +Node: Field Separators226429 +Node: Default Field Splitting229127 +Node: Regexp Field Splitting230245 +Node: Single Character Fields233922 +Node: Command Line Field Separator234982 +Node: Full Line Fields238200 +Ref: Full Line Fields-Footnote-1239722 +Ref: Full Line Fields-Footnote-2239768 +Node: Field Splitting Summary239869 +Node: Constant Size241943 +Node: Fixed width data242675 +Node: Skipping intervening246142 +Node: Allowing trailing data246940 +Node: Fields with fixed data247977 +Node: Splitting By Content249495 +Ref: Splitting By Content-Footnote-1253278 +Node: More CSV253441 +Node: Testing field creation255033 +Node: Multiple Line256658 +Node: Getline262935 +Node: Plain Getline265404 +Node: Getline/Variable267977 +Node: Getline/File269128 +Node: Getline/Variable/File270516 +Ref: Getline/Variable/File-Footnote-1272121 +Node: Getline/Pipe272209 +Node: Getline/Variable/Pipe274913 +Node: Getline/Coprocess276048 +Node: Getline/Variable/Coprocess277315 +Node: Getline Notes278057 +Node: Getline Summary280854 +Ref: table-getline-variants281278 +Node: Read Timeout282026 +Ref: Read Timeout-Footnote-1285932 +Node: Retrying Input285990 +Node: Command-line directories287189 +Node: Input Summary288095 +Node: Input Exercises291267 +Node: Printing291701 +Node: Print293535 +Node: Print Examples294992 +Node: Output Separators297772 +Node: OFMT299789 +Node: Printf301145 +Node: Basic Printf301930 +Node: Control Letters303504 +Node: Format Modifiers308666 +Node: Printf Examples314681 +Node: Redirection317167 +Node: Special FD324008 +Ref: Special FD-Footnote-1327176 +Node: Special Files327250 +Node: Other Inherited Files327867 +Node: Special Network328868 +Node: Special Caveats329728 +Node: Close Files And Pipes330677 +Ref: table-close-pipe-return-values337584 +Ref: Close Files And Pipes-Footnote-1338397 +Ref: Close Files And Pipes-Footnote-2338545 +Node: Nonfatal338697 +Node: Output Summary341035 +Node: Output Exercises342257 +Node: Expressions342936 +Node: Values344124 +Node: Constants344802 +Node: Scalar Constants345493 +Ref: Scalar Constants-Footnote-1348003 +Node: Nondecimal-numbers348253 +Node: Regexp Constants351254 +Node: Using Constant Regexps351780 +Node: Standard Regexp Constants352402 +Node: Strong Regexp Constants355590 +Node: Variables358602 +Node: Using Variables359259 +Node: Assignment Options361169 +Node: Conversion363640 +Node: Strings And Numbers364164 +Ref: Strings And Numbers-Footnote-1367227 +Node: Locale influences conversions367336 +Ref: table-locale-affects370094 +Node: All Operators370712 +Node: Arithmetic Ops371341 +Node: Concatenation374057 +Ref: Concatenation-Footnote-1376904 +Node: Assignment Ops377011 +Ref: table-assign-ops382002 +Node: Increment Ops383315 +Node: Truth Values and Conditions386775 +Node: Truth Values387849 +Node: Typing and Comparison388897 +Node: Variable Typing389717 +Ref: Variable Typing-Footnote-1396180 +Ref: Variable Typing-Footnote-2396252 +Node: Comparison Operators396329 +Ref: table-relational-ops396748 +Node: POSIX String Comparison400243 +Ref: POSIX String Comparison-Footnote-1401938 +Ref: POSIX String Comparison-Footnote-2402077 +Node: Boolean Ops402161 +Ref: Boolean Ops-Footnote-1406643 +Node: Conditional Exp406735 +Node: Function Calls408471 +Node: Precedence412348 +Node: Locales416007 +Node: Expressions Summary417639 +Node: Patterns and Actions420212 +Node: Pattern Overview421332 +Node: Regexp Patterns423009 +Node: Expression Patterns423551 +Node: Ranges427332 +Node: BEGIN/END430440 +Node: Using BEGIN/END431201 +Ref: Using BEGIN/END-Footnote-1433955 +Node: I/O And BEGIN/END434061 +Node: BEGINFILE/ENDFILE436374 +Node: Empty439605 +Node: Using Shell Variables439922 +Node: Action Overview442196 +Node: Statements444521 +Node: If Statement446369 +Node: While Statement447864 +Node: Do Statement449892 +Node: For Statement451040 +Node: Switch Statement454211 +Node: Break Statement456652 +Node: Continue Statement458744 +Node: Next Statement460571 +Node: Nextfile Statement462954 +Node: Exit Statement465643 +Node: Built-in Variables468046 +Node: User-modified469179 +Node: Auto-set476946 +Ref: Auto-set-Footnote-1493753 +Ref: Auto-set-Footnote-2493959 +Node: ARGC and ARGV494015 +Node: Pattern Action Summary498228 +Node: Arrays500658 +Node: Array Basics501987 +Node: Array Intro502831 +Ref: figure-array-elements504806 +Ref: Array Intro-Footnote-1507510 +Node: Reference to Elements507638 +Node: Assigning Elements510102 +Node: Array Example510593 +Node: Scanning an Array512352 +Node: Controlling Scanning515374 +Ref: Controlling Scanning-Footnote-1521830 +Node: Numeric Array Subscripts522146 +Node: Uninitialized Subscripts524330 +Node: Delete525949 +Ref: Delete-Footnote-1528701 +Node: Multidimensional528758 +Node: Multiscanning531853 +Node: Arrays of Arrays533444 +Node: Arrays Summary538212 +Node: Functions540305 +Node: Built-in541343 +Node: Calling Built-in542424 +Node: Numeric Functions544420 +Ref: Numeric Functions-Footnote-1548446 +Ref: Numeric Functions-Footnote-2549094 +Ref: Numeric Functions-Footnote-3549142 +Node: String Functions549414 +Ref: String Functions-Footnote-1573555 +Ref: String Functions-Footnote-2573683 +Ref: String Functions-Footnote-3573931 +Node: Gory Details574018 +Ref: table-sub-escapes575809 +Ref: table-sub-proposed577328 +Ref: table-posix-sub578691 +Ref: table-gensub-escapes580232 +Ref: Gory Details-Footnote-1581055 +Node: I/O Functions581209 +Ref: table-system-return-values587663 +Ref: I/O Functions-Footnote-1589743 +Ref: I/O Functions-Footnote-2589891 +Node: Time Functions590011 +Ref: Time Functions-Footnote-1600682 +Ref: Time Functions-Footnote-2600750 +Ref: Time Functions-Footnote-3600908 +Ref: Time Functions-Footnote-4601019 +Ref: Time Functions-Footnote-5601131 +Ref: Time Functions-Footnote-6601358 +Node: Bitwise Functions601624 +Ref: table-bitwise-ops602218 +Ref: Bitwise Functions-Footnote-1608281 +Ref: Bitwise Functions-Footnote-2608454 +Node: Type Functions608645 +Node: I18N Functions611508 +Node: User-defined613159 +Node: Definition Syntax613971 +Ref: Definition Syntax-Footnote-1619665 +Node: Function Example619736 +Ref: Function Example-Footnote-1622658 +Node: Function Calling622680 +Node: Calling A Function623268 +Node: Variable Scope624226 +Node: Pass By Value/Reference627220 +Node: Function Caveats629864 +Ref: Function Caveats-Footnote-1631911 +Node: Return Statement632031 +Node: Dynamic Typing635010 +Node: Indirect Calls635940 +Ref: Indirect Calls-Footnote-1646192 +Node: Functions Summary646320 +Node: Library Functions649025 +Ref: Library Functions-Footnote-1652632 +Ref: Library Functions-Footnote-2652775 +Node: Library Names652946 +Ref: Library Names-Footnote-1656613 +Ref: Library Names-Footnote-2656836 +Node: General Functions656922 +Node: Strtonum Function658025 +Node: Assert Function661047 +Node: Round Function664373 +Node: Cliff Random Function665913 +Node: Ordinal Functions666929 +Ref: Ordinal Functions-Footnote-1669992 +Ref: Ordinal Functions-Footnote-2670244 +Node: Join Function670454 +Ref: Join Function-Footnote-1672224 +Node: Getlocaltime Function672424 +Node: Readfile Function676166 +Node: Shell Quoting678143 +Node: Data File Management679544 +Node: Filetrans Function680176 +Node: Rewind Function684272 +Node: File Checking686181 +Ref: File Checking-Footnote-1687515 +Node: Empty Files687716 +Node: Ignoring Assigns689695 +Node: Getopt Function691245 +Ref: Getopt Function-Footnote-1706456 +Node: Passwd Functions706656 +Ref: Passwd Functions-Footnote-1715495 +Node: Group Functions715583 +Ref: Group Functions-Footnote-1723481 +Node: Walking Arrays723688 +Node: Library Functions Summary726696 +Node: Library Exercises728102 +Node: Sample Programs728567 +Node: Running Examples729337 +Node: Clones730065 +Node: Cut Program731289 +Node: Egrep Program741429 +Node: Id Program750430 +Node: Split Program760377 +Ref: Split Program-Footnote-1770267 +Node: Tee Program770440 +Node: Uniq Program773230 +Node: Wc Program780818 +Node: Bytes vs. Characters781215 +Node: Using extensions782763 +Node: wc program783517 +Node: Miscellaneous Programs788382 +Node: Dupword Program789595 +Node: Alarm Program791625 +Node: Translate Program796480 +Ref: Translate Program-Footnote-1801045 +Node: Labels Program801315 +Ref: Labels Program-Footnote-1804666 +Node: Word Sorting804750 +Node: History Sorting808822 +Node: Extract Program811047 +Node: Simple Sed819101 +Node: Igawk Program822175 +Ref: Igawk Program-Footnote-1836506 +Ref: Igawk Program-Footnote-2836708 +Ref: Igawk Program-Footnote-3836830 +Node: Anagram Program836945 +Node: Signature Program840007 +Node: Programs Summary841254 +Node: Programs Exercises842468 +Ref: Programs Exercises-Footnote-1846598 +Node: Advanced Features846684 +Node: Nondecimal Data848751 +Node: Array Sorting850342 +Node: Controlling Array Traversal851042 +Ref: Controlling Array Traversal-Footnote-1859410 +Node: Array Sorting Functions859528 +Ref: Array Sorting Functions-Footnote-1864619 +Node: Two-way I/O864815 +Ref: Two-way I/O-Footnote-1872536 +Ref: Two-way I/O-Footnote-2872723 +Node: TCP/IP Networking872805 +Node: Profiling875923 +Node: Extension Philosophy885232 +Node: Advanced Features Summary886711 +Node: Internationalization888726 +Node: I18N and L10N890206 +Node: Explaining gettext890893 +Ref: Explaining gettext-Footnote-1896785 +Ref: Explaining gettext-Footnote-2896970 +Node: Programmer i18n897135 +Ref: Programmer i18n-Footnote-1902084 +Node: Translator i18n902133 +Node: String Extraction902927 +Ref: String Extraction-Footnote-1904059 +Node: Printf Ordering904145 +Ref: Printf Ordering-Footnote-1906931 +Node: I18N Portability906995 +Ref: I18N Portability-Footnote-1909451 +Node: I18N Example909514 +Ref: I18N Example-Footnote-1912789 +Ref: I18N Example-Footnote-2912862 +Node: Gawk I18N912971 +Node: I18N Summary913620 +Node: Debugger914961 +Node: Debugging915961 +Node: Debugging Concepts916402 +Node: Debugging Terms918211 +Node: Awk Debugging920786 +Ref: Awk Debugging-Footnote-1921731 +Node: Sample Debugging Session921863 +Node: Debugger Invocation922397 +Node: Finding The Bug923783 +Node: List of Debugger Commands930257 +Node: Breakpoint Control931590 +Node: Debugger Execution Control935284 +Node: Viewing And Changing Data938646 +Node: Execution Stack942187 +Node: Debugger Info943824 +Node: Miscellaneous Debugger Commands947895 +Node: Readline Support952957 +Node: Limitations953853 +Node: Debugging Summary956407 +Node: Namespaces957686 +Node: Global Namespace958797 +Node: Qualified Names960195 +Node: Default Namespace961194 +Node: Changing The Namespace961935 +Node: Naming Rules963549 +Node: Internal Name Management965397 +Node: Namespace Example966439 +Node: Namespace And Features969001 +Node: Namespace Summary970436 +Node: Arbitrary Precision Arithmetic971913 +Node: Computer Arithmetic973400 +Ref: table-numeric-ranges977166 +Ref: table-floating-point-ranges977659 +Ref: Computer Arithmetic-Footnote-1978317 +Node: Math Definitions978374 +Ref: table-ieee-formats981350 +Node: MPFR features981917 +Node: FP Math Caution983635 +Ref: FP Math Caution-Footnote-1984707 +Node: Inexactness of computations985076 +Node: Inexact representation986107 +Node: Comparing FP Values987467 +Node: Errors accumulate988708 +Node: Strange values990164 +Ref: Strange values-Footnote-1992752 +Node: Getting Accuracy992857 +Node: Try To Round995567 +Node: Setting precision996466 +Ref: table-predefined-precision-strings997163 +Node: Setting the rounding mode998993 +Ref: table-gawk-rounding-modes999367 +Ref: Setting the rounding mode-Footnote-11003298 +Node: Arbitrary Precision Integers1003477 +Ref: Arbitrary Precision Integers-Footnote-11006652 +Node: Checking for MPFR1006801 +Node: POSIX Floating Point Problems1008275 +Ref: POSIX Floating Point Problems-Footnote-11012560 +Node: Floating point summary1012598 +Node: Dynamic Extensions1014788 +Node: Extension Intro1016341 +Node: Plugin License1017607 +Node: Extension Mechanism Outline1018404 +Ref: figure-load-extension1018843 +Ref: figure-register-new-function1020408 +Ref: figure-call-new-function1021500 +Node: Extension API Description1023562 +Node: Extension API Functions Introduction1025275 +Ref: table-api-std-headers1027111 +Node: General Data Types1031360 +Ref: General Data Types-Footnote-11039990 +Node: Memory Allocation Functions1040289 +Ref: Memory Allocation Functions-Footnote-11044790 +Node: Constructor Functions1044889 +Node: API Ownership of MPFR and GMP Values1048355 +Node: Registration Functions1049668 +Node: Extension Functions1050368 +Node: Exit Callback Functions1055690 +Node: Extension Version String1056940 +Node: Input Parsers1057603 +Node: Output Wrappers1070324 +Node: Two-way processors1074836 +Node: Printing Messages1077101 +Ref: Printing Messages-Footnote-11078272 +Node: Updating ERRNO1078425 +Node: Requesting Values1079164 +Ref: table-value-types-returned1079901 +Node: Accessing Parameters1080837 +Node: Symbol Table Access1082074 +Node: Symbol table by name1082586 +Ref: Symbol table by name-Footnote-11085610 +Node: Symbol table by cookie1085738 +Ref: Symbol table by cookie-Footnote-11089923 +Node: Cached values1089987 +Ref: Cached values-Footnote-11093523 +Node: Array Manipulation1093676 +Ref: Array Manipulation-Footnote-11094767 +Node: Array Data Types1094804 +Ref: Array Data Types-Footnote-11097462 +Node: Array Functions1097554 +Node: Flattening Arrays1102052 +Node: Creating Arrays1109028 +Node: Redirection API1113795 +Node: Extension API Variables1116628 +Node: Extension Versioning1117339 +Ref: gawk-api-version1117768 +Node: Extension GMP/MPFR Versioning1119499 +Node: Extension API Informational Variables1121127 +Node: Extension API Boilerplate1122200 +Node: Changes from API V11126174 +Node: Finding Extensions1127746 +Node: Extension Example1128305 +Node: Internal File Description1129103 +Node: Internal File Ops1133183 +Ref: Internal File Ops-Footnote-11144533 +Node: Using Internal File Ops1144673 +Ref: Using Internal File Ops-Footnote-11147056 +Node: Extension Samples1147330 +Node: Extension Sample File Functions1148859 +Node: Extension Sample Fnmatch1156508 +Node: Extension Sample Fork1157995 +Node: Extension Sample Inplace1159213 +Node: Extension Sample Ord1162839 +Node: Extension Sample Readdir1163675 +Ref: table-readdir-file-types1164564 +Node: Extension Sample Revout1165631 +Node: Extension Sample Rev2way1166220 +Node: Extension Sample Read write array1166960 +Node: Extension Sample Readfile1168902 +Node: Extension Sample Time1169997 +Node: Extension Sample API Tests1171749 +Node: gawkextlib1172241 +Node: Extension summary1175159 +Node: Extension Exercises1178861 +Node: Language History1180103 +Node: V7/SVR3.11181759 +Node: SVR41183911 +Node: POSIX1185345 +Node: BTL1186726 +Node: POSIX/GNU1187455 +Node: Feature History1193233 +Node: Common Extensions1209552 +Node: Ranges and Locales1210835 +Ref: Ranges and Locales-Footnote-11215451 +Ref: Ranges and Locales-Footnote-21215478 +Ref: Ranges and Locales-Footnote-31215713 +Node: Contributors1215936 +Node: History summary1221933 +Node: Installation1223313 +Node: Gawk Distribution1224257 +Node: Getting1224741 +Node: Extracting1225704 +Node: Distribution contents1227342 +Node: Unix Installation1233822 +Node: Quick Installation1234504 +Node: Shell Startup Files1236918 +Node: Additional Configuration Options1238007 +Node: Configuration Philosophy1240322 +Node: Non-Unix Installation1242691 +Node: PC Installation1243151 +Node: PC Binary Installation1243989 +Node: PC Compiling1244424 +Node: PC Using1245541 +Node: Cygwin1249094 +Node: MSYS1250318 +Node: VMS Installation1250920 +Node: VMS Compilation1251711 +Ref: VMS Compilation-Footnote-11252940 +Node: VMS Dynamic Extensions1252998 +Node: VMS Installation Details1254683 +Node: VMS Running1256936 +Node: VMS GNV1261215 +Node: VMS Old Gawk1261950 +Node: Bugs1262421 +Node: Bug address1263084 +Node: Usenet1266066 +Node: Maintainers1267070 +Node: Other Versions1268255 +Node: Installation summary1276120 +Node: Notes1277329 +Node: Compatibility Mode1278123 +Node: Additions1278905 +Node: Accessing The Source1279830 +Node: Adding Code1281267 +Node: New Ports1287486 +Node: Derived Files1291861 +Ref: Derived Files-Footnote-11297521 +Ref: Derived Files-Footnote-21297556 +Ref: Derived Files-Footnote-31298154 +Node: Future Extensions1298268 +Node: Implementation Limitations1298926 +Node: Extension Design1300136 +Node: Old Extension Problems1301280 +Ref: Old Extension Problems-Footnote-11302798 +Node: Extension New Mechanism Goals1302855 +Ref: Extension New Mechanism Goals-Footnote-11306219 +Node: Extension Other Design Decisions1306408 +Node: Extension Future Growth1308521 +Node: Notes summary1309127 +Node: Basic Concepts1310285 +Node: Basic High Level1310966 +Ref: figure-general-flow1311248 +Ref: figure-process-flow1311933 +Ref: Basic High Level-Footnote-11315234 +Node: Basic Data Typing1315419 +Node: Glossary1318747 +Node: Copying1350632 +Node: GNU Free Documentation License1388175 +Node: Index1413295 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index b472316b..591246c0 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -5970,6 +5970,100 @@ regexp that precedes them. For example, @code{/+/} matches a literal plus sign. However, many other versions of @command{awk} treat such a usage as a syntax error. +@cindex sidebar @subentry What About The Empty Regexp? +@ifdocbook +@docbook +<sidebar><title>What About The Empty Regexp?</title> +@end docbook + +@cindex empty regexps +@cindex regexps, empty +We describe here an advanced regexp usage. Feel free to skip it +upon first reading. + +You can supply an empty regexp constant (@samp{//}) in all places +where a regexp is expected. Is this useful? What does it match? + +It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string +between characters. This is best illustrated with the @code{gsub()} +function, which makes global substitutions in a string +(@pxref{String Functions}). Normal usage of @code{gsub()} is like +so: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC_CBA"} +> @kbd{ gsub(/B/, "bb", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} AbbC_CbbA +@end example + +We can use @code{gsub()} to see where the empty strings +are that match the empty regexp: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC"} +> @kbd{ gsub(//, "x", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} xAxBxCx +@end example + +@docbook +</sidebar> +@end docbook +@end ifdocbook + +@ifnotdocbook +@cartouche +@center @b{What About The Empty Regexp?} + + +@cindex empty regexps +@cindex regexps, empty +We describe here an advanced regexp usage. Feel free to skip it +upon first reading. + +You can supply an empty regexp constant (@samp{//}) in all places +where a regexp is expected. Is this useful? What does it match? + +It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string +between characters. This is best illustrated with the @code{gsub()} +function, which makes global substitutions in a string +(@pxref{String Functions}). Normal usage of @code{gsub()} is like +so: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC_CBA"} +> @kbd{ gsub(/B/, "bb", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} AbbC_CbbA +@end example + +We can use @code{gsub()} to see where the empty strings +are that match the empty regexp: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC"} +> @kbd{ gsub(//, "x", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} xAxBxCx +@end example +@end cartouche +@end ifnotdocbook + @node Interval Expressions @subsection Some Notes On Interval Expressions diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 2c2d7297..38e9dc0e 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -5752,6 +5752,46 @@ regexp that precedes them. For example, @code{/+/} matches a literal plus sign. However, many other versions of @command{awk} treat such a usage as a syntax error. +@sidebar What About The Empty Regexp? +@cindex empty regexps +@cindex regexps, empty +We describe here an advanced regexp usage. Feel free to skip it +upon first reading. + +You can supply an empty regexp constant (@samp{//}) in all places +where a regexp is expected. Is this useful? What does it match? + +It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string +between characters. This is best illustrated with the @code{gsub()} +function, which makes global substitutions in a string +(@pxref{String Functions}). Normal usage of @code{gsub()} is like +so: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC_CBA"} +> @kbd{ gsub(/B/, "bb", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} AbbC_CbbA +@end example + +We can use @code{gsub()} to see where the empty strings +are that match the empty regexp: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC"} +> @kbd{ gsub(//, "x", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} xAxBxCx +@end example +@end sidebar + @node Interval Expressions @subsection Some Notes On Interval Expressions |