Home | History | Annotate | only in /src/usr.bin/man
History log of /src/usr.bin/man
RevisionDateAuthorComments
 1.17 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.16 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.15 17-Feb-2014  uwe branches: 1.15.26;
config() in manconf.c now verifies _build (and _crunch) command
templates with fmtcheck(3) so annotate the printf that uses these
commands as safe with a __format_arg wrapper and drop
-Wno-format-nonliteral.

XXX: Using local wrapper for now, solving this in general would be
nice, but it raises namespace pollution issues.

XXX^2: catman(8) also uses manconf.c and uses _build and _crunch so it
can also benefit from this (but see above).
 1.14 19-Jul-2013  uwe Use -Wno-format-nonliteral instead of blanket -Wno-format.
 1.13 18-Jul-2013  christos use -Wno-format and revert "fixstring"
 1.12 18-Jul-2013  christos WARNS=6
- fix cast qual issues
- don't use snprintf on a user-provided buffer
 1.11 14-Apr-2009  lukem branches: 1.11.6; 1.11.12; 1.11.16;
Enable WARNS=4 by default for usr.bin, except for:
awk bdes checknr compile_et error gss hxtool kgetcred kinit
klist ldd less lex locale login m4 man menuc mk_cmds
mklocale msgc openssl rpcgen rpcinfo sdiff spell ssh
string2key telnet tn3270 verify_krb5_conf xlint
 1.10 05-Oct-2007  lukem branches: 1.10.14;
Convert to using raise_default_signal(3).
 1.9 08-Oct-2006  peter branches: 1.9.8;
WFORMAT is no more...
 1.8 13-Sep-2002  thorpej Rename man/config.{c,h} to man/manconf.{c,h}, so we don't have to
worry about problems including "config.h" when building as a host
tool.
 1.7 11-Oct-2000  is branches: 1.7.2;
More format string cleanup by sommerfeld.
 1.6 28-Sep-1995  tls branches: 1.6.8; 1.6.16;
