CVS commit: src/usr.bin/man

2022-06-19 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Jun 19 18:51:06 UTC 2022

Modified Files:
src/usr.bin/man: man.conf.5

Log Message:
man.conf.5: improve wording on searching alternate machine paths

As requested by uwe@. Hopefully this is clearer now.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.



CVS commit: src/usr.bin/man

2022-06-19 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Jun 19 18:51:06 UTC 2022

Modified Files:
src/usr.bin/man: man.conf.5

Log Message:
man.conf.5: improve wording on searching alternate machine paths

As requested by uwe@. Hopefully this is clearer now.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/usr.bin/man/man.conf.5:1.30
--- src/usr.bin/man/man.conf.5:1.29	Sat Jun 18 13:41:12 2022
+++ src/usr.bin/man/man.conf.5	Sun Jun 19 18:51:06 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: man.conf.5,v 1.29 2022/06/18 13:41:12 uwe Exp $
+.\"	$NetBSD: man.conf.5,v 1.30 2022/06/19 18:51:06 gutteridge Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -170,11 +170,11 @@ Defines additional paths to be searched 
 hardware name whose literal value is taken from
 .Xr uname 1
 .Fl m .
-For example on an amd64,
+For example, on an amd64, the
 .Ic _amd64
 control keyword is used, where
 .Ql x86
-is commonly supplied as an alternate machine path to also search.
+is supplied by default as an alternate machine path to also search.
 .El
 .Pp
 Section configuration lines in



CVS commit: src/usr.bin/man

2022-06-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jun 18 13:41:12 UTC 2022

Modified Files:
src/usr.bin/man: man.conf.5

Log Message:
man.conf(5): Tweak formatting for prettier PS output.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.28 src/usr.bin/man/man.conf.5:1.29
--- src/usr.bin/man/man.conf.5:1.28	Sat Jun 18 02:19:07 2022
+++ src/usr.bin/man/man.conf.5	Sat Jun 18 13:41:12 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: man.conf.5,v 1.28 2022/06/18 02:19:07 gutteridge Exp $
+.\"	$NetBSD: man.conf.5,v 1.29 2022/06/18 13:41:12 uwe Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -64,14 +64,14 @@ section subdirectory contains unformatte
 and
 .Xr mdoc 7 ) .
 Formatted manual pages are normally named with a trailing
-.Dq \.0
+.Ql \&.0
 suffix.
 .Pp
 The
 .Nm
 file contains comment and configuration lines.
 Comment lines start with the
-.Dq #
+.Ql #
 character.
 Blank lines are also treated as comment lines.
 Configuration lines consist of a configuration keyword followed by a
@@ -79,31 +79,37 @@ configuration string.
 There are two types of configuration keywords: control keywords and
 section keywords.
 Control keywords must start with the
-.Dq _
+.Ql _
 character.
 The following control keywords are currently defined:
-.Bl -tag -width XXmachineX
-.It _build
+.Bl -tag -width Ic
+.It Ic _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
 them.
 Manual file names, regardless of their format, are expected to end in a
-.Dq \.*
+.Dq \&.*
 pattern, i.e. a
-.Dq \&\.
+.Ql \&.
 followed by some suffix.
-The first field of a _build line contains a man page suffix specification.
+The first field of a
+.Ic _build
+line contains a man page suffix specification.
 The suffix specification may contain the normal shell globbing characters
-(NOT including curly braces
-.Pq Dq {} ) .
-The rest of the _build line is a shell command line whose standard
+.Po
+.Em not
+including csh-style curly braces
+.Pc .
+The rest of the
+.Ic _build
+line is a shell command line whose standard
 output is a formatted manual page that can be directly displayed to
 the user.
 There should be exactly one occurrence of the string
-.Dq %s
+.Ql %s
 in the shell command line, and it will
 be replaced by the name of the file which is being formatted.
-.It _crunch
+.It Ic _crunch
 Used by
 .Xr catman 8
 to determine how to crunch formatted pages
@@ -113,29 +119,27 @@ 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
+.Ql %s
 in the shell command line, and it will
 be replaced by the name of the output file.
-.It _default
+.It Ic _default
 Contains the system-wide default man path used to search for man pages.
-.It _mandb
+.It Ic _mandb
 Defines the full pathname (not just a directory path) for a database to
-be used
-by the
+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 {} ;
+including csh-style curly braces;
 to escape a shell globbing character,
 precede it with a backslash
-.Pq Dq \e .
-.It _subdir
+.Pq Ql \e .
+.It Ic _subdir
 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 /
