aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2017-05-21 22:28:28 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2017-05-21 22:28:28 +0000
commit4d16f068f299d6051b1ed364884765046c93b024 (patch)
tree256ddba1cac3710e02ded263e146a061702ad8fe /usr.bin
parent98120473abdf18ccc4dce2ae3da295d5d065b24c (diff)
downloadsrc-4d16f068f299d6051b1ed364884765046c93b024.tar.gz
src-4d16f068f299d6051b1ed364884765046c93b024.zip
Make catman(1) use mandoc(1) by default
catman(1) checks if mandoc(1) do support the manpage before trying to generate the catpage and falls back on nroff, using the same mechanism as man(1).
Notes
Notes: svn path=/head/; revision=318600
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/catman/catman.15
-rw-r--r--usr.bin/catman/catman.c26
2 files changed, 26 insertions, 5 deletions
diff --git a/usr.bin/catman/catman.1 b/usr.bin/catman/catman.1
index fe855872fd54..3b387c312750 100644
--- a/usr.bin/catman/catman.1
+++ b/usr.bin/catman/catman.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 3, 2005
+.Dd May 22, 2017
.Dt CATMAN 1
.Os
.Sh NAME
@@ -40,6 +40,8 @@ The
utility preformats all the man pages in
.Ar directories
using the
+.Nm mandoc
+command when supported, falling back on the
.Nm nroff Fl man
command.
Directories may be separated by colons instead of spaces.
@@ -99,6 +101,7 @@ environment variable is not set.
.Sh SEE ALSO
.Xr makewhatis 1 ,
.Xr man 1 ,
+.Xr mandoc 1 ,
.Xr nroff 1
.Sh HISTORY
A previous version of the
diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c
index 47906f5c35f3..c3897e1a715f 100644
--- a/usr.bin/catman/catman.c
+++ b/usr.bin/catman/catman.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <locale.h>
#include <langinfo.h>
#include <libgen.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -70,6 +71,8 @@ static char *lang_locale; /* short form of locale */
static const char *machine, *machine_arch;
static int exit_code; /* exit code to use when finished */
+extern char **environ;
+
/*
* -T argument for nroff
*/
@@ -93,6 +96,7 @@ static const char *locale_device[] = {
#define GZCAT_CMD "z"
enum Ziptype {NONE, BZIP, GZIP};
+static bool mandoc_locales = false;
static uid_t uid;
static int starting_dir;
static char tmp_file[MAXPATHLEN];
@@ -438,11 +442,24 @@ process_page(char *mandir, char *src, char *cat, enum Ziptype zipped)
}
snprintf(tmp_file, sizeof tmp_file, "%s.tmp", cat);
snprintf(cmd, sizeof cmd,
- "%scat %s | tbl | nroff -c -T%s -man | %s > %s.tmp",
+ "%scat %s | mandoc -Tlint -Wunsupp 2>/dev/null",
zipped == BZIP ? BZ2CAT_CMD : zipped == GZIP ? GZCAT_CMD : "",
- src, nroff_device,
- zipped == BZIP ? BZ2_CMD : zipped == GZIP ? GZ_CMD : "cat",
- cat);
+ src);
+ if (system(cmd) == 0) {
+ snprintf(cmd, sizeof cmd,
+ "%scat %s | mandoc -T%s | %s > %s.tmp",
+ zipped == BZIP ? BZ2CAT_CMD : zipped == GZIP ? GZCAT_CMD : "",
+ src, mandoc_locales ? "locale" : "ascii",
+ zipped == BZIP ? BZ2_CMD : zipped == GZIP ? GZ_CMD : "cat",
+ cat);
+ } else {
+ snprintf(cmd, sizeof cmd,
+ "%scat %s | tbl | nroff -c -T%s -man | %s > %s.tmp",
+ zipped == BZIP ? BZ2CAT_CMD : zipped == GZIP ? GZCAT_CMD : "",
+ src, nroff_device,
+ zipped == BZIP ? BZ2_CMD : zipped == GZIP ? GZ_CMD : "cat",
+ cat);
+ }
if (system(cmd) != 0)
err(1, "formatting pipeline");
if (rename(tmp_file, cat) < 0)
@@ -771,6 +788,7 @@ main(int argc, char **argv)
break;
case 'L':
determine_locale();
+ mandoc_locales = true;
break;
case 'n':
pretend++;