diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-07-02 17:33:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-07-02 17:33:37 -0400 |
commit | efd5f9ffb3145d1bb33d66ab38454b7fe4839e3b (patch) | |
tree | b413a58726ac1c3613a74d5ebb4702bbae2e4093 /IkiWiki.pm | |
parent | b9418274203916d1bea75c9da581a6a1dba0a30e (diff) |
factor out glob2re
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r-- | IkiWiki.pm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index d9b3dcdb4..c7328e427 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1290,6 +1290,13 @@ sub pagespec_valid ($) { #{{{ my $sub=pagespec_translate($spec); return ! $@; } #}}} + +sub glob2re ($) { #{{{ + my $re=quotemeta(shift); + $re=~s/\\\*/.*/g; + $re=~s/\\\?/./g; + return $re; +} #}}} package IkiWiki::FailReason; @@ -1337,12 +1344,8 @@ sub match_glob ($$;@) { #{{{ $glob="$from/$glob" if length $from; } - # turn glob into safe regexp - $glob=quotemeta($glob); - $glob=~s/\\\*/.*/g; - $glob=~s/\\\?/./g; - - if ($page=~/^$glob$/i) { + my $regexp=glob2re($glob); + if ($page=~/^$regexp$/i) { if (! IkiWiki::isinternal($page) || $params{internal}) { return IkiWiki::SuccessReason->new("$glob matches $page"); } |