+.Pq Ql /
 character.
 This list is also used, even if there is no trailing slash character,
 when a path is specified to the
@@ -147,28 +151,29 @@ environment variable, or by the
 and
 .Fl m
 options.
-.It _suffix
+.It Ic _suffix
 identifies the set of suffixes used for formatted man pages
 (the
-.Dq \.0
+.Ql \&.0
 suffix is normally used here).
 Formatted man pages can be directly displayed to the user.
-Each suffix may contain the normal shell globbing characters (NOT
-including curly braces
-.Pq Dq {} ) .
-.It _version
+Each suffix may contain the normal shell globbing characters
+.Po
+.Em not
+including csh-style curly braces
+.Pc .
+.It Ic _version
 Contains the version of the configuration file.
-.It _ Ns Aq machine
+.It Ic _ Ns Aq Ar machine
 Defines additional paths to be searched for the particular
-.Dv machine
+.Ar machine
 hardware name whose literal value is taken from
 .Xr uname 1
 .Fl m .
-For example on an
-.Dv amd64 ,
-.Dv _amd64
-is used, where
-.Dq x86
+For example on an amd64,
+.Ic _amd64
+control keyword is used, where
+.Ql x86
 is commonly supplied as an alternate machine path to also search.
 .El
 .Pp
@@ -178,13 +183,12 @@ consist of a section keyword naming the 
 string that defines the directory or 

CVS commit: src/usr.bin/man

2022-06-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jun 18 13:41:12 UTC 2022

Modified Files:
src/usr.bin/man: man.conf.5

Log Message:
man.conf(5): Tweak formatting for prettier PS output.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.



Re: CVS commit: src/usr.bin/man

2022-06-18 Thread Valery Ushakov
On Sat, Jun 18, 2022 at 02:19:07 +, David H. Gutteridge wrote:

> Module Name:  src
> Committed By: gutteridge
> Date: Sat Jun 18 02:19:07 UTC 2022
> 
> Modified Files:
>   src/usr.bin/man: man.conf.5
> 
> Log Message:
> man.conf.5: add details about the machine line and search order
> 
> Also, tweak some grammar, style, and markup while here.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.27 -r1.28 src/usr.bin/man/man.conf.5

Please, could you rephrase the bit about the _ keyword.  It
is not quite clear on the first reading which is the keyword and which
is the value (epecially in text output where formatting (wrong anyway
:) doesn't provide a hint).  Using "value" to talk about the keyword
doesn't help too.  Also, "commonly" in the added phrase is misleading
I'd say.  Commonly implies "not always", which is false - we suppply
x86 as an extra subdir in the default man.conf.  I know that passage
was not very clear to begin with, but you touch it you buy it :).

Not being a native speaker I don't dare touching it, I'm afraid to
make more mess.

TIA!

-uwe


CVS commit: src/usr.bin/man

2022-06-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jun 18 02:19:07 UTC 2022

Modified Files:
src/usr.bin/man: man.conf.5

Log Message:
man.conf.5: add details about the machine line and search order

Also, tweak some grammar, style, and markup while here.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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.27 src/usr.bin/man/man.conf.5:1.28
--- src/usr.bin/man/man.conf.5:1.27	Thu Jun 16 15:11:43 2016
+++ src/usr.bin/man/man.conf.5	Sat Jun 18 02:19:07 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: man.conf.5,v 1.27 2016/06/16 15:11:43 abhinav Exp $
+.\"	$NetBSD: man.conf.5,v 1.28 2022/06/18 02:19:07 gutteridge 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 June 16, 2016
+.Dd June 18, 2022
 .Dt MAN.CONF 5
 .Os
 .Sh NAME
@@ -45,8 +45,9 @@ file contains the default configuration 
 .Xr catman 8 ,
 and
 .Xr makemandb 8
-to find manual pages and information about manual pages (e.g. the
-whatis database).
+to find manual pages and information about manual pages (e.g., the
+.Xr whatis 1
+database).
 .Pp
 Manual pages are located by searching an ordered set of directories
 called the
@@ -106,8 +107,9 @@ be replaced by the name of the file whic
 Used by
 .Xr catman 8
 to determine how to crunch formatted pages
-which originally were compressed man pages: The first field lists a suffix
-which indicates what kind of compression were used to compress the man page.
+which originally were compressed man pages.
+The first field lists a suffix which indicates what kind of compression was
+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
@@ -159,13 +161,15 @@ Contains the version of the configuratio
 .It _ Ns Aq machine
 Defines additional paths to be searched for the particular
 .Dv machine
