don't check $@ after pagespec_translate

pagespec_translate may set $@ if it fails to parse a pagespec, but
due to memoization, this is not reliable. If a memoized call is repeated,
and $@ is already set for some other reason previously, it will remain
set through the call to pagespec_translate.

Instead, just check if pagespec_translate returns undef.
master
Joey Hess 2010-03-28 20:23:22 -04:00
parent b6666f5ac8
commit 799b93d258
2 changed files with 5 additions and 6 deletions

View File

@ -1796,7 +1796,7 @@ sub add_depends ($$;$) {
# Add explicit dependencies for influences.
my $sub=pagespec_translate($pagespec);
return if $@;
return unless defined $sub;
foreach my $p (keys %pagesources) {
my $r=$sub->($p, location => $page);
my $i=$r->influences;
@ -2001,7 +2001,7 @@ sub pagespec_match ($$;@) {
my $sub=pagespec_translate($spec);
return IkiWiki::ErrorReason->new("syntax error in pagespec \"$spec\"")
if $@ || ! defined $sub;
if ! defined $sub;
return $sub->($page, @params);
}
@ -2019,7 +2019,7 @@ sub pagespec_match_list ($$;@) {
my $sub=pagespec_translate($pagespec);
error "syntax error in pagespec \"$pagespec\""
if $@ || ! defined $sub;
if ! defined $sub;
my @candidates;
if (exists $params{list}) {
@ -2092,8 +2092,7 @@ sub pagespec_match_list ($$;@) {
sub pagespec_valid ($) {
my $spec=shift;
my $sub=pagespec_translate($spec);
return ! $@;
return defined pagespec_translate($spec);
}
sub glob2re ($) {

View File

@ -565,7 +565,7 @@ sub render_dependent ($$$$$$$) {
if (exists $depends{$p} && ! defined $reason) {
foreach my $dep (keys %{$depends{$p}}) {
my $sub=pagespec_translate($dep);
next if $@ || ! defined $sub;
next unless defined $sub;
# only consider internal files
# if the page explicitly depends