xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] get_maintainer.pl: Teach brace expansion
@ 2016-06-22 17:28 Anthony PERARD
  2016-06-24 11:09 ` George Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony PERARD @ 2016-06-22 17:28 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Anthony PERARD

This only implement a simpler non-nested brace expansion.

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 '(|)'.

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

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 9fda278..40c6d03 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -283,6 +283,12 @@ 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 ($value =~ s/([^\\])\{(|[^},]*[^,\\]),((|[^},]*[^,\\]),(|[^}]*[^\\]))\}/$1\{$2|$3\}/g) {}
+	    # Finish convertion by transforming '{,}' to '(|)'
+	    $value =~ s/([^\\])\{(|[^},]*[^,\\]),(|[^}]*[^\\])\}/$1($2|$3)/g;
+
 	    $value =~ s@\.@\\\.@g;       ##Convert . to \.
 	    $value =~ s/\*/\.\*/g;       ##Convert * to .*
 	    $value =~ s/\?/\./g;         ##Convert ? to .
@@ -637,6 +643,11 @@ 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 ($line =~ s/([^\\])\((|[^)|]*[^|\\])\|((|[^)|]*[^|\\])\|(|[^)]*[^\\]))\)/$1($2,$3)/g) {}
+                        # Finish convertion by transforming '(|)' to '{,}'
+			$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
http://lists.xen.org/xen-devel

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

* Re: [PATCH] get_maintainer.pl: Teach brace expansion
  2016-06-22 17:28 [PATCH] get_maintainer.pl: Teach brace expansion Anthony PERARD
@ 2016-06-24 11:09 ` George Dunlap
  2016-06-24 11:33   ` Anthony PERARD
  0 siblings, 1 reply; 3+ messages in thread
From: George Dunlap @ 2016-06-24 11:09 UTC (permalink / raw)
  To: Anthony PERARD
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Tim Deegan,
	xen-devel, Jan Beulich, Ian Jackson

On Wed, Jun 22, 2016 at 6:28 PM, Anthony PERARD
<anthony.perard@citrix.com> wrote:
> This only implement a simpler non-nested brace expansion.
>
> 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 '(|)'.

Can you give some examples of the sorts of MAINTAINER entries this
would allow (and maybe one that you intend to implement once this is
accepted)?

Thanks,
 -George

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

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

* Re: [PATCH] get_maintainer.pl: Teach brace expansion
  2016-06-24 11:09 ` George Dunlap
@ 2016-06-24 11:33   ` Anthony PERARD
  0 siblings, 0 replies; 3+ messages in thread
From: Anthony PERARD @ 2016-06-24 11:33 UTC (permalink / raw)
  To: George Dunlap
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Tim Deegan,
	xen-devel, Jan Beulich, Ian Jackson

On Fri, Jun 24, 2016 at 12:09:53PM +0100, George Dunlap wrote:
> On Wed, Jun 22, 2016 at 6:28 PM, Anthony PERARD
> <anthony.perard@citrix.com> wrote:
> > This only implement a simpler non-nested brace expansion.
> >
> > 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 '(|)'.
> 
> Can you give some examples of the sorts of MAINTAINER entries this
> would allow (and maybe one that you intend to implement once this is
> accepted)?

With this patch, every entry of the current MAINTAINER file would work!
The one below for example would return the right sections/maintainers.
$ ./scripts/get_maintainer.pl --sections -f xen/common/kexec.c

Also, for every invocation of the script, I've got this message (x3)
(without the patch):
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^xen/common/{ <-- HERE kexec,kimage}\.c/ at ./scripts/get_maintainer.pl line 731.

One example I've tried the patch with, by adding a bogus entry:
  xen/common/{kexec,kimage,extra,patterns}.{c,h,S}

By the way, --sections does not print the original pattern, but it print
the pattern converted by to globing from the regex.

-- 
Anthony PERARD

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

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

end of thread, other threads:[~2016-06-24 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 17:28 [PATCH] get_maintainer.pl: Teach brace expansion Anthony PERARD
2016-06-24 11:09 ` George Dunlap
2016-06-24 11:33   ` Anthony PERARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).