summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2015-06-17 16:55:55 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2015-06-17 16:55:55 -0400
commit12e3cbe4220792bbcb58f1d5d3dbbcc6e2f7a1db (patch)
treed5565c617545f99798285f8eefd4c43b9cbde6b6
parentac0ef52fe407b89c7968b927c7b2b513cc13963a (diff)
downloadgawk-12e3cbe4220792bbcb58f1d5d3dbbcc6e2f7a1db.tar.gz
For the inplace extension, add inplace variable to control whether it's active.
-rw-r--r--awklib/eg/lib/inplace.awk18
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gawk.info196
-rw-r--r--doc/gawk.texi23
-rw-r--r--doc/gawktexi.in23
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/inplace.3am9
-rw-r--r--test/ChangeLog5
-rw-r--r--test/inplace1.ok2
-rw-r--r--test/inplace2.ok2
-rw-r--r--test/inplace3.ok4
11 files changed, 193 insertions, 99 deletions
diff --git a/awklib/eg/lib/inplace.awk b/awklib/eg/lib/inplace.awk
index d1574654..15a83f58 100644
--- a/awklib/eg/lib/inplace.awk
+++ b/awklib/eg/lib/inplace.awk
@@ -5,15 +5,29 @@
# 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.
+# By default, each filename on the command line will be edited inplace.
+# But you can selectively disable this by adding an inplace=0 argument
+# prior to files that you do not want to process this way. You can then
+# reenable it later on the commandline by putting inplace=1 before files
+# that you wish to be subject to inplace editing.
+
# 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.
+BEGIN {
+ inplace = 1 # enabled by default
+}
+
BEGINFILE {
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
}
END {
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
}
diff --git a/doc/ChangeLog b/doc/ChangeLog
index d1a1de69..ab1ba2be 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * gawktexi.in: Document new inplace variable to control whether
+ inplace editing is active.
+
2015-06-13 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: Comment out exercise 10.3, since the answer
diff --git a/doc/gawk.info b/doc/gawk.info
index 5eda5ad9..2378fef8 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -25561,17 +25561,31 @@ The 'inplace' extension emulates GNU 'sed''s '-i' option, which performs
# 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.
+ # By default, each filename on the command line will be edited inplace.
+ # But you can selectively disable this by adding an inplace=0 argument
+ # prior to files that you do not want to process this way. You can then
+ # reenable it later on the commandline by putting inplace=1 before files
+ # that you wish to be subject to inplace editing.
+
# 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.
+ BEGIN {
+ inplace = 1 # enabled by default
+ }
+
BEGINFILE {
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
}
END {
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
}
For each regular file that is processed, the extension redirects
@@ -25582,6 +25596,12 @@ 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.
+ Note that the use of this feature can be controlled by placing
+'inplace=0' on the command-line prior to listing files that should not
+be processed this way. You can reenable inplace editing by adding an
+'inplace=1' argument prior to files that should be subject to inplace
+editing.
+
The '_inplace_filename' variable serves to keep track of the current
filename so as to not invoke 'inplace_end()' before processing the first
file.
@@ -34966,91 +34986,91 @@ Node: Extension Sample File Functions1023883
Node: Extension Sample Fnmatch1031532
Node: Extension Sample Fork1033019
Node: Extension Sample Inplace1034237
-Node: Extension Sample Ord1036323
-Node: Extension Sample Readdir1037159
-Ref: table-readdir-file-types1038048
-Node: Extension Sample Revout1038853
-Node: Extension Sample Rev2way1039442
-Node: Extension Sample Read write array1040182
-Node: Extension Sample Readfile1042124
-Node: Extension Sample Time1043219
-Node: Extension Sample API Tests1044567
-Node: gawkextlib1045059
-Node: Extension summary1047483
-Node: Extension Exercises1051175
-Node: Language History1052672
-Node: V7/SVR3.11054328
-Node: SVR41056481
-Node: POSIX1057915
-Node: BTL1059295
-Node: POSIX/GNU1060025
-Node: Feature History1065546
-Node: Common Extensions1078876
-Node: Ranges and Locales1080159
-Ref: Ranges and Locales-Footnote-11084775
-Ref: Ranges and Locales-Footnote-21084802
-Ref: Ranges and Locales-Footnote-31085037
-Node: Contributors1085258
-Node: History summary1090827
-Node: Installation1092207
-Node: Gawk Distribution1093152
-Node: Getting1093636
-Node: Extracting1094459
-Node: Distribution contents1096097
-Node: Unix Installation1101850
-Node: Quick Installation1102466
-Node: Additional Configuration Options1104893
-Node: Configuration Philosophy1106697
-Node: Non-Unix Installation1109067
-Node: PC Installation1109525
-Node: PC Binary Installation1110845
-Node: PC Compiling1112697
-Ref: PC Compiling-Footnote-11115721
-Node: PC Testing1115830
-Node: PC Using1117010
-Node: Cygwin1121124
-Node: MSYS1121894
-Node: VMS Installation1122395
-Node: VMS Compilation1123186
-Ref: VMS Compilation-Footnote-11124416
-Node: VMS Dynamic Extensions1124474
-Node: VMS Installation Details1126159
-Node: VMS Running1128412
-Node: VMS GNV1131253
-Node: VMS Old Gawk1131988
-Node: Bugs1132459
-Node: Other Versions1136573
-Node: Installation summary1143047
-Node: Notes1144105
-Node: Compatibility Mode1144970
-Node: Additions1145752
-Node: Accessing The Source1146677
-Node: Adding Code1148113
-Node: New Ports1154268
-Node: Derived Files1158756
-Ref: Derived Files-Footnote-11164241
-Ref: Derived Files-Footnote-21164276
-Ref: Derived Files-Footnote-31164874
-Node: Future Extensions1164988
-Node: Implementation Limitations1165646
-Node: Extension Design1166829
-Node: Old Extension Problems1167983
-Ref: Old Extension Problems-Footnote-11169501
-Node: Extension New Mechanism Goals1169558
-Ref: Extension New Mechanism Goals-Footnote-11172922
-Node: Extension Other Design Decisions1173111
-Node: Extension Future Growth1175224
-Node: Old Extension Mechanism1176060
-Node: Notes summary1177823
-Node: Basic Concepts1179005
-Node: Basic High Level1179686
-Ref: figure-general-flow1179968
-Ref: figure-process-flow1180653
-Ref: Basic High Level-Footnote-11183954
-Node: Basic Data Typing1184139
-Node: Glossary1187467
-Node: Copying1219413
-Node: GNU Free Documentation License1256952
-Node: Index1282070
+Node: Extension Sample Ord1037166
+Node: Extension Sample Readdir1038002
+Ref: table-readdir-file-types1038891
+Node: Extension Sample Revout1039696
+Node: Extension Sample Rev2way1040285
+Node: Extension Sample Read write array1041025
+Node: Extension Sample Readfile1042967
+Node: Extension Sample Time1044062
+Node: Extension Sample API Tests1045410
+Node: gawkextlib1045902
+Node: Extension summary1048326
+Node: Extension Exercises1052018
+Node: Language History1053515
+Node: V7/SVR3.11055171
+Node: SVR41057324
+Node: POSIX1058758
+Node: BTL1060138
+Node: POSIX/GNU1060868
+Node: Feature History1066389
+Node: Common Extensions1079719
+Node: Ranges and Locales1081002
+Ref: Ranges and Locales-Footnote-11085618
+Ref: Ranges and Locales-Footnote-21085645
+Ref: Ranges and Locales-Footnote-31085880
+Node: Contributors1086101
+Node: History summary1091670
+Node: Installation1093050
+Node: Gawk Distribution1093995
+Node: Getting1094479
+Node: Extracting1095302
+Node: Distribution contents1096940
+Node: Unix Installation1102693
+Node: Quick Installation1103309
+Node: Additional Configuration Options1105736
+Node: Configuration Philosophy1107540
+Node: Non-Unix Installation1109910
+Node: PC Installation1110368
+Node: PC Binary Installation1111688
+Node: PC Compiling1113540
+Ref: PC Compiling-Footnote-11116564
+Node: PC Testing1116673
+Node: PC Using1117853
+Node: Cygwin1121967
+Node: MSYS1122737
+Node: VMS Installation1123238
+Node: VMS Compilation1124029
+Ref: VMS Compilation-Footnote-11125259
+Node: VMS Dynamic Extensions1125317
+Node: VMS Installation Details1127002
+Node: VMS Running1129255
+Node: VMS GNV1132096
+Node: VMS Old Gawk1132831
+Node: Bugs1133302
+Node: Other Versions1137416
+Node: Installation summary1143890
+Node: Notes1144948
+Node: Compatibility Mode1145813
+Node: Additions1146595
+Node: Accessing The Source1147520
+Node: Adding Code1148956
+Node: New Ports1155111
+Node: Derived Files1159599
+Ref: Derived Files-Footnote-11165084
+Ref: Derived Files-Footnote-21165119
+Ref: Derived Files-Footnote-31165717
+Node: Future Extensions1165831
+Node: Implementation Limitations1166489
+Node: Extension Design1167672
+Node: Old Extension Problems1168826
+Ref: Old Extension Problems-Footnote-11170344
+Node: Extension New Mechanism Goals1170401
+Ref: Extension New Mechanism Goals-Footnote-11173765
+Node: Extension Other Design Decisions1173954
+Node: Extension Future Growth1176067
+Node: Old Extension Mechanism1176903
+Node: Notes summary1178666
+Node: Basic Concepts1179848
+Node: Basic High Level1180529
+Ref: figure-general-flow1180811
+Ref: figure-process-flow1181496
+Ref: Basic High Level-Footnote-11184797
+Node: Basic Data Typing1184982
+Node: Glossary1188310
+Node: Copying1220256
+Node: GNU Free Documentation License1257795
+Node: Index1282913

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 8c70f6c5..6927704d 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -34593,17 +34593,31 @@ 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.
+# By default, each filename on the command line will be edited inplace.
+# But you can selectively disable this by adding an inplace=0 argument
+# prior to files that you do not want to process this way. You can then
+# reenable it later on the commandline by putting inplace=1 before files
+# that you wish to be subject to inplace editing.
+
# 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.
+BEGIN @{
+ inplace = 1 # enabled by default
+@}
+
BEGINFILE @{
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
@}
END @{
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
@}
@end group
@c endfile
@@ -34617,6 +34631,11 @@ 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}.
+Note that the use of this feature can be controlled by placing @samp{inplace=0}
+on the command-line prior to listing files that should not be processed this
+way. You can reenable inplace editing by adding an @samp{inplace=1} argument
+prior to files that should be subject to inplace editing.
+
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.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index e4b422c7..58fa4f60 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -33684,17 +33684,31 @@ 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.
+# By default, each filename on the command line will be edited inplace.
+# But you can selectively disable this by adding an inplace=0 argument
+# prior to files that you do not want to process this way. You can then
+# reenable it later on the commandline by putting inplace=1 before files
+# that you wish to be subject to inplace editing.
+
# 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.
+BEGIN @{
+ inplace = 1 # enabled by default
+@}
+
BEGINFILE @{
if (_inplace_filename != "")
inplace_end(_inplace_filename, INPLACE_SUFFIX)
- inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ if (inplace)
+ inplace_begin(_inplace_filename = FILENAME, INPLACE_SUFFIX)
+ else
+ _inplace_filename = ""
@}
END @{
- inplace_end(FILENAME, INPLACE_SUFFIX)
+ if (_inplace_filename != "")
+ inplace_end(_inplace_filename, INPLACE_SUFFIX)
@}
@end group
@c endfile
@@ -33708,6 +33722,11 @@ 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}.
+Note that the use of this feature can be controlled by placing @samp{inplace=0}
+on the command-line prior to listing files that should not be processed this
+way. You can reenable inplace editing by adding an @samp{inplace=1} argument
+prior to files that should be subject to inplace editing.
+
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.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 1539ed97..5b372e9d 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * inplace.3am: Document new inplace variable to control whether
+ inplace editing is active.
+
2015-05-19 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.3: Release tar ball made.
diff --git a/extension/inplace.3am b/extension/inplace.3am
index 64aec91c..b1682e22 100644
--- a/extension/inplace.3am
+++ b/extension/inplace.3am
@@ -1,4 +1,4 @@
-.TH INPLACE 3am "Apr 08 2015" "Free Software Foundation" "GNU Awk Extension Modules"
+.TH INPLACE 3am "Jun 17 2015" "Free Software Foundation" "GNU Awk Extension Modules"
.SH NAME
inplace \- emulate sed/perl/ruby in-place editing
.SH SYNOPSIS
@@ -32,6 +32,13 @@ rule or on the command line, then the
extension concatenates that suffix onto the original
filename and uses the result as a filename for renaming
the original.
+.PP
+One can disable inplace editing selectively by placing
+.B inplace=0
+on the command line prior to files that should be processed normally.
+One can reenable inplace editing by placing
+.B inplace=1
+prior to files that should be subject to inplace editing.
... .SH NOTES
... .SH BUGS
.SH EXAMPLE
diff --git a/test/ChangeLog b/test/ChangeLog
index d5387b36..a9d130cc 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * inplace1.ok, inplace2.ok, inplace3.ok: Update line number in error
+ messages, since inplace.awk changed a bit.
+
2015-05-29 Arnold D. Robbins <arnold@skeeve.com>
* checknegtime.awk: New file.
diff --git a/test/inplace1.ok b/test/inplace1.ok
index 82562235..91b5276b 100644
--- a/test/inplace1.ok
+++ b/test/inplace1.ok
@@ -1,5 +1,5 @@
before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: 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 82562235..91b5276b 100644
--- a/test/inplace2.ok
+++ b/test/inplace2.ok
@@ -1,5 +1,5 @@
before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: 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 a7b7254f..deb926b9 100644
--- a/test/inplace3.ok
+++ b/test/inplace3.ok
@@ -1,11 +1,11 @@
before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
stdin start
is bar replaced?
stdin end
after
Before
-gawk: inplace:14: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
+gawk: inplace:25: warning: inplace_begin: disabling in-place editing for invalid FILENAME `-'
stdin start
is foo replaced?
stdin end