All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] get_maintainer.pl: Teach brace expansion
@ 2017-01-09 15:22 Anthony PERARD
  2017-01-09 15:36 ` Doug Goldstein
  2017-01-09 16:36 ` Ian Jackson
  0 siblings, 2 replies; 4+ messages in thread
From: Anthony PERARD @ 2017-01-09 15:22 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, 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 '(|)'.

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.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
v2:
- improve patch description
---
 scripts/get_maintainer.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 9fda278d9a..2804a5b5df 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -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");
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2] get_maintainer.pl: Teach brace expansion
  2017-01-09 15:22 [PATCH v2] get_maintainer.pl: Teach brace expansion Anthony PERARD
@ 2017-01-09 15:36 ` Doug Goldstein
  2017-01-09 16:36 ` Ian Jackson
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Goldstein @ 2017-01-09 15:36 UTC (permalink / raw)
  To: Anthony PERARD, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich


[-- Attachment #1.1.1: Type: text/plain, Size: 1341 bytes --]

On 1/9/17 9:22 AM, Anthony PERARD wrote:
> 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.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Tested-by: Doug Goldstein <cardoe@cardoe.com>

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.

-- 
Doug Goldstein


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 959 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2] get_maintainer.pl: Teach brace expansion
  2017-01-09 15:22 [PATCH v2] get_maintainer.pl: Teach brace expansion Anthony PERARD
  2017-01-09 15:36 ` Doug Goldstein
@ 2017-01-09 16:36 ` Ian Jackson
  2017-01-10 10:29   ` Wei Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Jackson @ 2017-01-09 16:36 UTC (permalink / raw)
  To: Anthony PERARD
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Tim Deegan, Jan Beulich, xen-devel

Anthony PERARD writes ("[PATCH v2] get_maintainer.pl: Teach brace expansion"):
> 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,

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

on the assumption that you have tested it.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2] get_maintainer.pl: Teach brace expansion
  2017-01-09 16:36 ` Ian Jackson
@ 2017-01-10 10:29   ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2017-01-10 10:29 UTC (permalink / raw)
  To: Ian Jackson
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Tim Deegan, Jan Beulich, Anthony PERARD, xen-devel

On Mon, Jan 09, 2017 at 04:36:41PM +0000, Ian Jackson wrote:
> Anthony PERARD writes ("[PATCH v2] get_maintainer.pl: Teach brace expansion"):
> > 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,
> 
> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
> 

Applied.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-01-10 10:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 15:22 [PATCH v2] get_maintainer.pl: Teach brace expansion Anthony PERARD
2017-01-09 15:36 ` Doug Goldstein
2017-01-09 16:36 ` Ian Jackson
2017-01-10 10:29   ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.