From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4F11913857C for ; Sat, 19 Jan 2013 21:43:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9EE7421C02E; Sat, 19 Jan 2013 21:43:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E710F21C00D for ; Sat, 19 Jan 2013 21:43:36 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C0F0433DA9B for ; Sat, 19 Jan 2013 21:43:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5CE0BE4077 for ; Sat, 19 Jan 2013 21:43:34 +0000 (UTC) From: "Sven Eden" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sven Eden" Message-ID: <1358405949.e78d0f4211ad6e5963c359d566965990d72d537c.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed.pl.in X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: e78d0f4211ad6e5963c359d566965990d72d537c X-VCS-Branch: master Date: Sat, 19 Jan 2013 21:43:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 10984877-9e0a-4441-a55f-33bfcd13a445 X-Archives-Hash: 37a9a07da1ab93225040a36679386da9 commit: e78d0f4211ad6e5963c359d566965990d72d537c Author: Sven Eden gmx de> AuthorDate: Thu Jan 17 06:59:09 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Thu Jan 17 06:59:09 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=e78d0f42 Fixed several Perl::Critic warnings. This has been done as a preparation for future changes implementing new features. The following warnings have been fixed: [Variables::RequireLexicalLoo pIterators] Loop iterator is not lexical (See page 108 of PBP) [Subroutines::RequireArgUnpacking] Always unpack @_ first (See page 178 of PBP) [Subroutines::ProhibitSubroutinePrototypes] Subroutine prototypes used (See page 194 of PBP) [Subrotines::RequireFinalReturn] Subroutine did not end with "return" (See page 197 of PBP) --- ufed.pl.in | 90 ++++++++++++++++++++++++++++++++---------------------------- 1 files changed, 48 insertions(+), 42 deletions(-) diff --git a/ufed.pl.in b/ufed.pl.in index 341cb55..7bd37b2 100644 --- a/ufed.pl.in +++ b/ufed.pl.in @@ -14,10 +14,10 @@ my $version = 'XX_PACKAGE_VERSION@'; my %use_descriptions; my %masked_descriptions; -sub finalise(@); -sub flags_dialog(); -sub read_use_descs(); -sub save_flags(@); +sub finalise; +sub flags_dialog; +sub read_use_descs; +sub save_flags; delete $Portage::all_flags{'*'}; @@ -56,17 +56,19 @@ for(keys %Portage::use_masked_flags) { flags_dialog; -sub finalise(@) { - return sort { +sub finalise { + my @arg = @_; + my @result = sort { ($a ne '-*') <=> ($b ne '-*') || ($a =~ /^-/) <=> ($b =~ /^-/) || $a cmp $b - } @_; + } @arg; + return @result; } -sub flags_dialog() { +sub flags_dialog { use POSIX (); POSIX::dup2 1, 3; POSIX::dup2 1, 4; @@ -87,47 +89,47 @@ sub flags_dialog() { } POSIX::close $iread; POSIX::close $owrite; - if(open my $fh, '>&=', $iwrite) { - - # Write masked flags first so they sort at the beginning of the list - for my $flag (sort { uc $a cmp uc $b } keys %masked_descriptions) { - print $fh "(" . $flag . ") msk " - . (exists($Portage::make_defaults_flags{$flag}) - ? $Portage::make_defaults_flags{$flag} ? '(+' :'(-' - : '( ') - . (exists($Portage::make_conf_flags{$flag}) - ? $Portage::make_conf_flags{$flag} ? '+)': '-)' - : ' )') - . ' ' . scalar(@{$masked_descriptions{$flag}}) . "\n"; - print $fh $_, "\n" for(@{$masked_descriptions{$flag}}); - } + my $outTxt = ""; - # Then write regular flags - for my $flag (sort { uc $a cmp uc $b } keys %use_descriptions) { - print $fh $flag - . (defined($Portage::make_conf_flags{$flag}) - ? $Portage::make_conf_flags{$flag} ? ' on ' : ' off ' - : ' def ' ) - . (exists($Portage::make_defaults_flags{$flag}) - ? $Portage::make_defaults_flags{$flag} ? '(+' :'(-' - : '( ') - . (exists($Portage::make_conf_flags{$flag}) - ? $Portage::make_conf_flags{$flag} ? '+)': '-)' - : ' )') - . ' ' . scalar(@{$use_descriptions{$flag}}) . "\n"; - print $fh $_, "\n" for(@{$use_descriptions{$flag}}); - } + # Write masked flags first so they sort at the beginning of the list + for my $flag (sort { uc $a cmp uc $b } keys %masked_descriptions) { + $outTxt .= sprintf ("(%s) msk (%s%s) %d\n", $flag, + exists($Portage::make_defaults_flags{$flag}) + ? $Portage::make_defaults_flags{$flag} ? '+' : '-' : ' ', + exists($Portage::make_conf_flags{$flag}) + ? $Portage::make_conf_flags{$flag} ? '+' : '-' : ' ', + scalar @{$masked_descriptions{$flag}} ); + $outTxt .= sprintf ("%s\n", $_) for(@{$masked_descriptions{$flag}}); + } + + # Then write regular flags + for my $flag (sort { uc $a cmp uc $b } keys %use_descriptions) { + $outTxt .= sprintf ("%s %s (%s%s) %d\n", $flag, + defined($Portage::make_conf_flags{$flag}) + ? $Portage::make_conf_flags{$flag} ? ' on ' : ' off ' : ' def ', + exists($Portage::make_defaults_flags{$flag}) + ? $Portage::make_defaults_flags{$flag} ? '+' : '-' : ' ', + exists($Portage::make_conf_flags{$flag}) + ? $Portage::make_conf_flags{$flag} ? '+' : '-' : ' ', + scalar @{$use_descriptions{$flag}} ); + $outTxt .= sprintf ("%s\n", $_) for(@{$use_descriptions{$flag}}); + } + + # Now let the interface know of the result + if (open my $fh, '>&=', $iwrite) { + print $fh $outTxt; close $fh; } else { die "Couldn't let interface know of flags\n"; } POSIX::close $iwrite; wait; - open my $fh, '<&=', $oread or die "Couldn't read output.\n"; if(POSIX::WIFEXITED($?)) { my $rc = POSIX::WEXITSTATUS($?); if($rc==0) { + open my $fh, '<&=', $oread or die "Couldn't read output.\n"; my @flags = grep { $_ ne '--*' } do { local $/; split /\n/, <$fh> }; + close $fh; save_flags finalise @flags; } elsif($rc==1) { print "Cancelled, not saving changes.\n" } @@ -136,9 +138,10 @@ sub flags_dialog() { { kill POSIX::WTERMSIG($?), $$ } else { exit 127 } + return; } -sub read_use_descs() { +sub read_use_descs { my %_use_descriptions; for my $dir(@Portage::portagedirs) { for(Portage::noncomments "$dir/profiles/use.desc") { @@ -160,9 +163,11 @@ sub read_use_descs() { for my $desc(sort keys %{$_use_local_descriptions{$_}}) { push @{$use_descriptions{$_}}, "Local flag: $desc (@{[sort keys %{$_use_local_descriptions{$_}{$desc}}]})" } } + return; } -sub save_flags(@) { +sub save_flags { + my (@flags) = @_; my $BLANK = qr{(?:[ \n\t]+|#.*)+}; # whitespace and comments my $UBLNK = qr{(?: # as above, but scan for #USE= [ \n\t]+ | @@ -176,7 +181,6 @@ sub save_flags(@) { my $BNUQV = qr{(?:[^ \\\n\t'"#]+|\\\n()|\\.)+}s;# unquoted value (scan for \\\n) my $BNDQV = qr{"(?:[^\\"]|\\\n()|\\.)*"}s; # doublequoted value (scan for \\\n) - my (@flags) = @_; my $contents; my $makeconf_name = "$Portage::eprefix/etc/portage/make.conf"; @@ -257,7 +261,7 @@ sub save_flags(@) { $flags = $nl.$flag; $length = length $flag; } - for $flag(@flags[1..$#flags]) { + for my $flag (@flags[1..$#flags]) { if($length + 1 + length $flag <= $linelength) { $flags .= " $flag"; $length += 1+length $flag; @@ -326,4 +330,6 @@ EOF print $makeconf $_; close $makeconf; } + + return; }