From: agriffis Date: Thu, 17 Mar 2005 15:56:51 +0000 (-0000) Subject: Sort keywords alphabetically X-Git-Tag: gentoolkit-0.2.4.3~307 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=be9ce5b140f9a299f137e093bb5caea45db228b2;p=gentoolkit.git Sort keywords alphabetically svn path=/; revision=199 --- 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/;