Skip to content

Commit c2e77b7

Browse files
committed
Add check_man script to check for man page warnings.
1 parent 38c0bdd commit c2e77b7

File tree

5 files changed

+176
-73
lines changed

5 files changed

+176
-73
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ po/zh_CN.mo
12791279
po/zh_CN.po
12801280
po/zh_TW.mo
12811281
po/zh_TW.po
1282+
scripts/check_man.in
12821283
scripts/config.guess
12831284
scripts/config.sub
12841285
scripts/generate_test_coverage.sh

configure

Lines changed: 100 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ PYTHON
674674
FLEX
675675
YFLAGS
676676
YACC
677+
NROFFPROG
678+
MANDOCPROG
677679
GROFFPROG
678680
TRPROG
679681
UNAMEPROG
@@ -17649,16 +17651,19 @@ printf "%s\n" "no" >&6; }
1764917651
fi
1765017652

1765117653

17652-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mandoc or nroff" >&5
17653-
printf %s "checking for mandoc or nroff... " >&6; }
17654-
if test ${ac_cv_path_NROFF+y}
17654+
# Extract the first word of "mandoc", so it can be a program name with args.
17655+
set dummy mandoc; ac_word=$2
17656+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
17657+
printf %s "checking for $ac_word... " >&6; }
17658+
if test ${ac_cv_path_MANDOCPROG+y}
1765517659
then :
1765617660
printf %s "(cached) " >&6
1765717661
else case e in #(
17658-
e)
17659-
if test -z "$NROFF"; then
17660-
ac_path_NROFF_found=false
17661-
# Loop through the user's path and test for each of PROGNAME-LIST
17662+
e) case $MANDOCPROG in
17663+
[\\/]* | ?:[\\/]*)
17664+
ac_cv_path_MANDOCPROG="$MANDOCPROG" # Let the user override the test with a path.
17665+
;;
17666+
*)
1766217667
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1766317668
for as_dir in $PATH
1766417669
do
@@ -17668,45 +17673,104 @@ do
1766817673
*/) ;;
1766917674
*) as_dir=$as_dir/ ;;
1767017675
esac
17671-
for ac_prog in mandoc nroff
17672-
do
1767317676
for ac_exec_ext in '' $ac_executable_extensions; do
17674-
ac_path_NROFF="$as_dir$ac_prog$ac_exec_ext"
17675-
as_fn_executable_p "$ac_path_NROFF" || continue
17676-
ac_cv_path_NROFF="$ac_path_NROFF"
17677-
$ac_path_NROFF_found && break 3
17678-
done
17679-
done
17677+
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
17678+
ac_cv_path_MANDOCPROG="$as_dir$ac_word$ac_exec_ext"
17679+
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
17680+
break 2
17681+
fi
17682+
done
1768017683
done
1768117684
IFS=$as_save_IFS
17682-
if test -z "$ac_cv_path_NROFF"; then
17683-
ac_cv_path_NROFF=no
17685+
17686+
test -z "$ac_cv_path_MANDOCPROG" && ac_cv_path_MANDOCPROG="mandoc"
17687+
;;
17688+
esac ;;
17689+
esac
17690+
fi
17691+
MANDOCPROG=$ac_cv_path_MANDOCPROG
17692+
if test -n "$MANDOCPROG"; then
17693+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOCPROG" >&5
17694+
printf "%s\n" "$MANDOCPROG" >&6; }
17695+
else
17696+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
17697+
printf "%s\n" "no" >&6; }
17698+
fi
17699+
17700+
17701+
if test "$ac_cv_path_MANDOCPROG" != "mandoc"
17702+
then :
17703+
17704+
ac_cv_path_NROFFPROG="$ac_cv_path_MANDOCPROG"
17705+
17706+
else case e in #(
17707+
e)
17708+
# Extract the first word of "nroff", so it can be a program name with args.
17709+
set dummy nroff; ac_word=$2
17710+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
17711+
printf %s "checking for $ac_word... " >&6; }
17712+
if test ${ac_cv_path_NROFFPROG+y}
17713+
then :
17714+
printf %s "(cached) " >&6
17715+
else case e in #(
17716+
e) case $NROFFPROG in
17717+
[\\/]* | ?:[\\/]*)
17718+
ac_cv_path_NROFFPROG="$NROFFPROG" # Let the user override the test with a path.
17719+
;;
17720+
*)
17721+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
17722+
for as_dir in $PATH
17723+
do
17724+
IFS=$as_save_IFS
17725+
case $as_dir in #(((
17726+
'') as_dir=./ ;;
17727+
*/) ;;
17728+
*) as_dir=$as_dir/ ;;
17729+
esac
17730+
for ac_exec_ext in '' $ac_executable_extensions; do
17731+
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
17732+
ac_cv_path_NROFFPROG="$as_dir$ac_word$ac_exec_ext"
17733+
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
17734+
break 2
1768417735
fi
17736+
done
17737+
done
17738+
IFS=$as_save_IFS
17739+
17740+
test -z "$ac_cv_path_NROFFPROG" && ac_cv_path_NROFFPROG="nroff"
17741+
;;
17742+
esac ;;
17743+
esac
17744+
fi
17745+
NROFFPROG=$ac_cv_path_NROFFPROG
17746+
if test -n "$NROFFPROG"; then
17747+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NROFFPROG" >&5
17748+
printf "%s\n" "$NROFFPROG" >&6; }
1768517749
else
17686-
ac_cv_path_NROFF=$NROFF
17750+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
17751+
printf "%s\n" "no" >&6; }
1768717752
fi
1768817753