-whose literal value is taken from
+hardware name whose literal value is taken from
 .Xr uname 1
 .Fl m .
 For example on an
 .Dv amd64 ,
 .Dv _amd64
-is used.
+is used, where
+.Dq x86
+is commonly supplied as an alternate machine path to also search.
 .El
 .Pp
 Section configuration lines in
@@ -184,7 +188,7 @@ Section keywords must not start with the
 character.
 .Pp
 A section path may contain either a list of absolute directories or
-a list of or relative directories (but not both).
+a list of relative directories (but not both).
 Relative directory paths are treated as a list of subdirectories that
 are appended to the current man path directory being searched.
 Section configuration lines with absolute directory paths (starting with
@@ -206,7 +210,8 @@ In addition to the above rules, the
 .Xr man 1
 command also always checks in each directory that it searches for
 a subdirectory with the same name as the current machine type.
-If the machine-specific directory is found, it is also searched.
+If a machine-specific subdirectory is found, it is also searched
+before the parent directory is.
 This allows the manual to contain machine-specific man pages.
 Note that the machine subdirectory does not need to be specified
 in the



CVS commit: src/usr.bin/man

2022-06-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jun 18 02:19:07 UTC 2022

Modified Files:
src/usr.bin/man: man.conf.5

Log Message:
man.conf.5: add details about the machine line and search order

Also, tweak some grammar, style, and markup while here.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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.



CVS commit: src/usr.bin/man

2022-06-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jun 18 02:14:39 UTC 2022

Modified Files:
src/usr.bin/man: man.1

Log Message:
man.1: add a small note about alternate machine name searches


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.



CVS commit: src/usr.bin/man

2022-06-17 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Jun 18 02:14:39 UTC 2022

Modified Files:
src/usr.bin/man: man.1

Log Message:
man.1: add a small note about alternate machine name searches


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/usr.bin/man/man.1:1.30
--- src/usr.bin/man/man.1:1.29	Thu Jun 16 15:10:58 2016
+++ src/usr.bin/man/man.1	Sat Jun 18 02:14:39 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: man.1,v 1.29 2016/06/16 15:10:58 abhinav Exp $
+.\"	$NetBSD: man.1,v 1.30 2022/06/18 02:14:39 gutteridge 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 16, 2016
+.Dd June 18, 2022
 .Dt MAN 1
 .Os
 .Sh NAME
@@ -213,7 +213,7 @@ As some man pages are intended only for 
 searches any subdirectories,
 with the same name as the current architecture,
 in every directory which it searches.
-Machine specific areas are checked before general areas.
+Machine-specific areas are checked before general areas.
 The current machine type may be overridden by setting the environment
 variable
 .Ev MACHINE
@@ -222,6 +222,12 @@ Machine-specific man pages may also be r
 prepending the relevant subdirectory name to the page name,
 separated by
 .Ql Pa \&/ .
+(See also the
+.Dq _ Ns Aq machine
+line in the
+.Xr man.conf 5
+configuration file, which defines additional supplemental paths related to a
+specific machine type.)
 .It Ev MANPATH
 The standard search path used by
 .Nm
@@ -235,7 +241,7 @@ The subdirectories to be searched as wel
 is specified by the
 .Dq _subdir
 line in the
-.Nm
+.Xr man.conf 5
 configuration file.
 .It Ev PAGER
 The pagination command used for writing the output.



CVS commit: src/usr.bin/man

2022-05-09 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue May 10 00:42:00 UTC 2022

Modified Files:
src/usr.bin/man: man.c

Log Message:
man.c: minor KNF


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 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.72 src/usr.bin/man/man.c:1.73
--- src/usr.bin/man/man.c:1.72	Tue Mar  8 23:13:05 2022
+++ src/usr.bin/man/man.c	Tue May 10 00:42:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.72 2022/03/08 23:13:05 rillig Exp $	*/
+/*	$NetBSD: man.c,v 1.73 2022/05/10 00:42:00 gutteridge 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.72 2022/03/08 23:13:05 rillig Exp $");
+__RCSID("$NetBSD: man.c,v 1.73 2022/05/10 00:42:00 gutteridge Exp $");
 #endif
 #endif /* not lint */
 
@@ -932,7 +932,7 @@ check_pager(const char *name)
 		++p;
 
 	/* make sure it's "more", not "morex" */
-	if (!strncmp(p, "more", 4) && (!p[4] || isspace((unsigned char)p[4]))){
+	if (!strncmp(p, "more", 4) && (!p[4] || isspace((unsigned char)p[4]))) {
 		char *newname;
 		(void)asprintf(, "%s %s", p, "-s");
 		name = newname;



CVS commit: src/usr.bin/man

2022-05-09 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue May 10 00:42:00 UTC 2022

Modified Files:
src/usr.bin/man: man.c

Log Message:
man.c: minor KNF


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 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.



Re: CVS commit: src/usr.bin/man

2022-03-10 Thread Roland Illig

Am 10.03.2022 um 22:48 schrieb David H. Gutteridge:

Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:13:05 UTC 2022

Modified Files:
 src/usr.bin/man: man.c

Log Message:
man: remove unused global variable 'instype' (since yesterday)

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.


Hi Roland,

Hardly the most pressing concern for us to discuss, but, the reason I'd
defined that global variable is because that's how NetBSD's "style"
document shows it's done in its enum example. I didn't think that was
necessary here, but took the "style" example literally.


Hi Dave,

I agree that taking the "style" example literally could lead to this
code, thank you for explaining how you arrived with this code.  In fact,
when I first saw your code I didn't realize that 'instype' was a
variable, I thought it would be a typedef name.  Only when I tried to
remove this unused name, the generated binary changed, which made me
cautious.

To avoid future misinterpretation, I fixed the enum example in
share/misc/style.


As for the other change you made (enum vs. int), I guess that's just bad
style on my part. I don't really work in C anymore, but when I did, in
my context, we treated enum and int as being interchangable. Good to
know.


I changed the parameter type from int to enum because this enables
stricter checks in the compilers and in lint.  They would report a
mismatch of enum types then.  The enum check in lint is not enabled by
default though, but still it is there (LINTFLAGS+= -e in the Makefile).

For usr.bin/man, there aren't many enum constants that could be
confused, but in other programs like usr.bin/make there are really many
of them, and 2 years ago there were even enum constants from different
types that used the same prefix "VAR_", which increased the confusion.
That's the reason that I prefer to be as specific with enum types as
possible.

Another benefit is that using 'enum' (or 'bool') instead of 'int'
communicates the purpose of the variable more precisely to human
readers, and I like this extra bit of precision.

Regards,
Roland


Re: CVS commit: src/usr.bin/man

2022-03-10 Thread David H. Gutteridge
> Module Name:src
> Committed By:   rillig
> Date:   Tue Mar  8 23:13:05 UTC 2022
> 
> Modified Files:
> src/usr.bin/man: man.c
> 
> Log Message:
> man: remove unused global variable 'instype' (since yesterday)
> 
> No functional change.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.71 -r1.72 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.

Hi Roland,

Hardly the most pressing concern for us to discuss, but, the reason I'd
defined that global variable is because that's how NetBSD's "style"
document shows it's done in its enum example. I didn't think that was
necessary here, but took the "style" example literally.

As for the other change you made (enum vs. int), I guess that's just bad
style on my part. I don't really work in C anymore, but when I did, in
my context, we treated enum and int as being interchangable. Good to
know.

Regards,

Dave



CVS commit: src/usr.bin/man

2022-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:13:05 UTC 2022

Modified Files:
src/usr.bin/man: man.c

Log Message:
man: remove unused global variable 'instype' (since yesterday)

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.71 src/usr.bin/man/man.c:1.72
--- src/usr.bin/man/man.c:1.71	Tue Mar  8 23:09:36 2022
+++ src/usr.bin/man/man.c	Tue Mar  8 23:13:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.71 2022/03/08 23:09:36 rillig Exp $	*/
+/*	$NetBSD: man.c,v 1.72 2022/03/08 23:13:05 rillig 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.71 2022/03/08 23:09:36 rillig Exp $");
+__RCSID("$NetBSD: man.c,v 1.72 2022/03/08 23:13:05 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -72,7 +72,7 @@ __RCSID("$NetBSD: man.c,v 1.71 2022/03/0
 enum inserttype {
 	INS_TAIL,
 	INS_HEAD
-} instype;
+};
 
 /*
  * manstate: structure collecting the current global state so we can



CVS commit: src/usr.bin/man

2022-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:13:05 UTC 2022

Modified Files:
src/usr.bin/man: man.c

Log Message:
man: remove unused global variable 'instype' (since yesterday)

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.



CVS commit: src/usr.bin/man

2022-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:09:36 UTC 2022

Modified Files:
src/usr.bin/man: man.c manconf.h

Log Message:
man: remove trailing whitespace

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/man/man.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/man/manconf.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.70 src/usr.bin/man/man.c:1.71
--- src/usr.bin/man/man.c:1.70	Tue Mar  8 23:05:32 2022
+++ src/usr.bin/man/man.c	Tue Mar  8 23:09:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.70 2022/03/08 23:05:32 rillig Exp $	*/
+/*	$NetBSD: man.c,v 1.71 2022/03/08 23:09:36 rillig 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.70 2022/03/08 23:05:32 rillig Exp $");
+__RCSID("$NetBSD: man.c,v 1.71 2022/03/08 23:09:36 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -75,7 +75,7 @@ enum inserttype {
 } instype;
 
 /*
- * manstate: structure collecting the current global state so we can 
+ * manstate: structure collecting the current global state so we can
  * easily identify it and pass it to helper functions in one arg.
  */
 struct manstate {
@@ -90,13 +90,13 @@ struct manstate {
 	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 */
 	TAG *suffixlist;	/* _suffix: for files that can be cat()'d */
 	TAG *buildlist;		/* _build: for files that must be built */
-	
+
 	/* tags for internal use */
 	TAG *intmp;		/* _intmp: tmp files we must cleanup */
 	TAG *missinglist;	/* _missing: pages we couldn't find */
@@ -246,8 +246,8 @@ main(int argc, char **argv)
 			argc--;
 		}
 
-	} 
-	
+	}
+
 	if (m.manpath == NULL)
 		m.manpath = getenv("MANPATH"); /* note: -M overrides getenv */
 
@@ -261,7 +261,7 @@ main(int argc, char **argv)
 	m.defaultpath = gettag("_default", 1);
 	m.subdirs = gettag("_subdir", 1);
 	m.suffixlist = gettag("_suffix", 1);
-	m.buildlist = gettag("_build", 1); 
+	m.buildlist = gettag("_build", 1);
 	/* internal use */
 	m.mymanpath = gettag("_new_path", 1);
 	m.missinglist = gettag("_missing", 1);
@@ -276,7 +276,7 @@ main(int argc, char **argv)
 	 * as config() will ensure that any additional entries will match
 	 * the first one.)
 	 */
-	abs_section = (m.section != NULL && 
+	abs_section = (m.section != NULL &&
 		!TAILQ_EMPTY(>entrylist) &&
 			*(TAILQ_FIRST(>entrylist)->s) == '/');
 
@@ -297,7 +297,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 
+	 * a section and that section's elements did not have
 	 * absolute paths.  in this case we use the section's
 	 * elements to override _subdir from the config file.
 	 *
@@ -312,10 +312,10 @@ main(int argc, char **argv)
 	 * go with the default.   in either case we need to append
 	 * the subdir and machine spec to each element of the path.
 	 *
-	 * for absolute section paths that come from the config file, 
-	 * we only append the subdir spec if the path ends in 
-	 * a '/' --- elements that do not end in '/' are assumed to 
-	 * not have subdirectories.  this is mainly for backward compat, 
+	 * for absolute section paths that come from the config file,
+	 * we only append the subdir spec if the path ends in
+	 * a '/' --- elements that do not end in '/' are assumed to
+	 * not have subdirectories.  this is mainly for backward compat,
 	 * but it allows non-subdir configs like:
 	 *	sect3   /usr/share/man/{old/,}cat3
 	 *	doc /usr/{pkg,share}/doc/{sendmail/op,sendmail/intro}
@@ -352,9 +352,9 @@ main(int argc, char **argv)
 	}
 
 	/*
-	 * [4] finally, prepend the "-m" m.addpath to mymanpath if it 
+	 * [4] finally, prepend the "-m" m.addpath to mymanpath if it
 	 * was specified.   subdirs and machine are always applied to
-	 * m.addpath. 
+	 * m.addpath.
 	 */
 	if (m.addpath) {
 
@@ -373,7 +373,7 @@ main(int argc, char **argv)
 		printmanpath();
 		exit(cleanup());
 	}
-		
+
 	/*
 	 * now m.mymanpath is complete!
 	 */
@@ -385,8 +385,8 @@ main(int argc, char **argv)
 #endif
 
 	/*
-	 * start searching for matching files and format them if necessary.   
-	 * setup an interrupt handler so that we can ensure that temporary 
+	 * start searching for matching files and format them if necessary.
+	 * setup an interrupt handler so that we can ensure that 

CVS commit: src/usr.bin/man

2022-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:09:36 UTC 2022

Modified Files:
src/usr.bin/man: man.c manconf.h

Log Message:
man: remove trailing whitespace

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/man/man.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/man/manconf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/man

2022-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:05:32 UTC 2022

Modified Files:
src/usr.bin/man: man.c

Log Message:
man: fix type mismatch between enum and int (since yesterday)

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 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.69 src/usr.bin/man/man.c:1.70
--- src/usr.bin/man/man.c:1.69	Mon Mar  7 22:43:39 2022
+++ src/usr.bin/man/man.c	Tue Mar  8 23:05:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.69 2022/03/07 22:43:39 gutteridge Exp $	*/
+/*	$NetBSD: man.c,v 1.70 2022/03/08 23:05:32 rillig 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.69 2022/03/07 22:43:39 gutteridge Exp $");
+__RCSID("$NetBSD: man.c,v 1.70 2022/03/08 23:05:32 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -122,7 +122,8 @@ static void	 jump(char **, const char *,
 static int	 manual(char *, struct manstate *, glob_t *);
 static void	 onsig(int) __dead;
 static void	 usage(void) __dead;
-static void	 addpath(struct manstate *, const char *, size_t, const char *, int);
+static void	 addpath(struct manstate *, const char *, size_t, const char *,
+		 enum inserttype);
 static const char *getclass(const char *);
 static void printmanpath(struct manstate *);
 
@@ -1018,14 +1019,14 @@ getclass(const char *machine)
 
 static void
 addpath(struct manstate *m, const char *dir, size_t len, const char *sub,
-	int ishead)
+	enum inserttype ishead)
 {
 	char buf[2 * MAXPATHLEN + 1];
 	(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,%s%s%s}",
 	 dir, (dir[len - 1] == '/') ? "" : "/", sub, m->machine,
 	 m->machclass ? "/" : "", m->machclass ? m->machclass : "",
 	 m->machclass ? "," : "");
-	if (addentry(m->mymanpath, buf, ishead) < 0)
+	if (addentry(m->mymanpath, buf, (int)ishead) < 0)
 		errx(EXIT_FAILURE, "malloc failed");
 }
 



CVS commit: src/usr.bin/man

2022-03-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  8 23:05:32 UTC 2022

Modified Files:
src/usr.bin/man: man.c

Log Message:
man: fix type mismatch between enum and int (since yesterday)

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 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.



CVS commit: src/usr.bin/man

2022-03-07 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Mon Mar  7 22:43:39 UTC 2022

Modified Files:
src/usr.bin/man: man.c

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 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.68 src/usr.bin/man/man.c:1.69
--- src/usr.bin/man/man.c:1.68	Mon Apr  6 19:53:22 2020
+++ src/usr.bin/man/man.c	Mon Mar  7 22:43:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.68 2020/04/06 19:53:22 maya Exp $	*/
+/*	$NetBSD: man.c,v 1.69 2022/03/07 22:43:39 gutteridge 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.68 2020/04/06 19:53:22 maya Exp $");
+__RCSID("$NetBSD: man.c,v 1.69 2022/03/07 22:43:39 gutteridge Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,6 +69,11 @@ __RCSID("$NetBSD: man.c,v 1.68 2020/04/0
 #define MAN_DEBUG 0		/* debug path output */
 #endif
 
+enum inserttype {
+	INS_TAIL,
+	INS_HEAD
+} instype;
+
 /*
  * manstate: structure collecting the current global state so we can 
  * easily identify it and pass it to helper functions in one arg.
@@ -117,7 +122,7 @@ static void	 jump(char **, const char *,
 static int	 manual(char *, struct manstate *, glob_t *);
 static void	 onsig(int) __dead;
 static void	 usage(void) __dead;
-static void	 addpath(struct manstate *, const char *, size_t, const char *);
+static void	 addpath(struct manstate *, const char *, size_t, const char *, int);
 static const char *getclass(const char *);
 static void printmanpath(struct manstate *);
 
@@ -327,7 +332,7 @@ main(int argc, char **argv)
 			if (len < 1)
 continue;
 			TAILQ_FOREACH(esubd, >entrylist, q)
-addpath(, p, len, esubd->s);
+addpath(, p, len, esubd->s, INS_TAIL);
 		}
 
 	} else {
@@ -335,12 +340,12 @@ main(int argc, char **argv)
 		TAILQ_FOREACH(epath, >entrylist, q) {
 			/* handle trailing "/" magic here ... */
 		  	if (abs_section && epath->s[epath->len - 1] != '/') {
-addpath(, "", 1, epath->s);
+addpath(, "", 1, epath->s, INS_TAIL);
 continue;
 			}
 
 			TAILQ_FOREACH(esubd, >entrylist, q)
-addpath(, epath->s, epath->len, esubd->s);
+addpath(, epath->s, epath->len, esubd->s, INS_TAIL);
 		}
 
 	}
