summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/manpath.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-05-07 12:07:29 +0000
committerschwarze <schwarze@openbsd.org>2015-05-07 12:07:29 +0000
commitef3112a4b97ecd950be8567216ed29b5a795b734 (patch)
treeb03cb12158cf4a21782ef184ff8d0309a0c4f9ed /usr.bin/mandoc/manpath.c
parentStyle spacing nits. (diff)
downloadwireguard-openbsd-ef3112a4b97ecd950be8567216ed29b5a795b734.tar.xz
wireguard-openbsd-ef3112a4b97ecd950be8567216ed29b5a795b734.zip
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@.
Diffstat (limited to 'usr.bin/mandoc/manpath.c')
-rw-r--r--usr.bin/mandoc/manpath.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/mandoc/manpath.c b/usr.bin/mandoc/manpath.c
index 4a11effb5ca..918f0064fcb 100644
--- a/usr.bin/mandoc/manpath.c
+++ b/usr.bin/mandoc/manpath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: manpath.c,v 1.14 2015/03/27 17:36:56 schwarze Exp $ */
+/* $OpenBSD: manpath.c,v 1.15 2015/05/07 12:07:29 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -39,7 +39,6 @@ void
manconf_parse(struct manconf *conf, const char *file,
char *defp, char *auxp)
{
- char manpath_default[] = MANPATH_DEFAULT;
char *insert;
/* Always prepend -m. */
@@ -59,8 +58,6 @@ manconf_parse(struct manconf *conf, const char *file,
/* 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;
}
@@ -164,13 +161,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;
@@ -204,6 +202,7 @@ manconf_file(struct manconf *conf, const char *file)
/* FALLTHROUGH */
case 0: /* manpath */
manpath_add(&conf->manpath, cp, 0);
+ *manpath_default = '\0';
break;
case 1: /* output */
manconf_output(&conf->output, cp);
@@ -212,8 +211,11 @@ manconf_file(struct manconf *conf, const char *file)
break;
}
}
-
fclose(stream);
+
+out:
+ if (*manpath_default != '\0')
+ manpath_parseline(&conf->manpath, manpath_default, 0);
}
void