Skip to contentSkip to conversation

get_maintainer.pl: Teach brace expansion

PATCH Applied Anthony PERARD 4 participants 4 messages Jan 9, 2017 – Jan 10, 2017 GET_MAINTAINER script

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 get_maintainer.pl: Teach brace expansion

Simpler non-nested brace expansion.

Some entries in the MAINTAINER are not understood by the script, the ones that contain {,}. This patch fixes it.

This will convert brace expansion style use in MAINTAINER into a regex that get_maintainer.pl can use to match a path again a maintainer section.

It is done by using two different regex, the first one will take care of converting ',' inside '{}' to a '|', one by one, as long as there is at least two commas. The second regex will do the final convertion of '{,}' to '(|)'.

With the patch, the right maintainers are displayed, instead of "THE REST" maintainers, when using the following command for e.g.

$ ./scripts/get_maintainer.pl -f docs/misc/kconfig.txt

The patch also get rid of the warnings, with recent perl:
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^docs/misc/kconfig{ <-- HERE ,-language}\.txt/ at ./scripts/get_maintainer.pl line 731.

---
v2:
- improve patch description

---
 scripts/get_maintainer.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)
scripts/get_maintainer.pl +13 -0
index 9fda278d9a..2804a5b5df 100755
@@ -283,6 +283,13 @@ while (<$maint>) {
 
 	##Filename pattern matching
 	if ($type eq "F" || $type eq "X") {
+	    # Bash brace expansion, not nested
+	    # match {,*,*} and transform ',' to '|' one by one.
+	    # While there is more than one ',', convert one to '|'.
+	    while ($value =~ s/([^\\])\{(|[^},]*[^,\\]),((|[^},]*[^,\\]),(|[^}]*[^\\]))\}/$1\{$2|$3\}/g) {
+	    }
+	    $value =~ s/([^\\])\{(|[^},]*[^,\\]),(|[^}]*[^\\])\}/$1($2|$3)/g;
+
 	    $value =~ s@\.@\\\.@g;       ##Convert . to \.
 	    $value =~ s/\*/\.\*/g;       ##Convert * to .*
 	    $value =~ s/\?/\./g;         ##Convert ? to .
@@ -637,6 +644,12 @@ sub get_maintainers {
 			$line =~ s/([^\\])\.$/$1\?/g;	##Convert . back to ?
 			$line =~ s/\\\./\./g;       	##Convert \. to .
 			$line =~ s/\.\*/\*/g;       	##Convert .* to *
+			## Convert (|) back to {,}
+			# match (|*|*) and transform '|' to ',' one by one
+			# While there is more than one '|', convert one to ','.
+			while ($line =~ s/([^\\])\((|[^)|]*[^|\\])\|((|[^)|]*[^|\\])\|(|[^)]*[^\\]))\)/$1($2,$3)/g) {
+			}
+			$line =~ s/([^\\])\((|[^)|]*[^|\\])\|(|[^)]*[^\\])\)/$1\{$2,$3\}/g;
 		    }
 		    $line =~ s/^([A-Z]):/$1:\t/g;
 		    print("$line\n");
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Tested-by on v2 1/1
#1 lore raw
Quoted 14 lines · Anthony PERARD

Simpler non-nested brace expansion.

Some entries in the MAINTAINER are not understood by the script, the ones that contain {,}. This patch fixes it.

This will convert brace expansion style use in MAINTAINER into a regex that get_maintainer.pl can use to match a path again a maintainer section.

It is done by using two different regex, the first one will take care of converting ',' inside '{}' to a '|', one by one, as long as there is at least two commas. The second regex will do the final convertion of '{,}' to '(|)'.

Quoted 8 lines

With the patch, the right maintainers are displayed, instead of "THE REST" maintainers, when using the following command for e.g.

$ ./scripts/get_maintainer.pl -f docs/misc/kconfig.txt

The patch also get rid of the warnings, with recent perl:
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^docs/misc/kconfig{ <-- HERE ,-language}\.txt/ at ./scripts/get_maintainer.pl line 731.

I won't pretend to say I know Perl so I didn't read the changes but I did test them and all is well and it gets rid of warnings on my machine.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 1/1
#2 lore raw
In reply to Anthony PERARD

Anthony PERARD writes ("[PATCH v2] get_maintainer.pl: Teach brace expansion"):

Quoted 4 lines

It is done by using two different regex, the first one will take care of converting ',' inside '{}' to a '|', one by one, as long as there is at least two commas. The second regex will do the final convertion of '{,}' to '(|)'.

What a palaver.

I don't want to nitpick your Perl code. I'm basically fine with anything here so long as it currently gives right answers.

But I wondered if you know about the /x and /e modifiers on perl regexps.

Anyway,

on the assumption that you have tested it.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Applied
#3 lore raw
Quoted 11 lines · Ian Jackson

Anthony PERARD writes ("[PATCH v2] get_maintainer.pl: Teach brace expansion"):

Quoted 4 lines

It is done by using two different regex, the first one will take care of converting ',' inside '{}' to a '|', one by one, as long as there is at least two commas. The second regex will do the final convertion of '{,}' to '(|)'.

What a palaver.

I don't want to nitpick your Perl code. I'm basically fine with anything here so long as it currently gives right answers.

Quoted 7 lines

But I wondered if you know about the /x and /e modifiers on perl regexps.

Anyway,

Applied.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel