more tag reorg
[ikiwiki] / doc / bugs / pagespec_parsing_chokes_on_function__40____41__.mdwn
1 The pagespec regexes don't allow functions with no arguments.
2
3 IkiWiki.pm, around line 1035:
4
5 <pre>
6 $spec=~m{
7                 \s*             # ignore whitespace
8                 (               # 1: match a single word
9                         \!              # !
10                 |
11                         \(              # (
12                 |
13                         \)              # )
14                 |
15                         \w+\([^\)]+\)   # command(params)
16                 |
17                         [^\s()]+        # any other text
18                 )
19                 \s*             # ignore whitespace
20         }igx
21 </pre>
22
23 command(params) of course might be just command(). (See 
24 conditional.pm: match_included.) Trying to feed 
25 ikiwiki a pagespec without params will get you instead:
26
27 IkiWiki::PageSpec::match_glob($page, q{function}, @params) ( )
28
29 Which is completely not desired. The second + on that line should be a *.
30
31 None of the builtin pagespecs "work" with no parameters, so it's hard to 
32 write a unit test for this. But can we at least write a helpful note in
33 case the user is given to rebuilding the wiki by hand. --Ethan
34
35 <pre>
36 --- ikiwiki/IkiWiki.pm  2007-07-26 15:15:22.716860000 -0700
37 +++ ikidev/IkiWiki.pm   2007-07-26 21:34:45.542248000 -0700
38 @@ -1032,7 +1032,7 @@
39                 |
40                         \)              # )
41                 |
42 -                       \w+\([^\)]+\)   # command(params)
43 +                       \w+\([^\)]*\)   # command(params)
44                 |
45                         [^\s()]+        # any other text
46                 )
47 @@ -1075,6 +1075,10 @@
48         }
49  
50         my $ret=eval pagespec_translate($spec);
51 +       if ($@){
52 +               my $t = pagespec_translate($spec);
53 +               print "evaluating pagespec failed: $t $@\n";
54 +       }
55         return IkiWiki::FailReason->new("syntax error") if $@;
56         return $ret;
57  }
58 </pre>
59
60 > Thanks, [[done]] --[[Joey]]
61 >
62 > Note that the printing of the error isn't needed though. pagespec_match()
63 > returns an IkiWiki::FailReason object if parsing fails, and its caller
64 > can use that as desired to print the error.