-/* $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 <schwarze@openbsd.org>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
#include <sys/stat.h>
#include <ctype.h>
+#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#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);
free(buf);
pclose(stream);
#else
- char manpath_default[] = MANPATH_DEFAULT;
char *insert;
/* Always prepend -m. */
/* 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;
}
size_t i;
if (NULL == (cp = realpath(dir, buf))) {
- if (complain) {
- fputs("manpath: ", stderr);
- perror(dir);
- }
+ if (complain)
+ warn("manpath: %s", dir);
return;
}
return;
if (stat(cp, &sb) == -1) {
- if (complain) {
- fputs("manpath: ", stderr);
- perror(dir);
- }
+ if (complain)
+ warn("manpath: %s", dir);
return;
}
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;
/* FALLTHROUGH */
case 0: /* manpath */
manpath_add(&conf->manpath, cp, 0);
+ *manpath_default = '\0';
break;
case 1: /* output */
manconf_output(&conf->output, cp);
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)