diff -urX ignorepats ikiwiki/IkiWiki/CGI.pm ikidev/IkiWiki/CGI.pm --- ikiwiki/IkiWiki/CGI.pm 2007-01-23 18:24:20.305761000 -0800 +++ ikidev/IkiWiki/CGI.pm 2007-01-28 12:40:20.397044000 -0800 @@ -43,7 +43,7 @@ foreach my $admin (@{$config{adminuser}}) { my $locked_pages=userinfo_get($admin, "locked_pages"); - if (pagespec_match($page, userinfo_get($admin, "locked_pages"))) { + if (pagespec_match($page, userinfo_get($admin, "locked_pages"), "")) { return 1 if $nonfatal; #translators: The first parameter is a page name, diff -urX ignorepats ikiwiki/IkiWiki/Plugin/brokenlinks.pm ikidev/IkiWiki/Plugin/brokenlinks.pm --- ikiwiki/IkiWiki/Plugin/brokenlinks.pm 2006-12-28 19:15:58.000000000 -0800 +++ ikidev/IkiWiki/Plugin/brokenlinks.pm 2007-01-28 13:24:34.802784000 -0800 @@ -20,7 +20,7 @@ my @broken; foreach my $page (keys %links) { - if (pagespec_match($page, $params{pages})) { + if (pagespec_match($page, $params{pages}, $params{page})) { foreach my $link (@{$links{$page}}) { next if $link =~ /.*\/discussion/i && $config{discussion}; my $bestlink=bestlink($page, $link); diff -urX ignorepats ikiwiki/IkiWiki/Plugin/inline.pm ikidev/IkiWiki/Plugin/inline.pm --- ikiwiki/IkiWiki/Plugin/inline.pm 2007-01-23 18:24:20.340760000 -0800 +++ ikidev/IkiWiki/Plugin/inline.pm 2007-01-28 12:44:51.445133000 -0800 @@ -81,7 +81,7 @@ my @list; foreach my $page (keys %pagesources) { next if $page eq $params{page}; - if (pagespec_match($page, $params{pages})) { + if (pagespec_match($page, $params{pages}, $params{page})) { push @list, $page; } } diff -urX ignorepats ikiwiki/IkiWiki/Plugin/linkmap.pm ikidev/IkiWiki/Plugin/linkmap.pm --- ikiwiki/IkiWiki/Plugin/linkmap.pm 2006-12-28 19:27:27.000000000 -0800 +++ ikidev/IkiWiki/Plugin/linkmap.pm 2007-01-28 13:25:08.657975000 -0800 @@ -48,7 +48,7 @@ # Get all the items to map. my %mapitems = (); foreach my $item (keys %links) { - if (pagespec_match($item, $params{pages})) { + if (pagespec_match($item, $params{pages}, $params{page})) { my $link=htmlpage($item); $link=IkiWiki::abs2rel($link, IkiWiki::dirname($params{page})); $mapitems{$item}=$link; diff -urX ignorepats ikiwiki/IkiWiki/Plugin/map.pm ikidev/IkiWiki/Plugin/map.pm --- ikiwiki/IkiWiki/Plugin/map.pm 2006-09-09 15:07:45.000000000 -0700 +++ ikidev/IkiWiki/Plugin/map.pm 2007-01-28 13:25:17.393485000 -0800 @@ -26,7 +26,7 @@ # Get all the items to map. my @mapitems = (); foreach my $page (keys %links) { - if (pagespec_match($page, $params{pages})) { + if (pagespec_match($page, $params{pages}, $params{page})) { push @mapitems, $page; } } diff -urX ignorepats ikiwiki/IkiWiki/Plugin/orphans.pm ikidev/IkiWiki/Plugin/orphans.pm --- ikiwiki/IkiWiki/Plugin/orphans.pm 2006-12-28 19:30:53.000000000 -0800 +++ ikidev/IkiWiki/Plugin/orphans.pm 2007-01-28 13:24:22.912649000 -0800 @@ -27,7 +27,7 @@ my @orphans; foreach my $page (keys %renderedfiles) { next if $linkedto{$page}; - next unless pagespec_match($page, $params{pages}); + next unless pagespec_match($page, $params{pages}, $params{page}); # If the page has a link to some other page, it's # indirectly linked to a page via that page's backlinks. next if grep { diff -urX ignorepats ikiwiki/IkiWiki/Plugin/pagecount.pm ikidev/IkiWiki/Plugin/pagecount.pm --- ikiwiki/IkiWiki/Plugin/pagecount.pm 2006-09-09 15:08:18.000000000 -0700 +++ ikidev/IkiWiki/Plugin/pagecount.pm 2007-01-28 13:24:54.011123000 -0800 @@ -22,7 +22,7 @@ return $#pages+1 if $params{pages} eq "*"; # optimisation my $count=0; foreach my $page (@pages) { - $count++ if pagespec_match($page, $params{pages}); + $count++ if pagespec_match($page, $params{pages}, $params{page}); } return $count; } # }}} diff -urX ignorepats ikiwiki/IkiWiki/Plugin/pagestats.pm ikidev/IkiWiki/Plugin/pagestats.pm --- ikiwiki/IkiWiki/Plugin/pagestats.pm 2006-09-09 15:05:20.000000000 -0700 +++ ikidev/IkiWiki/Plugin/pagestats.pm 2007-01-28 13:25:29.751477000 -0800 @@ -33,7 +33,7 @@ my %counts; my $max = 0; foreach my $page (keys %links) { - if (pagespec_match($page, $params{pages})) { + if (pagespec_match($page, $params{pages}, $params{page})) { my @bl = IkiWiki::backlinks($page); $counts{$page} = scalar(@bl); $max = $counts{$page} if $counts{$page} > $max; diff -urX ignorepats ikiwiki/IkiWiki/Render.pm ikidev/IkiWiki/Render.pm --- ikiwiki/IkiWiki/Render.pm 2007-01-23 18:24:20.359768000 -0800 +++ ikidev/IkiWiki/Render.pm 2007-01-28 12:53:36.117820000 -0800 @@ -350,7 +350,7 @@ foreach my $file (keys %rendered, @del) { next if $f eq $file; my $page=pagename($file); - if (pagespec_match($page, $depends{$p})) { + if (pagespec_match($page, $depends{$p}, "")) { debug(sprintf(gettext("rendering %s, which depends on %s"), $f, $page)); render($f); $rendered{$f}=1; diff -urX ignorepats ikiwiki/IkiWiki/UserInfo.pm ikidev/IkiWiki/UserInfo.pm --- ikiwiki/IkiWiki/UserInfo.pm 2007-01-04 03:51:39.000000000 -0800 +++ ikidev/IkiWiki/UserInfo.pm 2007-01-28 12:58:03.047049000 -0800 @@ -101,7 +101,7 @@ length $userinfo->{$user}->{subscriptions} && exists $userinfo->{$user}->{email} && length $userinfo->{$user}->{email} && - grep { pagespec_match($_, $userinfo->{$user}->{subscriptions}) } @pages) { + grep { pagespec_match($_, $userinfo->{$user}->{subscriptions}, "") } @pages) { push @ret, $userinfo->{$user}->{email}; } } diff -urX ignorepats ikiwiki/IkiWiki.pm ikidev/IkiWiki.pm --- ikiwiki/IkiWiki.pm 2007-01-23 18:24:20.411765000 -0800 +++ ikidev/IkiWiki.pm 2007-01-28 13:17:52.839748000 -0800 @@ -812,7 +812,13 @@ $code.=" match_$1(\$page, ".safequote($2).")"; } else { - $code.=" match_glob(\$page, ".safequote($word).")"; + if ($word =~ m!^./!) { + $word =~ s!^./!!g; + $code.=" match_glob(\$page, \$from.".safequote($word).")"; + } + else { + $code.=" match_glob(\$page, ".safequote($word).")"; + } } } @@ -856,9 +862,13 @@ } } #}}} -sub pagespec_match ($$) { #{{{ +sub pagespec_match ($$;$) { #{{{ my $page=shift; my $spec=shift; + my $from=shift; + if (! $from){ + $from = ""; + } return eval pagespec_translate($spec); } #}}} @@ -871,6 +881,9 @@ $glob=quotemeta($glob); $glob=~s/\\\*/.*/g; $glob=~s/\\\?/./g; + $glob=~s/\\\@/[^\/]*/g; + + $glob=~s!//!/!g; return $page=~/^$glob$/i; } #}}} diff -urX ignorepats ikiwiki/t/pagespec_match.t ikidev/t/pagespec_match.t --- ikiwiki/t/pagespec_match.t 2006-09-09 14:24:09.000000000 -0700 +++ ikidev/t/pagespec_match.t 2007-01-28 13:20:18.539394000 -0800 @@ -1,29 +1,32 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 35; +use Test::More tests => 38; BEGIN { use_ok("IkiWiki"); } -ok(pagespec_match("foo", "*")); -ok(pagespec_match("page", "?ag?")); -ok(! pagespec_match("page", "?a?g?")); -ok(pagespec_match("foo.png", "*.*")); -ok(! pagespec_match("foo", "*.*")); -ok(pagespec_match("foo", "foo or bar"), "simple list"); -ok(pagespec_match("bar", "foo or bar"), "simple list 2"); -ok(pagespec_match("foo", "f?? and !foz")); -ok(! pagespec_match("foo", "f?? and !foo")); -ok(! pagespec_match("foo", "* and !foo")); -ok(! pagespec_match("foo", "foo and !foo")); -ok(! pagespec_match("foo.png", "* and !*.*")); -ok(pagespec_match("foo", "(bar or ((meep and foo) or (baz or foo) or beep))")); +ok(pagespec_match("foo", "*", "")); +ok(pagespec_match("page", "?ag?", "")); +ok(! pagespec_match("page", "?a?g?", "")); +ok(pagespec_match("foo.png", "*.*", "")); +ok(! pagespec_match("foo", "*.*", "")); +ok(pagespec_match("foo", "foo or bar", ""), "simple list"); +ok(pagespec_match("bar", "foo or bar", ""), "simple list 2"); +ok(pagespec_match("foo", "f?? and !foz", "")); +ok(! pagespec_match("foo", "f?? and !foo", "")); +ok(! pagespec_match("foo", "* and !foo", "")); +ok(! pagespec_match("foo", "foo and !foo", "")); +ok(! pagespec_match("foo.png", "* and !*.*", "")); +ok(pagespec_match("foo", "(bar or ((meep and foo) or (baz or foo) or beep))", "")); +ok(pagespec_match("foo/bar", "./*", "foo"), "relative"); +ok(! pagespec_match("foo/bar", "./*", "foo/baz"), "relative fail"); +ok(pagespec_match("foo/bar", "*", "baz"), "absolute"); $links{foo}=[qw{bar baz}]; -ok(pagespec_match("foo", "link(bar)")); -ok(! pagespec_match("foo", "link(quux)")); -ok(pagespec_match("bar", "backlink(foo)")); -ok(! pagespec_match("quux", "backlink(foo)")); +ok(pagespec_match("foo", "link(bar)", "")); +ok(! pagespec_match("foo", "link(quux)", "")); +ok(pagespec_match("bar", "backlink(foo)", "")); +ok(! pagespec_match("quux", "backlink(foo)", "")); $IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006 $IkiWiki::pagectime{bar}=1154532695; # after