17754+
1768917755
;;
1769017756
esac
1769117757
fi
17692-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_NROFF" >&5
17693-
printf "%s\n" "$ac_cv_path_NROFF" >&6; }
17694-
case "$ac_cv_path_NROFF" in
17695-
*mandoc|no)
17696-
# Prefer mdoc format for mandoc (or when no formatter is present).
17697-
: ${MANTYPE='mdoc'}
17698-
;;
17699-
*)
17700-
# Check whether nroff supports -mdoc, this may produce incorrect
17701-
# results when cross-compiling.
17702-
test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
17703-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which macro set to use for manual pages" >&5
17758+
# Check whether nroff supports -mdoc, this may produce incorrect
17759+
# results when cross-compiling.
17760+
test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
17761+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which macro set to use for manual pages" >&5
1770417762
printf %s "checking which macro set to use for manual pages... " >&6; }
1770517763
if test ${sudo_cv_var_mantype+y}
1770617764
then :
1770717765
printf %s "(cached) " >&6
1770817766
else case e in #(
1770917767
e)
17768+
case "$ac_cv_path_NROFFPROG" in
17769+
*mandoc|nroff)
17770+
# Prefer mdoc format for mandoc (or when no formatter is present).
17771+
sudo_cv_var_mantype="mdoc"
17772+
;;
17773+
*)
1771017774
sudo_cv_var_mantype="man"
1771117775
echo ".Sh NAME" > conftest
1771217776
echo ".Nm sudo" >> conftest
@@ -17717,15 +17781,15 @@ else case e in #(
1771717781
sudo_cv_var_mantype="mdoc"
1771817782
fi
1771917783
rm -f conftest
17784+
;;
17785+
esac
1772017786

17721-
;;
17787+
;;
1772217788
esac
1772317789
fi
1772417790
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_mantype" >&5
1772517791
printf "%s\n" "$sudo_cv_var_mantype" >&6; }
17726-
MANTYPE="$sudo_cv_var_mantype"
17727-
;;
17728-
esac
17792+
MANTYPE="$sudo_cv_var_mantype"
1772917793

1773017794
if test -n "$sudo_cv_prev_host"
1773117795
then :
@@ -36485,7 +36549,7 @@ then :
3648536549

