From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751725AbdG1AaL (ORCPT ); Thu, 27 Jul 2017 20:30:11 -0400 Received: from smtprelay0185.hostedemail.com ([216.40.44.185]:46208 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751600AbdG1AaK (ORCPT ); Thu, 27 Jul 2017 20:30:10 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:560:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2731:2828:3138:3139:3140:3141:3142:3354:3622:3653:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:6119:6691:7903:9010:10004:10400:10848:11232:11658:11783:11914:12043:12291:12296:12555:12663:12683:12740:12895:13439:13894:14181:14659:14721:21080:21627:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: truck98_75ac95df5cd58 X-Filterd-Recvd-Size: 3564 Message-ID: <1501201807.5368.31.camel@perches.com> Subject: Re: [PATCH Y.A. RESEND] MAINTAINERS: fix alpha. ordering From: Joe Perches To: Linus Torvalds , Randy Dunlap Cc: LKML , Andrew Morton Date: Thu, 27 Jul 2017 17:30:07 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2017-07-23 at 16:14 -0700, Linus Torvalds wrote: > On Sun, Jul 23, 2017 at 1:00 PM, Linus Torvalds > wrote: > > > > Anyway, clearly my script showed something. I think my script is still > > doing the right thing, it's just that the input is questionable. > > I added a few actual checks for the error cases to the script, fixed > up the problems, and committed the end result. > > My perl skills are still very dubious, so I'm not proud of the script, > but it's there as "scripts/parse-mainainers.pl" now. The "output > sorted result" part could *easily* be changed into "output sorted > result into separate files based on the first word of the header" or > something. > > But in the meantime, at least that MAINTAINERS file should _really_ be > alpha-sorted now. Maybe add a reordering of the patterns so that each pattern list is in a specific order too ---  scripts/parse-maintainers.pl | 36 ++++++++++++++++++++++++++++++++----  1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/scripts/parse-maintainers.pl b/scripts/parse-maintainers.pl index a0fe34349b24..03e7405af1a3 100644 --- a/scripts/parse-maintainers.pl +++ b/scripts/parse-maintainers.pl @@ -4,7 +4,7 @@ use strict;    my %map;   -# sort comparison function +# sort comparison functions  sub by_category($$) {      my ($a, $b) = @_;   @@ -18,17 +18,45 @@ sub by_category($$) {      $a cmp $b;  }   +sub by_pattern($$) { +    my ($a, $b) = @_; +    my $preferred_order = 'MRPLWQTBSKCFX'; + +    my $rtn; +    $a = uc(substr($a, 0, 1)); +    $b = uc(substr($b, 0, 1)); + +    my $a_index = index($preferred_order, $a); +    my $b_index = index($preferred_order, $b); + +    $a_index = 1000 if ($a_index == -1); +    $b_index = 1000 if ($b_index == -1); + +    if ($a_index < $b_index) { + return -1; +    } elsif ($a_index == $b_index) { + return 0; +    } else { + return 1; +    } +} +  sub alpha_output {      my $key; -    my $sort_method = \&by_category;      my $sep = "";   -    foreach $key (sort $sort_method keys %map) { +    foreach $key (sort by_category keys %map) {          if ($key ne " ") {              print $sep . $key . "\n";              $sep = "\n";          } -        print $map{$key}; + if ($key eq " ") { +     print $map{$key}; + } else { +     foreach my $pattern (sort by_pattern split('\n', $map{$key})) { + print($pattern . "\n"); +     } + }      }  }