source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: implement -C (alternative config file) for apropos(1) and
@ 2011-12-12  2:00 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2011-12-12  2:00 UTC (permalink / raw)
  To: source

Log Message:
-----------
implement -C (alternative config file) for apropos(1) and mandocdb(8),
including various tweaks to the whatis(8) manual;
ok kristaps@

Modified Files:
--------------
    mdocml:
        apropos.1
        apropos.c
        catman.c
        cgi.c
        mandocdb.8
        mandocdb.c
        manpath.c
        manpath.h
        whatis.1

Revision Data
-------------
Index: mandocdb.8
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.8,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lmandocdb.8 -Lmandocdb.8 -u -p -r1.11 -r1.12
--- mandocdb.8
+++ mandocdb.8
@@ -23,7 +23,10 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl av
-.Op Ar dir ...
+.Op Fl C Ar file
+.Nm
+.Op Fl av
+.Ar dir ...
 .Nm
 .Op Fl v
 .Fl d Ar dir
@@ -69,10 +72,16 @@ uses the default paths stipulated by
 .Xr man 1 .
 .Pp
 The arguments are as follows:
-.Bl -tag -width Ds
+.Bl -tag -width "-C file"
 .It Fl a
 Use all directories and files found below
 .Ar dir ... .
+.It Fl C Ar file
+Specify an alternative configuration
+.Ar file
+in
+.Xr man.conf 5
+format.
 .It Fl d Ar dir
 Merge (remove and re-add)
 .Ar
@@ -141,7 +150,7 @@ length plus one) mapping to a 12-byte bi
 64-bit keyword type and 32-bit source
 .Sx Index Database
 record number, both in network-byte order.
-The typet bit-mask consists of the following
+The type bit-mask consists of the following
 values mapping into
 .Xr mdoc 7
 macro identifiers:
@@ -208,6 +217,10 @@ keyword database mapping keywords to a t
 A
 .Xr recno 3
 database of indexed file-names.
+.It Pa /etc/man.conf
+The default
+.Xr man 1
+configuration file.
 .El
 .Sh EXIT STATUS
 The
@@ -249,9 +262,12 @@ This usually indicates database corrupti
 arguments.
 .El
 .Sh SEE ALSO
+.Xr apropos 1 ,
 .Xr man 1 ,
+.Xr whatis 1 ,
 .Xr btree 3 ,
-.Xr recno 3
+.Xr recno 3 ,
+.Xr man.conf 5
 .Sh AUTHORS
 The
 .Nm
Index: manpath.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/manpath.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lmanpath.c -Lmanpath.c -u -p -r1.4 -r1.5
--- manpath.c
+++ manpath.c
@@ -36,7 +36,8 @@
 static	void	 manpath_add(struct manpaths *, const char *);
 
 void
-manpath_parse(struct manpaths *dirs, char *defp, char *auxp)
+manpath_parse(struct manpaths *dirs, const char *file,
+		char *defp, char *auxp)
 {
 
 	manpath_parseline(dirs, auxp);
@@ -45,7 +46,7 @@ manpath_parse(struct manpaths *dirs, cha
 		defp = getenv("MANPATH");
 
 	if (NULL == defp)
-		manpath_parseconf(dirs);
+		manpath_parseconf(dirs, file);
 	else
 		manpath_parseline(dirs, defp);
 }
@@ -91,7 +92,7 @@ manpath_add(struct manpaths *dirs, const
 }
 
 void
-manpath_parseconf(struct manpaths *dirs)
+manpath_parseconf(struct manpaths *dirs, const char *file)
 {
 #ifdef	USE_MANPATH
 	FILE		*stream;
@@ -124,7 +125,7 @@ manpath_parseconf(struct manpaths *dirs)
 	free(buf);
 	pclose(stream);
 #else
-	manpath_manconf(MAN_CONF_FILE, dirs);
+	manpath_manconf(dirs, file ? file : MAN_CONF_FILE);
 #endif
 }
 
@@ -140,7 +141,7 @@ manpath_free(struct manpaths *p)
 }
 
 void
-manpath_manconf(const char *file, struct manpaths *dirs)
+manpath_manconf(struct manpaths *dirs, const char *file)
 {
 	FILE		*stream;
 	char		*p, *q;
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lcgi.c -Lcgi.c -u -p -r1.29 -r1.30
--- cgi.c
+++ cgi.c
@@ -792,7 +792,7 @@ pg_show(const struct req *req, char *pat
 	}
 
 	memset(&ps, 0, sizeof(struct manpaths));
-	manpath_manconf("etc/catman.conf", &ps);
+	manpath_manconf(&ps, "etc/catman.conf");
 
 	if (vol >= (unsigned int)ps.sz) {
 		resp_error400();
@@ -878,7 +878,7 @@ pg_search(const struct req *req, char *p
 	}
 
 	memset(&ps, 0, sizeof(struct manpaths));
-	manpath_manconf("etc/catman.conf", &ps);
+	manpath_manconf(&ps, "etc/catman.conf");
 
 	/*
 	 * Poor man's tokenisation: just break apart by spaces.
Index: apropos.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -Lapropos.c -Lapropos.c -u -p -r1.23 -r1.24
--- apropos.c
+++ apropos.c
@@ -44,6 +44,7 @@ main(int argc, char *argv[])
 	struct opts	 opts;
 	struct expr	*e;
 	char		*defpaths, *auxpaths;
+	char		*conf_file;
 	extern int	 optind;
 	extern char	*optarg;
 
@@ -59,10 +60,14 @@ main(int argc, char *argv[])
 	memset(&opts, 0, sizeof(struct opts));
 
 	auxpaths = defpaths = NULL;
+	conf_file = NULL;
 	e = NULL;
 
-	while (-1 != (ch = getopt(argc, argv, "M:m:S:s:")))
+	while (-1 != (ch = getopt(argc, argv, "C:M:m:S:s:")))
 		switch (ch) {
+		case ('C'):
+			conf_file = optarg;
+			break;
 		case ('M'):
 			defpaths = optarg;
 			break;
@@ -88,7 +93,7 @@ main(int argc, char *argv[])
 
 	rc = 0;
 
-	manpath_parse(&paths, defpaths, auxpaths);
+	manpath_parse(&paths, conf_file, defpaths, auxpaths);
 
 	e = whatis ? termcomp(argc, argv, &terms) :
 		     exprcomp(argc, argv, &terms);
@@ -142,10 +147,11 @@ usage(void)
 {
 
 	fprintf(stderr, "usage: %s "
+			"[-C file] "
 			"[-M manpath] "
 			"[-m manpath] "
 			"[-S arch] "
 			"[-s section] "
-			"expression...\n",
+			"expression ...\n",
 			progname);
 }
Index: apropos.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos.1,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lapropos.1 -Lapropos.1 -u -p -r1.12 -r1.13
--- apropos.1
+++ apropos.1
@@ -22,11 +22,12 @@
 .Nd search manual page databases
 .Sh SYNOPSIS
 .Nm
+.Op Fl C Ar file
 .Op Fl M Ar manpath
 .Op Fl m Ar manpath
 .Op Fl S Ar arch
 .Op Fl s Ar section
-.Ar expression...
+.Ar expression ...
 .Sh DESCRIPTION
 The
 .Nm
@@ -37,6 +38,12 @@ evaluating on
 for each file in each database.
 Its arguments are as follows:
 .Bl -tag -width Ds
+.It Fl C Ar file
+Specify an alternative configuration
+.Ar file
+in
+.Xr man.conf 5
+format.
 .It Fl M Ar manpath
 Use the colon-separated path instead of the default list of paths
 searched for
@@ -237,6 +244,21 @@ manual databases.
 Invalid paths, or paths without manual databases, are ignored.
 Overridden by
 .Fl M .
+.El
+.Sh FILES
+.Bl -tag -width "/etc/man.conf" -compact
+.It Pa mandoc.db
+name of the
+.Xr mandocdb 8
+keyword database
+.It Pa mandoc.index
+name of the
+.Xr mandocdb 8
+filename database
+.It Pa /etc/man.conf
+default
+.Xr man 1
+configuration file
 .El
 .Sh EXIT STATUS
 .Ex -std
Index: catman.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/catman.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lcatman.c -Lcatman.c -u -p -r1.4 -r1.5
--- catman.c
+++ catman.c
@@ -112,7 +112,7 @@ main(int argc, char *argv[])
 	}
 
 	memset(&dirs, 0, sizeof(struct manpaths));
-	manpath_parse(&dirs, base, aux);
+	manpath_parse(&dirs, NULL, base, aux);
 	ch = manup(&dirs, buf);
 	manpath_free(&dirs);
 	return(ch ? EXIT_SUCCESS : EXIT_FAILURE);
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.33 -r1.34
--- mandocdb.c
+++ mandocdb.c
@@ -273,6 +273,7 @@ main(int argc, char *argv[])
 	struct manpaths	 dirs;
 	enum op		 op; /* current operation */
 	const char	*dir;
+	char		*conf_file;
 	char		*cp;
 	char		 pbuf[PATH_MAX],
 			 ibuf[MAXPATHLEN], /* index fname */
@@ -312,12 +313,16 @@ main(int argc, char *argv[])
 	maxrec = 0;
 	op = OP_NEW;
 	dir = NULL;
+	conf_file = NULL;
 
-	while (-1 != (ch = getopt(argc, argv, "ad:u:v")))
+	while (-1 != (ch = getopt(argc, argv, "aC:d:u:v")))
 		switch (ch) {
 		case ('a'):
 			use_all = 1;
 			break;
+		case ('C'):
+			conf_file = optarg;
+			break;
 		case ('d'):
 			dir = optarg;
 			op = OP_UPDATE;
@@ -426,7 +431,7 @@ main(int argc, char *argv[])
 			dirs.paths[i] = mandoc_strdup(cp);
 		}
 	} else
-		manpath_parse(&dirs, NULL, NULL);
+		manpath_parse(&dirs, conf_file, NULL, NULL);
 
 	for (i = 0; i < dirs.sz; i++) {
 		ibuf[0] = fbuf[0] = '\0';
@@ -1660,7 +1665,8 @@ usage(void)
 {
 
 	fprintf(stderr, "usage: %s [-v] "
-			"[-d dir [files...] |"
-			" -u dir [files...] |"
-			" dir...]\n", progname);
+			"[-C file] |"
+			" dir ... |"
+			" -d dir [file ...] |"
+			" -u dir [file ...]\n", progname);
 }
Index: manpath.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/manpath.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lmanpath.h -Lmanpath.h -u -p -r1.3 -r1.4
--- manpath.h
+++ manpath.h
@@ -29,9 +29,9 @@ struct	manpaths {
 
 __BEGIN_DECLS
 
-void	 manpath_manconf(const char *, struct manpaths *);
-void	 manpath_parse(struct manpaths *, char *, char *);
-void	 manpath_parseconf(struct manpaths *);
+void	 manpath_manconf(struct manpaths *, const char *);
+void	 manpath_parse(struct manpaths *, const char *, char *, char *);
+void	 manpath_parseconf(struct manpaths *, const char *);
 void	 manpath_parseline(struct manpaths *, char *);
 void	 manpath_free(struct manpaths *);
 
Index: whatis.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/whatis.1,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lwhatis.1 -Lwhatis.1 -u -p -r1.3 -r1.4
--- whatis.1
+++ whatis.1
@@ -19,32 +19,47 @@
 .Os
 .Sh NAME
 .Nm whatis
-.Nd search manual page databases
+.Nd search for manual pages by page names
 .Sh SYNOPSIS
 .Nm
+.Op Fl C Ar file
 .Op Fl M Ar manpath
 .Op Fl m Ar manpath
 .Op Fl S Ar arch
 .Op Fl s Ar section
-.Ar term...
+.Ar name ...
 .Sh DESCRIPTION
 The
 .Nm
-utility searches for manuals named or described with
-.Ar term
-in manual page databases generated by
-.Xr mandocdb 8 .
-Its arguments are as follows:
+utility searches databases generated by
+.Xr mandocdb 8
+for manuals containing the word
+.Ar name
+in their page name, ignoring case.
+It returns the header lines from all matching pages.
+You can then use the
+.Xr man 1
+command to get more information.
+.Pp
+The options are as follows:
 .Bl -tag -width Ds
+.It Fl C Ar file
+Specify an alternative configuration
+.Ar file
+in
+.Xr man.conf 5
+format.
 .It Fl M Ar manpath
-Use the colon-separated path instead of the default list of paths
-searched for
+Use the colon-separated
+.Ar manpath
+instead of the default list of paths searched for
 .Xr mandocdb 8
 databases.
 Invalid paths, or paths without manual databases, are ignored.
 .It Fl m Ar manpath
-Prepend the colon-separated paths to the list of paths searched
-for
+Prepend the colon-separated
+.Ar manpath
+to the list of paths searched for
 .Xr mandocdb 8
 databases.
 Invalid paths, or paths without manual databases, are ignored.
@@ -102,16 +117,44 @@ Invalid paths, or paths without manual d
 Overridden by
 .Fl M .
 .El
-.\" .Sh FILES
+.Sh FILES
+.Bl -tag -width "/etc/man.conf" -compact
+.It Pa mandoc.db
+name of the
+.Xr mandocdb 8
+keyword database
+.It Pa mandoc.index
+name of the
+.Xr mandocdb 8
+filename database
+.It Pa /etc/man.conf
+default
+.Xr man 1
+configuration file
+.El
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO
 .Xr apropos 1 ,
 .Xr man 1 ,
+.Xr man.conf 5 ,
 .Xr mandocdb 8
-.Sh AUTHORS
+.Sh HISTORY
 The
 .Nm
-utility was written by
+utility first appeared in
+.Bx 2 .
+It was rewritten from scratch as part of the
+.Xr mandocdb 8
+project for
+.Ox 5.1 .
+.Sh AUTHORS
+.An -nosplit
+.An Bill Joy
+wrote the original
+.Bx
+.Nm
+in 1979.
+The current version was written by
 .An Kristaps Dzonsons ,
 .Mt kristaps@bsd.lv .
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-12  2:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-12  2:00 mdocml: implement -C (alternative config file) for apropos(1) and schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).