From: Lionel Sambuc Date: Tue, 8 Oct 2013 17:00:16 +0000 (+0200) Subject: usr.bin/man: Update X-Git-Tag: v3.3.0~545 X-Git-Url: http://zhaoyanbai.com/repos/%22../static/icons/zlib_tech.html?a=commitdiff_plain;h=b9a6a72b654af8d91df22102959da93f389d8b8c;p=minix.git usr.bin/man: Update Change-Id: I0c5d2115ba384687032f7b2af50d99dedc323b7a --- diff --git a/etc/man.conf b/etc/man.conf index a21b7fe20..6b954cbd5 100644 --- a/etc/man.conf +++ b/etc/man.conf @@ -1,16 +1,69 @@ -_version BSD.2 -_subdir man{[1-9],1x} -_suffix .0 -_build .[1-9] mandoc %s -_build .tbl tbl %s | mandoc -_default /usr/{,pkg/{,gcc*/}}man -_whatdb /usr/{,pkg/{,gcc*/}}man/whatis.db -1 man1 -2 man2 -3 man3 -4 man4 -5 man5 -6 man6 -7 man7 -8 man8 -9 man9 +# $NetBSD: man.conf,v 1.31 2012/10/06 15:33:59 wiz Exp $ + +# Sheer, raging paranoia... +_version BSD.2 + +# The whatis/apropos database. +_mandb /var/db/man.db + +# Subdirectories for paths ending in '/', IN SEARCH ORDER. +_subdir cat1 man1 cat8 man8 cat6 man6 cat2 man2 cat3 man3 cat4 man4 cat5 man5 cat7 man7 man3f cat9 man9 catn mann catl manl + +# Files typed by suffix and their commands. +# Note the order, .Z must come after .[1-9].Z, or it will match first. +_suffix .0 +_build .0.Z /usr/bin/zcat %s +_build .0.bz2 /usr/bin/bzcat %s +_build .0.gz /usr/bin/zcat %s +_build .0.xz /usr/bin/xzcat %s +_build .[1-9ln] /usr/bin/mandoc %s +_build .[1-9ln].Z /usr/bin/zcat %s | /usr/bin/mandoc +_build .[1-9ln].bz2 /usr/bin/bzcat %s | /usr/bin/mandoc +_build .[1-9ln].gz /usr/bin/zcat %s | /usr/bin/mandoc +_build .[1-9ln].xz /usr/bin/xzcat %s | /usr/bin/mandoc +_build .tbl /usr/bin/mandoc %s +_build .tbl.Z /usr/bin/zcat %s | /usr/bin/mandoc +_build .tbl.bz2 /usr/bin/bzcat %s | /usr/bin/mandoc +_build .tbl.gz /usr/bin/zcat %s | /usr/bin/mandoc +_build .tbl.xz /usr/bin/xzcat %s | /usr/bin/mandoc + +_build .me /usr/bin/nroff -msafer -me %s 2>/dev/null | cat -s + +_crunch .Z /usr/bin/zcat > %s +_crunch .bz /usr/bin/bzcat > %s +_crunch .gz /usr/bin/zcat > %s +_crunch .xz /usr/bin/xzcat > %s + +# Sections and their directories. +# All paths ending in '/' are the equivalent of entries specifying that +# directory with all of the subdirectories listed for the keyword _subdir. + +# default +# MINIX: Add /usr/man ... +_default /usr/{,share,X11R7,X11R6,pkg,local}/man/ + +# Other sections that represent complete man subdirectories. +X11R7 /usr/X11R7/man/ +X11R6 /usr/X11R6/man/ +packages /usr/pkg/man/ +local /usr/local/man/ + +# Specific section/directory combinations. +1 {cat,man}1 +2 {cat,man}2 +3 {cat,man}3 +3F {cat,man}3f +3f {cat,man}3f +4 {cat,man}4 +5 {cat,man}5 +6 {cat,man}6 +7 {cat,man}7 +8 {cat,man}8 +9 {cat,man}9 +l {cat,man}l +n {cat,man}n + +# machine classes per machine +_i386 x86 +_amd64 x86 +_sparc64 sparc diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index bc0bca1f9..084328d1c 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -199,7 +199,7 @@ 2012/10/17 12:00:00,usr.bin/make 2012/10/17 12:00:00,usr.bin/Makefile 2012/10/17 12:00:00,usr.bin/Makefile.inc -2010/07/07 21:24:34,usr.bin/man +2012/10/17 12:00:00,usr.bin/man 2012/10/17 12:00:00,usr.bin/menuc 2013/10/25 12:00:00,usr.bin/mesg 2010/10/15 05:46:48,usr.bin/mkdep diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 index 9bc818d2f..96c921407 100644 --- a/usr.bin/man/man.1 +++ b/usr.bin/man/man.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.21 2009/10/07 08:30:31 cegger Exp $ +.\" $NetBSD: man.1,v 1.24 2011/10/07 10:52:31 mbalmer Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)man.1 8.2 (Berkeley) 1/2/94 .\" -.Dd October 6, 2009 +.Dd October 7, 2011 .Dt MAN 1 .Os .Sh NAME @@ -49,11 +49,13 @@ .Oc .Ar name Ar ... .Nm -.Op Fl k +.Fl k .Op Fl C Ar file .Op Fl M Ar path .Op Fl m Ar path .Ar keyword Ar ... +.Nm +.Fl p .Sh DESCRIPTION The .Nm @@ -130,6 +132,8 @@ is specified by the line in the .Nm configuration file. +.It Fl p +Print the search path for the manual pages. .It Fl s Restrict the directories that .Nm @@ -220,7 +224,7 @@ will be used. .Bl -hang -width /etc/man.conf -compact .It Pa /etc/man.conf default man configuration file. -.It Pa /usr/{share,X11R6,pkg,local}/man/whatis.db +.It Pa /usr/{share,X11R7,pkg,local}/man/whatis.db standard whatis/apropos database search path, set in .Pa /etc/man.conf . diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index ccc4149dc..99550d70d 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $ */ +/* $NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,12 +40,13 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\ #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $"); #endif #endif /* not lint */ #include #include +#include #include #include @@ -84,7 +85,8 @@ struct manstate { char *pathsearch; /* -S: path of man must contain this string */ char *sectionname; /* -s: limit search to a given man section */ int where; /* -w: just show paths of all matching files */ - + int getpath; /* -p: print the path of directories containing man pages */ + /* important tags from the config file */ TAG *defaultpath; /* _default: default MANPATH */ TAG *subdirs; /* _subdir: default subdir search list */ @@ -118,6 +120,7 @@ static void onsig(int); static void usage(void) __attribute__((__noreturn__)); static void addpath(struct manstate *, const char *, size_t, const char *); static const char *getclass(const char *); +static void printmanpath(struct manstate *); /* * main function @@ -137,7 +140,7 @@ main(int argc, char **argv) /* * parse command line... */ - while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1) + while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:ps:S:w")) != -1) switch (ch) { case 'a': m.all = 1; @@ -159,6 +162,9 @@ main(int argc, char **argv) case 'P': /* -P for backward compatibility */ m.manpath = strdup(optarg); break; + case 'p': + m.getpath = 1; + break; /* * The -f and -k options are backward compatible, * undocumented ways of calling whatis(1) and apropos(1). @@ -187,7 +193,7 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (!argc) + if (!m.getpath && !argc) usage(); /* @@ -358,6 +364,9 @@ main(int argc, char **argv) } + if (m.getpath) + printmanpath(&m); + /* * now m.mymanpath is complete! */ @@ -984,5 +993,55 @@ usage(void) (void)fprintf(stderr, "Usage: %s -k [-C cfg] [-M path] [-m path] keyword ...\n", getprogname()); + (void)fprintf(stderr, "Usage: %s -p\n", getprogname()); exit(EXIT_FAILURE); } + +/* + * printmanpath -- + * Prints a list of directories containing man pages. + */ +static void +printmanpath(struct manstate *m) +{ + ENTRY *esubd; + char *defaultpath = NULL; /* _default tag value from man.conf. */ + char *buf; /* for storing temporary values */ + char **ap; + glob_t pg; + struct stat sb; + TAG *path = m->defaultpath; + TAG *subdirs = m->subdirs; + + /* the tail queue is empty if no _default tag is defined in * man.conf */ + if (TAILQ_EMPTY(&path->entrylist)) + errx(EXIT_FAILURE, "Empty manpath"); + + defaultpath = TAILQ_LAST(&path->entrylist, tqh)->s; + + if (glob(defaultpath, GLOB_BRACE | GLOB_NOSORT, NULL, &pg) != 0) + err(EXIT_FAILURE, "glob failed"); + + if (pg.gl_matchc == 0) { + warnx("Default path in %s doesn't exist", _PATH_MANCONF); + globfree(&pg); + return; + } + + TAILQ_FOREACH(esubd, &subdirs->entrylist, q) { + /* Drop cat page directory, only sources are relevant. */ + if (strncmp(esubd->s, "man", 3)) + continue; + + for (ap = pg.gl_pathv; *ap != NULL; ++ap) { + if (asprintf(&buf, "%s%s", *ap, esubd->s) == -1) + err(EXIT_FAILURE, "memory allocation error"); + /* Skip non-directories. */ + if (stat(buf, &sb) == 0 && S_ISDIR(sb.st_mode)) + printf("%s\n", buf); + + free(buf); + } + } + globfree(&pg); +} diff --git a/usr.bin/man/man.conf.5 b/usr.bin/man/man.conf.5 index 9442e5d51..7100f24f6 100644 --- a/usr.bin/man/man.conf.5 +++ b/usr.bin/man/man.conf.5 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.20 2007/02/10 19:27:39 reed Exp $ +.\" $NetBSD: man.conf.5,v 1.22 2012/04/29 03:46:43 christos Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)man.conf.5 8.5 (Berkeley) 1/2/94 .\" -.Dd April 10, 2006 +.Dd April 28, 2012 .Dt MAN.CONF 5 .Os .Sh NAME @@ -98,9 +98,9 @@ The suffix specification may contain the normal shell globbing characters The rest of the _build line is a shell command line whose standard output is a formatted manual page that can be directly displayed to the user. -Any occurrences of the string +There should be exactly one occurrence of the string .Dq %s -in the shell command line will +in the shell command line, and it will be replaced by the name of the file which is being formatted. .It _crunch used by @@ -110,6 +110,10 @@ which originally were compressed man pages: The first field lists a suffix which indicates what kind of compression were used to compress the man page. The rest of the line must be a shell command line, used to compress the formatted pages. +There should be exactly one occurrence of the string +.Dq %s +in the shell command line, and it will +be replaced by the name of the output file. .It _default contains the system-wide default man path used to search for man pages. .It _subdir @@ -152,6 +156,16 @@ including curly braces to escape a shell globbing character, precede it with a backslash .Pq Dq \e . +.It _\*[Lt]machine\*[Gt] +The defines additional paths to be searched for the particular +.Dv machine +whose literal value is taken from +.Xr uname 1 +.Fl m . +For example on an +.Dv amd64 , +.Dv _amd64 +is used. .El .Pp Section configuration lines in @@ -219,6 +233,7 @@ _subdir cat[123] _suffix .0 _build .[1-9] nroff -man %s _build .tbl tbl %s | nroff -man +_i386 x86 _default /usr/share/man/ sect3 /usr/share/man/{old/,}cat3 .Ed