c3fa851474
- Fix typo in Summary - Stop overriding %_libexecdir with %_libdir - Fix the backward compatibility of the inplace extension: * Add gawk-inplace-namespace-part1.patch * Add gawk-inplace-namespace-part2.patch * Add gawk-inplace-namespace-part3.patch - Run autoreconf as part of the build process OBS-URL: https://build.opensuse.org/request/show/741824 OBS-URL: https://build.opensuse.org/package/show/Base:System/gawk?expand=0&rev=77
385 lines
14 KiB
Diff
385 lines
14 KiB
Diff
From 8ff0d3a5a55237f78a8c3076a07c38f7e1c1c5e9 Mon Sep 17 00:00:00 2001
|
|
From: "Arnold D. Robbins" <arnold@skeeve.com>
|
|
Date: Wed, 26 Jun 2019 21:44:37 +0300
|
|
Subject: [PATCH 3/3] Add backwards compatibility to inplace extension, update
|
|
doc and tests.
|
|
|
|
---
|
|
awklib/eg/lib/inplace.awk | 18 ++--
|
|
doc/ChangeLog | 5 +
|
|
doc/gawk.info | 189 +++++++++++++++++++-------------------
|
|
doc/gawk.texi | 18 ++--
|
|
doc/gawktexi.in | 18 ++--
|
|
extension/ChangeLog | 4 +
|
|
extension/inplace.3am | 24 +++--
|
|
test/ChangeLog | 4 +
|
|
test/inplace1.ok | 2 +-
|
|
test/inplace2.ok | 2 +-
|
|
test/inplace3.ok | 4 +-
|
|
11 files changed, 167 insertions(+), 121 deletions(-)
|
|
|
|
diff --git a/awklib/eg/lib/inplace.awk b/awklib/eg/lib/inplace.awk
|
|
index 68dad92e..0d40d16e 100644
|
|
--- a/awklib/eg/lib/inplace.awk
|
|
+++ b/awklib/eg/lib/inplace.awk
|
|
@@ -1,6 +1,6 @@
|
|
# inplace --- load and invoke the inplace extension.
|
|
#
|
|
-# Copyright (C) 2013, 2017 the Free Software Foundation, Inc.
|
|
+# Copyright (C) 2013, 2017, 2019 the Free Software Foundation, Inc.
|
|
#
|
|
# This file is part of GAWK, the GNU implementation of the
|
|
# AWK Programming Language.
|
|
@@ -25,16 +25,21 @@
|
|
# Revised for namespaces
|
|
# Arnold Robbins, arnold@skeeve.com
|
|
# July 2017
|
|
+# June 2019, add backwards compatibility
|
|
|
|
@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.
|
|
|
|
+# Before there were namespaces in gawk, this extension used
|
|
+# INPLACE_SUFFIX as the variable for making backup copies. We allow this
|
|
+# too, so that any code that used the previous version continues to work.
|
|
+
|
|
# By default, each filename on the command line will be edited inplace.
|
|
-# But you can selectively disable this by adding an inplace=0 argument
|
|
+# But you can selectively disable this by adding an inplace::enable=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
|
|
+# reenable it later on the commandline by putting inplace::enable=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
|
|
@@ -47,15 +52,16 @@ BEGIN {
|
|
}
|
|
|
|
BEGINFILE {
|
|
+ sfx = (suffix ? suffix : awk::INPLACE_SUFFIX)
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, sfx)
|
|
if (enable)
|
|
- begin(filename = FILENAME, suffix)
|
|
+ begin(filename = FILENAME, sfx)
|
|
else
|
|
filename = ""
|
|
}
|
|
|
|
END {
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, (suffix ? suffix : awk::INPLACE_SUFFIX))
|
|
}
|
|
diff --git a/doc/ChangeLog b/doc/ChangeLog
|
|
index 5ea91aaf..6a1a5ae4 100644
|
|
--- a/doc/ChangeLog
|
|
+++ b/doc/ChangeLog
|
|
@@ -1,3 +1,8 @@
|
|
+2019-06-26 Arnold D. Robbins <arnold@skeeve.com>
|
|
+
|
|
+ * gawktexi.in (Extension Sample Inplace): Fix backwards
|
|
+ compatibility. Thanks to Andrew Schorr for most of the change.
|
|
+
|
|
2019-06-18 Arnold D. Robbins <arnold@skeeve.com>
|
|
|
|
* 5.0.1: Release tar ball made.
|
|
diff --git a/doc/gawk.info b/doc/gawk.info
|
|
index e5a52702..4e46df9e 100644
|
|
--- a/doc/gawk.info
|
|
+++ b/doc/gawk.info
|
|
@@ -27693,10 +27693,14 @@ and functions in the 'inplace' namespace (*note Namespaces::):
|
|
# 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.
|
|
|
|
+ # Before there were namespaces in gawk, this extension used
|
|
+ # INPLACE_SUFFIX as the variable for making backup copies. We allow this
|
|
+ # too, so that any code that used the previous version continues to work.
|
|
+
|
|
# By default, each filename on the command line will be edited inplace.
|
|
- # But you can selectively disable this by adding an inplace=0 argument
|
|
+ # But you can selectively disable this by adding an inplace::enable=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
|
|
+ # reenable it later on the commandline by putting inplace::enable=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
|
|
@@ -27709,17 +27713,18 @@ and functions in the 'inplace' namespace (*note Namespaces::):
|
|
}
|
|
|
|
BEGINFILE {
|
|
+ sfx = (suffix ? suffix : awk::INPLACE_SUFFIX)
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, sfx)
|
|
if (enable)
|
|
- begin(filename = FILENAME, suffix)
|
|
+ begin(filename = FILENAME, sfx)
|
|
else
|
|
filename = ""
|
|
}
|
|
|
|
END {
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, (suffix ? suffix : awk::INPLACE_SUFFIX))
|
|
}
|
|
|
|
For each regular file that is processed, the extension redirects
|
|
diff --git a/doc/gawk.texi b/doc/gawk.texi
|
|
index 25fb3486..94ff298f 100644
|
|
--- a/doc/gawk.texi
|
|
+++ b/doc/gawk.texi
|
|
@@ -37601,7 +37601,7 @@ all the variables and functions in the @code{inplace} namespace
|
|
@ignore
|
|
@c file eg/lib/inplace.awk
|
|
#
|
|
-# Copyright (C) 2013, 2017 the Free Software Foundation, Inc.
|
|
+# Copyright (C) 2013, 2017, 2019 the Free Software Foundation, Inc.
|
|
#
|
|
# This file is part of GAWK, the GNU implementation of the
|
|
# AWK Programming Language.
|
|
@@ -37626,6 +37626,7 @@ all the variables and functions in the @code{inplace} namespace
|
|
# Revised for namespaces
|
|
# Arnold Robbins, arnold@@skeeve.com
|
|
# July 2017
|
|
+# June 2019, add backwards compatibility
|
|
@c endfile
|
|
@end ignore
|
|
@c file eg/lib/inplace.awk
|
|
@@ -37635,10 +37636,14 @@ all the variables and functions in the @code{inplace} namespace
|
|
# 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.
|
|
|
|
+# Before there were namespaces in gawk, this extension used
|
|
+# INPLACE_SUFFIX as the variable for making backup copies. We allow this
|
|
+# too, so that any code that used the previous version continues to work.
|
|
+
|
|
# By default, each filename on the command line will be edited inplace.
|
|
-# But you can selectively disable this by adding an inplace=0 argument
|
|
+# But you can selectively disable this by adding an inplace::enable=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
|
|
+# reenable it later on the commandline by putting inplace::enable=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
|
|
@@ -37655,10 +37660,11 @@ BEGIN @{
|
|
|
|
@group
|
|
BEGINFILE @{
|
|
+ sfx = (suffix ? suffix : awk::INPLACE_SUFFIX)
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, sfx)
|
|
if (enable)
|
|
- begin(filename = FILENAME, suffix)
|
|
+ begin(filename = FILENAME, sfx)
|
|
else
|
|
filename = ""
|
|
@}
|
|
@@ -37667,7 +37673,7 @@ BEGINFILE @{
|
|
@group
|
|
END @{
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, (suffix ? suffix : awk::INPLACE_SUFFIX))
|
|
@}
|
|
@end group
|
|
@c endfile
|
|
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
|
|
index c60b0238..55e485eb 100644
|
|
--- a/doc/gawktexi.in
|
|
+++ b/doc/gawktexi.in
|
|
@@ -36574,7 +36574,7 @@ all the variables and functions in the @code{inplace} namespace
|
|
@ignore
|
|
@c file eg/lib/inplace.awk
|
|
#
|
|
-# Copyright (C) 2013, 2017 the Free Software Foundation, Inc.
|
|
+# Copyright (C) 2013, 2017, 2019 the Free Software Foundation, Inc.
|
|
#
|
|
# This file is part of GAWK, the GNU implementation of the
|
|
# AWK Programming Language.
|
|
@@ -36599,6 +36599,7 @@ all the variables and functions in the @code{inplace} namespace
|
|
# Revised for namespaces
|
|
# Arnold Robbins, arnold@@skeeve.com
|
|
# July 2017
|
|
+# June 2019, add backwards compatibility
|
|
@c endfile
|
|
@end ignore
|
|
@c file eg/lib/inplace.awk
|
|
@@ -36608,10 +36609,14 @@ all the variables and functions in the @code{inplace} namespace
|
|
# 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.
|
|
|
|
+# Before there were namespaces in gawk, this extension used
|
|
+# INPLACE_SUFFIX as the variable for making backup copies. We allow this
|
|
+# too, so that any code that used the previous version continues to work.
|
|
+
|
|
# By default, each filename on the command line will be edited inplace.
|
|
-# But you can selectively disable this by adding an inplace=0 argument
|
|
+# But you can selectively disable this by adding an inplace::enable=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
|
|
+# reenable it later on the commandline by putting inplace::enable=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
|
|
@@ -36628,10 +36633,11 @@ BEGIN @{
|
|
|
|
@group
|
|
BEGINFILE @{
|
|
+ sfx = (suffix ? suffix : awk::INPLACE_SUFFIX)
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, sfx)
|
|
if (enable)
|
|
- begin(filename = FILENAME, suffix)
|
|
+ begin(filename = FILENAME, sfx)
|
|
else
|
|
filename = ""
|
|
@}
|
|
@@ -36640,7 +36646,7 @@ BEGINFILE @{
|
|
@group
|
|
END @{
|
|
if (filename != "")
|
|
- end(filename, suffix)
|
|
+ end(filename, (suffix ? suffix : awk::INPLACE_SUFFIX))
|
|
@}
|
|
@end group
|
|
@c endfile
|
|
diff --git a/extension/ChangeLog b/extension/ChangeLog
|
|
index 3d83f77e..22d73d09 100644
|
|
--- a/extension/ChangeLog
|
|
+++ b/extension/ChangeLog
|
|
@@ -1,3 +1,7 @@
|
|
+2019-06-26 Arnold D. Robbins <arnold@skeeve.com>
|
|
+
|
|
+ * inplace.3am: Update to match current code's behavior.
|
|
+
|
|
2019-06-18 Arnold D. Robbins <arnold@skeeve.com>
|
|
|
|
* 5.0.1: Release tar ball made.
|
|
diff --git a/extension/inplace.3am b/extension/inplace.3am
|
|
index 48fac54a..66047442 100644
|
|
--- a/extension/inplace.3am
|
|
+++ b/extension/inplace.3am
|
|
@@ -1,4 +1,4 @@
|
|
-.TH INPLACE 3am "Feb 02 2018" "Free Software Foundation" "GNU Awk Extension Modules"
|
|
+.TH INPLACE 3am "Jun 26 2018" "Free Software Foundation" "GNU Awk Extension Modules"
|
|
.SH NAME
|
|
inplace \- emulate sed/perl/ruby in-place editing
|
|
.SH SYNOPSIS
|
|
@@ -24,7 +24,7 @@ By default, each named file on the command line is
|
|
replaced with a new file of the same name whose contents
|
|
are the results of running the AWK program.
|
|
If the user supplies an AWK variable named
|
|
-.B INPLACE_SUFFIX
|
|
+.B inplace::suffix
|
|
in a
|
|
.B BEGIN
|
|
rule or on the command line, then the
|
|
@@ -33,17 +33,27 @@ extension concatenates that suffix onto the original
|
|
filename and uses the result as a filename for renaming
|
|
the original.
|
|
.PP
|
|
+For backwards compatibility, the variable will also check
|
|
+.B INPLACE_SUFFIX
|
|
+(in the
|
|
+.B awk
|
|
+namespace) for the suffix to use if
|
|
+.B inplace::suffix
|
|
+is not set.
|
|
+.PP
|
|
One can disable inplace editing selectively by placing
|
|
-.B inplace=0
|
|
+.B inplace::enable=0
|
|
on the command line prior to files that should be processed normally.
|
|
One can reenable inplace editing by placing
|
|
-.B inplace=1
|
|
+.B inplace::enable=1
|
|
prior to files that should be subject to inplace editing.
|
|
.\" .SH NOTES
|
|
.SH BUGS
|
|
-While the extension does attempt to preserve ownership and permissions, it makes no attempt to copy the ACLs from the original file.
|
|
+While the extension does attempt to preserve ownership and permissions,
|
|
+it makes no attempt to copy the ACLs from the original file.
|
|
.PP
|
|
-If the program dies prematurely, as might happen if an unhandled signal is received, a temporary file may be left behind.
|
|
+If the program dies prematurely, as might happen if an unhandled signal
|
|
+is received, a temporary file may be left behind.
|
|
.SH EXAMPLE
|
|
.ft CW
|
|
.nf
|
|
@@ -66,7 +76,7 @@ gawk -i inplace -f \f(CIscriptfile\fP files ...
|
|
Andrew Schorr,
|
|
.BR schorr@telemetry-investments.com .
|
|
.SH COPYING PERMISSIONS
|
|
-Copyright \(co 2012, 2013, 2015, 2018,
|
|
+Copyright \(co 2012, 2013, 2015, 2018, 2019,
|
|
Free Software Foundation, Inc.
|
|
.PP
|
|
Permission is granted to make and distribute verbatim copies of
|
|
diff --git a/test/ChangeLog b/test/ChangeLog
|
|
index 99391b0d..a538c593 100644
|
|
--- a/test/ChangeLog
|
|
+++ b/test/ChangeLog
|
|
@@ -5,6 +5,10 @@
|
|
nsawk2a.ok, nsawk2b.ok: New files.
|
|
Tests courtesy of Michal Jaegermann.
|
|
|
|
+ Unrelated:
|
|
+
|
|
+ * inplace1.ok, inplace2.ok, inplace3.ok: Updated after code changes.
|
|
+
|
|
2019-06-18 Arnold D. Robbins <arnold@skeeve.com>
|
|
|
|
* 5.0.1: Release tar ball made.
|
|
diff --git a/test/inplace1.ok b/test/inplace1.ok
|
|
index 753079b3..f2e36d46 100644
|
|
--- a/test/inplace1.ok
|
|
+++ b/test/inplace1.ok
|
|
@@ -1,5 +1,5 @@
|
|
before
|
|
-gawk: inplace:53: warning: inplace::begin: disabling in-place editing for invalid FILENAME `-'
|
|
+gawk: inplace:59: 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 753079b3..f2e36d46 100644
|
|
--- a/test/inplace2.ok
|
|
+++ b/test/inplace2.ok
|
|
@@ -1,5 +1,5 @@
|
|
before
|
|
-gawk: inplace:53: warning: inplace::begin: disabling in-place editing for invalid FILENAME `-'
|
|
+gawk: inplace:59: 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 7802a0c8..b6f26505 100644
|
|
--- a/test/inplace3.ok
|
|
+++ b/test/inplace3.ok
|
|
@@ -1,11 +1,11 @@
|
|
before
|
|
-gawk: inplace:53: warning: inplace::begin: disabling in-place editing for invalid FILENAME `-'
|
|
+gawk: inplace:59: warning: inplace::begin: disabling in-place editing for invalid FILENAME `-'
|
|
stdin start
|
|
is bar replaced?
|
|
stdin end
|
|
after
|
|
Before
|
|
-gawk: inplace:53: warning: inplace::begin: disabling in-place editing for invalid FILENAME `-'
|
|
+gawk: inplace:59: warning: inplace::begin: disabling in-place editing for invalid FILENAME `-'
|
|
stdin start
|
|
is foo replaced?
|
|
stdin end
|
|
--
|
|
2.22.0
|
|
|