From b7351daacd0d4a041a51b43d99b7bf589de54f53 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 9 Oct 2009 12:54:13 -0400 Subject: [PATCH] conditional: use yesno --- IkiWiki.pm | 2 +- IkiWiki/Plugin/conditional.pm | 2 +- t/yesno.t | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index fd7e23524..475e278c3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1792,7 +1792,7 @@ sub add_depends ($$;$) { # $depends_simple{$page}{lc $i} |= $i{$i}; # } #} - print STDERR "warning: use of add_depends; influences not tracked\n"; + print STDERR "warning: use of add_depends by ".caller()."; influences not tracked\n"; $depends{$page}{$pagespec} |= $deptype; return 1; diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index 7445dbdad..7ead701f2 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -29,7 +29,7 @@ sub preprocess_if (@) { } my $result=0; - if ((exists $params{all} && lc $params{all} eq "no") || + if (! IkiWiki::yesno($params{all}) || # An optimisation to avoid needless looping over every page # and adding of dependencies for simple uses of some of the # tests. diff --git a/t/yesno.t b/t/yesno.t index 60a8c071d..8770390a1 100755 --- a/t/yesno.t +++ b/t/yesno.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 10; +use Test::More tests => 11; BEGIN { use_ok("IkiWiki"); } @@ -19,3 +19,5 @@ ok(IkiWiki::yesno("NO") == 0); ok(IkiWiki::yesno("1") == 1); ok(IkiWiki::yesno("0") == 0); ok(IkiWiki::yesno("mooooooooooo") == 0); + +ok(IkiWiki::yesno(undef) == 0); -- 2.32.0.93.g670b81a890