Sync with 4.4BSD-Lite2
 1.5 22-Dec-1994  cgd specify man pages the new way.
 1.4 21-Dec-1993  cgd add man(1) ; part of new man(1) package from Bostic
 1.3 31-Jul-1993  mycroft Add RCS indentifiers.
 1.2 27-Jul-1993  jtc Add makewhatis script
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.16.1 18-Oct-2000  tv Pullup usr.bin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.6.8.1 19-Oct-2000  he Pull up revision 1.7 (requested by he):
Format string cleanup.
 1.7.2.1 03-Nov-2002  he Pull up revision 1.8 (requested by thorpej in ticket #787):
Rename man/config.{c,h} to man/manconf.{c,h}, so we do not
have to worry about problems including "config.h" when
building as a host tool.
 1.9.8.1 06-Nov-2007  matt sync with HEAD
 1.10.14.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.11.16.1 23-Jul-2013  riastradh sync with HEAD
 1.11.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.26.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17 13-Sep-2002  thorpej Rename man/config.{c,h} to man/manconf.{c,h}, so we don't have to
worry about problems including "config.h" when building as a host
tool.
 1.16 11-Jun-2002  lukem - getlist(): add "int create" arg, which creates list if it's not present
(using guts of now defunct addlist())
- use TAILQ_*() macros appropriately when manipulating tailqs
 1.15 22-Mar-2002  bouyer branches: 1.15.2;
Wrap RCSID in #ifdef/#endif, for build.sh -t on non-NetBSD system.
 1.14 29-May-2000  jdolecek g/c removelist()/renamelist(), the only user (catman(8)) was modified to not use them
 1.13 28-May-2000  dante Add a comment to note that removelist() and renamelist() are used by catman(8)
 1.12 28-May-2000  he Well, the removelist and renamelist functions were not unused;
they are still used by catman. Add them back.
 1.11 27-May-2000  jdolecek allow to specify relative paths for sections in man.conf - they are used
similarily to _subdir, but only when appropriate
fix -m handling, so that e.g. "man -m . 3 printf" works as it should
add new -S flag, to specify a string the result path has to contain
g/c some unused stuff

Written by Chuck Cranor, with only cosmetic changes & const poisoning by me.
 1.10 04-Apr-1999  dante branches: 1.10.6;
Handle '_crunch' section.
Add removelist() function
Add renamelist() function
 1.9 06-Nov-1998  christos branches: 1.9.2;
char -> unsigned char
 1.8 17-Oct-1997  mikel cleanup for WARNS=1
 1.7 28-Sep-1995  tls Sync with 4.4BSD-Lite2
 1.6 16-Jan-1995  mycroft Sync with 4.4-Lite, plus local changes.
 1.5 04-Jan-1994  cgd rename fgetline()
 1.4 22-Dec-1993  cgd kill a bit of redudancy
 1.3 22-Dec-1993  cgd kill that hack
 1.2 21-Dec-1993  cgd #ifdef out a changed interface, for now
 1.1 21-Dec-1993  cgd branches: 1.1.1;
add man(1) ; part of new man(1) package from Bostic
 1.1.1.2 28-Sep-1995  tls imported from 44lite2
 1.1.1.1 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.9.2.1 30-Apr-2000  he Pull up revision 1.10 (requested by kim):
Pull up various changes from the trunk:
o recognize _crunch in man.conf
 1.10.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.2.1 03-Nov-2002  he Pull up file removal (requested by thorpej in ticket #787):
Rename man/config.{c,h} to man/manconf.{c,h}, so we do not
have to worry about problems including "config.h" when
building as a host tool.
 1.7 13-Sep-2002  thorpej Rename man/config.{c,h} to man/manconf.{c,h}, so we don't have to
worry about problems including "config.h" when building as a host
tool.
 1.6 11-Jun-2002  lukem - getlist(): add "int create" arg, which creates list if it's not present
(using guts of now defunct addlist())
- use TAILQ_*() macros appropriately when manipulating tailqs
 1.5 28-May-2000  he branches: 1.5.4;
Well, the removelist and renamelist functions were not unused;
they are still used by catman. Add them back.
 1.4 27-May-2000  jdolecek allow to specify relative paths for sections in man.conf - they are used
similarily to _subdir, but only when appropriate
fix -m handling, so that e.g. "man -m . 3 printf" works as it should
add new -S flag, to specify a string the result path has to contain
g/c some unused stuff

Written by Chuck Cranor, with only cosmetic changes & const poisoning by me.
 1.3 04-Apr-1999  dante branches: 1.3.6;
Handle '_crunch' section.
Add removelist() function
Add renamelist() function
 1.2 28-Sep-1995  tls branches: 1.2.8;
Sync with 4.4BSD-Lite2
 1.1 21-Dec-1993  cgd branches: 1.1.1;
add man(1) ; part of new man(1) package from Bostic
 1.1.1.1 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.2.8.1 30-Apr-2000  he Pull up revision 1.3 (requested by kim):
Pull up various changes from the trunk:
o recognize _crunch in man.conf
 1.3.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.4.1 03-Nov-2002  he Pull up file removal (requested by thorpej in ticket #787):
Rename man/config.{c,h} to man/manconf.{c,h}, so we do not
have to worry about problems including "config.h" when
building as a host tool.
 1.32 02-Sep-2025  christos PR/59625: Ingo Schwarze: Add a new -l flag that specifies to interpret
arguments as filenames, keeping the current behavior of interpreting
arguments as filenames if they begin with "/" "./" or "../" for compatibility.
In the future we can remove that.
 1.31 29-Nov-2024  lukem man(1): document arguments in the list

For options that have an argument, add that argument to
the entry in the list.
 1.30 18-Jun-2022  gutteridge branches: 1.30.4;
man.1: add a small note about alternate machine name searches
 1.29 16-Jun-2016  abhinav Document -f option for man(1).
Also remove unsupported options for `man -k` from the synopsis and usage.
 1.28 14-Aug-2014  apb More detail about treating a local file as a man page,
and about how to request machine-specific man pages.
re
 1.27 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.26 18-Jul-2013  uwe whatis.db is no more, so don't mention its location in FILES.
 1.25 18-Jul-2013  uwe Remove unnecessary line wrap.
 1.24 07-Oct-2011  mbalmer branches: 1.24.2; 1.24.8; 1.24.12;
Refer to X11R7.
 1.23 14-Jun-2011  wiz Fix usage in man page and sync usage in executable with it.
 1.22 14-Jun-2011  joerg Add support for man -p to print the search path for manual pages (not
including cat page directories).

From Abhinav Upadhyay as part of Google's Summer of Code 2011
 1.21 07-Oct-2009  cegger branches: 1.21.4;
Mimic OSX behaviour:

On OS X it is possible to specify the manpage filename
with a full or relative path like this:

man ./foo.5

or

man /cd/foo/bar.1.gz

This is really helpful to view the manpage quickly while editing it.

patch presented on current-users@ and tech-userlevel@:
http://mail-index.netbsd.org/current-users/2009/10/06/msg010767.html
http://mail-index.netbsd.org/tech-userlevel/2009/10/06/msg002675.html

No objections
 1.20 13-Apr-2006  wiz branches: 1.20.28; 1.20.34;
Bump date for previous, slightly reword a sentencen.
 1.19 10-Apr-2006  chuck rework the wording in these man pages (mainly in man.conf.5) based on
some old notes I found to make it clearer and easier to understand
how the man stuff works (hopefully!).
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.17 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.16 30-Sep-2002  grant New sentence, new line. Some mdoc cleanup.
 1.15 20-Aug-2002  wiz Remove unneeded Ns.
 1.14 01-Dec-2001  wiz Whitespace cleanup.
 1.13 20-Apr-2001  pooka Remove /usr/X11/man/whatis.db from path list, as it can no longer found
in /etc/man.conf
 1.12 13-Aug-2000  fredb Supply missing "as".
 1.11 12-Jun-2000  simonb branches: 1.11.2;
Allow "-s" to specify a section name, ala the SysV man command.
Unlike the SysV man command, this doesn't allow for the -s argument
to be a list.
 1.10 27-May-2000  jdolecek allow to specify relative paths for sections in man.conf - they are used
similarily to _subdir, but only when appropriate
fix -m handling, so that e.g. "man -m . 3 printf" works as it should
add new -S flag, to specify a string the result path has to contain
g/c some unused stuff

Written by Chuck Cranor, with only cosmetic changes & const poisoning by me.
 1.9 08-Sep-1999  fredb branches: 1.9.6;
Doc previously undocumented `-k' option, correctly note mutually exclusive
options, various stylistic changes.
Closes PR bin/8325.
 1.8 13-Jun-1999  kleink Fall back to more(1) if PAGER is set but null.
 1.7 22-Mar-1999  garbled branches: 1.7.2;
More and more .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Many more to
come.
 1.6 12-Apr-1998  fair Added .Xr mdoc 7 and .Xr mdoc.samples 7 per PR#5284
 1.5 09-Jan-1998  perry RCS Id Police.
 1.4 19-Oct-1997  lukem fix up .Nm usage
 1.3 05-Dec-1995  jtc fix typo
 1.2 16-Jan-1995  mycroft Sync with 4.4-Lite, plus local changes.
 1.1 21-Dec-1993  cgd branches: 1.1.1;
add man(1) ; part of new man(1) package from Bostic
 1.1.1.1 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.7.2.2 30-Apr-2000  he Pull up revision 1.9 (requested by kim):
Pull up various changes from the trunk:
o man page typos fixed.
 1.7.2.1 23-Jun-1999  perry pullup 1.7->1.8 (kleink)
 1.9.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.11.2.1 13-Aug-2000  fredb Pullup 1.12: Fix typo (missing "as"). Approved by jhawk.
 1.20.34.1 21-Apr-2010  matt sync to netbsd-5
 1.20.28.1 08-Oct-2009  sborrill Pull up the following revisions(s) (requested by cegger in ticket #1076):
usr.bin/man/man.1: revision 1.21
usr.bin/man/man.c: revision 1.39

Allow man(1) to accept a pathname to a man file (e.g. man ./man.1)
 1.21.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.24.12.1 23-Jul-2013  riastradh sync with HEAD
 1.24.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.30.4.1 02-Aug-2025  perseant Sync with HEAD
 1.75 08-Sep-2025  jschauma Fix comment: '-f' and '-k' are in fact documented these days
 1.74 02-Sep-2025  christos PR/59625: Ingo Schwarze: Add a new -l flag that specifies to interpret
arguments as filenames, keeping the current behavior of interpreting
arguments as filenames if they begin with "/" "./" or "../" for compatibility.
In the future we can remove that.
 1.73 10-May-2022  gutteridge man.c: minor KNF
 1.72 08-Mar-2022  rillig man: remove unused global variable 'instype' (since yesterday)

No functional change.
 1.71 08-Mar-2022  rillig man: remove trailing whitespace

No binary change.
 1.70 08-Mar-2022  rillig man: fix type mismatch between enum and int (since yesterday)

No binary change.
 1.69 07-Mar-2022  gutteridge man.c: fix -m option so it works as documented

Refactoring work in man.c r. 1.40 from twelve years ago introduced a
regression where input from the -m option was appended rather than
prepended to the search paths. Problem reported by C. Chapman on
netbsd-users.
 1.68 06-Apr-2020  maya Exit successfully after printing the search path, stop further processing.

Continuing to process had the unintended effect that `man` failed to find
a matching manual page for {EMPTY LIST OF REQUESTED MANUAL PAGES}, and
exited with 1.

Prompted by a fish shell snippet that tried and failed to distinguish between
FreeBSD man (-p takes argument) and NetBSD man (-p no argument) by comparing
`man -p` exit code.

ok riastradh, logix (which also pointed out the manual page SYNOPSIS is
saying man -p should be used this way).
 1.67 15-Jun-2018  mrg branches: 1.67.2; 1.67.4;
move 'utsname' to the main() function scope, so that the reference to
it outside the block remains valid.

should fix an asan reported issue.
 1.66 02-May-2017  abhinav branches: 1.66.2; 1.66.8;
Teach man -p to respect the MANPATH environment variable and the -M option.

Currently, `man -p` generates its output based on the value of the _default tag
in man.conf. However, man(1) modifies its search path based on the value of the
MANPATH variable and the list of directories specified via the -M option. In such
a case, `man -p` does not represent the correct search path. This commit intends
to fix this.

This change has the side effect that now the output of `man -p` will also include
the machine class specific subdirectories (such as man8/x86), while previously it
did not. The output would include subdirectories only for those machine classes
which are specified in the man.conf file.

Also, with this change, it is possible to run makemandb(8), by setting MANPATH
environment variable (e.g. env MANPATH=/usr/share/man makemandb).

Patch reviewed by wiz@
 1.65 27-Apr-2017  abhinav Fix comment indentation at couple of places: Use \t instead of space
 1.64 16-Jun-2016  abhinav branches: 1.64.6;
Document -f option for man(1).
Also remove unsupported options for `man -k` from the synopsis and usage.
 1.63 21-May-2016  abhinav Remove unused include and unused constant. Ok from christos@.
 1.62 14-Aug-2014  apb For an argument to be interpreted as a local file name, bypassing the
search rules in man.conf or MANPATH, it must begin with "/", "./", or
"../". Simply testing whether it contains "/" is wrong, because it
breaks usage like "man 8 vax/boot".

This reverts revision 1.57 dated 2013-10-06,
"Be more permissive in interpreting man pages as filenames".
 1.61 17-Feb-2014  uwe branches: 1.61.4;
config() in manconf.c now verifies _build (and _crunch) command
templates with fmtcheck(3) so annotate the printf that uses these
commands as safe with a __format_arg wrapper and drop
-Wno-format-nonliteral.

XXX: Using local wrapper for now, solving this in general would be
nice, but it raises namespace pollution issues.

XXX^2: catman(8) also uses manconf.c and uses _build and _crunch so it
can also benefit from this (but see above).
 1.60 28-Oct-2013  christos Instead of guessing the suffix in the code, use the suffix list previously
loaded via man.conf(5). While there, zap unused iteration code.
(Franco Fichtner)
 1.59 06-Oct-2013  christos add more compression suffixes and local suffixes.
 1.58 06-Oct-2013  christos Recognize .gz and .bz2 suffixes so $ man ./man.1.gz works. From Franco Fichter
via dfly.
 1.57 06-Oct-2013  christos Be more permissive in interpreting man pages as filenames, from Franco
Fichter via dfly. fixes:
$ man usr.bin/man/man.1
 1.56 30-Jul-2013  joerg Mark the dead.
 1.55 19-Jul-2013  uwe Constify some more.
 1.54 19-Jul-2013  uwe Spell "keywords" without space. Fix couple of typos.
 1.53 19-Jul-2013  uwe manual_find_buildkeyword() - now that we control the format string, we
may use asterisk precision specification instead of temporary
modifying the _build string itself.
 1.52 19-Jul-2013  uwe Fix manual_find_buildkeyword() to not use non-literal printf format.
 1.51 18-Jul-2013  uwe Don't access memory outside the array if tmpdirlen == 0.
 1.50 18-Jul-2013  christos use -Wno-format and revert "fixstring"
 1.49 18-Jul-2013  christos Set the string to NUL instread of providing an new empty string (from uwe)
 1.48 18-Jul-2013  christos WARNS=6
- fix cast qual issues
- don't use snprintf on a user-provided buffer
 1.47 18-Jul-2013  uwe Revert previous; other errors from WARNS=3 obscured the error in jump().
 1.46 18-Jul-2013  uwe Constify jump() arguments appropriately.
 1.45 18-Jul-2013  uwe Move manstate::pagerlen so that its "length of the above" comment makes sense.
 1.44 03-Jan-2012  joerg branches: 1.44.6; 1.44.10;
If the default path doesn't result in a match, bail out early instead of
running into a segmentation fault. Based on patch by Abhinav Upadhyay.
 1.43 14-Jun-2011  wiz branches: 1.43.2;
Fix usage in man page and sync usage in executable with it.
 1.42 14-Jun-2011  joerg Add support for man -p to print the search path for manual pages (not
including cat page directories).

From Abhinav Upadhyay as part of Google's Summer of Code 2011
 1.41 07-Jul-2010  christos branches: 1.41.4;
get the value of the entry for the class not the key.
 1.40 23-May-2010  christos - centralize the snprintf code.
- use err where appropriate.
- add machclass which should be x86 when i386 and amd64 and can be specified
in man.conf as:
_i386 x86
_amd64 x86
so that we can support merged pages. Nothing uses this yet.
 1.39 07-Oct-2009  cegger Mimic OSX behaviour:

On OS X it is possible to specify the manpage filename
with a full or relative path like this:

man ./foo.5

or

man /cd/foo/bar.1.gz

This is really helpful to view the manpage quickly while editing it.

patch presented on current-users@ and tech-userlevel@:
http://mail-index.netbsd.org/current-users/2009/10/06/msg010767.html
http://mail-index.netbsd.org/tech-userlevel/2009/10/06/msg002675.html

No objections
 1.38 06-Oct-2009  cegger - use EXIT_FAILURE/EXIT_SUCCESS
- whitespace nits
- ansify cleanup()/usage()
- remove pointless parenthesis on return
 1.37 21-Jul-2008  lukem branches: 1.37.4; 1.37.10;
Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.36 05-Oct-2007  lukem branches: 1.36.8;
Convert to using raise_default_signal(3).
 1.35 05-Feb-2007  jwise branches: 1.35.4;
Since MAN_DEBUG is constant, go from if (MAN_DEBUG) to #if MAN_DEBUG
 1.34 01-May-2006  christos Coverity CID 2996: Don't return without closing fp.
 1.33 10-Apr-2006  chuck modified man(1):
- avoid double slashes when displaying man pages (got tired
of '/usr/share/man//cat1/man.0').
- got rid of __P() while working on it.
- incorporate some of my old notes explaining how manpath works into the
comments of the code itself.
- renamed some of the vars so that the code is consistent throughout
(and hopefully clearer and easier to understand)
- fixed relative man paths for multiple man pages (man did a chdir()
on the first man page it had to format --- this broke any remaining
relative path man pages left to process). save old directory and
fchdir() back to it after formatting.
- improved doc on "man -h" which does more than just whatis(1) [e.g.
"man -h fopen" prints the required include files and the prototypes
rather than just the one-liner you get with whatis(1)]
- manconf.c now fills in the "len" length field in the TAG/ENTRY
structures (man now uses len).

revise man.conf file reading stuff to return error on failure in
addentry/gettag (fka getlist) rather than just err()ing out. this
allows man(1) to call cleanup and delete its tmp files rather than
just leave them floating. revise other apps using this code
(makewhatis, apropos, catman, whatis) to expect this. also remove
__P on updated files.
 1.32 08-Apr-2006  christos change an int to size_t
 1.31 05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.30 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.29 13-Sep-2002  thorpej Rename man/config.{c,h} to man/manconf.{c,h}, so we don't have to
worry about problems including "config.h" when building as a host
tool.
 1.28 11-Jun-2002  lukem - getlist(): add "int create" arg, which creates list if it's not present
(using guts of now defunct addlist())
- use TAILQ_*() macros appropriately when manipulating tailqs
 1.27 14-Mar-2002  groo branches: 1.27.2;
Fix longstanding misuse of glob(3) and fnmatch(3) in man page search.
glob(3)-special characters are now escaped in the supplied man page names.

Makes ``man ['' work without mysterious quoting.
 1.26 19-Feb-2001  cgd convert to use getprogname()
 1.25 12-Jun-2000  simonb Allow "-s" to specify a section name, ala the SysV man command.
Unlike the SysV man command, this doesn't allow for the -s argument
to be a list.
 1.24 07-Jun-2000  thorpej check_pager() was using an uninitialized variable; fix it.
 1.23 27-May-2000  jdolecek allow to specify relative paths for sections in man.conf - they are used
similarily to _subdir, but only when appropriate
fix -m handling, so that e.g. "man -m . 3 printf" works as it should
add new -S flag, to specify a string the result path has to contain
g/c some unused stuff

Written by Chuck Cranor, with only cosmetic changes & const poisoning by me.
 1.22 09-Jan-2000  tsutsui branches: 1.22.2;
Use uname(3) to determine MACHINE type.
 1.21 02-Nov-1999  lukem revert previous
 1.20 02-Nov-1999  lukem remove superfluous '-' in getopt string
 1.19 22-Jul-1999  kleink branches: 1.19.2;
Try $TMPDIR first, then fall back to _PATH_TMP.
 1.18 22-Jul-1999  itohy A caught signal is blocked in the handler and
must be unblocked to do the default action.
The old code may generate weird exit status
on signals.
 1.17 19-Jun-1999  itohy Remove temp file on SIGPIPE (such as "man sh | head").
 1.16 13-Jun-1999  kleink Fall back to more(1) if PAGER is set but null.
 1.15 06-Nov-1998  christos branches: 1.15.2;
char -> unsigned char
 1.14 08-Oct-1998  wsanchez We can't define MACHINE from a makefile in Rhapsody, because you might be cross
compiling, or building a fat (multi-architecture) binary. Our compiler
defines __ARCHITECTURE__ for this use.
Fixed an off-by-one error that may occasionally cause man to seg fault. Found
by using a special strict malloc() implementation.
 1.13 25-Aug-1998  ross Add { and } to shut up egcs. Reformat the more questionable code.
 1.12 06-Jul-1998  kleink Since GLOB_NOCHECK is not set, explicitly check for a return value of
GLOB_NOMATCH from glob(). Noticed by Juergen Hannken-Illjes.
 1.11 19-Jun-1998  kleink GLOB_QUOTE is dead; per POSIX, backslash quoting of special characters being
enabled is the default behaviour.
 1.10 23-Nov-1997  tv When man was "fixed" to chdir() to the man root as historical man does,
it broke the -M option on relative paths (the chdir works as it should,
but the relative man page path is still used whole in nroff). This
repairs the situation by chopping the full pathname in half--one part
for the chdir, one part for the filename.
 1.9 17-Oct-1997  mikel branches: 1.9.2;
cleanup for WARNS=1
 1.8 10-Sep-1997  mikel resize a pathname buffer to MAXPATHLEN; from Matthias Scheler in PR 4101
 1.7 28-Sep-1995  tls Sync with 4.4BSD-Lite2
 1.6 20-Apr-1995  mycroft Pay attention to the section number, even if MANPATH or -M is specified.
 1.5 16-Jan-1995  mycroft Sync with 4.4-Lite, plus local changes.
 1.4 03-Jun-1994  jtc Fix from Christos Zoulas which makes relative paths in .so lines work when
man pages are formatted.
 1.3 17-Apr-1994  cgd fix from bostic for multiple match problem
 1.2 18-Mar-1994  cgd fix from Keith White <kwhite@csi.UOttawa.CA>, to DTRT when man -w's output
is redirected.
 1.1 21-Dec-1993  cgd branches: 1.1.1;
add man(1) ; part of new man(1) package from Bostic
 1.1.1.2 28-Sep-1995  tls imported from 44lite2
 1.1.1.1 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.9.2.1 26-Nov-1997  mellon Pull rev 1.10 up from trunk (tv)
 1.15.2.3 30-Apr-2000  he Pull up revisions 1.18-1.22 (requested by kim):
Pull up various changes from the trunk:
o fix signal handlers to avoid obscure exit codes
o clean up after SIGPIPE
o try TMPDIR env variable, fall back to _PATH_TMP
o fall back to more if PAGER is set but null
o use uname(3) to determine MACHINE type
 1.15.2.2 30-Apr-2000  he Pull up revision 1.17 (requested by kim):
Fix a problem where files were not removed on SIGPIPE.
 1.15.2.1 23-Jun-1999  perry pullup 1.15->1.16 (kleink)
 1.19.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.22.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.27.2.2 03-Nov-2002  he Pull up revision 1.28 (requested by he in ticket #787):
Make these compile again, after the changes in ticket #787.
 1.27.2.1 03-Nov-2002  he Pull up revision 1.29 (requested by thorpej in ticket #787):
Rename man/config.{c,h} to man/manconf.{c,h}, so we do not
have to worry about problems including "config.h" when
building as a host tool.
 1.35.4.1 06-Nov-2007  matt sync with HEAD
 1.36.8.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.37.10.1 21-Apr-2010  matt sync to netbsd-5
 1.37.4.1 08-Oct-2009  sborrill Pull up the following revisions(s) (requested by cegger in ticket #1076):
usr.bin/man/man.1: revision 1.21
usr.bin/man/man.c: revision 1.39

Allow man(1) to accept a pathname to a man file (e.g. man ./man.1)
 1.41.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.43.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.43.2.1 17-Apr-2012  yamt sync with head
 1.44.10.1 23-Jul-2013  riastradh sync with HEAD
 1.44.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.61.4.1 05-Jan-2016  snj Pull up following revision(s) (requested by mlelstv in ticket #1057):
usr.bin/man/man.c: revision 1.62
For an argument to be interpreted as a local file name, bypassing the
search rules in man.conf or MANPATH, it must begin with "/", "./", or
"../". Simply testing whether it contains "/" is wrong, because it
breaks usage like "man 8 vax/boot".
This reverts revision 1.57 dated 2013-10-06,
"Be more permissive in interpreting man pages as filenames".
 1.64.6.2 11-May-2017  pgoyette Sync with HEAD
 1.64.6.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.66.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.66.2.1 13-Mar-2022  martin Pull up following revision(s) (requested by gutteridge in ticket #1737):

usr.bin/man/man.c: revision 1.69
usr.bin/man/man.c: revision 1.70
usr.bin/man/man.c: revision 1.72

man.c: fix -m option so it works as documented

Refactoring work in man.c r. 1.40 from twelve years ago introduced a
regression where input from the -m option was appended rather than
prepended to the search paths. Problem reported by C. Chapman on
netbsd-users.

man: fix type mismatch between enum and int (since yesterday)
No binary change.

man: remove unused global variable 'instype' (since yesterday)
No functional change.
 1.67.4.2 13-Mar-2022  martin Pull up following revision(s) (requested by gutteridge in ticket #1433):

usr.bin/man/man.c: revision 1.69
usr.bin/man/man.c: revision 1.70
usr.bin/man/man.c: revision 1.72

man.c: fix -m option so it works as documented

Refactoring work in man.c r. 1.40 from twelve years ago introduced a
regression where input from the -m option was appended rather than
prepended to the search paths. Problem reported by C. Chapman on
netbsd-users.

man: fix type mismatch between enum and int (since yesterday)
No binary change.

man: remove unused global variable 'instype' (since yesterday)
No functional change.
 1.67.4.1 09-Apr-2020  martin Pull up following revision(s) (requested by maya in ticket #824):

usr.bin/man/man.c: revision 1.68

Exit successfully after printing the search path, stop further processing.

Continuing to process had the unintended effect that `man` failed to find
a matching manual page for {EMPTY LIST OF REQUESTED MANUAL PAGES}, and
exited with 1.

Prompted by a fish shell snippet that tried and failed to distinguish between
FreeBSD man (-p takes argument) and NetBSD man (-p no argument) by comparing
`man -p` exit code.

ok riastradh, logix (which also pointed out the manual page SYNOPSIS is
saying man -p should be used this way).
 1.67.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 29-Oct-1997  mikel kill redundant copy of src/etc/man.conf
 1.1 28-Sep-1995  tls branches: 1.1.1;
Initial revision
 1.1.1.1 28-Sep-1995  tls branches: 1.1.1.1.4;
imported from 44lite2
 1.1.1.1.4.1 30-Oct-1997  mellon man.conf obsoleted by src/etc/man.conf
 1.30 19-Jun-2022  gutteridge man.conf.5: improve wording on searching alternate machine paths

As requested by uwe@. Hopefully this is clearer now.
 1.29 18-Jun-2022  uwe man.conf(5): Tweak formatting for prettier PS output.
 1.28 18-Jun-2022  gutteridge man.conf.5: add details about the machine line and search order

Also, tweak some grammar, style, and markup while here.
 1.27 16-Jun-2016  abhinav Replace makewhatis(8) with makemandb(8) in SEE ALSO.
 1.26 07-Apr-2015  plunky change _whatdb => _mandb as that is the correct keyword here,
and move it to the correct position in the list.
 1.25 03-Mar-2015  christos there is no more makewhatis; it has been replaced by makemandb
 1.24 28-Jun-2013  wiz branches: 1.24.6;
Prefer Aq to \*[Lt] etc.
 1.23 27-Jun-2013  jdf * adjust indentation of list block
* fix capitalization
* remove superfluous word ('The')

Patch supplied by Bug Hunting.
 1.22 29-Apr-2012  christos branches: 1.22.2;
document _machine
 1.21 27-Dec-2011  apb Document the reality that the _build and _crunch commands should each
contain exactly one "%s". The previous description allowed any number
of "%s" in the _build command, but that does not match the actual
behaviour of either man(1) or catman(8).
 1.20 10-Feb-2007  reed branches: 1.20.34;
Add "catman" to the SEE ALSO.
 1.19 13-Apr-2006  wiz Bump date for previous.
New sentence, new line.
Remove trailing whitespace.
 1.18 10-Apr-2006  chuck fix .Xr to invalid man page that i put in by mistake
 1.17 10-Apr-2006  chuck rework the wording in these man pages (mainly in man.conf.5) based on
some old notes I found to make it clearer and easier to understand
how the man stuff works (hopefully!).
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.15 30-Sep-2002  grant New sentence, new line. Some mdoc cleanup.
 1.14 08-Mar-2002  wiz Xr makewhatis 8, not 1.
 1.13 08-Mar-2002  jdolecek xref makewhatis(8), it now uses man.conf too
 1.12 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.11 01-Dec-2001  wiz Sort sections.
 1.10 01-Dec-2001  wiz Whitespace cleanup.
 1.9 25-Jun-2001  lukem _whatdb has supported glob(3)ing pathnames for over 3 years ...
 1.8 27-May-2000  jdolecek allow to specify relative paths for sections in man.conf - they are used
similarily to _subdir, but only when appropriate
fix -m handling, so that e.g. "man -m . 3 printf" works as it should
add new -S flag, to specify a string the result path has to contain
g/c some unused stuff

Written by Chuck Cranor, with only cosmetic changes & const poisoning by me.
 1.7 19-Nov-1999  kristerw branches: 1.7.2;
Typos (from OpenBSD)
 1.6 04-Apr-1999  dante branches: 1.6.4;
Document '_crunch' section.
 1.5 09-Jan-1998  perry branches: 1.5.2;
RCS Id Police.
 1.4 19-Oct-1997  lukem fix up .Nm usage
 1.3 16-Jan-1995  mycroft Sync with 4.4-Lite, plus local changes.
 1.2 21-Dec-1993  cgd fix slight docbug
 1.1 21-Dec-1993  cgd branches: 1.1.1;
add man(1) ; part of new man(1) package from Bostic
 1.1.1.1 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.5.2.1 30-Apr-2000  he Pull up revisions 1.6-1.7 (requested by kim):
Pull up various changes from the trunk:
o man page typos fixed. Document _crunch.
 1.6.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.20.34.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.34.2 23-May-2012  yamt sync with head.
 1.20.34.1 17-Apr-2012  yamt sync with head
 1.22.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.6.1 14-Apr-2015  snj Pull up following revision(s) (requested by christos in ticket #676):
usr.bin/man/man.conf.5: revision 1.25
usr.sbin/makemandb/makemandb.8: revision 1.8
mention that this replaces makewhatis(8)
--
there is no more makewhatis; it has been replaced by makemandb
 1.8 17-Feb-2014  uwe Check _build and _crunch commands with fmtcheck(3), warn about and
ignore bad ones.
 1.7 18-Jul-2013  christos WARNS=6
- fix cast qual issues
- don't use snprintf on a user-provided buffer
 1.6 08-Mar-2008  christos branches: 1.6.6; 1.6.28; 1.6.34;
pass lint, from anon ymous
 1.5 10-Apr-2006  chuck branches: 1.5.12; 1.5.18;
modified man(1):
- avoid double slashes when displaying man pages (got tired
of '/usr/share/man//cat1/man.0').
- got rid of __P() while working on it.
- incorporate some of my old notes explaining how manpath works into the
comments of the code itself.
- renamed some of the vars so that the code is consistent throughout
(and hopefully clearer and easier to understand)
- fixed relative man paths for multiple man pages (man did a chdir()
on the first man page it had to format --- this broke any remaining
relative path man pages left to process). save old directory and
fchdir() back to it after formatting.
- improved doc on "man -h" which does more than just whatis(1) [e.g.
"man -h fopen" prints the required include files and the prototypes
rather than just the one-liner you get with whatis(1)]
- manconf.c now fills in the "len" length field in the TAG/ENTRY
structures (man now uses len).

revise man.conf file reading stuff to return error on failure in
addentry/gettag (fka getlist) rather than just err()ing out. this
allows man(1) to call cleanup and delete its tmp files rather than
just leave them floating. revise other apps using this code
(makewhatis, apropos, catman, whatis) to expect this. also remove
__P on updated files.
 1.4 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.2 13-Sep-2002  thorpej branches: 1.2.2;
Pull in config.h when building has a host tool.
 1.1 13-Sep-2002  thorpej Rename man/config.{c,h} to man/manconf.{c,h}, so we don't have to
worry about problems including "config.h" when building as a host
tool.
 1.2.2.3 03-Nov-2002  he Pull up revision 1.2 (requested by thorpej in ticket #788):
Pull in config.h when building as a host tool.
 1.2.2.2 03-Nov-2002  he Pull up revision 1.1 (new, requested by thorpej in ticket #787):
Rename man/config.{c,h} to man/manconf.{c,h}, so we do not
have to worry about problems including "config.h" when
building as a host tool.
 1.2.2.1 13-Sep-2002  he file manconf.c was added on branch netbsd-1-6 on 2002-11-03 13:47:55 +0000
 1.5.18.1 24-Mar-2008  keiichi sync with head.
 1.5.12.1 23-Mar-2008  matt sync with HEAD
 1.6.34.1 23-Jul-2013  riastradh sync with HEAD
 1.6.28.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4 08-Mar-2022  rillig man: remove trailing whitespace

No binary change.
 1.3 10-Apr-2006  chuck modified man(1):
- avoid double slashes when displaying man pages (got tired
of '/usr/share/man//cat1/man.0').
- got rid of __P() while working on it.
- incorporate some of my old notes explaining how manpath works into the
comments of the code itself.
- renamed some of the vars so that the code is consistent throughout
(and hopefully clearer and easier to understand)
- fixed relative man paths for multiple man pages (man did a chdir()
on the first man page it had to format --- this broke any remaining
relative path man pages left to process). save old directory and
fchdir() back to it after formatting.
- improved doc on "man -h" which does more than just whatis(1) [e.g.
"man -h fopen" prints the required include files and the prototypes
rather than just the one-liner you get with whatis(1)]
- manconf.c now fills in the "len" length field in the TAG/ENTRY
structures (man now uses len).

revise man.conf file reading stuff to return error on failure in
addentry/gettag (fka getlist) rather than just err()ing out. this
allows man(1) to call cleanup and delete its tmp files rather than
just leave them floating. revise other apps using this code
(makewhatis, apropos, catman, whatis) to expect this. also remove
__P on updated files.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.1 13-Sep-2002  thorpej branches: 1.1.2;
Rename man/config.{c,h} to man/manconf.{c,h}, so we don't have to
worry about problems including "config.h" when building as a host
tool.
 1.1.2.2 03-Nov-2002  he Pull up revision 1.1 (new, requested by thorpej in ticket #787):
Rename man/config.{c,h} to man/manconf.{c,h}, so we do not
have to worry about problems including "config.h" when
building as a host tool.
 1.1.2.1 13-Sep-2002  he file manconf.h was added on branch netbsd-1-6 on 2002-11-03 13:47:55 +0000
 1.7 21-May-2016  christos put back _PATH_WHATIS, it is used.
 1.6 21-May-2016  abhinav Remove unused include and unused constant. Ok from christos@.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.4 22-Jul-1999  kleink Try $TMPDIR first, then fall back to _PATH_TMP.
 1.3 28-Sep-1995  tls branches: 1.3.8;
Sync with 4.4BSD-Lite2
 1.2 16-Jan-1995  mycroft Sync with 4.4-Lite, plus local changes.
 1.1 21-Dec-1993  cgd branches: 1.1.1;
add man(1) ; part of new man(1) package from Bostic
 1.1.1.1 16-Jan-1995  mycroft Import original 4.4-Lite version.
 1.3.8.1 30-Apr-2000  he Pull up revision 1.4 (requested by kim):
Pull up various changes from the trunk:
o try TMPDIR env variable, fall back to _PATH_TMP

RSS XML Feed