mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] ptxd_lib_dgen.awk: Fix warning
@ 2015-04-29 19:06 Bernhard Walle
  2015-04-30 18:56 ` Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Walle @ 2015-04-29 19:06 UTC (permalink / raw)
  To: ptxdist; +Cc: Bernhard Walle

After upgrading my gawk to 4.1.2 (which Arch Linux did today), I get
tons of warnings like

gawk: /usr/lib/ptxdist-2015.04.0/scripts/lib/ptxd_lib_dgen.awk:386:
(FILENAME=/tmp/ptxdist.p1sg2M/dgen/platformconfig FNR=233) warning:
gensub: third argument `' treated as 1

This patch fixes the warnings. According to the documentation
https://www.gnu.org/software/gawk/manual/gawk.html#String-Functions:

| gensub(regexp, replacement, how [, target]) #
| ...
|
| If the how argument is a string that does not begin with ‘g’ or ‘G’, or
| if it is a number that is less than or equal to zero, only one
| substitution is performed. If how is zero, gawk issues a warning
| message.

So the fix should be safe.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 scripts/lib/ptxd_lib_dgen.awk | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/lib/ptxd_lib_dgen.awk b/scripts/lib/ptxd_lib_dgen.awk
index 9970953..c255706 100644
--- a/scripts/lib/ptxd_lib_dgen.awk
+++ b/scripts/lib/ptxd_lib_dgen.awk
@@ -89,7 +89,7 @@ $1 ~ /^[A-Z_]*PACKAGES-/ {
 	this_PKG = gensub(/^[A-Z_]*PACKAGES-\$\(PTXCONF_([^\)]*)\)/, "\\1", "g", $1);
 	this_PKG = gensub(/^[A-Z0-9_]*-\$\(PTXCONF_([^\)]*)\)/, "\\1", "g", this_PKG);
 
