diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-02-18 22:13:04 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-02-18 22:13:04 +0200 |
commit | 4e18d68de5a9aa2ab9c1860937dae4c467392f29 (patch) | |
tree | 9b64acfded3e2f5eeffb41c3afe1b4e4d8797dc0 | |
parent | e7b973ed393eba0e55fe1d0fe2f2235b268d3b2c (diff) | |
parent | c6acad5f8ccc81d092f4be09e0493b241e9a496b (diff) | |
download | egawk-4e18d68de5a9aa2ab9c1860937dae4c467392f29.tar.gz egawk-4e18d68de5a9aa2ab9c1860937dae4c467392f29.tar.bz2 egawk-4e18d68de5a9aa2ab9c1860937dae4c467392f29.zip |
Merge branch 'master' into feature/cmake
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | awklib/eg/prog/cut.awk | 4 | ||||
-rw-r--r-- | awklib/eg/prog/wc.awk | 2 | ||||
-rw-r--r-- | doc/ChangeLog | 9 | ||||
-rw-r--r-- | doc/gawk.info | 585 | ||||
-rw-r--r-- | doc/gawk.texi | 54 | ||||
-rw-r--r-- | doc/gawktexi.in | 54 |
7 files changed, 410 insertions, 303 deletions
@@ -78,7 +78,7 @@ Changes from 4.1.3 to 4.1.x --------------------------- 1. Updated to GNU autoconf 2.69, automake 1.15, gettext 0.19.5.1, - texinfo 6.1. + texinfo 6.1, texinfo.tex 2016-02-05.07. 2. z/OS support updated. @@ -93,6 +93,9 @@ Changes from 4.1.3 to 4.1.x 6. VMS support has been updated. +7. The profiler / pretty-printer now chains else-if statements instead + of causing cascading elses. + Changes from 4.1.2 to 4.1.3 --------------------------- diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk index 080279bc..fd77910d 100644 --- a/awklib/eg/prog/cut.awk +++ b/awklib/eg/prog/cut.awk @@ -35,7 +35,7 @@ BEGIN { " for delimiter\n", Optarg) > "/dev/stderr" Optarg = substr(Optarg, 1, 1) } - FS = Optarg + fs = FS = Optarg OFS = FS if (FS == " ") # defeat awk semantics FS = "[ ]" @@ -123,7 +123,7 @@ function set_charlist( field, i, j, f, g, n, m, t, nfields = j - 1 } { - if (by_fields && suppress && index($0, FS) == 0) + if (by_fields && suppress && index($0, fs) == 0) next for (i = 1; i <= nfields; i++) { diff --git a/awklib/eg/prog/wc.awk b/awklib/eg/prog/wc.awk index 95940ae4..c46d0984 100644 --- a/awklib/eg/prog/wc.awk +++ b/awklib/eg/prog/wc.awk @@ -30,7 +30,7 @@ BEGIN { if (! do_lines && ! do_words && ! do_chars) do_lines = do_words = do_chars = 1 - print_total = (ARGC - i > 2) + print_total = (ARGC - i > 1) } function beginfile(file) { diff --git a/doc/ChangeLog b/doc/ChangeLog index 035486f6..6017ee44 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,12 @@ +2016-02-18 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Fixes in wc.awk and in cut.awk. Thanks to David Ward, + dlward134@gmail.com. Added an example of use of rewind(), also + per suggestion from David Ward. + * gawktexi.in: Update info about Texinfo versions. + * gawktexi.in (Limitations): Fix Heisenberg Physics example and + spelling of Heisenberg's name. Thanks to Hermann Peifer. + 2016-02-14 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Revise for use with Texinfo 6.1. diff --git a/doc/gawk.info b/doc/gawk.info index 2eb590d0..35484814 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -15526,6 +15526,33 @@ should not call it from an 'ENDFILE' rule. (This isn't necessary anyway, because 'gawk' goes to the next file as soon as an 'ENDFILE' rule finishes!) + You need to be careful calling 'rewind()'. You can end up causing +infinite recursion if you don't pay attenion. Here is an example use: + + $ cat data + -| a + -| b + -| c + -| d + -| e + + $ cat test.awk + -| FNR == 3 && ! rewound { + -| rewound = 1 + -| rewind() + -| } + -| + -| { print FILENAME, FNR, $0 } + + $ gawk -f rewind.awk -f test.awk data + -| data 1 a + -| data 2 b + -| data 1 a + -| data 2 b + -| data 3 c + -| data 4 d + -| data 5 e + File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management @@ -16749,7 +16776,7 @@ by characters, the output field separator is set to the null string: " for delimiter\n", Optarg) > "/dev/stderr" Optarg = substr(Optarg, 1, 1) } - FS = Optarg + fs = FS = Optarg OFS = FS if (FS == " ") # defeat awk semantics FS = "[ ]" @@ -16766,11 +16793,15 @@ by characters, the output field separator is set to the null string: The code must take special care when the field delimiter is a space. Using a single space ('" "') for the value of 'FS' is incorrect--'awk' would separate fields with runs of spaces, TABs, and/or newlines, and we -want them to be separated with individual spaces. Also remember that -after 'getopt()' is through (as described in *note Getopt Function::), -we have to clear out all the elements of 'ARGV' from 1 to 'Optind', so -that 'awk' does not try to process the command-line options as file -names. +want them to be separated with individual spaces. To this end, we save +the original space character in the variable 'fs' for later use; after +setting 'FS' to '"[ ]"' we can't use it directly to see if the field +delimiter character is in the string. + + Also remember that after 'getopt()' is through (as described in *note +Getopt Function::), we have to clear out all the elements of 'ARGV' from +1 to 'Optind', so that 'awk' does not try to process the command-line +options as file names. After dealing with the command-line options, the program verifies that the options make sense. Only one or the other of '-c' and '-f' @@ -16894,7 +16925,7 @@ the next field also has data, then the separator character is written out between the fields: { - if (by_fields && suppress && index($0, FS) == 0) + if (by_fields && suppress && index($0, fs) == 0) next for (i = 1; i <= nfields; i++) { @@ -17724,7 +17755,7 @@ line: if (! do_lines && ! do_words && ! do_chars) do_lines = do_words = do_chars = 1 - print_total = (ARGC - i > 2) + print_total = (ARGC - i > 1) } The 'beginfile()' function is simple; it just resets the counts of @@ -21960,7 +21991,7 @@ debug (the "debuggee", if you will). The 'gawk' debugger is different; it is an integrated part of 'gawk' itself. This makes it possible, in rare cases, for 'gawk' to become an -excellent demonstrator of Heisenburg Uncertainty physics, where the mere +excellent demonstrator of Heisenberg Uncertainty physics, where the mere act of observing something can change it. Consider the following:(1) $ cat test.awk @@ -21994,13 +22025,13 @@ under the debugger: -| main() at `test.awk':1 -| 1 { print typeof($1), typeof($2) } gawk> n Get result from typeof() - -| strnum string Result for $2 isn't right + -| strnum number Result for $2 isn't right -| Program exited normally with exit value: 0 gawk> quit In this case, the act of comparing the new value of '$2' with the old one caused 'gawk' to evaluate it and determine that it is indeed a -string, and this is reflected in the result of 'typeof()'. +number, and this is reflected in the result of 'typeof()'. Cases like this where the debugger is not transparent to the program's execution should be rare. If you encounter one, please report @@ -35452,271 +35483,271 @@ Node: Shell Quoting641089 Node: Data File Management642490 Node: Filetrans Function643122 Node: Rewind Function647218 -Node: File Checking648604 -Ref: File Checking-Footnote-1649938 -Node: Empty Files650139 -Node: Ignoring Assigns652118 -Node: Getopt Function653668 -Ref: Getopt Function-Footnote-1665137 -Node: Passwd Functions665337 -Ref: Passwd Functions-Footnote-1674176 -Node: Group Functions674264 -Ref: Group Functions-Footnote-1682161 -Node: Walking Arrays682368 -Node: Library Functions Summary685376 -Node: Library Exercises686782 -Node: Sample Programs687247 -Node: Running Examples688017 -Node: Clones688745 -Node: Cut Program689969 -Node: Egrep Program699690 -Ref: Egrep Program-Footnote-1707202 -Node: Id Program707312 -Node: Split Program710992 -Ref: Split Program-Footnote-1714451 -Node: Tee Program714580 -Node: Uniq Program717370 -Node: Wc Program724796 -Ref: Wc Program-Footnote-1729051 -Node: Miscellaneous Programs729145 -Node: Dupword Program730358 -Node: Alarm Program732388 -Node: Translate Program737243 -Ref: Translate Program-Footnote-1741808 -Node: Labels Program742078 -Ref: Labels Program-Footnote-1745429 -Node: Word Sorting745513 -Node: History Sorting749585 -Node: Extract Program751420 -Node: Simple Sed758949 -Node: Igawk Program762023 -Ref: Igawk Program-Footnote-1776354 -Ref: Igawk Program-Footnote-2776556 -Ref: Igawk Program-Footnote-3776678 -Node: Anagram Program776793 -Node: Signature Program779855 -Node: Programs Summary781102 -Node: Programs Exercises782316 -Ref: Programs Exercises-Footnote-1786445 -Node: Advanced Features786536 -Node: Nondecimal Data788526 -Node: Array Sorting790117 -Node: Controlling Array Traversal790817 -Ref: Controlling Array Traversal-Footnote-1799184 -Node: Array Sorting Functions799302 -Ref: Array Sorting Functions-Footnote-1804393 -Node: Two-way I/O804589 -Ref: Two-way I/O-Footnote-1810409 -Ref: Two-way I/O-Footnote-2810596 -Node: TCP/IP Networking810678 -Node: Profiling813796 -Node: Advanced Features Summary822250 -Node: Internationalization824094 -Node: I18N and L10N825574 -Node: Explaining gettext826261 -Ref: Explaining gettext-Footnote-1831284 -Ref: Explaining gettext-Footnote-2831469 -Node: Programmer i18n831634 -Ref: Programmer i18n-Footnote-1836489 -Node: Translator i18n836538 -Node: String Extraction837332 -Ref: String Extraction-Footnote-1838464 -Node: Printf Ordering838550 -Ref: Printf Ordering-Footnote-1841336 -Node: I18N Portability841400 -Ref: I18N Portability-Footnote-1843856 -Node: I18N Example843919 -Ref: I18N Example-Footnote-1846725 -Node: Gawk I18N846798 -Node: I18N Summary847443 -Node: Debugger848784 -Node: Debugging849806 -Node: Debugging Concepts850247 -Node: Debugging Terms852056 -Node: Awk Debugging854631 -Node: Sample Debugging Session855537 -Node: Debugger Invocation856071 -Node: Finding The Bug857457 -Node: List of Debugger Commands863935 -Node: Breakpoint Control865268 -Node: Debugger Execution Control868962 -Node: Viewing And Changing Data872324 -Node: Execution Stack875698 -Node: Debugger Info877335 -Node: Miscellaneous Debugger Commands881406 -Node: Readline Support886494 -Node: Limitations887390 -Ref: Limitations-Footnote-1891621 -Node: Debugging Summary891672 -Node: Arbitrary Precision Arithmetic892951 -Node: Computer Arithmetic894367 -Ref: table-numeric-ranges897958 -Ref: Computer Arithmetic-Footnote-1898680 -Node: Math Definitions898737 -Ref: table-ieee-formats902051 -Ref: Math Definitions-Footnote-1902654 -Node: MPFR features902759 -Node: FP Math Caution904476 -Ref: FP Math Caution-Footnote-1905548 -Node: Inexactness of computations905917 -Node: Inexact representation906877 -Node: Comparing FP Values908237 -Node: Errors accumulate909319 -Node: Getting Accuracy910752 -Node: Try To Round913462 -Node: Setting precision914361 -Ref: table-predefined-precision-strings915058 -Node: Setting the rounding mode916888 -Ref: table-gawk-rounding-modes917262 -Ref: Setting the rounding mode-Footnote-1920670 -Node: Arbitrary Precision Integers920849 -Ref: Arbitrary Precision Integers-Footnote-1925766 -Node: POSIX Floating Point Problems925915 -Ref: POSIX Floating Point Problems-Footnote-1929797 -Node: Floating point summary929835 -Node: Dynamic Extensions932025 -Node: Extension Intro933578 -Node: Plugin License934844 -Node: Extension Mechanism Outline935641 -Ref: figure-load-extension936080 -Ref: figure-register-new-function937645 -Ref: figure-call-new-function938737 -Node: Extension API Description940799 -Node: Extension API Functions Introduction942331 -Node: General Data Types947190 -Ref: General Data Types-Footnote-1953145 -Node: Memory Allocation Functions953444 -Ref: Memory Allocation Functions-Footnote-1956289 -Node: Constructor Functions956388 -Node: Registration Functions958133 -Node: Extension Functions958818 -Node: Exit Callback Functions961117 -Node: Extension Version String962367 -Node: Input Parsers963030 -Node: Output Wrappers972915 -Node: Two-way processors977427 -Node: Printing Messages979691 -Ref: Printing Messages-Footnote-1980765 -Node: Updating ERRNO980918 -Node: Requesting Values981657 -Ref: table-value-types-returned982394 -Node: Accessing Parameters983277 -Node: Symbol Table Access984512 -Node: Symbol table by name985024 -Node: Symbol table by cookie987045 -Ref: Symbol table by cookie-Footnote-1991194 -Node: Cached values991258 -Ref: Cached values-Footnote-1994759 -Node: Array Manipulation994850 -Ref: Array Manipulation-Footnote-1995941 -Node: Array Data Types995978 -Ref: Array Data Types-Footnote-1998636 -Node: Array Functions998728 -Node: Flattening Arrays1002586 -Node: Creating Arrays1009494 -Node: Redirection API1014265 -Node: Extension API Variables1017096 -Node: Extension Versioning1017729 -Node: Extension API Informational Variables1019620 -Node: Extension API Boilerplate1020684 -Node: Finding Extensions1024498 -Node: Extension Example1025057 -Node: Internal File Description1025855 -Node: Internal File Ops1029935 -Ref: Internal File Ops-Footnote-11041697 -Node: Using Internal File Ops1041837 -Ref: Using Internal File Ops-Footnote-11044220 -Node: Extension Samples1044494 -Node: Extension Sample File Functions1046023 -Node: Extension Sample Fnmatch1053672 -Node: Extension Sample Fork1055159 -Node: Extension Sample Inplace1056377 -Node: Extension Sample Ord1059587 -Node: Extension Sample Readdir1060423 -Ref: table-readdir-file-types1061312 -Node: Extension Sample Revout1062117 -Node: Extension Sample Rev2way1062706 -Node: Extension Sample Read write array1063446 -Node: Extension Sample Readfile1065388 -Node: Extension Sample Time1066483 -Node: Extension Sample API Tests1067831 -Node: gawkextlib1068323 -Node: Extension summary1070770 -Node: Extension Exercises1074462 -Node: Language History1075959 -Node: V7/SVR3.11077615 -Node: SVR41079767 -Node: POSIX1081201 -Node: BTL1082580 -Node: POSIX/GNU1083309 -Node: Feature History1089171 -Node: Common Extensions1103541 -Node: Ranges and Locales1104824 -Ref: Ranges and Locales-Footnote-11109440 -Ref: Ranges and Locales-Footnote-21109467 -Ref: Ranges and Locales-Footnote-31109702 -Node: Contributors1109923 -Node: History summary1115492 -Node: Installation1116872 -Node: Gawk Distribution1117816 -Node: Getting1118300 -Node: Extracting1119261 -Node: Distribution contents1120899 -Node: Unix Installation1126993 -Node: Quick Installation1127675 -Node: Shell Startup Files1130089 -Node: Additional Configuration Options1131167 -Node: Configuration Philosophy1132972 -Node: Non-Unix Installation1135341 -Node: PC Installation1135799 -Node: PC Binary Installation1137119 -Node: PC Compiling1138971 -Ref: PC Compiling-Footnote-11141995 -Node: PC Testing1142104 -Node: PC Using1143284 -Node: Cygwin1147398 -Node: MSYS1148168 -Node: VMS Installation1148669 -Node: VMS Compilation1149460 -Ref: VMS Compilation-Footnote-11150689 -Node: VMS Dynamic Extensions1150747 -Node: VMS Installation Details1152432 -Node: VMS Running1154685 -Node: VMS GNV1158964 -Node: VMS Old Gawk1159699 -Node: Bugs1160170 -Node: Other Versions1164367 -Node: Installation summary1170951 -Node: Notes1172009 -Node: Compatibility Mode1172874 -Node: Additions1173656 -Node: Accessing The Source1174581 -Node: Adding Code1176016 -Node: New Ports1182235 -Node: Derived Files1186723 -Ref: Derived Files-Footnote-11192208 -Ref: Derived Files-Footnote-21192243 -Ref: Derived Files-Footnote-31192841 -Node: Future Extensions1192955 -Node: Implementation Limitations1193613 -Node: Extension Design1194796 -Node: Old Extension Problems1195950 -Ref: Old Extension Problems-Footnote-11197468 -Node: Extension New Mechanism Goals1197525 -Ref: Extension New Mechanism Goals-Footnote-11200889 -Node: Extension Other Design Decisions1201078 -Node: Extension Future Growth1203191 -Node: Old Extension Mechanism1204027 -Node: Notes summary1205790 -Node: Basic Concepts1206972 -Node: Basic High Level1207653 -Ref: figure-general-flow1207935 -Ref: figure-process-flow1208620 -Ref: Basic High Level-Footnote-11211921 -Node: Basic Data Typing1212106 -Node: Glossary1215434 -Node: Copying1247380 -Node: GNU Free Documentation License1284919 -Node: Index1310037 +Node: File Checking649123 +Ref: File Checking-Footnote-1650457 +Node: Empty Files650658 +Node: Ignoring Assigns652637 +Node: Getopt Function654187 +Ref: Getopt Function-Footnote-1665656 +Node: Passwd Functions665856 +Ref: Passwd Functions-Footnote-1674695 +Node: Group Functions674783 +Ref: Group Functions-Footnote-1682680 +Node: Walking Arrays682887 +Node: Library Functions Summary685895 +Node: Library Exercises687301 +Node: Sample Programs687766 +Node: Running Examples688536 +Node: Clones689264 +Node: Cut Program690488 +Node: Egrep Program700417 +Ref: Egrep Program-Footnote-1707929 +Node: Id Program708039 +Node: Split Program711719 +Ref: Split Program-Footnote-1715178 +Node: Tee Program715307 +Node: Uniq Program718097 +Node: Wc Program725523 +Ref: Wc Program-Footnote-1729778 +Node: Miscellaneous Programs729872 +Node: Dupword Program731085 +Node: Alarm Program733115 +Node: Translate Program737970 +Ref: Translate Program-Footnote-1742535 +Node: Labels Program742805 +Ref: Labels Program-Footnote-1746156 +Node: Word Sorting746240 +Node: History Sorting750312 +Node: Extract Program752147 +Node: Simple Sed759676 +Node: Igawk Program762750 +Ref: Igawk Program-Footnote-1777081 +Ref: Igawk Program-Footnote-2777283 +Ref: Igawk Program-Footnote-3777405 +Node: Anagram Program777520 +Node: Signature Program780582 +Node: Programs Summary781829 +Node: Programs Exercises783043 +Ref: Programs Exercises-Footnote-1787172 +Node: Advanced Features787263 +Node: Nondecimal Data789253 +Node: Array Sorting790844 +Node: Controlling Array Traversal791544 +Ref: Controlling Array Traversal-Footnote-1799911 +Node: Array Sorting Functions800029 +Ref: Array Sorting Functions-Footnote-1805120 +Node: Two-way I/O805316 +Ref: Two-way I/O-Footnote-1811136 +Ref: Two-way I/O-Footnote-2811323 +Node: TCP/IP Networking811405 +Node: Profiling814523 +Node: Advanced Features Summary822977 +Node: Internationalization824821 +Node: I18N and L10N826301 +Node: Explaining gettext826988 +Ref: Explaining gettext-Footnote-1832011 +Ref: Explaining gettext-Footnote-2832196 +Node: Programmer i18n832361 +Ref: Programmer i18n-Footnote-1837216 +Node: Translator i18n837265 +Node: String Extraction838059 +Ref: String Extraction-Footnote-1839191 +Node: Printf Ordering839277 +Ref: Printf Ordering-Footnote-1842063 +Node: I18N Portability842127 +Ref: I18N Portability-Footnote-1844583 +Node: I18N Example844646 +Ref: I18N Example-Footnote-1847452 +Node: Gawk I18N847525 +Node: I18N Summary848170 +Node: Debugger849511 +Node: Debugging850533 +Node: Debugging Concepts850974 +Node: Debugging Terms852783 +Node: Awk Debugging855358 +Node: Sample Debugging Session856264 +Node: Debugger Invocation856798 +Node: Finding The Bug858184 +Node: List of Debugger Commands864662 +Node: Breakpoint Control865995 +Node: Debugger Execution Control869689 +Node: Viewing And Changing Data873051 +Node: Execution Stack876425 +Node: Debugger Info878062 +Node: Miscellaneous Debugger Commands882133 +Node: Readline Support887221 +Node: Limitations888117 +Ref: Limitations-Footnote-1892348 +Node: Debugging Summary892399 +Node: Arbitrary Precision Arithmetic893678 +Node: Computer Arithmetic895094 +Ref: table-numeric-ranges898685 +Ref: Computer Arithmetic-Footnote-1899407 +Node: Math Definitions899464 +Ref: table-ieee-formats902778 +Ref: Math Definitions-Footnote-1903381 +Node: MPFR features903486 +Node: FP Math Caution905203 +Ref: FP Math Caution-Footnote-1906275 +Node: Inexactness of computations906644 +Node: Inexact representation907604 +Node: Comparing FP Values908964 +Node: Errors accumulate910046 +Node: Getting Accuracy911479 +Node: Try To Round914189 +Node: Setting precision915088 +Ref: table-predefined-precision-strings915785 +Node: Setting the rounding mode917615 +Ref: table-gawk-rounding-modes917989 +Ref: Setting the rounding mode-Footnote-1921397 +Node: Arbitrary Precision Integers921576 +Ref: Arbitrary Precision Integers-Footnote-1926493 +Node: POSIX Floating Point Problems926642 +Ref: POSIX Floating Point Problems-Footnote-1930524 +Node: Floating point summary930562 +Node: Dynamic Extensions932752 +Node: Extension Intro934305 +Node: Plugin License935571 +Node: Extension Mechanism Outline936368 +Ref: figure-load-extension936807 +Ref: figure-register-new-function938372 +Ref: figure-call-new-function939464 +Node: Extension API Description941526 +Node: Extension API Functions Introduction943058 +Node: General Data Types947917 +Ref: General Data Types-Footnote-1953872 +Node: Memory Allocation Functions954171 +Ref: Memory Allocation Functions-Footnote-1957016 +Node: Constructor Functions957115 +Node: Registration Functions958860 +Node: Extension Functions959545 +Node: Exit Callback Functions961844 +Node: Extension Version String963094 +Node: Input Parsers963757 +Node: Output Wrappers973642 +Node: Two-way processors978154 +Node: Printing Messages980418 +Ref: Printing Messages-Footnote-1981492 +Node: Updating ERRNO981645 +Node: Requesting Values982384 +Ref: table-value-types-returned983121 +Node: Accessing Parameters984004 +Node: Symbol Table Access985239 +Node: Symbol table by name985751 +Node: Symbol table by cookie987772 +Ref: Symbol table by cookie-Footnote-1991921 +Node: Cached values991985 +Ref: Cached values-Footnote-1995486 +Node: Array Manipulation995577 +Ref: Array Manipulation-Footnote-1996668 +Node: Array Data Types996705 +Ref: Array Data Types-Footnote-1999363 +Node: Array Functions999455 +Node: Flattening Arrays1003313 +Node: Creating Arrays1010221 +Node: Redirection API1014992 +Node: Extension API Variables1017823 +Node: Extension Versioning1018456 +Node: Extension API Informational Variables1020347 +Node: Extension API Boilerplate1021411 +Node: Finding Extensions1025225 +Node: Extension Example1025784 +Node: Internal File Description1026582 +Node: Internal File Ops1030662 +Ref: Internal File Ops-Footnote-11042424 +Node: Using Internal File Ops1042564 +Ref: Using Internal File Ops-Footnote-11044947 +Node: Extension Samples1045221 +Node: Extension Sample File Functions1046750 +Node: Extension Sample Fnmatch1054399 +Node: Extension Sample Fork1055886 +Node: Extension Sample Inplace1057104 +Node: Extension Sample Ord1060314 +Node: Extension Sample Readdir1061150 +Ref: table-readdir-file-types1062039 +Node: Extension Sample Revout1062844 +Node: Extension Sample Rev2way1063433 +Node: Extension Sample Read write array1064173 +Node: Extension Sample Readfile1066115 +Node: Extension Sample Time1067210 +Node: Extension Sample API Tests1068558 +Node: gawkextlib1069050 +Node: Extension summary1071497 +Node: Extension Exercises1075189 +Node: Language History1076686 +Node: V7/SVR3.11078342 +Node: SVR41080494 +Node: POSIX1081928 +Node: BTL1083307 +Node: POSIX/GNU1084036 +Node: Feature History1089898 +Node: Common Extensions1104268 +Node: Ranges and Locales1105551 +Ref: Ranges and Locales-Footnote-11110167 +Ref: Ranges and Locales-Footnote-21110194 +Ref: Ranges and Locales-Footnote-31110429 +Node: Contributors1110650 +Node: History summary1116219 +Node: Installation1117599 +Node: Gawk Distribution1118543 +Node: Getting1119027 +Node: Extracting1119988 +Node: Distribution contents1121626 +Node: Unix Installation1127720 +Node: Quick Installation1128402 +Node: Shell Startup Files1130816 +Node: Additional Configuration Options1131894 +Node: Configuration Philosophy1133699 +Node: Non-Unix Installation1136068 +Node: PC Installation1136526 +Node: PC Binary Installation1137846 +Node: PC Compiling1139698 +Ref: PC Compiling-Footnote-11142722 +Node: PC Testing1142831 +Node: PC Using1144011 +Node: Cygwin1148125 +Node: MSYS1148895 +Node: VMS Installation1149396 +Node: VMS Compilation1150187 +Ref: VMS Compilation-Footnote-11151416 +Node: VMS Dynamic Extensions1151474 +Node: VMS Installation Details1153159 +Node: VMS Running1155412 +Node: VMS GNV1159691 +Node: VMS Old Gawk1160426 +Node: Bugs1160897 +Node: Other Versions1165094 +Node: Installation summary1171678 +Node: Notes1172736 +Node: Compatibility Mode1173601 +Node: Additions1174383 +Node: Accessing The Source1175308 +Node: Adding Code1176743 +Node: New Ports1182962 +Node: Derived Files1187450 +Ref: Derived Files-Footnote-11192935 +Ref: Derived Files-Footnote-21192970 +Ref: Derived Files-Footnote-31193568 +Node: Future Extensions1193682 +Node: Implementation Limitations1194340 +Node: Extension Design1195523 +Node: Old Extension Problems1196677 +Ref: Old Extension Problems-Footnote-11198195 +Node: Extension New Mechanism Goals1198252 +Ref: Extension New Mechanism Goals-Footnote-11201616 +Node: Extension Other Design Decisions1201805 +Node: Extension Future Growth1203918 +Node: Old Extension Mechanism1204754 +Node: Notes summary1206517 +Node: Basic Concepts1207699 +Node: Basic High Level1208380 +Ref: figure-general-flow1208662 +Ref: figure-process-flow1209347 +Ref: Basic High Level-Footnote-11212648 +Node: Basic Data Typing1212833 +Node: Glossary1216161 +Node: Copying1248107 +Node: GNU Free Documentation License1285646 +Node: Index1310764 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 5ffc5335..33a823bc 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -225,10 +225,7 @@ @ignore Some comments on the layout for TeX. -1. Use at least texinfo.tex 2014-01-30.15 -2. When using @docbook, if the last line is part of a paragraph, end -it with a space and @c so that the lines won't run together. This is a -quirk of the language / makeinfo, and isn't going to change. +1. Use at least texinfo.tex 2016-02-05.07. @end ignore @c merge the function and variable indexes into the concept index @@ -21999,6 +21996,36 @@ Because of this, you should not call it from an @code{ENDFILE} rule. (This isn't necessary anyway, because @command{gawk} goes to the next file as soon as an @code{ENDFILE} rule finishes!) +You need to be careful calling @code{rewind()}. You can end up +causing infinite recursion if you don't pay attenion. Here is an +example use: + +@example +$ @kbd{cat data} +@print{} a +@print{} b +@print{} c +@print{} d +@print{} e + +$ cat @kbd{test.awk} +@print{} FNR == 3 && ! rewound @{ +@print{} rewound = 1 +@print{} rewind() +@print{} @} +@print{} +@print{} @{ print FILENAME, FNR, $0 @} + +$ @kbd{gawk -f rewind.awk -f test.awk data } +@print{} data 1 a +@print{} data 2 b +@print{} data 1 a +@print{} data 2 b +@print{} data 3 c +@print{} data 4 d +@print{} data 5 e +@end example + @node File Checking @subsection Checking for Readable @value{DDF}s @@ -23695,7 +23722,7 @@ BEGIN @{ " for delimiter\n", Optarg) > "/dev/stderr" Optarg = substr(Optarg, 1, 1) @} - FS = Optarg + fs = FS = Optarg OFS = FS if (FS == " ") # defeat awk semantics FS = "[ ]" @@ -23717,7 +23744,12 @@ special care when the field delimiter is a space. Using a single space (@code{@w{" "}}) for the value of @code{FS} is incorrect---@command{awk} would separate fields with runs of spaces, TABs, and/or newlines, and we want them to be separated with individual -spaces. Also remember that after @code{getopt()} is through +spaces. +To this end, we save the original space character in the variable +@code{fs} for later use; after setting @code{FS} to @code{"[ ]"} we can't +use it directly to see if the field delimiter character is in the string. + +Also remember that after @code{getopt()} is through (as described in @ref{Getopt Function}), we have to clear out all the elements of @code{ARGV} from 1 to @code{Optind}, @@ -23869,7 +23901,7 @@ written out between the fields: @example @c file eg/prog/cut.awk @{ - if (by_fields && suppress && index($0, FS) == 0) + if (by_fields && suppress && index($0, fs) == 0) next for (i = 1; i <= nfields; i++) @{ @@ -24934,7 +24966,7 @@ BEGIN @{ if (! do_lines && ! do_words && ! do_chars) do_lines = do_words = do_chars = 1 - print_total = (ARGC - i > 2) + print_total = (ARGC - i > 1) @} @c endfile @end example @@ -30494,7 +30526,7 @@ debug (the @dfn{debuggee}, if you will). The @command{gawk} debugger is different; it is an integrated part of @command{gawk} itself. This makes it possible, in rare cases, -for @command{gawk} to become an excellent demonstrator of Heisenburg +for @command{gawk} to become an excellent demonstrator of Heisenberg Uncertainty physics, where the mere act of observing something can change it. Consider the following:@footnote{Thanks to Hermann Peifer for this example.} @@ -30533,14 +30565,14 @@ gawk> @kbd{n} @ii{Keep going @dots{}} @print{} main() at `test.awk':1 @print{} 1 @{ print typeof($1), typeof($2) @} gawk> @kbd{n} @ii{Get result from} typeof() -@print{} strnum string @ii{Result for} $2 @ii{isn't right} +@print{} strnum number @ii{Result for} $2 @ii{isn't right} @print{} Program exited normally with exit value: 0 gawk> @kbd{quit} @end example In this case, the act of comparing the new value of @code{$2} with the old one caused @command{gawk} to evaluate it and determine that it -is indeed a string, and this is reflected in the result of +is indeed a number, and this is reflected in the result of @code{typeof()}. Cases like this where the debugger is not transparent to the program's diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 14257c81..7c9d473e 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -220,10 +220,7 @@ @ignore Some comments on the layout for TeX. -1. Use at least texinfo.tex 2014-01-30.15 -2. When using @docbook, if the last line is part of a paragraph, end -it with a space and @c so that the lines won't run together. This is a -quirk of the language / makeinfo, and isn't going to change. +1. Use at least texinfo.tex 2016-02-05.07. @end ignore @c merge the function and variable indexes into the concept index @@ -21090,6 +21087,36 @@ Because of this, you should not call it from an @code{ENDFILE} rule. (This isn't necessary anyway, because @command{gawk} goes to the next file as soon as an @code{ENDFILE} rule finishes!) +You need to be careful calling @code{rewind()}. You can end up +causing infinite recursion if you don't pay attenion. Here is an +example use: + +@example +$ @kbd{cat data} +@print{} a +@print{} b +@print{} c +@print{} d +@print{} e + +$ cat @kbd{test.awk} +@print{} FNR == 3 && ! rewound @{ +@print{} rewound = 1 +@print{} rewind() +@print{} @} +@print{} +@print{} @{ print FILENAME, FNR, $0 @} + +$ @kbd{gawk -f rewind.awk -f test.awk data } +@print{} data 1 a +@print{} data 2 b +@print{} data 1 a +@print{} data 2 b +@print{} data 3 c +@print{} data 4 d +@print{} data 5 e +@end example + @node File Checking @subsection Checking for Readable @value{DDF}s @@ -22786,7 +22813,7 @@ BEGIN @{ " for delimiter\n", Optarg) > "/dev/stderr" Optarg = substr(Optarg, 1, 1) @} - FS = Optarg + fs = FS = Optarg OFS = FS if (FS == " ") # defeat awk semantics FS = "[ ]" @@ -22808,7 +22835,12 @@ special care when the field delimiter is a space. Using a single space (@code{@w{" "}}) for the value of @code{FS} is incorrect---@command{awk} would separate fields with runs of spaces, TABs, and/or newlines, and we want them to be separated with individual -spaces. Also remember that after @code{getopt()} is through +spaces. +To this end, we save the original space character in the variable +@code{fs} for later use; after setting @code{FS} to @code{"[ ]"} we can't +use it directly to see if the field delimiter character is in the string. + +Also remember that after @code{getopt()} is through (as described in @ref{Getopt Function}), we have to clear out all the elements of @code{ARGV} from 1 to @code{Optind}, @@ -22960,7 +22992,7 @@ written out between the fields: @example @c file eg/prog/cut.awk @{ - if (by_fields && suppress && index($0, FS) == 0) + if (by_fields && suppress && index($0, fs) == 0) next for (i = 1; i <= nfields; i++) @{ @@ -24025,7 +24057,7 @@ BEGIN @{ if (! do_lines && ! do_words && ! do_chars) do_lines = do_words = do_chars = 1 - print_total = (ARGC - i > 2) + print_total = (ARGC - i > 1) @} @c endfile @end example @@ -29585,7 +29617,7 @@ debug (the @dfn{debuggee}, if you will). The @command{gawk} debugger is different; it is an integrated part of @command{gawk} itself. This makes it possible, in rare cases, -for @command{gawk} to become an excellent demonstrator of Heisenburg +for @command{gawk} to become an excellent demonstrator of Heisenberg Uncertainty physics, where the mere act of observing something can change it. Consider the following:@footnote{Thanks to Hermann Peifer for this example.} @@ -29624,14 +29656,14 @@ gawk> @kbd{n} @ii{Keep going @dots{}} @print{} main() at `test.awk':1 @print{} 1 @{ print typeof($1), typeof($2) @} gawk> @kbd{n} @ii{Get result from} typeof() -@print{} strnum string @ii{Result for} $2 @ii{isn't right} +@print{} strnum number @ii{Result for} $2 @ii{isn't right} @print{} Program exited normally with exit value: 0 gawk> @kbd{quit} @end example In this case, the act of comparing the new value of @code{$2} with the old one caused @command{gawk} to evaluate it and determine that it -is indeed a string, and this is reflected in the result of +is indeed a number, and this is reflected in the result of @code{typeof()}. Cases like this where the debugger is not transparent to the program's |