3648636550
fi
3648736551

36488-
ac_config_files="$ac_config_files Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers"
36552+
ac_config_files="$ac_config_files Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers scripts/check_man"
3648936553

3649036554
ac_config_commands="$ac_config_commands harness"
3649136555

@@ -37518,6 +37582,7 @@ do
3751837582
"plugins/sudoers/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/Makefile" ;;
3751937583
"plugins/sudoers/regress/harness") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/regress/harness" ;;
3752037584
"plugins/sudoers/sudoers") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/sudoers" ;;
37585+
"scripts/check_man") CONFIG_FILES="$CONFIG_FILES scripts/check_man" ;;
3752137586
"harness") CONFIG_COMMANDS="$CONFIG_COMMANDS harness" ;;
3752237587

3752337588
*) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;;

configure.ac

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,21 +1727,24 @@ AC_PATH_PROG(SHA1SUM, [sha1sum], [openssl dgst -sha1])
17271727
AC_PATH_PROG(UNAMEPROG, [uname], [uname])
17281728
AC_PATH_PROG(TRPROG, [tr], [tr])
17291729
AC_PATH_PROG(GROFFPROG, [groff], [groff])
1730-
AC_CACHE_CHECK([for mandoc or nroff], [ac_cv_path_NROFF], [
1731-
AC_PATH_PROGS_FEATURE_CHECK([NROFF], [mandoc nroff], [ac_cv_path_NROFF="$ac_path_NROFF"], [ac_cv_path_NROFF=no])
1732-
])
1733-
case "$ac_cv_path_NROFF" in
1734-
*mandoc|no)
1735-
# Prefer mdoc format for mandoc (or when no formatter is present).
1736-
: ${MANTYPE='mdoc'}
1737-
;;
1738-
*)
1739-
# Check whether nroff supports -mdoc, this may produce incorrect
1740-
# results when cross-compiling.
1741-
test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
1742-
AC_CACHE_CHECK([which macro set to use for manual pages],
1743-
[sudo_cv_var_mantype],
1744-
[
1730+
AC_PATH_PROG(MANDOCPROG, [mandoc], [mandoc])
1731+
AS_IF([test "$ac_cv_path_MANDOCPROG" != "mandoc"], [
1732+
ac_cv_path_NROFFPROG="$ac_cv_path_MANDOCPROG"
1733+
], [
1734+
AC_PATH_PROG(NROFFPROG, [nroff], [nroff])
1735+
])
1736+
# Check whether nroff supports -mdoc, this may produce incorrect
1737+
# results when cross-compiling.
1738+
test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
1739+
AC_CACHE_CHECK([which macro set to use for manual pages],
1740+
[sudo_cv_var_mantype],
1741+
[
1742+
case "$ac_cv_path_NROFFPROG" in
1743+
*mandoc|nroff)
1744+
# Prefer mdoc format for mandoc (or when no formatter is present).
1745+
sudo_cv_var_mantype="mdoc"
1746+
;;
1747+
*)
17451748
sudo_cv_var_mantype="man"
17461749
echo ".Sh NAME" > conftest
17471750
echo ".Nm sudo" >> conftest
@@ -1752,11 +1755,11 @@ case "$ac_cv_path_NROFF" in
17521755
sudo_cv_var_mantype="mdoc"
17531756
fi
17541757
rm -f conftest
1755-
]
1756-
)
1757-
MANTYPE="$sudo_cv_var_mantype"
1758-
;;
1759-
esac
1758+
;;
1759+
esac
1760+
]
1761+
)
1762+
MANTYPE="$sudo_cv_var_mantype"
17601763

17611764
dnl
17621765
dnl If a config.cache exists make sure it matches the current host.
@@ -4470,7 +4473,7 @@ AS_IF([test X"$INIT_SCRIPT" != X""], [
44704473
AC_CONFIG_FILES([etc/init.d/sudo.conf])
44714474
])
44724475

