source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Do not let the -m option or MANPATH with leading, trailing, or
@ 2015-05-07 12:08 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-05-07 12:08 UTC (permalink / raw)
  To: source

Log Message:
-----------
Do not let the -m option or MANPATH with leading, trailing, or double
colon override the default manpath, let them add to the default manpath.
Only override the default manpath by the -M option, by MANPATH without
leading, trailing, or double colon, or by "manpath" in man.conf(5).

Problem reported by Jan Stary <hans at stare dot cz>.
Patch OK'ed by millert@.

Modified Files:
--------------
    mdocml:
        manpath.c

Revision Data
-------------
Index: manpath.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/manpath.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -Lmanpath.c -Lmanpath.c -u -p -r1.24 -r1.25
--- manpath.c
+++ manpath.c
@@ -84,7 +84,6 @@ manconf_parse(struct manconf *conf, cons
 	free(buf);
 	pclose(stream);
 #else
-	char		 manpath_default[] = MANPATH_DEFAULT;
 	char		*insert;
 
 	/* Always prepend -m. */
@@ -104,8 +103,6 @@ manconf_parse(struct manconf *conf, cons
 	/* No MANPATH; use man.conf(5) only. */
 	if (NULL == defp || '\0' == defp[0]) {
 		manconf_file(conf, file);
-		if (conf->manpath.sz == 0)
-			manpath_parseline(&conf->manpath, manpath_default, 0);
 		return;
 	}
 
@@ -210,13 +207,14 @@ static void
 manconf_file(struct manconf *conf, const char *file)
 {
 	const char *const toks[] = { "manpath", "output", "_whatdb" };
+	char manpath_default[] = MANPATH_DEFAULT;
 
 	FILE		*stream;
 	char		*cp, *ep;
 	size_t		 len, tok;
 
 	if ((stream = fopen(file, "r")) == NULL)
-		return;
+		goto out;
 
 	while ((cp = fgetln(stream, &len)) != NULL) {
 		ep = cp + len;
@@ -250,6 +248,7 @@ manconf_file(struct manconf *conf, const
 			/* FALLTHROUGH */
 		case 0:  /* manpath */
 			manpath_add(&conf->manpath, cp, 0);
+			*manpath_default = '\0';
 			break;
 		case 1:  /* output */
 			manconf_output(&conf->output, cp);
@@ -258,8 +257,11 @@ manconf_file(struct manconf *conf, const
 			break;
 		}
 	}
-
 	fclose(stream);
+
+out:
+	if (*manpath_default != '\0')
+		manpath_parseline(&conf->manpath, manpath_default, 0);
 }
 
 void
--
 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:[~2015-05-07 12:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07 12:08 mdocml: Do not let the -m option or MANPATH with leading, trailing, or 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).