From be9ce5b140f9a299f137e093bb5caea45db228b2 Mon Sep 17 00:00:00 2001 From: agriffis Date: Thu, 17 Mar 2005 15:56:51 +0000 Subject: [PATCH] Sort keywords alphabetically svn path=/; revision=199 --- trunk/src/ekeyword/ekeyword | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/trunk/src/ekeyword/ekeyword b/trunk/src/ekeyword/ekeyword index e02a6e8..46935df 100644 --- a/trunk/src/ekeyword/ekeyword +++ b/trunk/src/ekeyword/ekeyword @@ -17,7 +17,7 @@ my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$'; my (@kw); # make sure the cmdline consists of keywords and ebuilds -unless (@ARGV > 1 && $ARGV[0] =~ /$kw_re/o) { +unless (@ARGV > 0) { die "syntax: ekeyword { arch | ~[arch] | -[arch] } ebuild...\n" } for my $a (@ARGV) { @@ -87,9 +87,14 @@ for my $f (@ARGV) { # replace -STAR with -* $quoted =~ s/-STAR\b/-*/; - # fixup spacing - $quoted =~ s/^\s*(.*?)\s*$/$1/; # leading/trailing - $quoted =~ s/\s+/ /g; # inner + # sort keywords and fix spacing + $quoted = join " ", sort { + (my $sa = $a) =~ s/^\W//; + (my $sb = $b) =~ s/^\W//; + return -1 if $sa eq '*'; + return +1 if $sb eq '*'; + $sa cmp $sb; + } split " ", $quoted; # re-insert quoted to KEYWORDS s/(["']).*?["']/$1$quoted$1/; -- 2.26.2