From ef3d183d5bfcadc1edfd4c4446606dee8066f2f6 Mon Sep 17 00:00:00 2001 From: agriffis Date: Fri, 9 Apr 2004 15:31:02 +0000 Subject: [PATCH] Add ability to modify all keywords via all, ~all, or -all, for example: ekeyword -all ~alpha ia64 blah.ebuild svn path=/; revision=101 --- trunk/src/ekeyword/ChangeLog | 4 ++++ trunk/src/ekeyword/ekeyword | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/trunk/src/ekeyword/ChangeLog b/trunk/src/ekeyword/ChangeLog index b3c4cff..3ab0d56 100644 --- a/trunk/src/ekeyword/ChangeLog +++ b/trunk/src/ekeyword/ChangeLog @@ -1,3 +1,7 @@ +09 Apr 2004 Aron Griffis + * Add ability to modify all keywords via all, ~all, or -all, for + example: ekeyword -all ~alpha ia64 blah.ebuild + 31 Mar 2004 Aron Griffis * Fix bug 28426 with patch from Mr_Bones_ to keep ekeyword from confusing ppc and ppc64 diff --git a/trunk/src/ekeyword/ekeyword b/trunk/src/ekeyword/ekeyword index be9cd64..4845c38 100644 --- a/trunk/src/ekeyword/ekeyword +++ b/trunk/src/ekeyword/ekeyword @@ -16,7 +16,7 @@ my ($kw_re) = '^[-~]?\w+$'; # make sure the cmdline consists of keywords and ebuilds unless (@ARGV > 1 && $ARGV[0] =~ /$kw_re/o) { - die "syntax: ekeyword { arch | ~arch | -arch } ebuild...\n" + die "syntax: ekeyword { arch | ~[arch] | -[arch] } ebuild...\n" } for my $a (@ARGV) { next if $a =~ /$kw_re/o; # keyword @@ -38,7 +38,22 @@ for my $f (@ARGV) { /^KEYWORDS/ or print, next; for my $k (@kw) { (my $arch = $k) =~ s/^[-~]//; - s/[-~]?$arch\b/$k/ || s/(.*?['"].*?)\s*(?=['"])/$1 $k/; + if ($arch eq 'all') { + # remove "all" so that only leader is left (blank, ~ or -) + $k =~ s/all//; + + # extract the quoted section from KEYWORDS + (my $quoted = $_) =~ s/^.*["'](.*?)["'].*/$1/s; + + # modify every keyword in the list + $quoted =~ s/(^|\s)[-~]?(?=\w)/$1$k/g; + + # re-insert to KEYWORDS + s/(["']).*?["']/$1$quoted$1/; + } else { + # modify just one keyword + s/[-~]?$arch\b/$k/ || s/(.*?['"].*?)\s*(?=['"])/$1 $k/; + } } print $_, or die "Can't write $f.new: $!\n"; } -- 2.26.2