diff options
-rw-r--r-- | awklib/ChangeLog | 4 | ||||
-rw-r--r-- | awklib/eg/network/stoxpred.awk | 29 | ||||
-rw-r--r-- | awklib/eg/prog/extract.awk | 11 | ||||
-rw-r--r-- | awklib/eg/prog/indirectcall.awk | 45 | ||||
-rw-r--r-- | awklib/extract.awk | 10 | ||||
-rw-r--r-- | doc/ChangeLog | 8 | ||||
-rw-r--r-- | doc/gawk.info | 492 | ||||
-rw-r--r-- | doc/gawk.texi | 29 | ||||
-rw-r--r-- | doc/gawktexi.in | 29 |
9 files changed, 390 insertions, 267 deletions
diff --git a/awklib/ChangeLog b/awklib/ChangeLog index 4fdcb8b2..acc0d205 100644 --- a/awklib/ChangeLog +++ b/awklib/ChangeLog @@ -1,3 +1,7 @@ +2018-05-27 Arnold D. Robbins <arnold@skeeve.com> + + * extract.awk: Updated after changes. + 2018-04-11 Arnold D. Robbins <arnold@skeeve.com> * .gitignore: Add pwcat.c and grcat.c. Remove igawk. Sort the list. diff --git a/awklib/eg/network/stoxpred.awk b/awklib/eg/network/stoxpred.awk index 62744c14..aa1fbe9f 100644 --- a/awklib/eg/network/stoxpred.awk +++ b/awklib/eg/network/stoxpred.awk @@ -1,3 +1,32 @@ +BEGIN { + Init() + ReadQuotes() + CleanUp() + Prediction() + Report() + SendMail() +} +function Init() { + if (ARGC != 1) { + print "STOXPRED - daily stock share prediction" + print "IN:\n no parameters, nothing on stdin" + print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80" + print "OUT:\n commented predictions as email" + print "JK 09.10.2000" + exit + } + # Remember ticker symbols from Dow Jones Industrial Index + StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \ + SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \ + MRK XOM EK IP", name); + # Remember the current date as the end of the time series + day = strftime("%d") + month = strftime("%m") + year = strftime("%Y") + if (Proxy == "") Proxy = "chart.yahoo.com" + if (ProxyPort == 0) ProxyPort = 80 + YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort +} function ReadQuotes() { # Retrieve historical data for each ticker symbol FS = "," diff --git a/awklib/eg/prog/extract.awk b/awklib/eg/prog/extract.awk index f5dfcf40..ff598e8e 100644 --- a/awklib/eg/prog/extract.awk +++ b/awklib/eg/prog/extract.awk @@ -30,7 +30,7 @@ BEGIN { IGNORECASE = 1 } } if ($3 != curfile) { if (curfile != "") - close(curfile) + filelist[curfile]++ # save to close later curfile = $3 } @@ -60,14 +60,13 @@ BEGIN { IGNORECASE = 1 } print join(a, 1, n, SUBSEP) > curfile } } +END { + for (f in filelist) + close(filelist[f]) +} function unexpected_eof() { printf("extract: %s:%d: unexpected EOF or error\n", FILENAME, FNR) > "/dev/stderr" exit 1 } - -END { - if (curfile) - close(curfile) -} diff --git a/awklib/eg/prog/indirectcall.awk b/awklib/eg/prog/indirectcall.awk index 165b022a..b2b82686 100644 --- a/awklib/eg/prog/indirectcall.awk +++ b/awklib/eg/prog/indirectcall.awk @@ -1,3 +1,48 @@ +# indirectcall.awk --- Demonstrate indirect function calls +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# January 2009 +# average --- return the average of the values in fields $first - $last + +function average(first, last, sum, i) +{ + sum = 0; + for (i = first; i <= last; i++) + sum += $i + + return sum / (last - first + 1) +} + +# sum --- return the sum of the values in fields $first - $last + +function sum(first, last, ret, i) +{ + ret = 0; + for (i = first; i <= last; i++) + ret += $i + + return ret +} +# For each record, print the class name and the requested statistics +{ + class_name = $1 + gsub(/_/, " ", class_name) # Replace _ with spaces + + # find start + for (i = 1; i <= NF; i++) { + if ($i == "data:") { + start = i + 1 + break + } + } + + printf("%s:\n", class_name) + for (i = 2; $i != "data:"; i++) { + the_function = $i + printf("\t%s: <%s>\n", $i, @the_function(start, NF) "") + } + print "" +} # num_lt --- do a numeric less than comparison function num_lt(left, right) diff --git a/awklib/extract.awk b/awklib/extract.awk index 2662574b..96fc9498 100644 --- a/awklib/extract.awk +++ b/awklib/extract.awk @@ -30,7 +30,7 @@ BEGIN { IGNORECASE = 1 } } if ($3 != curfile) { if (curfile != "") - close(curfile) + filelist[curfile]++ # save to close later curfile = $3 } @@ -60,6 +60,10 @@ BEGIN { IGNORECASE = 1 } print join(a, 1, n, SUBSEP) > curfile } } +END { + for (f in filelist) + close(filelist[f]) +} function unexpected_eof() { printf("extract: %s:%d: unexpected EOF or error\n", @@ -67,10 +71,6 @@ function unexpected_eof() exit 1 } -END { - if (curfile) - close(curfile) -} # join.awk --- join an array into a string # # Arnold Robbins, arnold@gnu.org, Public Domain diff --git a/doc/ChangeLog b/doc/ChangeLog index d7b2d858..f4008f00 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2018-05-27 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (Extract Program): Bug fix. Keep the files open + in case one program's bits are intermixed with another's. + Then close them all at the end. Bug report was about + indirectcall.awk but affected another file as well. Thanks + to Ramasahayam Reddy <rureddy57@gmail.com> for the report. + 2018-05-23 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in (Auto-Set): For PROCINFO["sorted_in"], make the xref diff --git a/doc/gawk.info b/doc/gawk.info index 1e3133a3..eb35cef3 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -19003,7 +19003,7 @@ back into a single line. That line is then printed to the output file: } if ($3 != curfile) { if (curfile != "") - close(curfile) + filelist[curfile]++ # save to close later curfile = $3 } @@ -19042,6 +19042,19 @@ source file (as has been done here!) without any hassle. The file is only closed when a new data file name is encountered or at the end of the input file. + When a new file name is encountered, instead of closing the file, the +program saves the name of the current file in 'filelist'. This makes it +possible to interleave the code for more than one file in the Texinfo +input file. (Previous versions of this program _did_ close the file. +But because of the '>' redirection, a file whose parts were not all one +after the other ended up getting clobbered.) An 'END' rule then closes +all the open files when processing is finished: + + END { + for (f in filelist) + close(filelist[f]) + } + Finally, the function 'unexpected_eof()' prints an appropriate error message and then exits. The 'END' rule handles the final cleanup, closing the open file: @@ -19053,11 +19066,6 @@ closing the open file: exit 1 } - END { - if (curfile) - close(curfile) - } - File: gawk.info, Node: Simple Sed, Next: Igawk Program, Prev: Extract Program, Up: Miscellaneous Programs @@ -36363,241 +36371,241 @@ Ref: Labels Program-Footnote-1764674 Node: Word Sorting764758 Node: History Sorting768830 Node: Extract Program770665 -Node: Simple Sed778195 -Node: Igawk Program781269 -Ref: Igawk Program-Footnote-1795600 -Ref: Igawk Program-Footnote-2795802 -Ref: Igawk Program-Footnote-3795924 -Node: Anagram Program796039 -Node: Signature Program799101 -Node: Programs Summary800348 -Node: Programs Exercises801562 -Ref: Programs Exercises-Footnote-1805691 -Node: Advanced Features805782 -Node: Nondecimal Data807772 -Node: Array Sorting809363 -Node: Controlling Array Traversal810063 -Ref: Controlling Array Traversal-Footnote-1818431 -Node: Array Sorting Functions818549 -Ref: Array Sorting Functions-Footnote-1823640 -Node: Two-way I/O823836 -Ref: Two-way I/O-Footnote-1830388 -Ref: Two-way I/O-Footnote-2830575 -Node: TCP/IP Networking830657 -Node: Profiling833775 -Ref: Profiling-Footnote-1842447 -Node: Advanced Features Summary842770 -Node: Internationalization844614 -Node: I18N and L10N846094 -Node: Explaining gettext846781 -Ref: Explaining gettext-Footnote-1852673 -Ref: Explaining gettext-Footnote-2852858 -Node: Programmer i18n853023 -Ref: Programmer i18n-Footnote-1857972 -Node: Translator i18n858021 -Node: String Extraction858815 -Ref: String Extraction-Footnote-1859947 -Node: Printf Ordering860033 -Ref: Printf Ordering-Footnote-1862819 -Node: I18N Portability862883 -Ref: I18N Portability-Footnote-1865339 -Node: I18N Example865402 -Ref: I18N Example-Footnote-1868208 -Node: Gawk I18N868281 -Node: I18N Summary868926 -Node: Debugger870267 -Node: Debugging871290 -Node: Debugging Concepts871731 -Node: Debugging Terms873540 -Node: Awk Debugging876115 -Node: Sample Debugging Session877021 -Node: Debugger Invocation877555 -Node: Finding The Bug878941 -Node: List of Debugger Commands885419 -Node: Breakpoint Control886752 -Node: Debugger Execution Control890446 -Node: Viewing And Changing Data893808 -Node: Execution Stack897182 -Node: Debugger Info898819 -Node: Miscellaneous Debugger Commands902890 -Node: Readline Support907952 -Node: Limitations908848 -Node: Debugging Summary910957 -Node: Arbitrary Precision Arithmetic912236 -Node: Computer Arithmetic913721 -Ref: table-numeric-ranges917487 -Ref: table-floating-point-ranges917980 -Ref: Computer Arithmetic-Footnote-1918638 -Node: Math Definitions918695 -Ref: table-ieee-formats922011 -Ref: Math Definitions-Footnote-1922614 -Node: MPFR features922719 -Node: FP Math Caution924437 -Ref: FP Math Caution-Footnote-1925509 -Node: Inexactness of computations925878 -Node: Inexact representation926838 -Node: Comparing FP Values928198 -Node: Errors accumulate929280 -Node: Getting Accuracy930713 -Node: Try To Round933423 -Node: Setting precision934322 -Ref: table-predefined-precision-strings935019 -Node: Setting the rounding mode936849 -Ref: table-gawk-rounding-modes937223 -Ref: Setting the rounding mode-Footnote-1941154 -Node: Arbitrary Precision Integers941333 -Ref: Arbitrary Precision Integers-Footnote-1944508 -Node: Checking for MPFR944657 -Node: POSIX Floating Point Problems946131 -Ref: POSIX Floating Point Problems-Footnote-1950002 -Node: Floating point summary950040 -Node: Dynamic Extensions952230 -Node: Extension Intro953783 -Node: Plugin License955049 -Node: Extension Mechanism Outline955846 -Ref: figure-load-extension956285 -Ref: figure-register-new-function957850 -Ref: figure-call-new-function958942 -Node: Extension API Description961004 -Node: Extension API Functions Introduction962646 -Node: General Data Types968186 -Ref: General Data Types-Footnote-1976547 -Node: Memory Allocation Functions976846 -Ref: Memory Allocation Functions-Footnote-1981056 -Node: Constructor Functions981155 -Node: Registration Functions984741 -Node: Extension Functions985426 -Node: Exit Callback Functions990641 -Node: Extension Version String991891 -Node: Input Parsers992554 -Node: Output Wrappers1005275 -Node: Two-way processors1009787 -Node: Printing Messages1012052 -Ref: Printing Messages-Footnote-11013223 -Node: Updating ERRNO1013376 -Node: Requesting Values1014115 -Ref: table-value-types-returned1014852 -Node: Accessing Parameters1015788 -Node: Symbol Table Access1017023 -Node: Symbol table by name1017535 -Node: Symbol table by cookie1019324 -Ref: Symbol table by cookie-Footnote-11023509 -Node: Cached values1023573 -Ref: Cached values-Footnote-11027109 -Node: Array Manipulation1027262 -Ref: Array Manipulation-Footnote-11028353 -Node: Array Data Types1028390 -Ref: Array Data Types-Footnote-11031048 -Node: Array Functions1031140 -Node: Flattening Arrays1035638 -Node: Creating Arrays1042614 -Node: Redirection API1047381 -Node: Extension API Variables1050214 -Node: Extension Versioning1050925 -Ref: gawk-api-version1051354 -Node: Extension GMP/MPFR Versioning1053085 -Node: Extension API Informational Variables1054713 -Node: Extension API Boilerplate1055786 -Node: Changes from API V11059760 -Node: Finding Extensions1061332 -Node: Extension Example1061891 -Node: Internal File Description1062689 -Node: Internal File Ops1066769 -Ref: Internal File Ops-Footnote-11078119 -Node: Using Internal File Ops1078259 -Ref: Using Internal File Ops-Footnote-11080642 -Node: Extension Samples1080916 -Node: Extension Sample File Functions1082445 -Node: Extension Sample Fnmatch1090094 -Node: Extension Sample Fork1091581 -Node: Extension Sample Inplace1092799 -Node: Extension Sample Ord1096016 -Node: Extension Sample Readdir1096852 -Ref: table-readdir-file-types1097741 -Node: Extension Sample Revout1098546 -Node: Extension Sample Rev2way1099135 -Node: Extension Sample Read write array1099875 -Node: Extension Sample Readfile1101817 -Node: Extension Sample Time1102912 -Node: Extension Sample API Tests1104260 -Node: gawkextlib1104752 -Node: Extension summary1107670 -Node: Extension Exercises1111372 -Node: Language History1112870 -Node: V7/SVR3.11114526 -Node: SVR41116678 -Node: POSIX1118112 -Node: BTL1119492 -Node: POSIX/GNU1120221 -Node: Feature History1125999 -Node: Common Extensions1141858 -Node: Ranges and Locales1143141 -Ref: Ranges and Locales-Footnote-11147757 -Ref: Ranges and Locales-Footnote-21147784 -Ref: Ranges and Locales-Footnote-31148019 -Node: Contributors1148240 -Node: History summary1154185 -Node: Installation1155565 -Node: Gawk Distribution1156509 -Node: Getting1156993 -Node: Extracting1157956 -Node: Distribution contents1159594 -Node: Unix Installation1166074 -Node: Quick Installation1166756 -Node: Shell Startup Files1169170 -Node: Additional Configuration Options1170259 -Node: Configuration Philosophy1172552 -Node: Non-Unix Installation1174921 -Node: PC Installation1175381 -Node: PC Binary Installation1176219 -Node: PC Compiling1176654 -Node: PC Using1177771 -Node: Cygwin1180986 -Node: MSYS1182085 -Node: VMS Installation1182586 -Node: VMS Compilation1183377 -Ref: VMS Compilation-Footnote-11184606 -Node: VMS Dynamic Extensions1184664 -Node: VMS Installation Details1186349 -Node: VMS Running1188602 -Node: VMS GNV1192881 -Node: VMS Old Gawk1193616 -Node: Bugs1194087 -Node: Bug address1194750 -Node: Usenet1197542 -Node: Maintainers1198319 -Node: Other Versions1199580 -Node: Installation summary1206342 -Node: Notes1207544 -Node: Compatibility Mode1208409 -Node: Additions1209191 -Node: Accessing The Source1210116 -Node: Adding Code1211553 -Node: New Ports1217772 -Node: Derived Files1222260 -Ref: Derived Files-Footnote-11227906 -Ref: Derived Files-Footnote-21227941 -Ref: Derived Files-Footnote-31228539 -Node: Future Extensions1228653 -Node: Implementation Limitations1229311 -Node: Extension Design1230494 -Node: Old Extension Problems1231648 -Ref: Old Extension Problems-Footnote-11233166 -Node: Extension New Mechanism Goals1233223 -Ref: Extension New Mechanism Goals-Footnote-11236587 -Node: Extension Other Design Decisions1236776 -Node: Extension Future Growth1238889 -Node: Old Extension Mechanism1239725 -Node: Notes summary1241488 -Node: Basic Concepts1242670 -Node: Basic High Level1243351 -Ref: figure-general-flow1243633 -Ref: figure-process-flow1244318 -Ref: Basic High Level-Footnote-11247619 -Node: Basic Data Typing1247804 -Node: Glossary1251132 -Node: Copying1282970 -Node: GNU Free Documentation License1320513 -Node: Index1345633 +Node: Simple Sed778716 +Node: Igawk Program781790 +Ref: Igawk Program-Footnote-1796121 +Ref: Igawk Program-Footnote-2796323 +Ref: Igawk Program-Footnote-3796445 +Node: Anagram Program796560 +Node: Signature Program799622 +Node: Programs Summary800869 +Node: Programs Exercises802083 +Ref: Programs Exercises-Footnote-1806212 +Node: Advanced Features806303 +Node: Nondecimal Data808293 +Node: Array Sorting809884 +Node: Controlling Array Traversal810584 +Ref: Controlling Array Traversal-Footnote-1818952 +Node: Array Sorting Functions819070 +Ref: Array Sorting Functions-Footnote-1824161 +Node: Two-way I/O824357 +Ref: Two-way I/O-Footnote-1830909 +Ref: Two-way I/O-Footnote-2831096 +Node: TCP/IP Networking831178 +Node: Profiling834296 +Ref: Profiling-Footnote-1842968 +Node: Advanced Features Summary843291 +Node: Internationalization845135 +Node: I18N and L10N846615 +Node: Explaining gettext847302 +Ref: Explaining gettext-Footnote-1853194 +Ref: Explaining gettext-Footnote-2853379 +Node: Programmer i18n853544 +Ref: Programmer i18n-Footnote-1858493 +Node: Translator i18n858542 +Node: String Extraction859336 +Ref: String Extraction-Footnote-1860468 +Node: Printf Ordering860554 +Ref: Printf Ordering-Footnote-1863340 +Node: I18N Portability863404 +Ref: I18N Portability-Footnote-1865860 +Node: I18N Example865923 +Ref: I18N Example-Footnote-1868729 +Node: Gawk I18N868802 +Node: I18N Summary869447 +Node: Debugger870788 +Node: Debugging871811 +Node: Debugging Concepts872252 +Node: Debugging Terms874061 +Node: Awk Debugging876636 +Node: Sample Debugging Session877542 +Node: Debugger Invocation878076 +Node: Finding The Bug879462 +Node: List of Debugger Commands885940 +Node: Breakpoint Control887273 +Node: Debugger Execution Control890967 +Node: Viewing And Changing Data894329 +Node: Execution Stack897703 +Node: Debugger Info899340 +Node: Miscellaneous Debugger Commands903411 +Node: Readline Support908473 +Node: Limitations909369 +Node: Debugging Summary911478 +Node: Arbitrary Precision Arithmetic912757 +Node: Computer Arithmetic914242 +Ref: table-numeric-ranges918008 +Ref: table-floating-point-ranges918501 +Ref: Computer Arithmetic-Footnote-1919159 +Node: Math Definitions919216 +Ref: table-ieee-formats922532 +Ref: Math Definitions-Footnote-1923135 +Node: MPFR features923240 +Node: FP Math Caution924958 +Ref: FP Math Caution-Footnote-1926030 +Node: Inexactness of computations926399 +Node: Inexact representation927359 +Node: Comparing FP Values928719 +Node: Errors accumulate929801 +Node: Getting Accuracy931234 +Node: Try To Round933944 +Node: Setting precision934843 +Ref: table-predefined-precision-strings935540 +Node: Setting the rounding mode937370 +Ref: table-gawk-rounding-modes937744 +Ref: Setting the rounding mode-Footnote-1941675 +Node: Arbitrary Precision Integers941854 +Ref: Arbitrary Precision Integers-Footnote-1945029 +Node: Checking for MPFR945178 +Node: POSIX Floating Point Problems946652 +Ref: POSIX Floating Point Problems-Footnote-1950523 +Node: Floating point summary950561 +Node: Dynamic Extensions952751 +Node: Extension Intro954304 +Node: Plugin License955570 +Node: Extension Mechanism Outline956367 +Ref: figure-load-extension956806 +Ref: figure-register-new-function958371 +Ref: figure-call-new-function959463 +Node: Extension API Description961525 +Node: Extension API Functions Introduction963167 +Node: General Data Types968707 +Ref: General Data Types-Footnote-1977068 +Node: Memory Allocation Functions977367 +Ref: Memory Allocation Functions-Footnote-1981577 +Node: Constructor Functions981676 +Node: Registration Functions985262 +Node: Extension Functions985947 +Node: Exit Callback Functions991162 +Node: Extension Version String992412 +Node: Input Parsers993075 +Node: Output Wrappers1005796 +Node: Two-way processors1010308 +Node: Printing Messages1012573 +Ref: Printing Messages-Footnote-11013744 +Node: Updating ERRNO1013897 +Node: Requesting Values1014636 +Ref: table-value-types-returned1015373 +Node: Accessing Parameters1016309 +Node: Symbol Table Access1017544 +Node: Symbol table by name1018056 +Node: Symbol table by cookie1019845 +Ref: Symbol table by cookie-Footnote-11024030 +Node: Cached values1024094 +Ref: Cached values-Footnote-11027630 +Node: Array Manipulation1027783 +Ref: Array Manipulation-Footnote-11028874 +Node: Array Data Types1028911 +Ref: Array Data Types-Footnote-11031569 +Node: Array Functions1031661 +Node: Flattening Arrays1036159 +Node: Creating Arrays1043135 +Node: Redirection API1047902 +Node: Extension API Variables1050735 +Node: Extension Versioning1051446 +Ref: gawk-api-version1051875 +Node: Extension GMP/MPFR Versioning1053606 +Node: Extension API Informational Variables1055234 +Node: Extension API Boilerplate1056307 +Node: Changes from API V11060281 +Node: Finding Extensions1061853 +Node: Extension Example1062412 +Node: Internal File Description1063210 +Node: Internal File Ops1067290 +Ref: Internal File Ops-Footnote-11078640 +Node: Using Internal File Ops1078780 +Ref: Using Internal File Ops-Footnote-11081163 +Node: Extension Samples1081437 +Node: Extension Sample File Functions1082966 +Node: Extension Sample Fnmatch1090615 +Node: Extension Sample Fork1092102 +Node: Extension Sample Inplace1093320 +Node: Extension Sample Ord1096537 +Node: Extension Sample Readdir1097373 +Ref: table-readdir-file-types1098262 +Node: Extension Sample Revout1099067 +Node: Extension Sample Rev2way1099656 +Node: Extension Sample Read write array1100396 +Node: Extension Sample Readfile1102338 +Node: Extension Sample Time1103433 +Node: Extension Sample API Tests1104781 +Node: gawkextlib1105273 +Node: Extension summary1108191 +Node: Extension Exercises1111893 +Node: Language History1113391 +Node: V7/SVR3.11115047 +Node: SVR41117199 +Node: POSIX1118633 +Node: BTL1120013 +Node: POSIX/GNU1120742 +Node: Feature History1126520 +Node: Common Extensions1142379 +Node: Ranges and Locales1143662 +Ref: Ranges and Locales-Footnote-11148278 +Ref: Ranges and Locales-Footnote-21148305 +Ref: Ranges and Locales-Footnote-31148540 +Node: Contributors1148761 +Node: History summary1154706 +Node: Installation1156086 +Node: Gawk Distribution1157030 +Node: Getting1157514 +Node: Extracting1158477 +Node: Distribution contents1160115 +Node: Unix Installation1166595 +Node: Quick Installation1167277 +Node: Shell Startup Files1169691 +Node: Additional Configuration Options1170780 +Node: Configuration Philosophy1173073 +Node: Non-Unix Installation1175442 +Node: PC Installation1175902 +Node: PC Binary Installation1176740 +Node: PC Compiling1177175 +Node: PC Using1178292 +Node: Cygwin1181507 +Node: MSYS1182606 +Node: VMS Installation1183107 +Node: VMS Compilation1183898 +Ref: VMS Compilation-Footnote-11185127 +Node: VMS Dynamic Extensions1185185 +Node: VMS Installation Details1186870 +Node: VMS Running1189123 +Node: VMS GNV1193402 +Node: VMS Old Gawk1194137 +Node: Bugs1194608 +Node: Bug address1195271 +Node: Usenet1198063 +Node: Maintainers1198840 +Node: Other Versions1200101 +Node: Installation summary1206863 +Node: Notes1208065 +Node: Compatibility Mode1208930 +Node: Additions1209712 +Node: Accessing The Source1210637 +Node: Adding Code1212074 +Node: New Ports1218293 +Node: Derived Files1222781 +Ref: Derived Files-Footnote-11228427 +Ref: Derived Files-Footnote-21228462 +Ref: Derived Files-Footnote-31229060 +Node: Future Extensions1229174 +Node: Implementation Limitations1229832 +Node: Extension Design1231015 +Node: Old Extension Problems1232169 +Ref: Old Extension Problems-Footnote-11233687 +Node: Extension New Mechanism Goals1233744 +Ref: Extension New Mechanism Goals-Footnote-11237108 +Node: Extension Other Design Decisions1237297 +Node: Extension Future Growth1239410 +Node: Old Extension Mechanism1240246 +Node: Notes summary1242009 +Node: Basic Concepts1243191 +Node: Basic High Level1243872 +Ref: figure-general-flow1244154 +Ref: figure-process-flow1244839 +Ref: Basic High Level-Footnote-11248140 +Node: Basic Data Typing1248325 +Node: Glossary1251653 +Node: Copying1283491 +Node: GNU Free Documentation License1321034 +Node: Index1346154 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index b6685951..9a3c75fd 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -21081,7 +21081,7 @@ using indirect function calls: @ignore @c file eg/prog/indirectcall.awk # -# Arnold Robbins, arnold@skeeve.com, Public Domain +# Arnold Robbins, arnold@@skeeve.com, Public Domain # January 2009 @c endfile @end ignore @@ -26728,7 +26728,7 @@ line. That line is then printed to the output file: @} if ($3 != curfile) @{ if (curfile != "") - close(curfile) + filelist[curfile]++ # save to close later curfile = $3 @} @@ -26772,6 +26772,26 @@ sample source file (as has been done here!) without any hassle. The file is only closed when a new @value{DF} name is encountered or at the end of the input file. +When a new @value{FN} is encountered, instead of closing the file, +the program saves the name of the current file in @code{filelist}. +This makes it possible to interleave the code for more than one file in +the Texinfo input file. (Previous versions of this program @emph{did} +close the file. But because of the @samp{>} redirection, a file whose +parts were not all one after the other ended up getting clobbered.) +An @code{END} rule then closes all the open files when processing +is finished: + +@example +@c file eg/prog/extract.awk +@group +END @{ + for (f in filelist) + close(filelist[f]) +@} +@end group +@c endfile +@end example + Finally, the function @code{@w{unexpected_eof()}} prints an appropriate error message and then exits. The @code{END} rule handles the final cleanup, closing the open file: @@ -26786,11 +26806,6 @@ function unexpected_eof() exit 1 @} @end group - -END @{ - if (curfile) - close(curfile) -@} @c endfile @end example diff --git a/doc/gawktexi.in b/doc/gawktexi.in index b62d12cd..c645a8ec 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -20124,7 +20124,7 @@ using indirect function calls: @ignore @c file eg/prog/indirectcall.awk # -# Arnold Robbins, arnold@skeeve.com, Public Domain +# Arnold Robbins, arnold@@skeeve.com, Public Domain # January 2009 @c endfile @end ignore @@ -25741,7 +25741,7 @@ line. That line is then printed to the output file: @} if ($3 != curfile) @{ if (curfile != "") - close(curfile) + filelist[curfile]++ # save to close later curfile = $3 @} @@ -25785,6 +25785,26 @@ sample source file (as has been done here!) without any hassle. The file is only closed when a new @value{DF} name is encountered or at the end of the input file. +When a new @value{FN} is encountered, instead of closing the file, +the program saves the name of the current file in @code{filelist}. +This makes it possible to interleave the code for more than one file in +the Texinfo input file. (Previous versions of this program @emph{did} +close the file. But because of the @samp{>} redirection, a file whose +parts were not all one after the other ended up getting clobbered.) +An @code{END} rule then closes all the open files when processing +is finished: + +@example +@c file eg/prog/extract.awk +@group +END @{ + for (f in filelist) + close(filelist[f]) +@} +@end group +@c endfile +@end example + Finally, the function @code{@w{unexpected_eof()}} prints an appropriate error message and then exits. The @code{END} rule handles the final cleanup, closing the open file: @@ -25799,11 +25819,6 @@ function unexpected_eof() exit 1 @} @end group - -END @{ - if (curfile) - close(curfile) -@} @c endfile @end example |