diff options
-rw-r--r-- | awklib/eg/lib/inplace.awk | 9 | ||||
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/gawk.info | 185 | ||||
-rw-r--r-- | doc/gawk.texi | 13 | ||||
-rw-r--r-- | doc/gawktexi.in | 13 | ||||
-rw-r--r-- | extension/ChangeLog | 6 | ||||
-rw-r--r-- | extension/inplace.3am | 23 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/inplace1.ok | 2 | ||||
-rw-r--r-- | test/inplace2.ok | 2 | ||||
-rw-r--r-- | test/inplace3.ok | 4 |
11 files changed, 151 insertions, 117 deletions
diff --git a/awklib/eg/lib/inplace.awk b/awklib/eg/lib/inplace.awk index 6403a228..d1574654 100644 --- a/awklib/eg/lib/inplace.awk +++ b/awklib/eg/lib/inplace.awk @@ -5,10 +5,15 @@ # Please set INPLACE_SUFFIX to make a backup copy. For example, you may # want to set INPLACE_SUFFIX to .bak on the command line or in a BEGIN rule. +# N.B. We call inplace_end() in the BEGINFILE and END rules so that any +# actions in an ENDFILE rule will be redirected as expected. + BEGINFILE { - inplace_begin(FILENAME, INPLACE_SUFFIX) + if (_inplace_filename != "") + inplace_end(_inplace_filename, INPLACE_SUFFIX) + inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX) } -ENDFILE { +END { inplace_end(FILENAME, INPLACE_SUFFIX) } diff --git a/doc/ChangeLog b/doc/ChangeLog index f8a317fa..f2fa97bc 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2015-03-17 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in: Modify inplace.awk to call inplace_end in BEGINFILE + and END instead of in ENDFILE. This way, actions in ENDFILE rules + will be redirected as expected. + 2015-03-17 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Turn "positive" into non-negative as appropriate. diff --git a/doc/gawk.info b/doc/gawk.info index 2d4fd906..d6aea49f 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -25670,11 +25670,16 @@ performs "in-place" editing of each input file. It uses the bundled # Please set INPLACE_SUFFIX to make a backup copy. For example, you may # want to set INPLACE_SUFFIX to .bak on the command line or in a BEGIN rule. + # N.B. We call inplace_end() in the BEGINFILE and END rules so that any + # actions in an ENDFILE rule will be redirected as expected. + BEGINFILE { - inplace_begin(FILENAME, INPLACE_SUFFIX) + if (_inplace_filename != "") + inplace_end(_inplace_filename, INPLACE_SUFFIX) + inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX) } - ENDFILE { + END { inplace_end(FILENAME, INPLACE_SUFFIX) } @@ -25686,6 +25691,10 @@ the extension restores standard output to its original destination. If a backup file name created by appending that suffix. Finally, the temporary file is renamed to the original file name. + The `_inplace_filename' variable serves to keep track of the current +filename so as to not invoke `inplace_end()' before processing the +first file. + If any error occurs, the extension issues a fatal error to terminate processing immediately without damaging the original file. @@ -34955,91 +34964,91 @@ Node: Extension Sample File Functions1023254 Node: Extension Sample Fnmatch1030935 Node: Extension Sample Fork1032423 Node: Extension Sample Inplace1033638 -Node: Extension Sample Ord1035314 -Node: Extension Sample Readdir1036150 -Ref: table-readdir-file-types1037027 -Node: Extension Sample Revout1037838 -Node: Extension Sample Rev2way1038427 -Node: Extension Sample Read write array1039167 -Node: Extension Sample Readfile1041107 -Node: Extension Sample Time1042202 -Node: Extension Sample API Tests1043550 -Node: gawkextlib1044041 -Node: Extension summary1046719 -Node: Extension Exercises1050408 -Node: Language History1051130 -Node: V7/SVR3.11052786 -Node: SVR41054939 -Node: POSIX1056373 -Node: BTL1057754 -Node: POSIX/GNU1058485 -Node: Feature History1064006 -Node: Common Extensions1077104 -Node: Ranges and Locales1078476 -Ref: Ranges and Locales-Footnote-11083095 -Ref: Ranges and Locales-Footnote-21083122 -Ref: Ranges and Locales-Footnote-31083357 -Node: Contributors1083578 -Node: History summary1089118 -Node: Installation1090497 -Node: Gawk Distribution1091443 -Node: Getting1091927 -Node: Extracting1092750 -Node: Distribution contents1094387 -Node: Unix Installation1100141 -Node: Quick Installation1100758 -Node: Additional Configuration Options1103182 -Node: Configuration Philosophy1104985 -Node: Non-Unix Installation1107354 -Node: PC Installation1107812 -Node: PC Binary Installation1109132 -Node: PC Compiling1110980 -Ref: PC Compiling-Footnote-11114001 -Node: PC Testing1114110 -Node: PC Using1115286 -Node: Cygwin1119401 -Node: MSYS1120171 -Node: VMS Installation1120672 -Node: VMS Compilation1121464 -Ref: VMS Compilation-Footnote-11122693 -Node: VMS Dynamic Extensions1122751 -Node: VMS Installation Details1124435 -Node: VMS Running1126686 -Node: VMS GNV1129526 -Node: VMS Old Gawk1130261 -Node: Bugs1130731 -Node: Other Versions1134620 -Node: Installation summary1141054 -Node: Notes1142113 -Node: Compatibility Mode1142978 -Node: Additions1143760 -Node: Accessing The Source1144685 -Node: Adding Code1146120 -Node: New Ports1152277 -Node: Derived Files1156759 -Ref: Derived Files-Footnote-11162234 -Ref: Derived Files-Footnote-21162268 -Ref: Derived Files-Footnote-31162864 -Node: Future Extensions1162978 -Node: Implementation Limitations1163584 -Node: Extension Design1164832 -Node: Old Extension Problems1165986 -Ref: Old Extension Problems-Footnote-11167503 -Node: Extension New Mechanism Goals1167560 -Ref: Extension New Mechanism Goals-Footnote-11170920 -Node: Extension Other Design Decisions1171109 -Node: Extension Future Growth1173217 -Node: Old Extension Mechanism1174053 -Node: Notes summary1175815 -Node: Basic Concepts1177001 -Node: Basic High Level1177682 -Ref: figure-general-flow1177954 -Ref: figure-process-flow1178553 -Ref: Basic High Level-Footnote-11181782 -Node: Basic Data Typing1181967 -Node: Glossary1185295 -Node: Copying1217224 -Node: GNU Free Documentation License1254780 -Node: Index1279916 +Node: Extension Sample Ord1035724 +Node: Extension Sample Readdir1036560 +Ref: table-readdir-file-types1037437 +Node: Extension Sample Revout1038248 +Node: Extension Sample Rev2way1038837 +Node: Extension Sample Read write array1039577 +Node: Extension Sample Readfile1041517 +Node: Extension Sample Time1042612 +Node: Extension Sample API Tests1043960 +Node: gawkextlib1044451 +Node: Extension summary1047129 +Node: Extension Exercises1050818 +Node: Language History1051540 +Node: V7/SVR3.11053196 +Node: SVR41055349 +Node: POSIX1056783 +Node: BTL1058164 +Node: POSIX/GNU1058895 +Node: Feature History1064416 +Node: Common Extensions1077514 +Node: Ranges and Locales1078886 +Ref: Ranges and Locales-Footnote-11083505 +Ref: Ranges and Locales-Footnote-21083532 +Ref: Ranges and Locales-Footnote-31083767 +Node: Contributors1083988 +Node: History summary1089528 +Node: Installation1090907 +Node: Gawk Distribution1091853 +Node: Getting1092337 +Node: Extracting1093160 +Node: Distribution contents1094797 +Node: Unix Installation1100551 +Node: Quick Installation1101168 +Node: Additional Configuration Options1103592 +Node: Configuration Philosophy1105395 +Node: Non-Unix Installation1107764 +Node: PC Installation1108222 +Node: PC Binary Installation1109542 +Node: PC Compiling1111390 +Ref: PC Compiling-Footnote-11114411 +Node: PC Testing1114520 +Node: PC Using1115696 +Node: Cygwin1119811 +Node: MSYS1120581 +Node: VMS Installation1121082 +Node: VMS Compilation1121874 +Ref: VMS Compilation-Footnote-11123103 +Node: VMS Dynamic Extensions1123161 +Node: VMS Installation Details1124845 +Node: VMS Running1127096 +Node: VMS GNV1129936 +Node: VMS Old Gawk1130671 +Node: Bugs1131141 +Node: Other Versions1135030 +Node: Installation summary1141464 +Node: Notes1142523 +Node: Compatibility Mode1143388 +Node: Additions1144170 +Node: Accessing The Source1145095 +Node: Adding Code1146530 +Node: New Ports1152687 +Node: Derived Files1157169 +Ref: Derived Files-Footnote-11162644 +Ref: Derived Files-Footnote-21162678 +Ref: Derived Files-Footnote-31163274 +Node: Future Extensions1163388 +Node: Implementation Limitations1163994 +Node: Extension Design1165242 +Node: Old Extension Problems1166396 +Ref: Old Extension Problems-Footnote-11167913 +Node: Extension New Mechanism Goals1167970 +Ref: Extension New Mechanism Goals-Footnote-11171330 +Node: Extension Other Design Decisions1171519 +Node: Extension Future Growth1173627 +Node: Old Extension Mechanism1174463 +Node: Notes summary1176225 +Node: Basic Concepts1177411 +Node: Basic High Level1178092 +Ref: figure-general-flow1178364 +Ref: figure-process-flow1178963 +Ref: Basic High Level-Footnote-11182192 +Node: Basic Data Typing1182377 +Node: Glossary1185705 +Node: Copying1217634 +Node: GNU Free Documentation License1255190 +Node: Index1280326 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 8d219a0f..96d3370e 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -34595,11 +34595,16 @@ properly: # Please set INPLACE_SUFFIX to make a backup copy. For example, you may # want to set INPLACE_SUFFIX to .bak on the command line or in a BEGIN rule. +# N.B. We call inplace_end() in the BEGINFILE and END rules so that any +# actions in an ENDFILE rule will be redirected as expected. + BEGINFILE @{ - inplace_begin(FILENAME, INPLACE_SUFFIX) + if (_inplace_filename != "") + inplace_end(_inplace_filename, INPLACE_SUFFIX) + inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX) @} -ENDFILE @{ +END @{ inplace_end(FILENAME, INPLACE_SUFFIX) @} @end group @@ -34614,6 +34619,10 @@ If @code{INPLACE_SUFFIX} is not an empty string, the original file is linked to a backup @value{FN} created by appending that suffix. Finally, the temporary file is renamed to the original @value{FN}. +The @code{_inplace_filename} variable serves to keep track of the +current filename so as to not invoke @code{inplace_end()} before +processing the first file. + If any error occurs, the extension issues a fatal error to terminate processing immediately without damaging the original file. diff --git a/doc/gawktexi.in b/doc/gawktexi.in index d4067f70..08a9f7c3 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -33686,11 +33686,16 @@ properly: # Please set INPLACE_SUFFIX to make a backup copy. For example, you may # want to set INPLACE_SUFFIX to .bak on the command line or in a BEGIN rule. +# N.B. We call inplace_end() in the BEGINFILE and END rules so that any +# actions in an ENDFILE rule will be redirected as expected. + BEGINFILE @{ - inplace_begin(FILENAME, INPLACE_SUFFIX) + if (_inplace_filename != "") + inplace_end(_inplace_filename, INPLACE_SUFFIX) + inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX) @} -ENDFILE @{ +END @{ inplace_end(FILENAME, INPLACE_SUFFIX) @} @end group @@ -33705,6 +33710,10 @@ If @code{INPLACE_SUFFIX} is not an empty string, the original file is linked to a backup @value{FN} created by appending that suffix. Finally, the temporary file is renamed to the original @value{FN}. +The @code{_inplace_filename} variable serves to keep track of the +current filename so as to not invoke @code{inplace_end()} before +processing the first file. + If any error occurs, the extension issues a fatal error to terminate processing immediately without damaging the original file. diff --git a/extension/ChangeLog b/extension/ChangeLog index 9d7e6173..b3c9c0d7 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,9 @@ +2015-03-18 Arnold D. Robbins <arnold@skeeve.com> + + * inplace.3am (SYNOPSIS): Updated to not show the contents + of the extension. + (BUGS): Removed. + 2015-03-17 Arnold D. Robbins <arnold@skeeve.com> * inplace.c (do_inplace_begin): Jump through more hoops to satisfy diff --git a/extension/inplace.3am b/extension/inplace.3am index d6339c4a..f8fc098f 100644 --- a/extension/inplace.3am +++ b/extension/inplace.3am @@ -1,21 +1,10 @@ -.TH INPLACE 3am "Mar 16 2015" "Free Software Foundation" "GNU Awk Extension Modules" +.TH INPLACE 3am "Mar 18 2015" "Free Software Foundation" "GNU Awk Extension Modules" .SH NAME inplace \- emulate sed/perl/ruby in-place editing .SH SYNOPSIS .ft CW .nf -@load "inplace" - -# Please set INPLACE_SUFFIX to make a backup copy. For example, you may -# want to set INPLACE_SUFFIX to .bak on the command line or in a BEGIN rule. - -BEGINFILE { - inplace_begin(FILENAME, INPLACE_SUFFIX) -} - -ENDFILE { - inplace_end(FILENAME, INPLACE_SUFFIX) -} +gawk -i inplace ... .fi .ft R .SH DESCRIPTION @@ -27,8 +16,7 @@ and .BR inplace_end() . These functions are meant to be invoked from the .I inplace.awk -wrapper (whose contents are displayed above) -which is installed when +wrapper which is installed when .I gawk is. .PP @@ -45,10 +33,7 @@ extension concatenates that suffix onto the original filename and uses the result as a filename for renaming the original. ... .SH NOTES -.SH BUGS -As currently written, output from an \f(CWENDFILE\fP -rule does not get redirected into the replacement file. -Neither does output from an \f(CWEND\fP rule. +... .SH BUGS .SH EXAMPLE .ft CW .nf diff --git a/test/ChangeLog b/test/ChangeLog index 24d6bcd7..c33ac108 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-03-17 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * inplace1.ok, inplace2.ok, inplace3.ok: Update error message line + numbers to reflect changes to inplace.awk. + 2015-03-17 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (mpfrmemok1): New test. diff --git a/test/inplace1.ok b/test/inplace1.ok index ffcb768d..82562235 100644 --- a/test/inplace1.ok +++ b/test/inplace1.ok @@ -1,5 +1,5 @@ before -gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' +gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' stdin start is bar replaced? stdin end diff --git a/test/inplace2.ok b/test/inplace2.ok index ffcb768d..82562235 100644 --- a/test/inplace2.ok +++ b/test/inplace2.ok @@ -1,5 +1,5 @@ before -gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' +gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' stdin start is bar replaced? stdin end diff --git a/test/inplace3.ok b/test/inplace3.ok index 7cd960bc..a7b7254f 100644 --- a/test/inplace3.ok +++ b/test/inplace3.ok @@ -1,11 +1,11 @@ before -gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' +gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' stdin start is bar replaced? stdin end after Before -gawk: inplace:9: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' +gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-' stdin start is foo replaced? stdin end |