From: agriffis Date: Mon, 12 Jan 2004 23:54:00 +0000 (-0000) Subject: allow multiple keywords X-Git-Tag: gentoolkit-0.2.4.3~439 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c0ea7e9a4beb8d7dc687adae1440928fab95a9f6;p=gentoolkit.git allow multiple keywords svn path=/; revision=63 --- diff --git a/trunk/src/ekeyword/ChangeLog b/trunk/src/ekeyword/ChangeLog index 6cdc211..20942f2 100644 --- a/trunk/src/ekeyword/ChangeLog +++ b/trunk/src/ekeyword/ChangeLog @@ -1,2 +1,5 @@ +2004-01-12 Aron Griffis + * Allow multiple keywords + 2004-01-07 Karl Trygve Kalleberg * Added Makefile diff --git a/trunk/src/ekeyword/ekeyword b/trunk/src/ekeyword/ekeyword index f5eb133..420c979 100644 --- a/trunk/src/ekeyword/ekeyword +++ b/trunk/src/ekeyword/ekeyword @@ -12,22 +12,35 @@ # > KEYWORDS="x86 ppc sparc ~alpha" -die "syntax: ekeyword { arch | ~arch | -arch } ebuild...\n" unless @ARGV > 1; +my ($kw_re) = '^[-~]?\w+$'; -my $kw = shift @ARGV; -(my $arch = $kw) =~ s|^[-~]||; - -die "$kw doesn't look like a keyword to me\n" unless $arch =~ /^\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" +} +for my $a (@ARGV) { + next if $a =~ /$kw_re/o; # keyword + next if $a =~ /^\S+\.ebuild$/; # ebuild + die "I don't understand $a\n"; +} for my $f (@ARGV) { + if ($f =~ /$kw_re/o) { + push @kw, $f; + next; + } + open I, "<$f" or die "Can't read $f: $!\n"; open O, ">$f.new" or die "Can't create $f.new: $!\n"; select O; while () { - /^KEYWORDS/ or print, next; - s/[-~]?$arch/$kw/ || s/(.*?['"].*?)\s*(?=['"])/$1 $kw/; - print $_, or die "Can't write $f.new: $!\n"; + /^KEYWORDS/ or print, next; + for my $k (@kw) { + (my $arch = $k) =~ s/^[-~]//; + s/[-~]?$arch/$k/ || s/(.*?['"].*?)\s*(?=['"])/$1 $k/; + } + print $_, or die "Can't write $f.new: $!\n"; } close I;