@@ -358,7 +363,7 @@ main(int argc, char **argv)
 			if (len < 1)
 continue;
 			TAILQ_FOREACH(esubd, >entrylist, q)
-addpath(, p, len, esubd->s);
+addpath(, p, len, esubd->s, INS_HEAD); /* Add to front */
 		}
 
 	}
@@ -1012,14 +1017,15 @@ getclass(const char *machine)
 }
 
 static void
-addpath(struct manstate *m, const char *dir, size_t len, const char *sub)
+addpath(struct manstate *m, const char *dir, size_t len, const char *sub,
+	int ishead)
 {
 	char buf[2 * MAXPATHLEN + 1];
 	(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,%s%s%s}",
 	 dir, (dir[len - 1] == '/') ? "" : "/", sub, m->machine,
 	 m->machclass ? "/" : "", m->machclass ? m->machclass : "",
 	 m->machclass ? "," : "");
-	if (addentry(m->mymanpath, buf, 0) < 0)
+	if (addentry(m->mymanpath, buf, ishead) < 0)
 		errx(EXIT_FAILURE, "malloc failed");
 }
 



CVS commit: src/usr.bin/man

2022-03-07 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Mon Mar  7 22:43:39 UTC 2022

Modified Files:
src/usr.bin/man: man.c

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 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.



