mirror of
https://github.com/moparisthebest/pacman
synced 2024-10-31 15:45:03 -04:00
pacsearch: fields are treated uniformly when printing
We include the leading space in the match for 'group' and 'installed'. This allows us to remove the conditions when printing. Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
e2fe052576
commit
894773eb5b
@ -91,11 +91,8 @@ sub print_pkg {
|
|||||||
} else {
|
} else {
|
||||||
print "$MAGENTA";
|
print "$MAGENTA";
|
||||||
}
|
}
|
||||||
print "$v[0]/$RESET$BOLD$v[1] $GREEN$v[2]";
|
print "$v[0]/$RESET$BOLD$v[1] $GREEN$v[2]$BLUE$v[3]$CYAN$v[4]$RESET\n";
|
||||||
print " $BLUE$v[3]" if $v[3] ne "";
|
print "$v[5]\n";
|
||||||
print " $CYAN$v[4]" if $v[4] ne "";
|
|
||||||
print " $RESET\n";
|
|
||||||
print " $v[5]\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my %allpkgs = ();
|
my %allpkgs = ();
|
||||||
@ -110,8 +107,10 @@ if ($#syncpkgs >= 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach $_ (@syncpkgs) {
|
foreach $_ (@syncpkgs) {
|
||||||
# we grab the following fields: repo, name, ver, group, installed, and desc
|
# We grab the following fields: repo, name, ver, group, installed, and
|
||||||
my @pkgfields = /^(.*?)\/(.*?) (.*?) ?(\(.*?\))? ?(\[.*\])?\n(.*)$/s;
|
# desc. We grab leading space for 'group' and 'installed' so that we do not
|
||||||
|
# need to test if non-empty when printing.
|
||||||
|
my @pkgfields = /^(.*?)\/(.*?) (.*?)( \(.*?\))?( \[.*\])?\n(.*)$/s;
|
||||||
if(not @pkgfields) {
|
if(not @pkgfields) {
|
||||||
# skip any non-matching line and just print it for the user
|
# skip any non-matching line and just print it for the user
|
||||||
print $_, "\n";
|
print $_, "\n";
|
||||||
@ -135,15 +134,16 @@ if ($#querypkgs >= 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach $_ (@querypkgs) {
|
foreach $_ (@querypkgs) {
|
||||||
# we grab the following fields: repo, name, ver, group, installed, and desc
|
# We grab the same field as before, even the "installed" which is always
|
||||||
my @pkgfields = /^(.*?)\/(.*?) (.*?) ?(\(.*?\))? ?(\[.*\])?\n(.*)$/s;
|
# empty for local searches. This allows us to reserve a cell in @pkgfields.
|
||||||
|
my @pkgfields = /^(.*?)\/(.*?) (.*?)( \(.*?\))?( \[.*\])?\n(.*)$/s;
|
||||||
# skip any non-matching line
|
# skip any non-matching line
|
||||||
next if not defined $pkgfields[1];
|
next if not defined $pkgfields[1];
|
||||||
# check if the package was listed in the sync out
|
# check if the package was listed in the sync out
|
||||||
if (not exists $allpkgs{$pkgfields[1] . $pkgfields[2]}) {
|
if (not exists $allpkgs{$pkgfields[1] . $pkgfields[2]}) {
|
||||||
# since 'group' is optional, we should fill it in if necessary
|
# since 'group' is optional, we should fill it in if necessary
|
||||||
$pkgfields[3] = "" if not defined $pkgfields[3];
|
$pkgfields[3] = "" if not defined $pkgfields[3];
|
||||||
$pkgfields[4] = "[$LC_INSTALLED]";
|
$pkgfields[4] = " [$LC_INSTALLED]";
|
||||||
push (@pkglist, \@pkgfields);
|
push (@pkglist, \@pkgfields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user