summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
authoragriffis <agriffis@gentoo.org>2005-03-17 15:56:51 +0000
committeragriffis <agriffis@gentoo.org>2005-03-17 15:56:51 +0000
commitbe9ce5b140f9a299f137e093bb5caea45db228b2 (patch)
tree629ba54f40a9d9de30da171137b85ea45fc77dba /trunk
parent2f1e3e0e4c17fe18d7f1002e7f3f9e63a9d88431 (diff)
downloadgentoolkit-be9ce5b140f9a299f137e093bb5caea45db228b2.tar.gz
Sort keywords alphabetically
svn path=/; revision=199
Diffstat (limited to 'trunk')
-rw-r--r--trunk/src/ekeyword/ekeyword13
1 files 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/;