CVS commit: src/usr.bin/man

2020-04-06 Thread Maya Rashish
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();
+		exit(cleanup());
+	}
 		
 	/*
 	 * now m.mymanpath is complete!



CVS commit: src/usr.bin/man

2020-04-06 Thread Maya Rashish
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.



CVS commit: src/usr.bin/man

2018-06-15 Thread matthew green
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() == -1)
 			err(EXIT_FAILURE, "uname");
 		m.machine = utsname.machine;



CVS commit: src/usr.bin/man

2018-06-15 Thread matthew green
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.



CVS commit: src/usr.bin/man

2017-05-02 Thread Abhinav Upadhyay
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(>entrylist))
 		errx(EXIT_FAILURE, "Empty manpath");
 		
-	defaultpath = TAILQ_LAST(>entrylist, tqh)->s;
-	
-	if (glob(defaultpath, GLOB_BRACE | GLOB_NOSORT, NULL, ) != 0)
-		err(EXIT_FAILURE, "glob failed");
-
-	if (pg.gl_matchc == 0) {
-		warnx("Default path in %s doesn't exist", _PATH_MANCONF);
-		globfree();
-		return;
-	}
+	TAILQ_FOREACH(epath, >entrylist, q) {
+		if (glob(epath->s, GLOB_BRACE | GLOB_NOSORT, NULL, ) != 0)
+			err(EXIT_FAILURE, "glob failed");
 
-	TAILQ_FOREACH(esubd, >entrylist, q) {
-		/* Drop cat page directory, only sources are relevant. */
-		if (strncmp(esubd->s, "man", 3))
+		if (pg.gl_matchc == 0) {
+			globfree();
 			continue;
+		}
 
 		for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