-	is_pkg = this_pkg = gensub(/^[[:space:]]*\<(.*)\>[[:space:]]*$/,"\\1","", $2);
+	is_pkg = this_pkg = gensub(/^[[:space:]]*\<(.*)\>[[:space:]]*$/,"\\1",1, $2);
 	if (this_pkg ~ /[A-Z]+/) {
 		print \
 			"\n" \
@@ -222,8 +222,8 @@ function write_vars_pkg_all(this_PKG, this_pkg, prefix) {
 	print this_PKG "_DEVPKG = " prefix this_devpkg			> DGEN_DEPS_PRE;
 	print this_PKG "_SOURCES = $(" this_PKG "_SOURCE)"		> DGEN_DEPS_PRE
 
-	target_PKG = gensub(/^HOST_|^CROSS_/, "", "", this_PKG);
-	PREFIX = gensub(/^(HOST_|CROSS_).*/, "\\1", "", this_PKG);
+	target_PKG = gensub(/^HOST_|^CROSS_/, "", 1, this_PKG);
+	PREFIX = gensub(/^(HOST_|CROSS_).*/, "\\1", 1, this_PKG);
 
 	# define default ${PKG}, ${PKG}_SOURCE, ${PKG}_DIR
 	if ((prefix != "") && (target_PKG in PKG_to_pkg)) {
@@ -352,7 +352,7 @@ function write_deps_pkg_active_image(this_PKG, this_pkg, prefix) {
 	n = split(this_PKG_DEPS, this_DEP_array, " ");
 	for (i = 1; i <= n; i++) {
 		this_dep = PKG_to_pkg[this_DEP_array[i]]
-		this_dep_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", "", this_dep)
+		this_dep_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", 1, this_dep)
 		if (this_dep_prefix == "")
 			print "$(" this_PKG "_IMAGE): "         "$(STATEDIR)/" this_dep ".targetinstall.post"	> DGEN_DEPS_POST;
 		else
@@ -371,7 +371,7 @@ END {
 	# for all pkgs
 	for (this_PKG in PKG_to_pkg) {
 		this_pkg = PKG_to_pkg[this_PKG];
-		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", "", this_pkg)
+		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", 1, this_pkg)
 
 		write_include(this_PKG)
 		if (this_pkg_prefix != "image-") {
@@ -383,7 +383,7 @@ END {
 	# for active pkgs
 	for (this_PKG in active_PKG_to_pkg) {
 		this_pkg = PKG_to_pkg[this_PKG];
-		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", "", this_pkg)
+		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", 1, this_pkg)
 
 		if (this_pkg_prefix != "image-") {
 			write_deps_pkg_active(this_PKG, this_pkg, this_pkg_prefix)
-- 
2.3.7


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ptxdist] [PATCH] ptxd_lib_dgen.awk: Fix warning
  2015-04-29 19:06 [ptxdist] [PATCH] ptxd_lib_dgen.awk: Fix warning Bernhard Walle
@ 2015-04-30 18:56 ` Michael Olbrich
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2015-04-30 18:56 UTC (permalink / raw)
  To: ptxdist

On Wed, Apr 29, 2015 at 09:06:18PM +0200, Bernhard Walle wrote:
> After upgrading my gawk to 4.1.2 (which Arch Linux did today), I get
> tons of warnings like
> 
> gawk: /usr/lib/ptxdist-2015.04.0/scripts/lib/ptxd_lib_dgen.awk:386:
> (FILENAME=/tmp/ptxdist.p1sg2M/dgen/platformconfig FNR=233) warning:
> gensub: third argument `' treated as 1
> 
> This patch fixes the warnings. According to the documentation
> https://www.gnu.org/software/gawk/manual/gawk.html#String-Functions:
> 
> | gensub(regexp, replacement, how [, target]) #
> | ...
> |
> | If the how argument is a string that does not begin with ‘g’ or ‘G’, or
> | if it is a number that is less than or equal to zero, only one
> | substitution is performed. If how is zero, gawk issues a warning
> | message.
> 
> So the fix should be safe.

Yes, this seems to be the correct fix. Works for me[tm] anyways.
Thanks, applied.

Michael

> Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
> ---
>  scripts/lib/ptxd_lib_dgen.awk | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/lib/ptxd_lib_dgen.awk b/scripts/lib/ptxd_lib_dgen.awk
> index 9970953..c255706 100644
> --- a/scripts/lib/ptxd_lib_dgen.awk
> +++ b/scripts/lib/ptxd_lib_dgen.awk
> @@ -89,7 +89,7 @@ $1 ~ /^[A-Z_]*PACKAGES-/ {
>  	this_PKG = gensub(/^[A-Z_]*PACKAGES-\$\(PTXCONF_([^\)]*)\)/, "\\1", "g", $1);
>  	this_PKG = gensub(/^[A-Z0-9_]*-\$\(PTXCONF_([^\)]*)\)/, "\\1", "g", this_PKG);
>  
> -	is_pkg = this_pkg = gensub(/^[[:space:]]*\<(.*)\>[[:space:]]*$/,"\\1","", $2);
> +	is_pkg = this_pkg = gensub(/^[[:space:]]*\<(.*)\>[[:space:]]*$/,"\\1",1, $2);
>  	if (this_pkg ~ /[A-Z]+/) {
>  		print \
>  			"\n" \
> @@ -222,8 +222,8 @@ function write_vars_pkg_all(this_PKG, this_pkg, prefix) {
>  	print this_PKG "_DEVPKG = " prefix this_devpkg			> DGEN_DEPS_PRE;
>  	print this_PKG "_SOURCES = $(" this_PKG "_SOURCE)"		> DGEN_DEPS_PRE
>  
> -	target_PKG = gensub(/^HOST_|^CROSS_/, "", "", this_PKG);
> -	PREFIX = gensub(/^(HOST_|CROSS_).*/, "\\1", "", this_PKG);
> +	target_PKG = gensub(/^HOST_|^CROSS_/, "", 1, this_PKG);
> +	PREFIX = gensub(/^(HOST_|CROSS_).*/, "\\1", 1, this_PKG);
>  
>  	# define default ${PKG}, ${PKG}_SOURCE, ${PKG}_DIR
>  	if ((prefix != "") && (target_PKG in PKG_to_pkg)) {
> @@ -352,7 +352,7 @@ function write_deps_pkg_active_image(this_PKG, this_pkg, prefix) {
>  	n = split(this_PKG_DEPS, this_DEP_array, " ");
>  	for (i = 1; i <= n; i++) {
>  		this_dep = PKG_to_pkg[this_DEP_array[i]]
> -		this_dep_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", "", this_dep)
> +		this_dep_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", 1, this_dep)
>  		if (this_dep_prefix == "")
>  			print "$(" this_PKG "_IMAGE): "         "$(STATEDIR)/" this_dep ".targetinstall.post"	> DGEN_DEPS_POST;
>  		else
> @@ -371,7 +371,7 @@ END {
>  	# for all pkgs
>  	for (this_PKG in PKG_to_pkg) {
>  		this_pkg = PKG_to_pkg[this_PKG];
> -		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", "", this_pkg)
> +		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", 1, this_pkg)
>  
>  		write_include(this_PKG)
>  		if (this_pkg_prefix != "image-") {
> @@ -383,7 +383,7 @@ END {
>  	# for active pkgs
>  	for (this_PKG in active_PKG_to_pkg) {
>  		this_pkg = PKG_to_pkg[this_PKG];
> -		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", "", this_pkg)
> +		this_pkg_prefix = gensub(/^(host-|cross-|image-|).*/, "\\1", 1, this_pkg)
>  
>  		if (this_pkg_prefix != "image-") {
>  			write_deps_pkg_active(this_PKG, this_pkg, this_pkg_prefix)
> -- 
> 2.3.7
> 
> 
> -- 
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-30 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29 19:06 [ptxdist] [PATCH] ptxd_lib_dgen.awk: Fix warning Bernhard Walle
2015-04-30 18:56 ` Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox