www: Prefer <name>.<section> pages over <name>

This commit is contained in:
Yorhel 2023-05-26 12:22:47 +02:00
parent 7302a6408a
commit f5b35efdc3

View file

@ -181,13 +181,17 @@ sub man_pref {
sub man_pref_name {
my($name, $where) = @_;
my $man = man_pref undef, sql_and $where, sql 'm.name =', \$name;
return ($man, '') if length $man->{name};
# Check the <name>.<section> format first, because ~most~ cases where
# there's a collision in the format, the <name>-only page is either
# uninteresting or a file name parsing error.
if ($name =~ /^(.+)\.([^.]+)$/) {
my($n, $s) = ($1,$2);
my $man = man_pref $s, sql_and $where, sql 'm.name =', \$n;
return ($man, $s) if length $man->{name};
}
return (undef, '') if $name !~ s/\.([^.]+)$// || !length $name;
my $section = $1;
$man = man_pref $section, sql_and $where, sql 'm.name =', \$name;
length $man->{name} ? ($man, $section) : (undef, '');
my $man = man_pref undef, sql_and $where, sql 'm.name =', \$name;
length $man->{name} ? ($man, '') : (undef, '');
}