-			if (asprintf(, "%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, ) == 0 && S_ISDIR(sb.st_mode))
-printf("%s\n", buf);
-
-			free(buf);
+			if (stat(*ap, ) == 0 && S_ISDIR(sb.st_mode))
+printf("%s\n", *ap);
 		}
+		globfree();
 	}
-	globfree();
 }



CVS commit: src/usr.bin/man

2017-05-02 Thread Abhinav Upadhyay
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.



CVS commit: src/usr.bin/man

2017-04-27 Thread Abhinav Upadhyay
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.



CVS commit: src/usr.bin/man

2017-04-27 Thread Abhinav Upadhyay
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

2016-06-16 Thread Abhinav Upadhyay
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

2016-06-16 Thread Abhinav Upadhyay
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.



CVS commit: src/usr.bin/man

2016-06-16 Thread Abhinav Upadhyay
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

2016-06-16 Thread Abhinav Upadhyay
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.



CVS commit: src/usr.bin/man

2016-05-21 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2016-05-21 Thread Christos Zoulas
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

2016-05-21 Thread Abhinav Upadhyay
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.



CVS commit: src/usr.bin/man

2016-05-21 Thread Abhinav Upadhyay
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

2015-04-07 Thread Iain Hibbert
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.



CVS commit: src/usr.bin/man

2015-04-07 Thread Iain Hibbert
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

2015-03-03 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2015-03-03 Thread Christos Zoulas
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



re: CVS commit: src/usr.bin/man

2014-08-14 Thread matthew green

Alan Barrett writes:
 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.

what about trying to stat() it and use it, as a last resort?
it's always kind of bothered me man file.1 doesn't work,
and the ./ workaround always seems sleezy.


.mrg.


CVS commit: src/usr.bin/man

2014-08-14 Thread Alan Barrett
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

2014-08-14 Thread Alan Barrett
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

2014-08-14 Thread Alan Barrett
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.



CVS commit: src/usr.bin/man

2014-08-14 Thread Alan Barrett
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.



CVS commit: src/usr.bin/man

2014-02-16 Thread Valeriy E. Ushakov
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

2014-02-16 Thread Valeriy E. Ushakov
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

2014-02-16 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2014-02-16 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-10-28 Thread Christos Zoulas
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

2013-10-06 Thread Christos Zoulas
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

2013-10-06 Thread Christos Zoulas
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

2013-10-06 Thread Christos Zoulas
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

2013-10-06 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2013-10-06 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2013-10-06 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2013-07-30 Thread Joerg Sonnenberger
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

2013-07-30 Thread Joerg Sonnenberger
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.



