aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-05-07 12:08:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-05-07 12:08:13 +0000
commit667473518738834b5cdfc45d130d58d09d1c76d0 (patch)
treef68bac9717d542e9b53a9a8af2e0b07ea55cf505
parent631dcbd03b42795bbc37c57d62a32f1ebbe3f1b9 (diff)
downloadmandoc-667473518738834b5cdfc45d130d58d09d1c76d0.tar.gz
mandoc-667473518738834b5cdfc45d130d58d09d1c76d0.tar.zst
mandoc-667473518738834b5cdfc45d130d58d09d1c76d0.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@.
-rw-r--r--manpath.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/manpath.c b/manpath.c
index 2bb83684..9446ea69 100644
--- a/manpath.c
+++ b/manpath.c
@@ -1,4 +1,4 @@
-/* $Id: manpath.c,v 1.24 2015/04/28 16:13:45 schwarze Exp $ */
+/* $Id: manpath.c,v 1.25 2015/05/07 12:08:13 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -84,7 +84,6 @@ manconf_parse(struct manconf *conf, const char *file,
free(buf);
pclose(stream);
#else
- char manpath_default[] = MANPATH_DEFAULT;
char *insert;
/* Always prepend -m. */
@@ -104,8 +103,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;
}
@@ -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 char *file)
/* 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 char *file)
break;
}
}
-
fclose(stream);
+
+out:
+ if (*manpath_default != '\0')
+ manpath_parseline(&conf->manpath, manpath_default, 0);
}
void