ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Pod.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Pod.pm (file contents):
Revision 1.22 by root, Sun Mar 30 11:31:09 2008 UTC vs.
Revision 1.23 by root, Sun Mar 30 13:02:26 2008 UTC

40sub is_prefix_of($@) { 40sub is_prefix_of($@) {
41 my ($node, @path) = @_; 41 my ($node, @path) = @_;
42 42
43 return 1 unless @path; 43 return 1 unless @path;
44 44
45 my $kw = lc pop @path; 45 my $kw = pop @path;
46 46
47 $node = $node->[N_PARENT] 47 $node = $node->[N_PARENT]
48 or return 0; 48 or return 0;
49 49
50 #TODO: maybe get rid of lowercasing?
51 return scalar grep lc eq $kw, @{ $node->[N_KW] }; 50 return scalar grep $_ eq $kw, @{ $node->[N_KW] };
52} 51}
53 52
54sub find(@) { 53sub find(@) {
55 my (@path) = @_; 54 my (@path) = @_;
56 55
57 return unless @path; 56 return unless @path;
58 57
59 my $kw = lc pop @path; 58 my $kw = pop @path;
60 59
61 # TODO: make sure results are unique 60 my %res = map +($_, $_),
62
63 grep { is_prefix_of $_, @path } 61 grep { is_prefix_of $_, @path }
64 map @$_, 62 map @$_,
65 $kw eq "*" ? @wiki{sort keys %wiki} 63 $kw eq "*" ? values %wiki
66 : $wiki{$kw} || () 64 : $wiki{$kw} || ();
65
66 values %res
67} 67}
68 68
69sub full_path_of($) { 69sub full_path_of($) {
70 my ($node) = @_; 70 my ($node) = @_;
71 71
72 my @path; 72 my @path;
73 73
74 # skip toplevel hierarchy pod/, because its not a document
75 while ($node->[N_PARENT]) { 74 while ($node) {
76 unshift @path, $node; 75 unshift @path, $node;
77 $node = $node->[N_PARENT]; 76 $node = $node->[N_PARENT];
78 } 77 }
79 78
80 @path 79 @path

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines