source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Support leading, trailing and double colons in MANPATH to
@ 2011-12-24 22:37 kristaps
  2011-12-25  0:14 ` Kristaps Dzonsons
  0 siblings, 1 reply; 2+ messages in thread
From: kristaps @ 2011-12-24 22:37 UTC (permalink / raw)
  To: source

Log Message:
-----------
Support leading, trailing and double colons in MANPATH to prepend,
append or insert the man.conf(5) default path; compatible with GNU
manpath(1), implementation by kristaps@, heavily tweaked by schwarze@.

Updates to MANPATH documentation applied to whatis.1, apropos.1, and
catman.8 also.

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

Revision Data
-------------
Index: catman.8
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/catman.8,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lcatman.8 -Lcatman.8 -u -p -r1.3 -r1.4
--- catman.8
+++ catman.8
@@ -80,11 +80,22 @@ is specified, all files are updated.
 .Sh ENVIRONMENT
 .Bl -tag -width Ds
 .It Ev MANPATH
-Colon-separated paths overriding the default list of paths searched for
+Colon-separated paths modifying the default list of paths searched for
 manual databases.
 Invalid paths, or paths without manual databases, are ignored.
 Overridden by
 .Fl M .
+If
+.Ev MANPATH
+begins with a
+.Sq \&: ,
+it is appended to the default list;
+else if it ends with
+.Sq \&: ,
+it is prepended to the default list; else if it contains
+.Sq \&:: ,
+the default list is inserted between the colons.
+If none of these conditions are met, it overrides the default list.
 .El
 .Sh EXIT STATUS
 .Ex -std
Index: manpath.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/manpath.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lmanpath.c -Lmanpath.c -u -p -r1.7 -r1.8
--- manpath.c
+++ manpath.c
@@ -87,15 +87,54 @@ manpath_parse(struct manpaths *dirs, con
 	free(buf);
 	pclose(stream);
 #else
-	manpath_parseline(dirs, auxp);
+	char		*insert;
 
-	if (NULL == defp)
-		defp = getenv("MANPATH");
+	/* Always prepend -m. */
+ 	manpath_parseline(dirs, auxp);
+ 
+	/* If -M is given, it overrides everything else. */
+	if (NULL != defp) {
+		manpath_parseline(dirs, defp);
+		return;
+	}
+
+	/* MANPATH and man.conf(5) cooperate. */
+	defp = getenv("MANPATH");
+	if (NULL == file)
+		file = MAN_CONF_FILE;
+
+	/* No MANPATH; use man.conf(5) only. */
+	if (NULL == defp || '\0' == defp[0]) {
+		manpath_manconf(dirs, file);
+		return;
+	}
+
+	/* Prepend man.conf(5) to MANPATH. */
+	if (':' == defp[0]) {
+		manpath_manconf(dirs, file);
+		manpath_parseline(dirs, defp);
+		return;
+	}
+
+	/* Append man.conf(5) to MANPATH. */
+	if (':' == defp[(int)strlen(defp) - 1]) {
+		manpath_parseline(dirs, defp);
+		manpath_manconf(dirs, file);
+		return;
+	}
 
-	if (NULL == defp)
-		manpath_manconf(dirs, file ? file : MAN_CONF_FILE);
-	else
+	/* Insert man.conf(5) into MANPATH. */
+	insert = strstr(defp, "::");
+	if (NULL != insert) {
+		*insert++ = '\0';
 		manpath_parseline(dirs, defp);
+		manpath_manconf(dirs, file);
+		manpath_parseline(dirs, insert + 1);
+		return;
+	}
+
+	/* MANPATH overrides man.conf(5) completely. */
+	manpath_parseline(dirs, defp);
 #endif
 }
 
Index: apropos.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos.1,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lapropos.1 -Lapropos.1 -u -p -r1.13 -r1.14
--- apropos.1
+++ apropos.1
@@ -239,11 +239,22 @@ Text production:
 .Sh ENVIRONMENT
 .Bl -tag -width Ds
 .It Ev MANPATH
-Colon-separated paths overriding the default list of paths searched for
+Colon-separated paths modifying the default list of paths searched for
 manual databases.
 Invalid paths, or paths without manual databases, are ignored.
 Overridden by
 .Fl M .
+If
+.Ev MANPATH
+begins with a
+.Sq \&: ,
+it is appended to the default list;
+else if it ends with
+.Sq \&: ,
+it is prepended to the default list; else if it contains
+.Sq \&:: ,
+the default list is inserted between the colons.
+If none of these conditions are met, it overrides the default list.
 .El
 .Sh FILES
 .Bl -tag -width "/etc/man.conf" -compact
Index: whatis.1
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/whatis.1,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lwhatis.1 -Lwhatis.1 -u -p -r1.4 -r1.5
--- whatis.1
+++ whatis.1
@@ -111,11 +111,22 @@ as follows:
 .Sh ENVIRONMENT
 .Bl -tag -width Ds
 .It Ev MANPATH
-Colon-separated paths overriding the default list of paths searched for
+Colon-separated paths modifying the default list of paths searched for
 manual databases.
 Invalid paths, or paths without manual databases, are ignored.
 Overridden by
 .Fl M .
+If
+.Ev MANPATH
+begins with a
+.Sq \&: ,
+it is appended to the default list;
+else if it ends with
+.Sq \&: ,
+it is prepended to the default list; else if it contains
+.Sq \&:: ,
+the default list is inserted between the colons.
+If none of these conditions are met, it overrides the default list.
 .El
 .Sh FILES
 .Bl -tag -width "/etc/man.conf" -compact
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: mdocml: Support leading, trailing and double colons in MANPATH to
  2011-12-24 22:37 mdocml: Support leading, trailing and double colons in MANPATH to kristaps
@ 2011-12-25  0:14 ` Kristaps Dzonsons
  0 siblings, 0 replies; 2+ messages in thread
From: Kristaps Dzonsons @ 2011-12-25  0:14 UTC (permalink / raw)
  To: source

> Log Message:
> -----------
> Support leading, trailing and double colons in MANPATH to prepend,
> append or insert the man.conf(5) default path; compatible with GNU
> manpath(1), implementation by kristaps@, heavily tweaked by schwarze@.

Quick note: manpath(1) isn't a GNU utility, it's a generic one supplied 
in man-db (http://man-db.nongnu.org/) and the regular man package 
(http://primates.ximian.com/~flucifredi/man/).
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-25  0:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-24 22:37 mdocml: Support leading, trailing and double colons in MANPATH to kristaps
2011-12-25  0:14 ` Kristaps Dzonsons

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).