CVS commit: src/usr.bin/man
Module Name:src Committed By: maya Date: Mon Apr 6 19:53:22 UTC 2020 Modified Files: src/usr.bin/man: man.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.67 src/usr.bin/man/man.c:1.68 --- src/usr.bin/man/man.c:1.67 Fri Jun 15 20:16:35 2018 +++ src/usr.bin/man/man.c Mon Apr 6 19:53:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.67 2018/06/15 20:16:35 mrg Exp $ */ +/* $NetBSD: man.c,v 1.68 2020/04/06 19:53:22 maya Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.67 2018/06/15 20:16:35 mrg Exp $"); +__RCSID("$NetBSD: man.c,v 1.68 2020/04/06 19:53:22 maya Exp $"); #endif #endif /* not lint */ @@ -363,8 +363,10 @@ main(int argc, char **argv) } - if (m.getpath) + if (m.getpath) { printmanpath(&m); + exit(cleanup()); + } /* * now m.mymanpath is complete!
CVS commit: src/usr.bin/man
Module Name:src Committed By: mrg Date: Fri Jun 15 20:16:35 UTC 2018 Modified Files: src/usr.bin/man: man.c Log Message: move 'utsname' to the main() function scope, so that the reference to it outside the block remains valid. should fix an asan reported issue. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.66 src/usr.bin/man/man.c:1.67 --- src/usr.bin/man/man.c:1.66 Tue May 2 14:19:23 2017 +++ src/usr.bin/man/man.c Fri Jun 15 20:16:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.66 2017/05/02 14:19:23 abhinav Exp $ */ +/* $NetBSD: man.c,v 1.67 2018/06/15 20:16:35 mrg Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.66 2017/05/02 14:19:23 abhinav Exp $"); +__RCSID("$NetBSD: man.c,v 1.67 2018/06/15 20:16:35 mrg Exp $"); #endif #endif /* not lint */ @@ -128,6 +128,7 @@ int main(int argc, char **argv) { static struct manstate m; + struct utsname utsname; int ch, abs_section, found; ENTRY *esubd, *epath; char *p, **ap, *cmd; @@ -204,8 +205,6 @@ main(int argc, char **argv) config(m.conffile);/* exits on error ... */ if ((m.machine = getenv("MACHINE")) == NULL) { - struct utsname utsname; - if (uname(&utsname) == -1) err(EXIT_FAILURE, "uname"); m.machine = utsname.machine;
CVS commit: src/usr.bin/man
Module Name:src Committed By: abhinav Date: Tue May 2 14:19:23 UTC 2017 Modified Files: src/usr.bin/man: man.c Log Message: 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@ To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.65 src/usr.bin/man/man.c:1.66 --- src/usr.bin/man/man.c:1.65 Thu Apr 27 09:31:50 2017 +++ src/usr.bin/man/man.c Tue May 2 14:19:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.65 2017/04/27 09:31:50 abhinav Exp $ */ +/* $NetBSD: man.c,v 1.66 2017/05/02 14:19:23 abhinav Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.65 2017/04/27 09:31:50 abhinav Exp $"); +__RCSID("$NetBSD: man.c,v 1.66 2017/05/02 14:19:23 abhinav Exp $"); #endif #endif /* not lint */ @@ -1046,44 +1046,33 @@ usage(void) static void printmanpath(struct manstate *m) { - ENTRY *esubd; - char *defaultpath = NULL; /* _default tag value from man.conf. */ - char *buf; /* for storing temporary values */ + ENTRY *epath; char **ap; glob_t pg; struct stat sb; - TAG *path = m->defaultpath; - TAG *subdirs = m->subdirs; + TAG *path = m->mymanpath; /* 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(epath, &path->entrylist, q) { + if (glob(epath->s, GLOB_BRACE | GLOB_NOSORT, NULL, &pg) != 0) + err(EXIT_FAILURE, "glob failed"); - TAILQ_FOREACH(esubd, &subdirs->entrylist, q) { - /* Drop cat page directory, only sources are relevant. */ - if (strncmp(esubd->s, "man", 3)) + if (pg.gl_matchc == 0) { + globfree(&pg); 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 cat page directories */ + if (strstr(*ap, "/cat") != NULL) +continue; /* Skip non-directories. */ - if (stat(buf, &sb) == 0 && S_ISDIR(sb.st_mode)) -printf("%s\n", buf); - - free(buf); + if (stat(*ap, &sb) == 0 && S_ISDIR(sb.st_mode)) +printf("%s\n", *ap); } + globfree(&pg); } - globfree(&pg); }
CVS commit: src/usr.bin/man
Module Name:src Committed By: abhinav Date: Thu Apr 27 09:31:51 UTC 2017 Modified Files: src/usr.bin/man: man.c Log Message: Fix comment indentation at couple of places: Use \t instead of space To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.64 src/usr.bin/man/man.c:1.65 --- src/usr.bin/man/man.c:1.64 Thu Jun 16 15:10:58 2016 +++ src/usr.bin/man/man.c Thu Apr 27 09:31:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.64 2016/06/16 15:10:58 abhinav Exp $ */ +/* $NetBSD: man.c,v 1.65 2017/04/27 09:31:50 abhinav Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.64 2016/06/16 15:10:58 abhinav Exp $"); +__RCSID("$NetBSD: man.c,v 1.65 2017/04/27 09:31:50 abhinav Exp $"); #endif #endif /* not lint */ @@ -293,7 +293,7 @@ main(int argc, char **argv) /* * [2] section can now only be non-null if the user asked for * a section and that section's elements did not have - * absolute paths. in this case we use the section's + * absolute paths. in this case we use the section's * elements to override _subdir from the config file. * * after this step, we are done processing "m.section"... @@ -428,7 +428,7 @@ main(int argc, char **argv) /* * normal case - we display things in a single command, so - * build a list of things to display. first compute total + * build a list of things to display. first compute total * length of buffer we will need so we can malloc it. */ for (ap = pg.gl_pathv, len = m.pagerlen + 1; *ap != NULL; ++ap) {
CVS commit: src/usr.bin/man
Module Name:src Committed By: abhinav Date: Thu Jun 16 15:11:43 UTC 2016 Modified Files: src/usr.bin/man: man.conf.5 Log Message: Replace makewhatis(8) with makemandb(8) in SEE ALSO. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.26 src/usr.bin/man/man.conf.5:1.27 --- src/usr.bin/man/man.conf.5:1.26 Tue Apr 7 10:17:21 2015 +++ src/usr.bin/man/man.conf.5 Thu Jun 16 15:11:43 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.26 2015/04/07 10:17:21 plunky Exp $ +.\" $NetBSD: man.conf.5,v 1.27 2016/06/16 15:11:43 abhinav 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 March 3, 2015 +.Dd June 16, 2016 .Dt MAN.CONF 5 .Os .Sh NAME @@ -283,4 +283,4 @@ of them were searched. .Xr fnmatch 3 , .Xr glob 3 , .Xr catman 8 , -.Xr makewhatis 8 +.Xr makemandb 8
CVS commit: src/usr.bin/man
Module Name:src Committed By: abhinav Date: Thu Jun 16 15:10:58 UTC 2016 Modified Files: src/usr.bin/man: man.1 man.c Log Message: Document -f option for man(1). Also remove unsupported options for `man -k` from the synopsis and usage. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/man/man.1 cvs rdiff -u -r1.63 -r1.64 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.28 src/usr.bin/man/man.1:1.29 --- src/usr.bin/man/man.1:1.28 Thu Aug 14 15:44:47 2014 +++ src/usr.bin/man/man.1 Thu Jun 16 15:10:58 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.28 2014/08/14 15:44:47 apb Exp $ +.\" $NetBSD: man.1,v 1.29 2016/06/16 15:10:58 abhinav 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 August 14, 2014 +.Dd June 16, 2016 .Dt MAN 1 .Os .Sh NAME @@ -49,10 +49,12 @@ .Oc .Ar name Ar ... .Nm -.Fl k .Op Fl C Ar file -.Op Fl M Ar path -.Op Fl m Ar path +.Fl f +.Ar command Ar ... +.Nm +.Op Fl C Ar file +.Fl k .Ar keyword Ar ... .Nm .Fl p @@ -82,6 +84,12 @@ Copy the man page to the standard output .Xr more 1 to paginate it. This is done by default if the standard output is not a terminal device. +.It Fl f +Synonym for +.Xr whatis 1 . +It searches man pages for +.Ar command +in their names and displays header lines from all matching pages. .It Fl h Display only the .Dq Tn SYNOPSIS @@ -90,7 +98,7 @@ For commands, this is typically the comm For library functions, this usually contains the required include files and function prototypes. .It Fl k -Display the header lines for any man pages matching +Search man pages for .Ar keyword Ns Pq s , in the same manner as .Xr apropos 1 . Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.63 src/usr.bin/man/man.c:1.64 --- src/usr.bin/man/man.c:1.63 Sat May 21 17:21:40 2016 +++ src/usr.bin/man/man.c Thu Jun 16 15:10:58 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.63 2016/05/21 17:21:40 abhinav Exp $ */ +/* $NetBSD: man.c,v 1.64 2016/06/16 15:10:58 abhinav Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.63 2016/05/21 17:21:40 abhinav Exp $"); +__RCSID("$NetBSD: man.c,v 1.64 2016/06/16 15:10:58 abhinav Exp $"); #endif #endif /* not lint */ @@ -1031,8 +1031,9 @@ usage(void) { (void)fprintf(stderr, "Usage: %s [-acw|-h] [-C cfg] [-M path] " "[-m path] [-S srch] [[-s] sect] name ...\n", getprogname()); + (void)fprintf(stderr, "Usage: %s [-C file] -f command ...\n", getprogname()); (void)fprintf(stderr, - "Usage: %s -k [-C cfg] [-M path] [-m path] keyword ...\n", + "Usage: %s [-C file] -k keyword ...\n", getprogname()); (void)fprintf(stderr, "Usage: %s -p\n", getprogname()); exit(EXIT_FAILURE);
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Sat May 21 20:54:34 UTC 2016 Modified Files: src/usr.bin/man: pathnames.h Log Message: put back _PATH_WHATIS, it is used. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/man/pathnames.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/pathnames.h diff -u src/usr.bin/man/pathnames.h:1.6 src/usr.bin/man/pathnames.h:1.7 --- src/usr.bin/man/pathnames.h:1.6 Sat May 21 13:21:40 2016 +++ src/usr.bin/man/pathnames.h Sat May 21 16:54:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.6 2016/05/21 17:21:40 abhinav Exp $ */ +/* $NetBSD: pathnames.h,v 1.7 2016/05/21 20:54:34 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,4 +35,5 @@ #define _PATH_MANCONF "/etc/man.conf" #define _PATH_PAGER "/usr/bin/more -s" +#define _PATH_WHATIS "whatis.db" #define TMPFILE "man.XX"
CVS commit: src/usr.bin/man
Module Name:src Committed By: abhinav Date: Sat May 21 17:21:40 UTC 2016 Modified Files: src/usr.bin/man: man.c pathnames.h Log Message: Remove unused include and unused constant. Ok from christos@. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/usr.bin/man/man.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/man/pathnames.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.62 src/usr.bin/man/man.c:1.63 --- src/usr.bin/man/man.c:1.62 Thu Aug 14 15:31:12 2014 +++ src/usr.bin/man/man.c Sat May 21 17:21:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.62 2014/08/14 15:31:12 apb Exp $ */ +/* $NetBSD: man.c,v 1.63 2016/05/21 17:21:40 abhinav Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.62 2014/08/14 15:31:12 apb Exp $"); +__RCSID("$NetBSD: man.c,v 1.63 2016/05/21 17:21:40 abhinav Exp $"); #endif #endif /* not lint */ @@ -51,7 +51,6 @@ __RCSID("$NetBSD: man.c,v 1.62 2014/08/1 #include #include -#include #include #include #include @@ -160,7 +159,8 @@ main(int argc, char **argv) break; case 'M': case 'P': /* -P for backward compatibility */ - m.manpath = strdup(optarg); + if ((m.manpath = strdup(optarg)) == NULL) +err(EXIT_FAILURE, "malloc failed"); break; case 'p': m.getpath = 1; Index: src/usr.bin/man/pathnames.h diff -u src/usr.bin/man/pathnames.h:1.5 src/usr.bin/man/pathnames.h:1.6 --- src/usr.bin/man/pathnames.h:1.5 Thu Aug 7 11:15:11 2003 +++ src/usr.bin/man/pathnames.h Sat May 21 17:21:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.5 2003/08/07 11:15:11 agc Exp $ */ +/* $NetBSD: pathnames.h,v 1.6 2016/05/21 17:21:40 abhinav Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,5 +35,4 @@ #define _PATH_MANCONF "/etc/man.conf" #define _PATH_PAGER "/usr/bin/more -s" -#define _PATH_WHATIS "whatis.db" #define TMPFILE "man.XX"
CVS commit: src/usr.bin/man
Module Name:src Committed By: plunky Date: Tue Apr 7 10:17:21 UTC 2015 Modified Files: src/usr.bin/man: man.conf.5 Log Message: change _whatdb => _mandb as that is the correct keyword here, and move it to the correct position in the list. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.25 src/usr.bin/man/man.conf.5:1.26 --- src/usr.bin/man/man.conf.5:1.25 Tue Mar 3 17:59:32 2015 +++ src/usr.bin/man/man.conf.5 Tue Apr 7 10:17:21 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.25 2015/03/03 17:59:32 christos Exp $ +.\" $NetBSD: man.conf.5,v 1.26 2015/04/07 10:17:21 plunky Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -116,6 +116,20 @@ 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 _mandb +Defines the full pathname (not just a directory path) for a database to +be used +by the +.Xr apropos 1 +and +.Xr whatis 1 +commands. +The pathname may contain the normal shell globbing characters, +including curly braces +.Pq Dq {} ; +to escape a shell globbing character, +precede it with a backslash +.Pq Dq \e . .It _subdir Contains the list (in search order) of section subdirectories which will be searched in any man path directory named with a trailing slash @@ -142,20 +156,6 @@ including curly braces .Pq Dq {} ) . .It _version Contains the version of the configuration file. -.It _whatdb -Defines the full pathname (not just a directory path) for a database to -be used -by the -.Xr apropos 1 -and -.Xr whatis 1 -commands. -The pathname may contain the normal shell globbing characters, -including curly braces -.Pq Dq {} ; -to escape a shell globbing character, -precede it with a backslash -.Pq Dq \e . .It _ Ns Aq machine Defines additional paths to be searched for the particular .Dv machine
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Tue Mar 3 17:59:32 UTC 2015 Modified Files: src/usr.bin/man: man.conf.5 Log Message: there is no more makewhatis; it has been replaced by makemandb To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.24 src/usr.bin/man/man.conf.5:1.25 --- src/usr.bin/man/man.conf.5:1.24 Fri Jun 28 06:13:18 2013 +++ src/usr.bin/man/man.conf.5 Tue Mar 3 12:59:32 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.24 2013/06/28 10:13:18 wiz Exp $ +.\" $NetBSD: man.conf.5,v 1.25 2015/03/03 17:59:32 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 28, 2012 +.Dd March 3, 2015 .Dt MAN.CONF 5 .Os .Sh NAME @@ -44,7 +44,7 @@ file contains the default configuration .Xr whatis 1 , .Xr catman 8 , and -.Xr makewhatis 8 +.Xr makemandb 8 to find manual pages and information about manual pages (e.g. the whatis database). .Pp
CVS commit: src/usr.bin/man
Module Name:src Committed By: apb Date: Thu Aug 14 15:44:47 UTC 2014 Modified Files: src/usr.bin/man: man.1 Log Message: More detail about treating a local file as a man page, and about how to request machine-specific man pages. re To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/man/man.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.27 src/usr.bin/man/man.1:1.28 --- src/usr.bin/man/man.1:1.27 Tue Mar 18 18:20:45 2014 +++ src/usr.bin/man/man.1 Thu Aug 14 15:44:47 2014 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.27 2014/03/18 18:20:45 riastradh Exp $ +.\" $NetBSD: man.1,v 1.28 2014/08/14 15:44:47 apb 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 7, 2011 +.Dd August 14, 2014 .Dt MAN 1 .Os .Sh NAME @@ -175,7 +175,13 @@ option. .Pp If .Ar name -is given with a full or relative path then +is given with a full path (beginning with +.Ql Pa \&/ ) +or a relative path that begins with +.Ql Pa .\&/ +or +.Ql Pa .\&./ , +then .Nm interprets it as a file specification, so that you can do .Nm @@ -183,6 +189,14 @@ interprets it as a file specification, s or even .Nm .Cm /cd/foo/bar.1.gz . +If +.Ar name +contains +.Ql Pa / +but does not match one of the above cases, then the +search path is used; this allows you to request +machine-specific man pages, such as +.Nm Cm vax/boot . .Sh ENVIRONMENT .Bl -tag -width MANPATHX .It Ev MACHINE @@ -196,6 +210,10 @@ The current machine type may be overridd variable .Ev MACHINE to the name of a specific architecture. +Machine-specific man pages may also be requested by +prepending the relevant subdirectory name to the page name, +separated by +.Ql Pa \&/ . .It Ev MANPATH The standard search path used by .Nm
CVS commit: src/usr.bin/man
Module Name:src Committed By: apb Date: Thu Aug 14 15:31:12 UTC 2014 Modified Files: src/usr.bin/man: man.c Log Message: 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". To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.61 src/usr.bin/man/man.c:1.62 --- src/usr.bin/man/man.c:1.61 Mon Feb 17 03:10:12 2014 +++ src/usr.bin/man/man.c Thu Aug 14 15:31:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.61 2014/02/17 03:10:12 uwe Exp $ */ +/* $NetBSD: man.c,v 1.62 2014/08/14 15:31:12 apb Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.61 2014/02/17 03:10:12 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.62 2014/08/14 15:31:12 apb Exp $"); #endif #endif /* not lint */ @@ -574,10 +574,14 @@ manual(char *page, struct manstate *mp, *eptr = '\0'; /* - * If 'page' contains a slash then it's - * interpreted as a file specification. + * If 'page' is given with an absolute path, + * or a relative path explicitly beginning with "./" + * or "../", then interpret it as a file specification. */ - if (strchr(page, '/') != NULL) { + if ((page[0] == '/') + || (page[0] == '.' && page[1] == '/') + || (page[0] == '.' && page[1] == '.' && page[2] == '/') + ) { /* check if file actually exists */ (void)strlcpy(buf, escpage, sizeof(buf)); error = glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg);
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Mon Feb 17 03:10:12 UTC 2014 Modified Files: src/usr.bin/man: Makefile man.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/man/Makefile cvs rdiff -u -r1.60 -r1.61 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/Makefile diff -u src/usr.bin/man/Makefile:1.14 src/usr.bin/man/Makefile:1.15 --- src/usr.bin/man/Makefile:1.14 Fri Jul 19 04:17:02 2013 +++ src/usr.bin/man/Makefile Mon Feb 17 03:10:12 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.14 2013/07/19 04:17:02 uwe Exp $ +# $NetBSD: Makefile,v 1.15 2014/02/17 03:10:12 uwe Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 WARNS?= 6 @@ -7,8 +7,6 @@ PROG= man SRCS= man.c manconf.c MAN= man.1 man.conf.5 -COPTS.man.c += -Wno-format-nonliteral - DPADD+= ${LIBUTIL} LDADD+= -lutil Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.60 src/usr.bin/man/man.c:1.61 --- src/usr.bin/man/man.c:1.60 Mon Oct 28 23:46:17 2013 +++ src/usr.bin/man/man.c Mon Feb 17 03:10:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.60 2013/10/28 23:46:17 christos Exp $ */ +/* $NetBSD: man.c,v 1.61 2014/02/17 03:10:12 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.60 2013/10/28 23:46:17 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.61 2014/02/17 03:10:12 uwe Exp $"); #endif #endif /* not lint */ @@ -714,6 +714,18 @@ next:anyfound = 1; return anyfound; } +/* + * A do-nothing counterpart to fmtcheck(3) that only supplies the + * __format_arg marker. Actual fmtcheck(3) call is done once in + * config(). + */ +__always_inline __format_arg(2) +static inline const char * +fmtcheck_ok(const char *userfmt, const char *template) +{ + return userfmt; +} + /* * build_page -- * Build a man page for display. @@ -788,7 +800,7 @@ build_page(const char *fmt, char **pathp exit(EXIT_FAILURE); } (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath); - (void)snprintf(cmd, sizeof(cmd), buf, p); + (void)snprintf(cmd, sizeof(cmd), fmtcheck_ok(buf, "%s"), p); (void)system(cmd); (void)close(fd); if ((*pathp = strdup(tpath)) == NULL) {
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Mon Feb 17 02:53:48 UTC 2014 Modified Files: src/usr.bin/man: manconf.c Log Message: Check _build and _crunch commands with fmtcheck(3), warn about and ignore bad ones. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/man/manconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/manconf.c diff -u src/usr.bin/man/manconf.c:1.7 src/usr.bin/man/manconf.c:1.8 --- src/usr.bin/man/manconf.c:1.7 Thu Jul 18 15:39:08 2013 +++ src/usr.bin/man/manconf.c Mon Feb 17 02:53:48 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: manconf.c,v 1.7 2013/07/18 15:39:08 christos Exp $ */ +/* $NetBSD: manconf.c,v 1.8 2014/02/17 02:53:48 uwe Exp $ */ /* * Copyright (c) 1989, 1993, 1995 @@ -45,7 +45,7 @@ #if 0 static char sccsid[] = "@(#)config.c 8.8 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: manconf.c,v 1.7 2013/07/18 15:39:08 christos Exp $"); +__RCSID("$NetBSD: manconf.c,v 1.8 2014/02/17 02:53:48 uwe Exp $"); #endif #endif /* not lint */ @@ -147,6 +147,8 @@ config(const char *fname) * rest of the line as a single entry. */ if (!strcmp(p, "_build") || !strcmp(p, "_crunch")) { +const char *u; + /* * The reason we're not just using * strtok(3) for all of the parsing is @@ -154,6 +156,19 @@ config(const char *fname) * has only a single token on it. */ while (*++t && isspace((unsigned char)*t)); +#ifndef HAVE_NBTOOL_CONFIG_H +/* pre-verify user-supplied command format */ +u = t; +while (*u && !isspace((unsigned char)*u)) + ++u; +while (*u && isspace((unsigned char)*u)) + ++u; +if (fmtcheck(u, "%s") != u) { + warnx("%s:%d: invalid %s command ignored", + fname, lcnt, p); + continue; +} +#endif /* !HAVE_NBTOOL_CONFIG_H */ if (addentry(tp, t, 0) == -1) errx(EXIT_FAILURE, "addentry: malloc failed");
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Mon Oct 28 23:46:17 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: 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) To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.59 src/usr.bin/man/man.c:1.60 --- src/usr.bin/man/man.c:1.59 Sun Oct 6 13:14:49 2013 +++ src/usr.bin/man/man.c Mon Oct 28 19:46:17 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.59 2013/10/06 17:14:49 christos Exp $ */ +/* $NetBSD: man.c,v 1.60 2013/10/28 23:46:17 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.59 2013/10/06 17:14:49 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.60 2013/10/28 23:46:17 christos Exp $"); #endif #endif /* not lint */ @@ -465,8 +465,46 @@ main(int argc, char **argv) } static int +manual_find_literalfile(struct manstate *mp, char **pv) +{ + ENTRY *suffix; + int found; + char buf[MAXPATHLEN]; + const char *p; + int suflen; + + found = 0; + + /* + * Expand both '*' and suffix to force an actual + * match via fnmatch(3). Since the only match in pg + * is the literal file, the match is genuine. + */ + + TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) { + for (p = suffix->s, suflen = 0; + *p != '\0' && !isspace((unsigned char)*p); + ++p) + ++suflen; + if (*p == '\0') + continue; + + (void)snprintf(buf, sizeof(buf), "*%.*s", suflen, suffix->s); + + if (!fnmatch(buf, *pv, 0)) { + if (!mp->where) +build_page(p + 1, pv, mp); + found = 1; + break; + } + } + + return found; +} + +static int manual_find_buildkeyword(const char *prefix, const char *escpage, - struct manstate *mp, glob_t *pg, size_t cnt) +struct manstate *mp, char **pv) { ENTRY *suffix; int found; @@ -485,10 +523,10 @@ manual_find_buildkeyword(const char *pre continue; (void)snprintf(buf, sizeof(buf), "%s%s%.*s", - prefix, escpage, suflen, suffix->s); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { + prefix, escpage, suflen, suffix->s); + if (!fnmatch(buf, *pv, 0)) { if (!mp->where) -build_page(p + 1, &pg->gl_pathv[cnt], mp); +build_page(p + 1, pv, mp); found = 1; break; } @@ -554,35 +592,12 @@ manual(char *page, struct manstate *mp, if (pg->gl_matchc == 0) goto notfound; - /* clip suffix for the suffix check below */ - if ((p = strrchr(escpage, '.')) != NULL) { - /* Should get suffixes from the configuration file */ - if (strcmp(p, ".gz") == 0 || strcmp(p, ".bz2") == 0 || - strcmp(p, ".Z") == 0 || strcmp(p, ".xz") == 0) { -*p = '\0'; -p = strrchr(escpage, '.'); - } - if (p && strchr("0123456789ln", p[1]) != NULL) -*p = '\0'; - } - - found = 0; - for (cnt = pg->gl_pathc - pg->gl_matchc; - cnt < pg->gl_pathc; ++cnt) - { - found = manual_find_buildkeyword("", escpage, -mp, pg, cnt); - if (found) { -anyfound = 1; -if (!mp->all) { - /* Delete any other matches. */ - while (++cnt< pg->gl_pathc) - *pg->gl_pathv[cnt] = '\0'; - break; -} -continue; - } - + /* literal file only yields one match */ + cnt = pg->gl_pathc - pg->gl_matchc; + + if (manual_find_literalfile(mp, &pg->gl_pathv[cnt])) { + anyfound = 1; + } else { /* It's not a man page, forget about it. */ *pg->gl_pathv[cnt] = '\0'; } @@ -666,7 +681,7 @@ manual(char *page, struct manstate *mp, /* Try the _build keywords next. */ found = manual_find_buildkeyword("*/", escpage, -mp, pg, cnt); +mp, &pg->gl_pathv[cnt]); if (found) { next:anyfound = 1; if (!mp->all) {
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Sun Oct 6 16:43:41 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Recognize .gz and .bz2 suffixes so $ man ./man.1.gz works. From Franco Fichter via dfly. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.57 src/usr.bin/man/man.c:1.58 --- src/usr.bin/man/man.c:1.57 Sun Oct 6 12:29:26 2013 +++ src/usr.bin/man/man.c Sun Oct 6 12:43:41 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.57 2013/10/06 16:29:26 christos Exp $ */ +/* $NetBSD: man.c,v 1.58 2013/10/06 16:43:41 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.57 2013/10/06 16:29:26 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.58 2013/10/06 16:43:41 christos Exp $"); #endif #endif /* not lint */ @@ -555,9 +555,14 @@ manual(char *page, struct manstate *mp, goto notfound; /* clip suffix for the suffix check below */ - p = strrchr(escpage, '.'); - if (p && p[0] == '.' && isdigit((unsigned char)p[1])) - p[0] = '\0'; + if ((p = strrchr(escpage, '.')) != NULL) { + if (strcmp(p, ".gz") == 0 || strcmp(p, ".bz2") == 0) { +*p = '\0'; +p = strrchr(escpage, '.'); + } + if (p && isdigit((unsigned char)p[1])) +*p = '\0'; + } found = 0; for (cnt = pg->gl_pathc - pg->gl_matchc;
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Sun Oct 6 17:14:49 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: add more compression suffixes and local suffixes. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.58 src/usr.bin/man/man.c:1.59 --- src/usr.bin/man/man.c:1.58 Sun Oct 6 12:43:41 2013 +++ src/usr.bin/man/man.c Sun Oct 6 13:14:49 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.58 2013/10/06 16:43:41 christos Exp $ */ +/* $NetBSD: man.c,v 1.59 2013/10/06 17:14:49 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.58 2013/10/06 16:43:41 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.59 2013/10/06 17:14:49 christos Exp $"); #endif #endif /* not lint */ @@ -556,11 +556,13 @@ manual(char *page, struct manstate *mp, /* clip suffix for the suffix check below */ if ((p = strrchr(escpage, '.')) != NULL) { - if (strcmp(p, ".gz") == 0 || strcmp(p, ".bz2") == 0) { + /* Should get suffixes from the configuration file */ + if (strcmp(p, ".gz") == 0 || strcmp(p, ".bz2") == 0 || + strcmp(p, ".Z") == 0 || strcmp(p, ".xz") == 0) { *p = '\0'; p = strrchr(escpage, '.'); } - if (p && isdigit((unsigned char)p[1])) + if (p && strchr("0123456789ln", p[1]) != NULL) *p = '\0'; }
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Sun Oct 6 16:29:26 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Be more permissive in interpreting man pages as filenames, from Franco Fichter via dfly. fixes: $ man usr.bin/man/man.1 To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.56 src/usr.bin/man/man.c:1.57 --- src/usr.bin/man/man.c:1.56 Tue Jul 30 11:10:04 2013 +++ src/usr.bin/man/man.c Sun Oct 6 12:29:26 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.56 2013/07/30 15:10:04 joerg Exp $ */ +/* $NetBSD: man.c,v 1.57 2013/10/06 16:29:26 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.56 2013/07/30 15:10:04 joerg Exp $"); +__RCSID("$NetBSD: man.c,v 1.57 2013/10/06 16:29:26 christos Exp $"); #endif #endif /* not lint */ @@ -536,10 +536,10 @@ manual(char *page, struct manstate *mp, *eptr = '\0'; /* - * If 'page' is given with a full or relative path - * then interpret it as a file specification. + * If 'page' contains a slash then it's + * interpreted as a file specification. */ - if ((page[0] == '/') || (page[0] == '.')) { + if (strchr(page, '/') != NULL) { /* check if file actually exists */ (void)strlcpy(buf, escpage, sizeof(buf)); error = glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg);
CVS commit: src/usr.bin/man
Module Name:src Committed By: joerg Date: Tue Jul 30 15:10:04 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Mark the dead. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.55 src/usr.bin/man/man.c:1.56 --- src/usr.bin/man/man.c:1.55 Fri Jul 19 05:05:59 2013 +++ src/usr.bin/man/man.c Tue Jul 30 15:10:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.55 2013/07/19 05:05:59 uwe Exp $ */ +/* $NetBSD: man.c,v 1.56 2013/07/30 15:10:04 joerg Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.55 2013/07/19 05:05:59 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.56 2013/07/30 15:10:04 joerg Exp $"); #endif #endif /* not lint */ @@ -114,10 +114,10 @@ static void cat(const char *); static const char *check_pager(const char *); static int cleanup(void); static void how(const char *); -static void jump(char **, const char *, const char *); +static void jump(char **, const char *, const char *) __dead; static int manual(char *, struct manstate *, glob_t *); -static void onsig(int); -static void usage(void) __attribute__((__noreturn__)); +static void onsig(int) __dead; +static void usage(void) __dead; static void addpath(struct manstate *, const char *, size_t, const char *); static const char *getclass(const char *); static void printmanpath(struct manstate *);
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Fri Jul 19 05:05:59 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Constify some more. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.54 src/usr.bin/man/man.c:1.55 --- src/usr.bin/man/man.c:1.54 Fri Jul 19 04:59:46 2013 +++ src/usr.bin/man/man.c Fri Jul 19 05:05:59 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.54 2013/07/19 04:59:46 uwe Exp $ */ +/* $NetBSD: man.c,v 1.55 2013/07/19 05:05:59 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.54 2013/07/19 04:59:46 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.55 2013/07/19 05:05:59 uwe Exp $"); #endif #endif /* not lint */ @@ -109,11 +109,11 @@ struct manstate { /* * prototypes */ -static void build_page(char *, char **, struct manstate *); -static void cat(char *); +static void build_page(const char *, char **, struct manstate *); +static void cat(const char *); static const char *check_pager(const char *); static int cleanup(void); -static void how(char *); +static void how(const char *); static void jump(char **, const char *, const char *); static int manual(char *, struct manstate *, glob_t *); static void onsig(int); @@ -470,7 +470,8 @@ manual_find_buildkeyword(const char *pre { ENTRY *suffix; int found; - char *p, buf[MAXPATHLEN]; + char buf[MAXPATHLEN]; + const char *p; int suflen; found = 0; @@ -696,7 +697,7 @@ next:anyfound = 1; * Build a man page for display. */ static void -build_page(char *fmt, char **pathp, struct manstate *mp) +build_page(const char *fmt, char **pathp, struct manstate *mp) { static int warned; int olddir, fd, n; @@ -793,12 +794,13 @@ build_page(char *fmt, char **pathp, stru * display how information */ static void -how(char *fname) +how(const char *fname) { FILE *fp; int lcnt, print; - char *p, buf[256]; + char buf[256]; + const char *p; if (!(fp = fopen(fname, "r"))) { warn("%s", fname); @@ -840,7 +842,7 @@ how(char *fname) * cat out the file */ static void -cat(char *fname) +cat(const char *fname) { int fd; ssize_t n;
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Fri Jul 19 04:59:46 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Spell "keywords" without space. Fix couple of typos. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.53 src/usr.bin/man/man.c:1.54 --- src/usr.bin/man/man.c:1.53 Fri Jul 19 04:55:05 2013 +++ src/usr.bin/man/man.c Fri Jul 19 04:59:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.53 2013/07/19 04:55:05 uwe Exp $ */ +/* $NetBSD: man.c,v 1.54 2013/07/19 04:59:46 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.53 2013/07/19 04:55:05 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.54 2013/07/19 04:59:46 uwe Exp $"); #endif #endif /* not lint */ @@ -474,7 +474,7 @@ manual_find_buildkeyword(const char *pre int suflen; found = 0; - /* Try the _build key words next. */ + /* Try the _build keywords next. */ TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) { for (p = suffix->s, suflen = 0; *p != '\0' && !isspace((unsigned char)*p); @@ -631,11 +631,11 @@ manual(char *page, struct manstate *mp, } /* - * Try the _suffix key words first. + * Try the _suffix keywords first. * * XXX - * Older versions of man.conf didn't have the suffix - * key words, it was assumed that everything was a .0. + * Older versions of man.conf didn't have the _suffix + * keywords, it was assumed that everything was a .0. * We just test for .0 first, it's fast and probably * going to hit. */ @@ -656,7 +656,7 @@ manual(char *page, struct manstate *mp, if (found) goto next; - /* Try the _build key words next. */ + /* Try the _build keywords next. */ found = manual_find_buildkeyword("*/", escpage, mp, pg, cnt); if (found) { @@ -746,7 +746,7 @@ build_page(char *fmt, char **pathp, stru } - /* advance fmt pass the suffix spec to the printf format string */ + /* advance fmt past the suffix spec to the printf format string */ for (; *fmt && isspace((unsigned char)*fmt); ++fmt) continue;
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Fri Jul 19 04:55:06 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: manual_find_buildkeyword() - now that we control the format string, we may use asterisk precision specification instead of temporary modifying the _build string itself. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.52 src/usr.bin/man/man.c:1.53 --- src/usr.bin/man/man.c:1.52 Fri Jul 19 04:18:10 2013 +++ src/usr.bin/man/man.c Fri Jul 19 04:55:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.52 2013/07/19 04:18:10 uwe Exp $ */ +/* $NetBSD: man.c,v 1.53 2013/07/19 04:55:05 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.52 2013/07/19 04:18:10 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.53 2013/07/19 04:55:05 uwe Exp $"); #endif #endif /* not lint */ @@ -471,28 +471,26 @@ manual_find_buildkeyword(const char *pre ENTRY *suffix; int found; char *p, buf[MAXPATHLEN]; + int suflen; found = 0; /* Try the _build key words next. */ TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) { - for (p = suffix->s; + for (p = suffix->s, suflen = 0; *p != '\0' && !isspace((unsigned char)*p); ++p) - continue; + ++suflen; if (*p == '\0') continue; - *p = '\0'; - (void)snprintf(buf, sizeof(buf), "%s%s%s", - prefix, escpage, suffix->s); + (void)snprintf(buf, sizeof(buf), "%s%s%.*s", + prefix, escpage, suflen, suffix->s); if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { if (!mp->where) build_page(p + 1, &pg->gl_pathv[cnt], mp); - *p = ' '; found = 1; break; - } - *p = ' '; + } } return found;
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Fri Jul 19 04:18:10 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Fix manual_find_buildkeyword() to not use non-literal printf format. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.51 src/usr.bin/man/man.c:1.52 --- src/usr.bin/man/man.c:1.51 Thu Jul 18 16:33:31 2013 +++ src/usr.bin/man/man.c Fri Jul 19 04:18:10 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.51 2013/07/18 16:33:31 uwe Exp $ */ +/* $NetBSD: man.c,v 1.52 2013/07/19 04:18:10 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.51 2013/07/18 16:33:31 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.52 2013/07/19 04:18:10 uwe Exp $"); #endif #endif /* not lint */ @@ -465,7 +465,7 @@ main(int argc, char **argv) } static int -manual_find_buildkeyword(char *escpage, const char *fmt, +manual_find_buildkeyword(const char *prefix, const char *escpage, struct manstate *mp, glob_t *pg, size_t cnt) { ENTRY *suffix; @@ -483,7 +483,8 @@ manual_find_buildkeyword(char *escpage, continue; *p = '\0'; - (void)snprintf(buf, sizeof(buf), fmt, escpage, suffix->s); + (void)snprintf(buf, sizeof(buf), "%s%s%s", + prefix, escpage, suffix->s); if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { if (!mp->where) build_page(p + 1, &pg->gl_pathv[cnt], mp); @@ -563,7 +564,7 @@ manual(char *page, struct manstate *mp, for (cnt = pg->gl_pathc - pg->gl_matchc; cnt < pg->gl_pathc; ++cnt) { - found = manual_find_buildkeyword(escpage, "%s%s", + found = manual_find_buildkeyword("", escpage, mp, pg, cnt); if (found) { anyfound = 1; @@ -658,7 +659,7 @@ manual(char *page, struct manstate *mp, goto next; /* Try the _build key words next. */ - found = manual_find_buildkeyword(escpage, "*/%s%s", + found = manual_find_buildkeyword("*/", escpage, mp, pg, cnt); if (found) { next:anyfound = 1;
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Fri Jul 19 04:17:02 UTC 2013 Modified Files: src/usr.bin/man: Makefile Log Message: Use -Wno-format-nonliteral instead of blanket -Wno-format. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/man/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/Makefile diff -u src/usr.bin/man/Makefile:1.13 src/usr.bin/man/Makefile:1.14 --- src/usr.bin/man/Makefile:1.13 Thu Jul 18 16:28:52 2013 +++ src/usr.bin/man/Makefile Fri Jul 19 04:17:02 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.13 2013/07/18 16:28:52 christos Exp $ +# $NetBSD: Makefile,v 1.14 2013/07/19 04:17:02 uwe Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 WARNS?= 6 @@ -7,7 +7,7 @@ PROG= man SRCS= man.c manconf.c MAN= man.1 man.conf.5 -COPTS.man.c += -Wno-format +COPTS.man.c += -Wno-format-nonliteral DPADD+= ${LIBUTIL} LDADD+= -lutil
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Thu Jul 18 16:33:31 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Don't access memory outside the array if tmpdirlen == 0. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.50 src/usr.bin/man/man.c:1.51 --- src/usr.bin/man/man.c:1.50 Thu Jul 18 16:28:52 2013 +++ src/usr.bin/man/man.c Thu Jul 18 16:33:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.50 2013/07/18 16:28:52 christos Exp $ */ +/* $NetBSD: man.c,v 1.51 2013/07/18 16:33:31 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.50 2013/07/18 16:28:52 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.51 2013/07/18 16:33:31 uwe Exp $"); #endif #endif /* not lint */ @@ -759,7 +759,7 @@ build_page(char *fmt, char **pathp, stru tmpdir = _PATH_TMP; tmpdirlen = strlen(tmpdir); (void)snprintf(tpath, sizeof (tpath), "%s%s%s", tmpdir, - (tmpdirlen && tmpdir[tmpdirlen-1] == '/') ? "" : "/", TMPFILE); + (tmpdirlen > 0 && tmpdir[tmpdirlen-1] == '/') ? "" : "/", TMPFILE); if ((fd = mkstemp(tpath)) == -1) { warn("%s", tpath); (void)cleanup();
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Thu Jul 18 16:28:52 UTC 2013 Modified Files: src/usr.bin/man: Makefile man.c Log Message: use -Wno-format and revert "fixstring" To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/man/Makefile cvs rdiff -u -r1.49 -r1.50 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/Makefile diff -u src/usr.bin/man/Makefile:1.12 src/usr.bin/man/Makefile:1.13 --- src/usr.bin/man/Makefile:1.12 Thu Jul 18 11:39:08 2013 +++ src/usr.bin/man/Makefile Thu Jul 18 12:28:52 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.12 2013/07/18 15:39:08 christos Exp $ +# $NetBSD: Makefile,v 1.13 2013/07/18 16:28:52 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 WARNS?= 6 @@ -7,6 +7,8 @@ PROG= man SRCS= man.c manconf.c MAN= man.1 man.conf.5 +COPTS.man.c += -Wno-format + DPADD+= ${LIBUTIL} LDADD+= -lutil Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.49 src/usr.bin/man/man.c:1.50 --- src/usr.bin/man/man.c:1.49 Thu Jul 18 12:01:25 2013 +++ src/usr.bin/man/man.c Thu Jul 18 12:28:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.49 2013/07/18 16:01:25 christos Exp $ */ +/* $NetBSD: man.c,v 1.50 2013/07/18 16:28:52 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.49 2013/07/18 16:01:25 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.50 2013/07/18 16:28:52 christos Exp $"); #endif #endif /* not lint */ @@ -464,21 +464,6 @@ main(int argc, char **argv) exit(cleanup()); } -static void -fixstring(char *buf, size_t len, const char *fmt, const char *str) -{ - const char *ptr = strstr(fmt, "%s"); - size_t l; - if (ptr == NULL) { - strlcpy(buf, fmt, len); - return; - } - l = (size_t)(ptr - fmt) + 1; - strlcpy(buf, fmt, MIN(l, len)); - strlcat(buf, str, len); - strlcat(buf, ptr + 2, len); -} - static int manual_find_buildkeyword(char *escpage, const char *fmt, struct manstate *mp, glob_t *pg, size_t cnt) @@ -498,7 +483,7 @@ manual_find_buildkeyword(char *escpage, continue; *p = '\0'; - fixstring(buf, sizeof(buf), fmt, escpage); + (void)snprintf(buf, sizeof(buf), fmt, escpage, suffix->s); if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { if (!mp->where) build_page(p + 1, &pg->gl_pathv[cnt], mp); @@ -781,7 +766,7 @@ build_page(char *fmt, char **pathp, stru exit(EXIT_FAILURE); } (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath); - fixstring(cmd, sizeof(cmd), buf, p); + (void)snprintf(cmd, sizeof(cmd), buf, p); (void)system(cmd); (void)close(fd); if ((*pathp = strdup(tpath)) == NULL) {
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Thu Jul 18 16:01:25 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Set the string to NUL instread of providing an new empty string (from uwe) To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.48 src/usr.bin/man/man.c:1.49 --- src/usr.bin/man/man.c:1.48 Thu Jul 18 11:39:08 2013 +++ src/usr.bin/man/man.c Thu Jul 18 12:01:25 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.48 2013/07/18 15:39:08 christos Exp $ */ +/* $NetBSD: man.c,v 1.49 2013/07/18 16:01:25 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.48 2013/07/18 15:39:08 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.49 2013/07/18 16:01:25 christos Exp $"); #endif #endif /* not lint */ @@ -122,8 +122,6 @@ static void addpath(struct manstate *, static const char *getclass(const char *); static void printmanpath(struct manstate *); -static char EMPTY[1]; - /* * main function */ @@ -587,14 +585,14 @@ manual(char *page, struct manstate *mp, if (!mp->all) { /* Delete any other matches. */ while (++cnt< pg->gl_pathc) - pg->gl_pathv[cnt] = EMPTY; + *pg->gl_pathv[cnt] = '\0'; break; } continue; } /* It's not a man page, forget about it. */ - pg->gl_pathv[cnt] = EMPTY; + *pg->gl_pathv[cnt] = '\0'; } notfound: @@ -643,7 +641,7 @@ manual(char *page, struct manstate *mp, if (mp->pathsearch) { p = strstr(pg->gl_pathv[cnt], mp->pathsearch); if (!p || strchr(p, '/') == NULL) { - pg->gl_pathv[cnt] = EMPTY; /* zap! */ + *pg->gl_pathv[cnt] = '\0'; /* zap! */ continue; } } @@ -682,14 +680,14 @@ next:anyfound = 1; if (!mp->all) { /* Delete any other matches. */ while (++cnt< pg->gl_pathc) - pg->gl_pathv[cnt] = EMPTY; + *pg->gl_pathv[cnt] = '\0'; break; } continue; } /* It's not a man page, forget about it. */ - pg->gl_pathv[cnt] = EMPTY; + *pg->gl_pathv[cnt] = '\0'; } if (anyfound && !mp->all)
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Thu Jul 18 15:39:08 UTC 2013 Modified Files: src/usr.bin/man: Makefile man.c manconf.c Log Message: WARNS=6 - fix cast qual issues - don't use snprintf on a user-provided buffer To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/man/Makefile cvs rdiff -u -r1.47 -r1.48 src/usr.bin/man/man.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/man/manconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/Makefile diff -u src/usr.bin/man/Makefile:1.11 src/usr.bin/man/Makefile:1.12 --- src/usr.bin/man/Makefile:1.11 Tue Apr 14 18:15:23 2009 +++ src/usr.bin/man/Makefile Thu Jul 18 11:39:08 2013 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.11 2009/04/14 22:15:23 lukem Exp $ +# $NetBSD: Makefile,v 1.12 2013/07/18 15:39:08 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -WARNS?= 2 # XXX -Wcast-qual issues +WARNS?= 6 PROG= man SRCS= man.c manconf.c Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.47 src/usr.bin/man/man.c:1.48 --- src/usr.bin/man/man.c:1.47 Thu Jul 18 00:05:32 2013 +++ src/usr.bin/man/man.c Thu Jul 18 11:39:08 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.47 2013/07/18 04:05:32 uwe Exp $ */ +/* $NetBSD: man.c,v 1.48 2013/07/18 15:39:08 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.47 2013/07/18 04:05:32 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.48 2013/07/18 15:39:08 christos Exp $"); #endif #endif /* not lint */ @@ -114,7 +114,7 @@ static void cat(char *); static const char *check_pager(const char *); static int cleanup(void); static void how(char *); -static void jump(char **, char *, char *); +static void jump(char **, const char *, const char *); static int manual(char *, struct manstate *, glob_t *); static void onsig(int); static void usage(void) __attribute__((__noreturn__)); @@ -122,13 +122,15 @@ static void addpath(struct manstate *, static const char *getclass(const char *); static void printmanpath(struct manstate *); +static char EMPTY[1]; + /* * main function */ int main(int argc, char **argv) { - static struct manstate m = { 0 }; /* init to zero */ + static struct manstate m; int ch, abs_section, found; ENTRY *esubd, *epath; char *p, **ap, *cmd; @@ -464,6 +466,21 @@ main(int argc, char **argv) exit(cleanup()); } +static void +fixstring(char *buf, size_t len, const char *fmt, const char *str) +{ + const char *ptr = strstr(fmt, "%s"); + size_t l; + if (ptr == NULL) { + strlcpy(buf, fmt, len); + return; + } + l = (size_t)(ptr - fmt) + 1; + strlcpy(buf, fmt, MIN(l, len)); + strlcat(buf, str, len); + strlcat(buf, ptr + 2, len); +} + static int manual_find_buildkeyword(char *escpage, const char *fmt, struct manstate *mp, glob_t *pg, size_t cnt) @@ -483,7 +500,7 @@ manual_find_buildkeyword(char *escpage, continue; *p = '\0'; - (void)snprintf(buf, sizeof(buf), fmt, escpage, suffix->s); + fixstring(buf, sizeof(buf), fmt, escpage); if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { if (!mp->where) build_page(p + 1, &pg->gl_pathv[cnt], mp); @@ -570,14 +587,14 @@ manual(char *page, struct manstate *mp, if (!mp->all) { /* Delete any other matches. */ while (++cnt< pg->gl_pathc) - pg->gl_pathv[cnt] = ""; + pg->gl_pathv[cnt] = EMPTY; break; } continue; } /* It's not a man page, forget about it. */ - pg->gl_pathv[cnt] = ""; + pg->gl_pathv[cnt] = EMPTY; } notfound: @@ -626,7 +643,7 @@ manual(char *page, struct manstate *mp, if (mp->pathsearch) { p = strstr(pg->gl_pathv[cnt], mp->pathsearch); if (!p || strchr(p, '/') == NULL) { - pg->gl_pathv[cnt] = ""; /* zap! */ + pg->gl_pathv[cnt] = EMPTY; /* zap! */ continue; } } @@ -665,14 +682,14 @@ next:anyfound = 1; if (!mp->all) { /* Delete any other matches. */ while (++cnt< pg->gl_pathc) - pg->gl_pathv[cnt] = ""; + pg->gl_pathv[cnt] = EMPTY; break; } continue; } /* It's not a man page, forget about it. */ - pg->gl_pathv[cnt] = ""; + pg->gl_pathv[cnt] = EMPTY; } if (anyfound && !mp->all) @@ -700,7 +717,8 @@ static void build_page(char *fmt, char **pathp, struct manstate *mp) { static int warned; - int olddir, fd, n, tmpdirlen; + int olddir, fd, n; + size_t tmpdirlen; char *p, *b; char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[MAXPATHLEN]; const char *tmpdir; @@ -765,7 +783,7 @@ build_page(char *fmt, char **pathp, stru exit(EXIT_FAILURE); } (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath); - (void)snprintf(cmd, sizeof(cmd), buf, p); + fixstring(cmd, sizeof(cmd), buf, p); (void)system(cmd); (void)close(fd); if ((*pathp = st
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Thu Jul 18 04:05:32 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Revert previous; other errors from WARNS=3 obscured the error in jump(). To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.46 src/usr.bin/man/man.c:1.47 --- src/usr.bin/man/man.c:1.46 Thu Jul 18 04:02:31 2013 +++ src/usr.bin/man/man.c Thu Jul 18 04:05:32 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.46 2013/07/18 04:02:31 uwe Exp $ */ +/* $NetBSD: man.c,v 1.47 2013/07/18 04:05:32 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.46 2013/07/18 04:02:31 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.47 2013/07/18 04:05:32 uwe Exp $"); #endif #endif /* not lint */ @@ -114,7 +114,7 @@ static void cat(char *); static const char *check_pager(const char *); static int cleanup(void); static void how(char *); -static void jump(char **, const char *, const char *); +static void jump(char **, char *, char *); static int manual(char *, struct manstate *, glob_t *); static void onsig(int); static void usage(void) __attribute__((__noreturn__)); @@ -898,7 +898,7 @@ check_pager(const char *name) * strip out flag argument and jump */ static void -jump(char **argv, const char *flag, const char *name) +jump(char **argv, char *flag, char *name) { char **arg;
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Thu Jul 18 04:02:31 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Constify jump() arguments appropriately. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.45 src/usr.bin/man/man.c:1.46 --- src/usr.bin/man/man.c:1.45 Thu Jul 18 03:48:22 2013 +++ src/usr.bin/man/man.c Thu Jul 18 04:02:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.45 2013/07/18 03:48:22 uwe Exp $ */ +/* $NetBSD: man.c,v 1.46 2013/07/18 04:02:31 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.45 2013/07/18 03:48:22 uwe Exp $"); +__RCSID("$NetBSD: man.c,v 1.46 2013/07/18 04:02:31 uwe Exp $"); #endif #endif /* not lint */ @@ -114,7 +114,7 @@ static void cat(char *); static const char *check_pager(const char *); static int cleanup(void); static void how(char *); -static void jump(char **, char *, char *); +static void jump(char **, const char *, const char *); static int manual(char *, struct manstate *, glob_t *); static void onsig(int); static void usage(void) __attribute__((__noreturn__)); @@ -898,7 +898,7 @@ check_pager(const char *name) * strip out flag argument and jump */ static void -jump(char **argv, char *flag, char *name) +jump(char **argv, const char *flag, const char *name) { char **arg;
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Thu Jul 18 03:48:22 UTC 2013 Modified Files: src/usr.bin/man: man.c Log Message: Move manstate::pagerlen so that its "length of the above" comment makes sense. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.44 src/usr.bin/man/man.c:1.45 --- src/usr.bin/man/man.c:1.44 Tue Jan 3 17:49:57 2012 +++ src/usr.bin/man/man.c Thu Jul 18 03:48:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $ */ +/* $NetBSD: man.c,v 1.45 2013/07/18 03:48:22 uwe Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $"); +__RCSID("$NetBSD: man.c,v 1.45 2013/07/18 03:48:22 uwe Exp $"); #endif #endif /* not lint */ @@ -101,9 +101,9 @@ struct manstate { /* other misc stuff */ const char *pager; /* pager to use */ + size_t pagerlen; /* length of the above */ const char *machine; /* machine */ const char *machclass; /* machine class */ - size_t pagerlen; /* length of the above */ }; /*
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Thu Jul 18 03:40:31 UTC 2013 Modified Files: src/usr.bin/man: man.1 Log Message: whatis.db is no more, so don't mention its location in FILES. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/man/man.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.25 src/usr.bin/man/man.1:1.26 --- src/usr.bin/man/man.1:1.25 Thu Jul 18 03:38:25 2013 +++ src/usr.bin/man/man.1 Thu Jul 18 03:40:31 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.25 2013/07/18 03:38:25 uwe Exp $ +.\" $NetBSD: man.1,v 1.26 2013/07/18 03:40:31 uwe Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -223,10 +223,6 @@ will be used. .Bl -hang -width /etc/man.conf -compact .It Pa /etc/man.conf default man configuration file. -.It Pa /usr/{share,X11R7,pkg,local}/man/whatis.db -standard whatis/apropos database search path, -set in -.Pa /etc/man.conf . .El .Sh SEE ALSO .Xr apropos 1 ,
CVS commit: src/usr.bin/man
Module Name:src Committed By: uwe Date: Thu Jul 18 03:38:25 UTC 2013 Modified Files: src/usr.bin/man: man.1 Log Message: Remove unnecessary line wrap. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/man/man.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.24 src/usr.bin/man/man.1:1.25 --- src/usr.bin/man/man.1:1.24 Fri Oct 7 10:52:31 2011 +++ src/usr.bin/man/man.1 Thu Jul 18 03:38:25 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.24 2011/10/07 10:52:31 mbalmer Exp $ +.\" $NetBSD: man.1,v 1.25 2013/07/18 03:38:25 uwe Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -201,8 +201,7 @@ The standard search path used by .Nm may be overridden by specifying a path in the .Ev MANPATH -environment -variable. +environment variable. The format of the path is a colon .Pq Dq \&: separated list of directories.
CVS commit: src/usr.bin/man
Module Name:src Committed By: wiz Date: Fri Jun 28 10:13:18 UTC 2013 Modified Files: src/usr.bin/man: man.conf.5 Log Message: Prefer Aq to \*[Lt] etc. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.23 src/usr.bin/man/man.conf.5:1.24 --- src/usr.bin/man/man.conf.5:1.23 Thu Jun 27 21:55:10 2013 +++ src/usr.bin/man/man.conf.5 Fri Jun 28 10:13:18 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.23 2013/06/27 21:55:10 jdf Exp $ +.\" $NetBSD: man.conf.5,v 1.24 2013/06/28 10:13:18 wiz Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -81,7 +81,7 @@ Control keywords must start with the .Dq _ character. The following control keywords are currently defined: -.Bl -tag -width "_\*[Lt]machine\*[Gt]" +.Bl -tag -width XXmachineX .It _build Identifies the set of suffixes used for manual pages that must be formatted for display and the command that should be used to format @@ -156,7 +156,7 @@ including curly braces to escape a shell globbing character, precede it with a backslash .Pq Dq \e . -.It _\*[Lt]machine\*[Gt] +.It _ Ns Aq machine Defines additional paths to be searched for the particular .Dv machine whose literal value is taken from @@ -241,7 +241,7 @@ sect3 /usr/share/man/{old/,}cat3 By default, the command .Dq Li man mktemp will search for -.Dq mktemp.\*[Lt]any_digit\*[Gt] +.Dq mktemp. Ns Aq any_digit and .Dq mktemp.tbl in the directories @@ -260,7 +260,7 @@ searched. If .Dq mktemp.tbl was found first, the command -.Dq Li tbl \*[Lt]manual page\*[Gt] | nroff -man +.Dq Li tbl Ao manual page Ac | nroff -man would be run to build a man page for display to the user. .Pp The command
CVS commit: src/usr.bin/man
Module Name:src Committed By: jdf Date: Thu Jun 27 21:55:10 UTC 2013 Modified Files: src/usr.bin/man: man.conf.5 Log Message: * adjust indentation of list block * fix capitalization * remove superfluous word ('The') Patch supplied by Bug Hunting. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.22 src/usr.bin/man/man.conf.5:1.23 --- src/usr.bin/man/man.conf.5:1.22 Sun Apr 29 03:46:43 2012 +++ src/usr.bin/man/man.conf.5 Thu Jun 27 21:55:10 2013 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.22 2012/04/29 03:46:43 christos Exp $ +.\" $NetBSD: man.conf.5,v 1.23 2013/06/27 21:55:10 jdf Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -81,9 +81,9 @@ Control keywords must start with the .Dq _ character. The following control keywords are currently defined: -.Bl -tag -width "_version" +.Bl -tag -width "_\*[Lt]machine\*[Gt]" .It _build -identifies the set of suffixes used for manual pages that must be +Identifies the set of suffixes used for manual pages that must be formatted for display and the command that should be used to format them. Manual file names, regardless of their format, are expected to end in a @@ -103,7 +103,7 @@ There should be exactly one occurrence o in the shell command line, and it will be replaced by the name of the file which is being formatted. .It _crunch -used by +Used by .Xr catman 8 to determine how to crunch formatted pages which originally were compressed man pages: The first field lists a suffix @@ -115,9 +115,9 @@ There should be exactly one occurrence o 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. +Contains the system-wide default man path used to search for man pages. .It _subdir -contains the list (in search order) of section subdirectories which will +Contains the list (in search order) of section subdirectories which will be searched in any man path directory named with a trailing slash .Pq Dq / character. @@ -141,9 +141,9 @@ Each suffix may contain the normal shell including curly braces .Pq Dq {} ) . .It _version -contains the version of the configuration file. +Contains the version of the configuration file. .It _whatdb -defines the full pathname (not just a directory path) for a database to +Defines the full pathname (not just a directory path) for a database to be used by the .Xr apropos 1 @@ -157,7 +157,7 @@ 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 +Defines additional paths to be searched for the particular .Dv machine whose literal value is taken from .Xr uname 1
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Sun Apr 29 03:46:43 UTC 2012 Modified Files: src/usr.bin/man: man.conf.5 Log Message: document _machine To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.21 src/usr.bin/man/man.conf.5:1.22 --- src/usr.bin/man/man.conf.5:1.21 Tue Dec 27 08:15:55 2011 +++ src/usr.bin/man/man.conf.5 Sat Apr 28 23:46:43 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.conf.5,v 1.21 2011/12/27 13:15:55 apb 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 December 27, 2011 +.Dd April 28, 2012 .Dt MAN.CONF 5 .Os .Sh NAME @@ -156,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 @@ -223,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
CVS commit: src/usr.bin/man
Module Name:src Committed By: joerg Date: Tue Jan 3 17:49:57 UTC 2012 Modified Files: src/usr.bin/man: man.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.43 src/usr.bin/man/man.c:1.44 --- src/usr.bin/man/man.c:1.43 Tue Jun 14 20:08:45 2011 +++ src/usr.bin/man/man.c Tue Jan 3 17:49:57 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.43 2011/06/14 20:08:45 wiz Exp $ */ +/* $NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.43 2011/06/14 20:08:45 wiz Exp $"); +__RCSID("$NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $"); #endif #endif /* not lint */ @@ -1021,7 +1021,13 @@ printmanpath(struct manstate *m) 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))
CVS commit: src/usr.bin/man
Module Name:src Committed By: apb Date: Tue Dec 27 13:15:55 UTC 2011 Modified Files: src/usr.bin/man: man.conf.5 Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/man/man.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.conf.5 diff -u src/usr.bin/man/man.conf.5:1.20 src/usr.bin/man/man.conf.5:1.21 --- src/usr.bin/man/man.conf.5:1.20 Sat Feb 10 19:27:39 2007 +++ src/usr.bin/man/man.conf.5 Tue Dec 27 13:15:55 2011 @@ -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.21 2011/12/27 13:15:55 apb 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 December 27, 2011 .Dt MAN.CONF 5 .Os .Sh NAME @@ -98,9 +98,9 @@ The suffix specification may contain the 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 pag 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
CVS commit: src/usr.bin/man
Module Name:src Committed By: mbalmer Date: Fri Oct 7 10:52:31 UTC 2011 Modified Files: src/usr.bin/man: man.1 Log Message: Refer to X11R7. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/man/man.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.23 src/usr.bin/man/man.1:1.24 --- src/usr.bin/man/man.1:1.23 Tue Jun 14 20:08:45 2011 +++ src/usr.bin/man/man.1 Fri Oct 7 10:52:31 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.23 2011/06/14 20:08:45 wiz 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 June 14, 2011 +.Dd October 7, 2011 .Dt MAN 1 .Os .Sh NAME @@ -224,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 .
CVS commit: src/usr.bin/man
Module Name:src Committed By: wiz Date: Tue Jun 14 20:08:46 UTC 2011 Modified Files: src/usr.bin/man: man.1 man.c Log Message: Fix usage in man page and sync usage in executable with it. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/man/man.1 cvs rdiff -u -r1.42 -r1.43 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.22 src/usr.bin/man/man.1:1.23 --- src/usr.bin/man/man.1:1.22 Tue Jun 14 18:53:48 2011 +++ src/usr.bin/man/man.1 Tue Jun 14 20:08:45 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.22 2011/06/14 18:53:48 joerg Exp $ +.\" $NetBSD: man.1,v 1.23 2011/06/14 20:08:45 wiz Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -49,13 +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 -.Op Fl p +.Fl p .Sh DESCRIPTION The .Nm Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.42 src/usr.bin/man/man.c:1.43 --- src/usr.bin/man/man.c:1.42 Tue Jun 14 18:53:48 2011 +++ src/usr.bin/man/man.c Tue Jun 14 20:08:45 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.42 2011/06/14 18:53:48 joerg Exp $ */ +/* $NetBSD: man.c,v 1.43 2011/06/14 20:08:45 wiz Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.42 2011/06/14 18:53:48 joerg Exp $"); +__RCSID("$NetBSD: man.c,v 1.43 2011/06/14 20:08:45 wiz Exp $"); #endif #endif /* not lint */ @@ -993,6 +993,7 @@ (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); }
CVS commit: src/usr.bin/man
Module Name:src Committed By: joerg Date: Tue Jun 14 18:53:48 UTC 2011 Modified Files: src/usr.bin/man: man.1 man.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/man/man.1 cvs rdiff -u -r1.41 -r1.42 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.21 src/usr.bin/man/man.1:1.22 --- src/usr.bin/man/man.1:1.21 Wed Oct 7 08:30:31 2009 +++ src/usr.bin/man/man.1 Tue Jun 14 18:53:48 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.21 2009/10/07 08:30:31 cegger Exp $ +.\" $NetBSD: man.1,v 1.22 2011/06/14 18:53:48 joerg 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 June 14, 2011 .Dt MAN 1 .Os .Sh NAME @@ -54,6 +54,8 @@ .Op Fl M Ar path .Op Fl m Ar path .Ar keyword Ar ... +.Nm +.Op Fl p .Sh DESCRIPTION The .Nm @@ -130,6 +132,8 @@ 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 Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.41 src/usr.bin/man/man.c:1.42 --- src/usr.bin/man/man.c:1.41 Wed Jul 7 21:24:34 2010 +++ src/usr.bin/man/man.c Tue Jun 14 18:53:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $ */ +/* $NetBSD: man.c,v 1.42 2011/06/14 18:53:48 joerg Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,12 +40,13 @@ #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.42 2011/06/14 18:53:48 joerg Exp $"); #endif #endif /* not lint */ #include #include +#include #include #include @@ -84,7 +85,8 @@ 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 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 @@ /* * 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 @@ 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 @@ argc -= optind; argv += optind; - if (!argc) + if (!m.getpath && !argc) usage(); /* @@ -358,6 +364,9 @@ } + if (m.getpath) + printmanpath(&m); + /* * now m.mymanpath is complete! */ @@ -986,3 +995,46 @@ 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"); + + 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); +}
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Wed Jul 7 21:24:34 UTC 2010 Modified Files: src/usr.bin/man: man.c Log Message: get the value of the entry for the class not the key. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.40 src/usr.bin/man/man.c:1.41 --- src/usr.bin/man/man.c:1.40 Sun May 23 18:04:36 2010 +++ src/usr.bin/man/man.c Wed Jul 7 17:24:34 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.40 2010/05/23 22:04:36 christos Exp $ */ +/* $NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.40 2010/05/23 22:04:36 christos Exp $"); +__RCSID("$NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $"); #endif #endif /* not lint */ @@ -956,7 +956,8 @@ TAG *t; snprintf(buf, sizeof(buf), "_%s", machine); t = gettag(buf, 0); - return t != NULL && t->s ? t->s : NULL; + return t != NULL && !TAILQ_EMPTY(&t->entrylist) ? + TAILQ_FIRST(&t->entrylist)->s : NULL; } static void
CVS commit: src/usr.bin/man
Module Name:src Committed By: christos Date: Sun May 23 22:04:36 UTC 2010 Modified Files: src/usr.bin/man: man.c Log Message: - 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. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.39 src/usr.bin/man/man.c:1.40 --- src/usr.bin/man/man.c:1.39 Wed Oct 7 04:30:31 2009 +++ src/usr.bin/man/man.c Sun May 23 18:04:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.39 2009/10/07 08:30:31 cegger Exp $ */ +/* $NetBSD: man.c,v 1.40 2010/05/23 22:04:36 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.39 2009/10/07 08:30:31 cegger Exp $"); +__RCSID("$NetBSD: man.c,v 1.40 2010/05/23 22:04:36 christos Exp $"); #endif #endif /* not lint */ @@ -60,6 +60,7 @@ #include #include #include +#include #include "manconf.h" #include "pathnames.h" @@ -98,6 +99,8 @@ /* other misc stuff */ const char *pager; /* pager to use */ + const char *machine; /* machine */ + const char *machclass; /* machine class */ size_t pagerlen; /* length of the above */ }; @@ -112,7 +115,9 @@ static void jump(char **, char *, char *); static int manual(char *, struct manstate *, glob_t *); static void onsig(int); -static void usage(void); +static void usage(void) __attribute__((__noreturn__)); +static void addpath(struct manstate *, const char *, size_t, const char *); +static const char *getclass(const char *); /* * main function @@ -122,12 +127,13 @@ { static struct manstate m = { 0 }; /* init to zero */ int ch, abs_section, found; - const char *machine; ENTRY *esubd, *epath; - char *p, **ap, *cmd, buf[MAXPATHLEN * 2]; + char *p, **ap, *cmd; size_t len; glob_t pg; + setprogname(argv[0]); + setlocale(LC_ALL, ""); /* * parse command line... */ @@ -191,16 +197,16 @@ */ config(m.conffile);/* exits on error ... */ - if ((machine = getenv("MACHINE")) == NULL) { + if ((m.machine = getenv("MACHINE")) == NULL) { struct utsname utsname; - if (uname(&utsname) == -1) { - perror("uname"); - exit(EXIT_FAILURE); - } - machine = utsname.machine; + if (uname(&utsname) == -1) + err(EXIT_FAILURE, "uname"); + m.machine = utsname.machine; } + m.machclass = getclass(m.machine); + if (!m.cat && !m.how && !m.where) { /* if we need a pager ... */ if (!isatty(STDOUT_FILENO)) { m.cat = 1; @@ -315,38 +321,21 @@ len = strlen(p); if (len < 1) continue; - TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q) { -snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - p, (p[len-1] == '/') ? "" : "/", - esubd->s, machine); -if (addentry(m.mymanpath, buf, 0) < 0) - errx(EXIT_FAILURE, "malloc failed"); - } + TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q) +addpath(&m, p, len, esubd->s); } } else { TAILQ_FOREACH(epath, &m.defaultpath->entrylist, q) { /* handle trailing "/" magic here ... */ - if (abs_section && - epath->s[epath->len - 1] != '/') { - -(void)snprintf(buf, sizeof(buf), -"%s{/%s,}", epath->s, machine); -if (addentry(m.mymanpath, buf, 0) < 0) - errx(EXIT_FAILURE, "malloc failed"); + if (abs_section && epath->s[epath->len - 1] != '/') { +addpath(&m, "", 1, epath->s); continue; } - TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q) { -snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - epath->s, - (epath->s[epath->len-1] == '/') ? "" - : "/", - esubd->s, machine); -if (addentry(m.mymanpath, buf, 0) < 0) - errx(EXIT_FAILURE, "malloc failed"); - } + TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q) +addpath(&m, epath->s, epath->len, esubd->s); } } @@ -363,14 +352,8 @@ len = strlen(p); if (len < 1) continue; - TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q) { -snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - p, (p[len-1] == '/') ? "" : "/", - esubd->s, machine); -/* add at front */ -if (addentry(m.mymanpath, buf, 1) < 0) - errx(EXIT_FAILURE, "malloc failed"); - } + TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q) +addpath(&m, p, len, esubd->s); } } @@ -917,8 +900,7 @@ for (; *arg; ++arg) arg[0] = arg[1]; execvp(name, argv); - (void)fprintf(stderr, "%s: Command not found.\n", name); - exit(EXIT_FAILURE); + err(EXIT_FAILURE, "Cannot execute `%s'", name); } /* @@ -967,6 +949,28 @@ return rval; } +static const char * +getclass(const char *machine) +{ + char buf[BU
CVS commit: src/usr.bin/man
Module Name:src Committed By: cegger Date: Wed Oct 7 08:30:31 UTC 2009 Modified Files: src/usr.bin/man: man.1 man.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/man/man.1 cvs rdiff -u -r1.38 -r1.39 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.1 diff -u src/usr.bin/man/man.1:1.20 src/usr.bin/man/man.1:1.21 --- src/usr.bin/man/man.1:1.20 Thu Apr 13 21:10:44 2006 +++ src/usr.bin/man/man.1 Wed Oct 7 08:30:31 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: man.1,v 1.20 2006/04/13 21:10:44 wiz Exp $ +.\" $NetBSD: man.1,v 1.21 2009/10/07 08:30:31 cegger 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 April 10, 2006 +.Dd October 6, 2009 .Dt MAN 1 .Os .Sh NAME @@ -168,6 +168,17 @@ argument will be used as if specified by the .Ql Fl s option. +.Pp +If +.Ar name +is given with a full or relative path then +.Nm +interprets it as a file specification, so that you can do +.Nm +.Cm ./foo.5 +or even +.Nm +.Cm /cd/foo/bar.1.gz . .Sh ENVIRONMENT .Bl -tag -width MANPATHX .It Ev MACHINE Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.38 src/usr.bin/man/man.c:1.39 --- src/usr.bin/man/man.c:1.38 Tue Oct 6 06:43:15 2009 +++ src/usr.bin/man/man.c Wed Oct 7 08:30:31 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.38 2009/10/06 06:43:15 cegger Exp $ */ +/* $NetBSD: man.c,v 1.39 2009/10/07 08:30:31 cegger Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.38 2009/10/06 06:43:15 cegger Exp $"); +__RCSID("$NetBSD: man.c,v 1.39 2009/10/07 08:30:31 cegger Exp $"); #endif #endif /* not lint */ @@ -472,6 +472,39 @@ exit(cleanup()); } +static int +manual_find_buildkeyword(char *escpage, const char *fmt, + struct manstate *mp, glob_t *pg, size_t cnt) +{ + ENTRY *suffix; + int found; + char *p, buf[MAXPATHLEN]; + + found = 0; + /* Try the _build key words next. */ + TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) { + for (p = suffix->s; + *p != '\0' && !isspace((unsigned char)*p); + ++p) + continue; + if (*p == '\0') + continue; + + *p = '\0'; + (void)snprintf(buf, sizeof(buf), fmt, escpage, suffix->s); + if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { + if (!mp->where) +build_page(p + 1, &pg->gl_pathv[cnt], mp); + *p = ' '; + found = 1; + break; + } + *p = ' '; + } + + return found; +} + /* * manual -- * Search the manuals for the pages. @@ -510,6 +543,63 @@ *eptr = '\0'; + /* + * If 'page' is given with a full or relative path + * then interpret it as a file specification. + */ + if ((page[0] == '/') || (page[0] == '.')) { + /* check if file actually exists */ + (void)strlcpy(buf, escpage, sizeof(buf)); + error = glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg); + if (error != 0) { + if (error == GLOB_NOMATCH) { +goto notfound; + } else { +errx(EXIT_FAILURE, "glob failed"); + } + } + + if (pg->gl_matchc == 0) + goto notfound; + + /* clip suffix for the suffix check below */ + p = strrchr(escpage, '.'); + if (p && p[0] == '.' && isdigit((unsigned char)p[1])) + p[0] = '\0'; + + found = 0; + for (cnt = pg->gl_pathc - pg->gl_matchc; + cnt < pg->gl_pathc; ++cnt) + { + found = manual_find_buildkeyword(escpage, "%s%s", +mp, pg, cnt); + if (found) { +anyfound = 1; +if (!mp->all) { + /* Delete any other matches. */ + while (++cnt< pg->gl_pathc) + pg->gl_pathv[cnt] = ""; + break; +} +continue; + } + + /* It's not a man page, forget about it. */ + pg->gl_pathv[cnt] = ""; + } + + notfound: + if (!anyfound) { + if (addentry(mp->missinglist, page, 0) < 0) { +warn("malloc"); +(void)cleanup(); +exit(EXIT_FAILURE); + } + } + free(escpage); + return anyfound; + } + /* For each man directory in mymanpath ... */ TAILQ_FOREACH(mdir, &mp->mymanpath->entrylist, q) { @@ -576,28 +666,8 @@ goto next; /* Try the _build key words next. */ - found = 0; - TAILQ_FOREACH(suffix, &mp->buildlist->entrylist, q) { -for (p = suffix->s; -*p != '\0' && !isspace((unsigned char)*p); -++p) - continue; -if (*p == '\0') - continue; -*p = '\0';
CVS commit: src/usr.bin/man
Module Name:src Committed By: cegger Date: Tue Oct 6 06:43:15 UTC 2009 Modified Files: src/usr.bin/man: man.c Log Message: - use EXIT_FAILURE/EXIT_SUCCESS - whitespace nits - ansify cleanup()/usage() - remove pointless parenthesis on return To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/usr.bin/man/man.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/man/man.c diff -u src/usr.bin/man/man.c:1.37 src/usr.bin/man/man.c:1.38 --- src/usr.bin/man/man.c:1.37 Mon Jul 21 14:19:24 2008 +++ src/usr.bin/man/man.c Tue Oct 6 06:43:15 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: man.c,v 1.37 2008/07/21 14:19:24 lukem Exp $ */ +/* $NetBSD: man.c,v 1.38 2009/10/06 06:43:15 cegger Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -__RCSID("$NetBSD: man.c,v 1.37 2008/07/21 14:19:24 lukem Exp $"); +__RCSID("$NetBSD: man.c,v 1.38 2009/10/06 06:43:15 cegger Exp $"); #endif #endif /* not lint */ @@ -104,7 +104,6 @@ /* * prototypes */ -int main(int, char **); static void build_page(char *, char **, struct manstate *); static void cat(char *); static const char *check_pager(const char *); @@ -197,7 +196,7 @@ if (uname(&utsname) == -1) { perror("uname"); - exit(1); + exit(EXIT_FAILURE); } machine = utsname.machine; } @@ -220,7 +219,7 @@ m.section = gettag(m.sectionname, 0); /* -s must be a section */ if (m.section == NULL) - errx(1, "unknown section: %s", m.sectionname); + errx(EXIT_FAILURE, "unknown section: %s", m.sectionname); } else if (argc > 1) { @@ -252,7 +251,7 @@ m.intmp = gettag("_intmp", 1); if (!m.defaultpath || !m.subdirs || !m.suffixlist || !m.buildlist || !m.mymanpath || !m.missinglist || !m.intmp) - errx(1, "malloc failed"); + errx(EXIT_FAILURE, "malloc failed"); /* * are we using a section whose elements are all absolute paths? @@ -321,7 +320,7 @@ p, (p[len-1] == '/') ? "" : "/", esubd->s, machine); if (addentry(m.mymanpath, buf, 0) < 0) - errx(1, "malloc failed"); + errx(EXIT_FAILURE, "malloc failed"); } } @@ -335,7 +334,7 @@ (void)snprintf(buf, sizeof(buf), "%s{/%s,}", epath->s, machine); if (addentry(m.mymanpath, buf, 0) < 0) - errx(1, "malloc failed"); + errx(EXIT_FAILURE, "malloc failed"); continue; } @@ -346,7 +345,7 @@ : "/", esubd->s, machine); if (addentry(m.mymanpath, buf, 0) < 0) - errx(1, "malloc failed"); + errx(EXIT_FAILURE, "malloc failed"); } } @@ -370,7 +369,7 @@ esubd->s, machine); /* add at front */ if (addentry(m.mymanpath, buf, 1) < 0) - errx(1, "malloc failed"); + errx(EXIT_FAILURE, "malloc failed"); } } @@ -404,7 +403,7 @@ /* if nothing found, we're done. */ if (!found) { (void)cleanup(); - exit (1); + exit(EXIT_FAILURE); } /* @@ -416,7 +415,7 @@ continue; cat(*ap); } - exit (cleanup()); + exit(cleanup()); } if (m.how) { for (ap = pg.gl_pathv; *ap != NULL; ++ap) { @@ -448,7 +447,7 @@ if ((cmd = malloc(len)) == NULL) { warn("malloc"); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } /* now build the command string... */ @@ -495,7 +494,7 @@ if ((escpage = malloc((2 * strlen(page)) + 1)) == NULL) { warn("malloc"); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } p = page; @@ -526,7 +525,7 @@ else { warn("globbing"); (void)cleanup(); -exit(1); +exit(EXIT_FAILURE); } } if (pg->gl_matchc == 0) @@ -623,12 +622,12 @@ if (addentry(mp->missinglist, page, 0) < 0) { warn("malloc"); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } } free(escpage); - return (anyfound); + return anyfound; } /* @@ -701,7 +700,7 @@ if ((fd = mkstemp(tpath)) == -1) { warn("%s", tpath); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath); (void)snprintf(cmd, sizeof(cmd), buf, p); @@ -710,14 +709,14 @@ if ((*pathp = strdup(tpath)) == NULL) { warn("malloc"); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } /* Link the built file into the remove-when-done list. */ if (addentry(mp->intmp, *pathp, 0) < 0) { warn("malloc"); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } /* restore old directory so relative manpaths still work */ @@ -742,7 +741,7 @@ if (!(fp = fopen(fname, "r"))) { warn("%s", fname); (void)cleanup(); - exit (1); + exit(EXIT_FAILURE); } #define S1 "SYNOPSIS" #define S2 "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS" @@ -787,18 +786,18 @@ if ((fd = open(fname, O_RDONLY, 0)) < 0) { warn("%s", fname); (void)cleanup(); - exit(1); + exit(EXIT_FAILURE); } while ((n = read(fd, buf, sizeof(buf))) > 0) if (write(