[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] get_maintainer.pl: Teach brace expansion



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@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.