=================================================================== RCS file: /cvs/mandoc/manpath.c,v retrieving revision 1.24 retrieving revision 1.27 diff -u -p -r1.24 -r1.27 --- mandoc/manpath.c 2015/04/28 16:13:45 1.24 +++ mandoc/manpath.c 2015/10/11 21:12:55 1.27 @@ -1,4 +1,4 @@ -/* $Id: manpath.c,v 1.24 2015/04/28 16:13:45 schwarze Exp $ */ +/* $Id: manpath.c,v 1.27 2015/10/11 21:12:55 schwarze Exp $ */ /* * Copyright (c) 2011, 2014, 2015 Ingo Schwarze * Copyright (c) 2011 Kristaps Dzonsons @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,9 @@ #include "mandoc_aux.h" #include "manconf.h" +#if !HAVE_MANPATH static void manconf_file(struct manconf *, const char *); +#endif static void manpath_add(struct manpaths *, const char *, int); static void manpath_parseline(struct manpaths *, char *, int); @@ -84,7 +87,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 +106,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; } @@ -166,10 +166,8 @@ manpath_add(struct manpaths *dirs, const char *dir, in size_t i; if (NULL == (cp = realpath(dir, buf))) { - if (complain) { - fputs("manpath: ", stderr); - perror(dir); - } + if (complain) + warn("manpath: %s", dir); return; } @@ -178,10 +176,8 @@ manpath_add(struct manpaths *dirs, const char *dir, in return; if (stat(cp, &sb) == -1) { - if (complain) { - fputs("manpath: ", stderr); - perror(dir); - } + if (complain) + warn("manpath: %s", dir); return; } @@ -206,17 +202,19 @@ manconf_free(struct manconf *conf) free(conf->output.style); } +#if !HAVE_MANPATH 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,9 +257,13 @@ manconf_file(struct manconf *conf, const char *file) break; } } - fclose(stream); + +out: + if (*manpath_default != '\0') + manpath_parseline(&conf->manpath, manpath_default, 0); } +#endif void manconf_output(struct manoutput *conf, const char *cp)