From owner-svn-src-head@freebsd.org Sun May 21 22:28:29 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B91BCD78E47; Sun, 21 May 2017 22:28:29 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B7661795; Sun, 21 May 2017 22:28:29 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4LMSS2N047767; Sun, 21 May 2017 22:28:28 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4LMSSJV047765; Sun, 21 May 2017 22:28:28 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201705212228.v4LMSSJV047765@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 21 May 2017 22:28:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318600 - head/usr.bin/catman X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 May 2017 22:28:29 -0000 Author: bapt Date: Sun May 21 22:28:28 2017 New Revision: 318600 URL: https://svnweb.freebsd.org/changeset/base/318600 Log: 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). Modified: head/usr.bin/catman/catman.1 head/usr.bin/catman/catman.c Modified: head/usr.bin/catman/catman.1 ============================================================================== --- head/usr.bin/catman/catman.1 Sun May 21 22:10:08 2017 (r318599) +++ head/usr.bin/catman/catman.1 Sun May 21 22:28:28 2017 (r318600) @@ -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 Modified: head/usr.bin/catman/catman.c ============================================================================== --- head/usr.bin/catman/catman.c Sun May 21 22:10:08 2017 (r318599) +++ head/usr.bin/catman/catman.c Sun May 21 22:28:28 2017 (r318600) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -70,6 +71,8 @@ static char *lang_locale; /* short form 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, ch } 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++;