summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@chiark.greenend.org.uk>2023-08-06 20:09:25 +0000
committerColin Watson <cjwatson@chiark.greenend.org.uk>2023-08-06 20:09:25 +0000
commit65b2b9acf676e68e1998e00036f2cb3262f42cd5 (patch)
tree9c6f75bdd7b1844c50cf2e56b7a86bea9af11cce
parentc0cf547e8f0b18ea6777ad46e6491aafd9f237b4 (diff)
man: Allow disabling warnings enabled by default in groff
-rw-r--r--NEWS.md2
-rw-r--r--man/Rules.man3
-rwxr-xr-xman/check-man25
-rw-r--r--man/man1/man.man16
-rw-r--r--src/man.c8
5 files changed, 27 insertions, 17 deletions
diff --git a/NEWS.md b/NEWS.md
index d4ef874d..3f03f4ba 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -30,6 +30,8 @@ Improvements:
options on to `whatis` and `apropos` respectively.
* Always pass a line length to `nroff`, even if we believe that it matches
the default.
+ * Allow disabling `groff` warnings via `man --warnings`, by prefixing a
+ warning name with `!`.
man-db 2.11.2 (8 January 2023)
==============================
diff --git a/man/Rules.man b/man/Rules.man
index 55ff35d6..5d273256 100644
--- a/man/Rules.man
+++ b/man/Rules.man
@@ -25,8 +25,7 @@ CLEANFILES = $(man1_MANS) $(man5_MANS) $(man8_MANS) replace.sed
if !CROSS_COMPILING
TESTS_ENVIRONMENT = top_builddir="$(top_builddir)"; export top_builddir; \
- LINGUA="$(LINGUA)"; export LINGUA; \
- EGREP="$(EGREP)"; export EGREP;
+ LINGUA="$(LINGUA)"; export LINGUA;
LOG_COMPILER = @SHELL@ $(top_srcdir)/man/check-man
TESTS = $(man1_MANS) $(man5_MANS) $(man8_MANS)
endif
diff --git a/man/check-man b/man/check-man
index f8985a0d..b28e039c 100755
--- a/man/check-man
+++ b/man/check-man
@@ -2,8 +2,8 @@
set -e
# Check that a manual page formats without errors. Lintian does something
-# similar for Debian packages. Relies on top_builddir, LINGUA, and EGREP
-# variables exported from 'make check', or you can set them manually.
+# similar for Debian packages. Relies on top_builddir and LINGUA variables
+# exported from 'make check', or you can set them manually.
if [ -z "$top_builddir" ]; then
echo "top_builddir unset; try 'make check' instead?"
@@ -11,28 +11,27 @@ if [ -z "$top_builddir" ]; then
elif [ -z "$LINGUA" ]; then
echo "LINGUA unset; try 'make check' instead?"
exit 77
-elif [ -z "$EGREP" ]; then
- echo "EGREP unset; try 'make check' instead?"
- exit 77
fi
[ -x "$top_builddir/src/man" ] || exit 77
+warnings=mac
+# Ignore wrapping failures for CJK manual pages; this should go away once
+# groff supports these natively.
+# Indeed, even for other languages we're going to get "cannot adjust line"
+# if %manpath_config_file% expands to something long. Hmm. We'll just ignore
+# this across the board for now.
+warnings="$warnings,!break"
+
code=0
errors="$(LC_ALL=C MANWIDTH=80 MAN_KEEP_FORMATTING=1 "$top_builddir/libtool" \
--mode=execute \
-dlopen "$top_builddir/lib/.libs/libman.la" \
-dlopen "$top_builddir/libdb/.libs/libmandb.la" \
- "$top_builddir/src/man" --warnings -E UTF-8 -l "$1" \
+ "$top_builddir/src/man" --warnings="$warnings" -E UTF-8 \
+ -l "$1" \
2>&1 >/dev/null)" || code=$?
-# Ignore wrapping failures for CJK manual pages; this should go away once
-# groff supports these natively.
-# Indeed, even for other languages we're going to get "cannot adjust line"
-# if %manpath_config_file% expands to something long. Hmm. We'll just ignore
-# this across the board for now.
-errors="$(echo "$errors" | $EGREP -v "(cannot adjust line|(can't|cannot) break line)")" || true
-
if [ "$code" != 0 ]; then
echo "man -E UTF-8 -l $1 failed with exit status $code and error output:"
echo "$errors"
diff --git a/man/man1/man.man1 b/man/man1/man.man1
index cf27f0fb..6319ab9f 100644
--- a/man/man1/man.man1
+++ b/man/man1/man.man1
@@ -436,6 +436,12 @@ pages.
.I warnings
is a comma-separated list of warning names; if it is not supplied, the
default is "mac".
+To disable a
+.I groff
+warning, prefix it with "!": for example,
+.B \-\-warnings=mac,!break
+enables warnings in the "mac" category and disables warnings in the "break"
+category.
See the \(lqWarnings\(rq node in
.B info groff
for a list of available warning names.
diff --git a/src/man.c b/src/man.c
index 68515eed..5d3be39f 100644
--- a/src/man.c
+++ b/src/man.c
@@ -1429,8 +1429,12 @@ static pipeline *make_roff_command (const char *dir, const char *file,
#endif /* !TROFF_IS_GROFF */
#ifdef NROFF_WARNINGS
- GL_LIST_FOREACH (roff_warnings, warning)
- pipecmd_argf (cmd, "-w%s", warning);
+ GL_LIST_FOREACH (roff_warnings, warning) {
+ if (warning[0] == '!')
+ pipecmd_argf (cmd, "-W%s", warning + 1);
+ else
+ pipecmd_argf (cmd, "-w%s", warning);
+ }
#endif /* NROFF_WARNINGS */
#ifdef HEIRLOOM_NROFF