diff --git a/MANIFEST b/MANIFEST index b117ca809..9de403f70 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1279,6 +1279,7 @@ po/zh_CN.mo po/zh_CN.po po/zh_TW.mo po/zh_TW.po +scripts/check_man.in scripts/config.guess scripts/config.sub scripts/generate_test_coverage.sh diff --git a/configure b/configure index fce5b8d6f..f617c3a7d 100755 --- a/configure +++ b/configure @@ -674,6 +674,8 @@ PYTHON FLEX YFLAGS YACC +NROFFPROG +MANDOCPROG GROFFPROG TRPROG UNAMEPROG @@ -17649,16 +17651,19 @@ printf "%s\n" "no" >&6; } fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mandoc or nroff" >&5 -printf %s "checking for mandoc or nroff... " >&6; } -if test ${ac_cv_path_NROFF+y} +# Extract the first word of "mandoc", so it can be a program name with args. +set dummy mandoc; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_MANDOCPROG+y} then : printf %s "(cached) " >&6 else case e in #( - e) - if test -z "$NROFF"; then - ac_path_NROFF_found=false - # Loop through the user's path and test for each of PROGNAME-LIST + e) case $MANDOCPROG in + [\\/]* | ?:[\\/]*) + ac_cv_path_MANDOCPROG="$MANDOCPROG" # Let the user override the test with a path. + ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do @@ -17668,45 +17673,104 @@ do */) ;; *) as_dir=$as_dir/ ;; esac - for ac_prog in mandoc nroff - do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_NROFF="$as_dir$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_NROFF" || continue -ac_cv_path_NROFF="$ac_path_NROFF" - $ac_path_NROFF_found && break 3 - done - done + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_MANDOCPROG="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done done IFS=$as_save_IFS - if test -z "$ac_cv_path_NROFF"; then - ac_cv_path_NROFF=no - fi -else - ac_cv_path_NROFF=$NROFF + + test -z "$ac_cv_path_MANDOCPROG" && ac_cv_path_MANDOCPROG="mandoc" + ;; +esac ;; +esac fi +MANDOCPROG=$ac_cv_path_MANDOCPROG +if test -n "$MANDOCPROG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOCPROG" >&5 +printf "%s\n" "$MANDOCPROG" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +if test "$ac_cv_path_MANDOCPROG" != "mandoc" +then : + + ac_cv_path_NROFFPROG="$ac_cv_path_MANDOCPROG" + +else case e in #( + e) + # Extract the first word of "nroff", so it can be a program name with args. +set dummy nroff; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_NROFFPROG+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) case $NROFFPROG in + [\\/]* | ?:[\\/]*) + ac_cv_path_NROFFPROG="$NROFFPROG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_NROFFPROG="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_NROFFPROG" && ac_cv_path_NROFFPROG="nroff" + ;; +esac ;; +esac +fi +NROFFPROG=$ac_cv_path_NROFFPROG +if test -n "$NROFFPROG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NROFFPROG" >&5 +printf "%s\n" "$NROFFPROG" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_NROFF" >&5 -printf "%s\n" "$ac_cv_path_NROFF" >&6; } -case "$ac_cv_path_NROFF" in -*mandoc|no) - # Prefer mdoc format for mandoc (or when no formatter is present). - : ${MANTYPE='mdoc'} - ;; -*) - # Check whether nroff supports -mdoc, this may produce incorrect - # results when cross-compiling. - test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which macro set to use for manual pages" >&5 +# Check whether nroff supports -mdoc, this may produce incorrect +# results when cross-compiling. +test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which macro set to use for manual pages" >&5 printf %s "checking which macro set to use for manual pages... " >&6; } if test ${sudo_cv_var_mantype+y} then : printf %s "(cached) " >&6 else case e in #( e) + case "$ac_cv_path_NROFFPROG" in + *mandoc|nroff) + # Prefer mdoc format for mandoc (or when no formatter is present). + sudo_cv_var_mantype="mdoc" + ;; + *) sudo_cv_var_mantype="man" echo ".Sh NAME" > conftest echo ".Nm sudo" >> conftest @@ -17717,15 +17781,15 @@ else case e in #( sudo_cv_var_mantype="mdoc" fi rm -f conftest + ;; + esac - ;; + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_mantype" >&5 printf "%s\n" "$sudo_cv_var_mantype" >&6; } - MANTYPE="$sudo_cv_var_mantype" - ;; -esac +MANTYPE="$sudo_cv_var_mantype" if test -n "$sudo_cv_prev_host" then : @@ -36485,7 +36549,7 @@ then : fi -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" +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" ac_config_commands="$ac_config_commands harness" @@ -37518,6 +37582,7 @@ do "plugins/sudoers/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/Makefile" ;; "plugins/sudoers/regress/harness") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/regress/harness" ;; "plugins/sudoers/sudoers") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/sudoers" ;; + "scripts/check_man") CONFIG_FILES="$CONFIG_FILES scripts/check_man" ;; "harness") CONFIG_COMMANDS="$CONFIG_COMMANDS harness" ;; *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index eb2b605f4..bb74ef27b 100644 --- a/configure.ac +++ b/configure.ac @@ -1727,21 +1727,24 @@ AC_PATH_PROG(SHA1SUM, [sha1sum], [openssl dgst -sha1]) AC_PATH_PROG(UNAMEPROG, [uname], [uname]) AC_PATH_PROG(TRPROG, [tr], [tr]) AC_PATH_PROG(GROFFPROG, [groff], [groff]) -AC_CACHE_CHECK([for mandoc or nroff], [ac_cv_path_NROFF], [ - AC_PATH_PROGS_FEATURE_CHECK([NROFF], [mandoc nroff], [ac_cv_path_NROFF="$ac_path_NROFF"], [ac_cv_path_NROFF=no]) +AC_PATH_PROG(MANDOCPROG, [mandoc], [mandoc]) +AS_IF([test "$ac_cv_path_MANDOCPROG" != "mandoc"], [ + ac_cv_path_NROFFPROG="$ac_cv_path_MANDOCPROG" +], [ + AC_PATH_PROG(NROFFPROG, [nroff], [nroff]) ]) -case "$ac_cv_path_NROFF" in -*mandoc|no) - # Prefer mdoc format for mandoc (or when no formatter is present). - : ${MANTYPE='mdoc'} - ;; -*) - # Check whether nroff supports -mdoc, this may produce incorrect - # results when cross-compiling. - test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE" - AC_CACHE_CHECK([which macro set to use for manual pages], - [sudo_cv_var_mantype], - [ +# Check whether nroff supports -mdoc, this may produce incorrect +# results when cross-compiling. +test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE" +AC_CACHE_CHECK([which macro set to use for manual pages], + [sudo_cv_var_mantype], + [ + case "$ac_cv_path_NROFFPROG" in + *mandoc|nroff) + # Prefer mdoc format for mandoc (or when no formatter is present). + sudo_cv_var_mantype="mdoc" + ;; + *) sudo_cv_var_mantype="man" echo ".Sh NAME" > conftest echo ".Nm sudo" >> conftest @@ -1752,11 +1755,11 @@ case "$ac_cv_path_NROFF" in sudo_cv_var_mantype="mdoc" fi rm -f conftest - ] - ) - MANTYPE="$sudo_cv_var_mantype" - ;; -esac + ;; + esac + ] +) +MANTYPE="$sudo_cv_var_mantype" dnl dnl If a config.cache exists make sure it matches the current host. @@ -4470,7 +4473,7 @@ AS_IF([test X"$INIT_SCRIPT" != X""], [ AC_CONFIG_FILES([etc/init.d/sudo.conf]) ]) -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]) +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]) AC_CONFIG_COMMANDS([harness], [chmod +x lib/util/regress/harness plugins/sudoers/regress/harness]) AC_OUTPUT diff --git a/docs/Makefile.in b/docs/Makefile.in index e1ebd1d67..89c8e6cbe 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -32,11 +32,10 @@ scriptdir = $(top_srcdir)/scripts # Tools to use SED = @SED@ IGOR = igor -MANDOC = mandoc +MANDOC = @MANDOCPROG@ MANCOMPRESS = @MANCOMPRESS@ MANCOMPRESSEXT = @MANCOMPRESSEXT@ TR = @TRPROG@ -GROFF = @GROFFPROG@ # Our install program supports extra flags... INSTALL = $(SHELL) $(scriptdir)/install-sh -c @@ -119,21 +118,7 @@ igor: exit $$rval lint: all - @if [ "$(mantype)" != "mdoc" ]; then \ - echo "make lint only supported for mdoc manuals" 1>&2; \ - exit 1; \ - else \ - rval=0; \ - for m in $(DOCS); do \ - echo $(MANDOC) -Tlint -Wwarning $$m; \ - $(MANDOC) -Tlint -Wwarning $$m || rval=`expr $$rval + $$?`; \ - if [ -n "$(GROFF)" ]; then \ - echo $(GROFF) -mandoc -K utf8 -rF0 -rHY=0 -ww -b -z $$m; \ - $(GROFF) -mandoc -K utf8 -rF0 -rHY=0 -ww -b -z $$m || rval=`expr $$rval + $$?`; \ - fi; \ - done; \ - exit $$rval; \ - fi + $(SHELL) $(top_builddir)/scripts/check_man $(DOCS) depend: diff --git a/scripts/check_man.in b/scripts/check_man.in new file mode 100755 index 000000000..587219979 --- /dev/null +++ b/scripts/check_man.in @@ -0,0 +1,49 @@ +#!/bin/sh + +MANDOC="@MANDOCPROG@" +GROFF="@GROFFPROG@" +MANTYPE="@MANTYPE@" +EGREP="@EGREP@" + +if [ "$MANTYPE" != "mdoc" ]; then + echo "$0 only supports mdoc manuals" 1>&2 + exit 1 +fi + +TFILE=`mktemp -t check_man.XXXXXX` || exit 1 + +rval=0 +while [ $# != 0 ]; do + if [ "$MANDOC" != "mandoc" ]; then + # Ignore OS warning and missing cross-references + $MANDOC -Tlint $1 | $EGREP -v 'STYLE: (operating system explicitly specified|referenced manual not found):' > "$TFILE" 2>&1 + if [ -s "$TFILE" ]; then + rval=`expr $rval + 1` + cat "$TFILE" + fi + fi + + if [ "$GROFF" != "groff" ]; then + $GROFF -mandoc -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -b -z $1 || \ + rval=`expr $rval + $?` + fi + + $EGREP '^\.It[ ].*[ ]Ta$' $1 > "$TFILE" 2>&1 + if [ -s "$TFILE" ]; then + rval=`expr $rval + 1` + echo "Empty table cell at EOL leads to trailing whitespace:" + cat "$TFILE" + fi + + $EGREP '[ ]$' $1 > "$TFILE" 2>&1 + if [ -s "$TFILE" ]; then + rval=`expr $rval + 1` + echo "Trailing whitespace:" + cat "$TFILE" + fi + + shift +done + +rm -f "$TFILE" +exit $rval