#!/bin/bash
#
# Copyright, the authors of the Linux man-pages project
# SPDX-License-Identifier: GPL-3.0-or-later

set -Eeuo pipefail;


if test $# -lt 1; then
	>&2 printf '%s\n' "$(basename "$0"): error: Too few arguments."
	exit 1;
fi;

s="$1";
shift;

if test $# -lt 1; then
	preconv;
else
	find -H "$@" -not -type d \
	| xargs preconv;
fi \
| pcre2grep -M \
	-e '^\.lf 1 ' \
	-e '^\.TH ' \
	-e '(?s)^\.SH ('"$s"')$(?:(?!^\.(lf 1|TH|SH) ).)*';
