From 799b93d258bad917262ac160df74136f05d4a451 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 28 Mar 2010 20:23:22 -0400 Subject: [PATCH] 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. --- IkiWiki.pm | 9 ++++----- IkiWiki/Render.pm | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 927d62940..6739ba56c 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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 ($) { diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index af24df155..abafb0887 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -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 -- 2.26.2