4473-
AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers])
4476+
AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers scripts/check_man])
44744477
AC_CONFIG_COMMANDS([harness], [chmod +x lib/util/regress/harness plugins/sudoers/regress/harness])
44754478

44764479
AC_OUTPUT

docs/Makefile.in

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ scriptdir = $(top_srcdir)/scripts
3232
# Tools to use
3333
SED = @SED@
3434
IGOR = igor
35-
MANDOC = mandoc
35+
MANDOC = @MANDOCPROG@
3636
MANCOMPRESS = @MANCOMPRESS@
3737
MANCOMPRESSEXT = @MANCOMPRESSEXT@
3838
TR = @TRPROG@
39-
GROFF = @GROFFPROG@
4039

4140
# Our install program supports extra flags...
4241
INSTALL = $(SHELL) $(scriptdir)/install-sh -c
@@ -119,21 +118,7 @@ igor:
119118
exit $$rval
120119

121120
lint: all
122-
@if [ "$(mantype)" != "mdoc" ]; then \
123-
echo "make lint only supported for mdoc manuals" 1>&2; \
124-
exit 1; \
125-
else \
126-
rval=0; \
127-
for m in $(DOCS); do \
128-
echo $(MANDOC) -Tlint -Wwarning $$m; \
129-
$(MANDOC) -Tlint -Wwarning $$m || rval=`expr $$rval + $$?`; \
130-
if [ -n "$(GROFF)" ]; then \
131-
echo $(GROFF) -mandoc -K utf8 -rF0 -rHY=0 -ww -b -z $$m; \
132-
$(GROFF) -mandoc -K utf8 -rF0 -rHY=0 -ww -b -z $$m || rval=`expr $$rval + $$?`; \
133-
fi; \
134-
done; \
135-
exit $$rval; \
136-
fi
121+
$(SHELL) $(top_builddir)/scripts/check_man $(DOCS)
137122

138123
depend:
139124

scripts/check_man.in

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
MANDOC="@MANDOCPROG@"
4+
GROFF="@GROFFPROG@"
5+
MANTYPE="@MANTYPE@"
6+
EGREP="@EGREP@"
7+
8+
if [ "$MANTYPE" != "mdoc" ]; then
9+
echo "$0 only supports mdoc manuals" 1>&2
10+
exit 1
11+
fi
12+
13+
TFILE=`mktemp -t check_man.XXXXXX` || exit 1
14+
15+
rval=0
16+
while [ $# != 0 ]; do
17+
if [ "$MANDOC" != "mandoc" ]; then
18+
# Ignore OS warning and missing cross-references
19+
$MANDOC -Tlint $1 | $EGREP -v 'STYLE: (operating system explicitly specified|referenced manual not found):' > "$TFILE" 2>&1
20+
if [ -s "$TFILE" ]; then
21+
rval=`expr $rval + 1`
22+
cat "$TFILE"
23+
fi
24+
fi
25+
26+
if [ "$GROFF" != "groff" ]; then
27+
$GROFF -mandoc -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -b -z $1 || \
28+
rval=`expr $rval + $?`
29+
fi
30+
31+
$EGREP '^\.It[ ].*[ ]Ta$' $1 > "$TFILE" 2>&1
32+
if [ -s "$TFILE" ]; then
33+
rval=`expr $rval + 1`
34+
echo "Empty table cell at EOL leads to trailing whitespace:"
35+
cat "$TFILE"
36+
fi
37+
38+
$EGREP '[ ]$' $1 > "$TFILE" 2>&1
39+
if [ -s "$TFILE" ]; then
40+
rval=`expr $rval + 1`
41+
echo "Trailing whitespace:"
42+
cat "$TFILE"
43+
fi
44+
45+
shift
46+
done
47+
48+
rm -f "$TFILE"
49+
exit $rval

0 commit comments

Comments
 (0)