Re: CVS commit: src/usr.bin/man

2013-07-18 Thread Valery Ushakov
On Thu, Jul 18, 2013 at 11:39:08 -0400, Christos Zoulas wrote:

 - fix cast qual issues

Do you really need EMPTY hack?  Why not just (untested)

- pg-gl_pathv[cnt] = ;
+ *pg-gl_pathv[cnt] = '\0';

-uwe


Re: CVS commit: src/usr.bin/man

2013-07-18 Thread Valery Ushakov
On Thu, Jul 18, 2013 at 11:39:08 -0400, Christos Zoulas wrote:

 - don't use snprintf on a user-provided buffer

This:

- (void)snprintf(buf, sizeof(buf), fmt, escpage, suffix-s);
+ fixstring(buf, sizeof(buf), fmt, escpage);

seems wrong, as it loses suffix-s, doesn't it?

And fixstring is a terrible name.

-uwe


CVS commit: src/usr.bin/man

2013-07-18 Thread Christos Zoulas
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 = strdup(tpath)) == NULL) {
@@ -842,7 +860,8 @@ 

CVS commit: src/usr.bin/man

2013-07-18 Thread Christos Zoulas
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

2013-07-18 Thread Christos Zoulas
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

2013-07-18 Thread Valeriy E. Ushakov
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

2013-07-18 Thread Valeriy E. Ushakov
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

2013-07-18 Thread Valeriy E. Ushakov
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

2013-07-18 Thread Valeriy E. Ushakov
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

2013-07-18 Thread Valeriy E. Ushakov
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

2013-07-18 Thread Valeriy E. Ushakov
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

2013-07-18 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2013-07-18 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-18 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-18 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-18 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-18 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-17 Thread Valeriy E. Ushakov
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

2013-07-17 Thread Valeriy E. Ushakov
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

2013-07-17 Thread Valeriy E. Ushakov
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

2013-07-17 Thread Valeriy E. Ushakov
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

2013-07-17 Thread Valeriy E. Ushakov
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

2013-07-17 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-17 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-07-17 Thread Valeriy E. Ushakov
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.



CVS commit: src/usr.bin/man

2013-06-28 Thread Thomas Klausner
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

2013-06-28 Thread Thomas Klausner
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.



CVS commit: src/usr.bin/man

2013-06-27 Thread Julian Fagir
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

2013-06-27 Thread Julian Fagir
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.



CVS commit: src/usr.bin/man

2012-04-28 Thread Christos Zoulas
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

2012-04-28 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/man

2012-01-03 Thread Joerg Sonnenberger
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

2012-01-03 Thread Joerg Sonnenberger
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.



CVS commit: src/usr.bin/man

2011-12-27 Thread Alan Barrett
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.



CVS commit: src/usr.bin/man

2011-10-07 Thread Marc Balmer
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

2011-10-07 Thread Marc Balmer
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.



CVS commit: src/usr.bin/man

2011-06-14 Thread Joerg Sonnenberger
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 sys/param.h
 #include sys/queue.h
+#include sys/stat.h
 #include sys/utsname.h
 
 #include ctype.h
@@ -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

2011-06-14 Thread Thomas Klausner
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

2011-06-14 Thread Joerg Sonnenberger
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.



CVS commit: src/usr.bin/man

2011-06-14 Thread Thomas Klausner
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.



CVS commit: src/usr.bin/man

2010-07-07 Thread Christos Zoulas
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



  1   2   >