From ed9f89c2efc8d5212291c25d9a23943984bbf2eb Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 7 Nov 2006 09:04:22 +0000 Subject: factorize --- urpmf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'urpmf') diff --git a/urpmf b/urpmf index 6ab2cced..e4cacaee 100755 --- a/urpmf +++ b/urpmf @@ -124,26 +124,26 @@ my $multi = 0; my $multitag = ''; my %multitags = map { $_ => 1 } qw(conffiles conflicts files obsoletes provides requires); my %usedtags; -while ($qf =~ /%[-\d]*(\w+)/g) { - ++$multi, $multitag = $1 if $multitags{$1}; - $usedtags{$1} = 1; -} -$multi > 1 - and $urpm->{fatal}->(1, N("Incorrect format: you may use only one multi-valued tag")); (my $proto = $qf) =~ s/%([-\d]*)(\w+)/%${1}s/g; my $sprintfargs = join(', ', map { + $usedtags{$1} = 1; if ($_ eq 'media') { '$urpm::currentmedia->{name}'; } elsif ($_ eq 'fullname') { 'scalar($pkg->fullname)'; - } elsif ($_ eq $multitag) { + } elsif ($multitags{$_}) { + $multi++; + $multitag = $_; '$mt'; } else { '$pkg->' . $_; } } $qf =~ /%[-\d]*(\w+)/g); +$multi > 1 + and $urpm->{fatal}->(1, N("Incorrect format: you may use only one multi-valued tag")); + my $next_st = $multi ? 'next' : 'return 1'; my @inner = ( "my \$s = sprintf(qq{$proto}, $sprintfargs);", -- cgit v1.2.1