prt-auf: fixed the --regex switch in find_port_by_name()
This commit is contained in:
parent
ffb34d639f
commit
238c856e31
@ -373,11 +373,12 @@ sub get_pkgfile_fields {
|
|||||||
|
|
||||||
sub find_port_by_file { # for now only used to search footprints, but can be generalized
|
sub find_port_by_file { # for now only used to search footprints, but can be generalized
|
||||||
my $portfile = shift; my $query = shift; my ($lp, $candidate, $fh); my %hits=();
|
my $portfile = shift; my $query = shift; my ($lp, $candidate, $fh); my %hits=();
|
||||||
|
$query =~ s/\+/\\\+/g unless ($osearch{regex}==1);
|
||||||
|
$query =~ s/\./\\\./g unless ($osearch{regex}==1);
|
||||||
my $linewanted = qr/$query/is;
|
my $linewanted = qr/$query/is;
|
||||||
LOCALENTRY: foreach $lp (@localports) {
|
LOCALENTRY: foreach $lp (@localports) {
|
||||||
open ($fh, "$lp/$portfile") or die "cannot open $portfile for $lp\n";
|
open ($fh, "$lp/$portfile") or die "cannot open $portfile for $lp\n";
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
next if ($portfile eq "Pkgfile" and $_ !~ /^(name=|# Description)/);
|
|
||||||
next LOCALENTRY if $hits{$lp};
|
next LOCALENTRY if $hits{$lp};
|
||||||
$hits{$lp} = $_ if $_ =~ $linewanted;
|
$hits{$lp} = $_ if $_ =~ $linewanted;
|
||||||
} close ($fh);
|
} close ($fh);
|
||||||
@ -409,9 +410,12 @@ sub find_port_by_name {
|
|||||||
my $query = shift; my $exact=shift; my $fullpath=shift; my $exhaustive=shift;
|
my $query = shift; my $exact=shift; my $fullpath=shift; my $exhaustive=shift;
|
||||||
$query =~ s/\+/\\\+/g unless ($osearch{regex}==1);
|
$query =~ s/\+/\\\+/g unless ($osearch{regex}==1);
|
||||||
$query =~ s/\./\\\./g unless ($osearch{regex}==1);
|
$query =~ s/\./\\\./g unless ($osearch{regex}==1);
|
||||||
|
$query =~ s/\^/\// if (($osearch{regex}==1) and ($exact==0));
|
||||||
my $pattern = ($exact==1) ? qr/\/$query$/s : qr/$query/is;
|
my $pattern = ($exact==1) ? qr/\/$query$/s : qr/$query/is;
|
||||||
my @hits = grep { $_ =~ $pattern } @allports;
|
# my @names_only = map { $_ => (split /\//, $_)[-1] } @allports;
|
||||||
@hits = grep { s/^(.*)\/// } @hits if ($fullpath==0);
|
my @hits = grep { $_ =~ $pattern } @allports;
|
||||||
|
@hits = grep { s/^.*\/// } @hits if ($fullpath==0);
|
||||||
|
|
||||||
return @hits if ($exhaustive==1);
|
return @hits if ($exhaustive==1);
|
||||||
return $hits[0] if ($exhaustive==0);
|
return $hits[0] if ($exhaustive==0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user