From patchwork Mon Jan 9 15:22:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 9505199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AFE4606E1 for ; Mon, 9 Jan 2017 15:24:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9DF284F0 for ; Mon, 9 Jan 2017 15:24:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83938284F2; Mon, 9 Jan 2017 15:24:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E68E284F1 for ; Mon, 9 Jan 2017 15:24:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQbmQ-0004Pj-L4; Mon, 09 Jan 2017 15:22:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQbmP-0004Pd-IK for xen-devel@lists.xenproject.org; Mon, 09 Jan 2017 15:22:37 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id B5/E8-14551-CBAA3785; Mon, 09 Jan 2017 15:22:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFLMWRWlGSWpSXmKPExsXitHRDpO6eVcU RBu/6hC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyvC7ewF9wTrtj8ybKB8Rt/FyMHh4SAv8T2 b7JdjJwcbAIGEiumX2UECYsIqEjc3mvQxcjFwSzwmkni2IT5LCA1wgI2EvPm7GYFqWEBqjl2L gUkzCtgJ9H8+whYiYSAvMSutousILaQgJrEjYXLWCBqBCVOznwCZjMLSEgcfPGCeQIj9ywkqV lIUgsYmVYxahSnFpWlFukaWeglFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgSGQT0 DA+MOxvYTfocYJTmYlER5HaMKIoT4kvJTKjMSizPii0pzUosPMcpwcChJ8K5cWRwhJFiUmp5a kZaZAwxImLQEB4+SCG8mSJq3uCAxtzgzHSJ1ilFRSpy3CCQhAJLIKM2Da4NFwSVGWSlhXkYGB gYhnoLUotzMElT5V4ziHIxKwrz6IFN4MvNK4Ka/AlrMBLQ40g5scUkiQkqqgTE0fMnm5nNmP0 Pu887XDdPIcdwiFXXljVLUYRcBlqvlC7mY5p8v42pauYBZL4dbnffp1ruutZP/1y52rjzTf3P 7jP3bFc0//vZla6h7U64/503S9kTfrcdk9Nd/2GX/XDgup1AicmPmHR6jWaozn14VVdtg41y5 SF62rll4y2b+TWZNIqcr1JVYijMSDbWYi4oTAYVuf899AgAA X-Env-Sender: prvs=175e0583c=anthony.perard@citrix.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1483975354!72109553!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2371 invoked from network); 9 Jan 2017 15:22:36 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 9 Jan 2017 15:22:36 -0000 X-IronPort-AV: E=Sophos;i="5.33,339,1477958400"; d="scan'208";a="398710746" From: Anthony PERARD To: Date: Mon, 9 Jan 2017 15:22:32 +0000 Message-ID: <20170109152232.13012-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Jan Beulich , Anthony PERARD Subject: [Xen-devel] [PATCH v2] get_maintainer.pl: Teach brace expansion X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Doug Goldstein Acked-by: Ian Jackson --- 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");