aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-09 19:35:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-09 19:35:25 +0000
commit324d681dc664dcafae58984dfa627d1330143efc (patch)
treeccddef5b737adc05248a6b549086aad28d20118b /mandocdb.c
parent874ac26ff8affa95d651832b3050f9fd13ae9aca (diff)
downloadmandoc-324d681dc664dcafae58984dfa627d1330143efc.tar.gz
mandoc-324d681dc664dcafae58984dfa627d1330143efc.tar.zst
mandoc-324d681dc664dcafae58984dfa627d1330143efc.zip
If a manpath directory (for example, a _whatdb entry from man.conf(5)
or an entry in the MANPATH environment variable) does not exist, silently skip it. This brings makewhatis(8) back closer to the behaviour of espie@'s version and ought to shut up the weekly(8) whining observed by henning@ on machines not having xbase installed. Also, don't error out after the first unusable manpath entry, still try the others. Of course, still complain about non-existent directories specified on the command line and about any directories failing for other reasons than ENOENT.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 3a93cfea..8dd21494 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.164 2014/09/07 03:08:47 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.165 2014/09/09 19:35:25 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -169,7 +169,7 @@ static void putmdockey(const struct mpage *,
const struct mdoc_node *, uint64_t);
static void render_key(struct mchars *, struct str *);
static void say(const char *, const char *, ...);
-static int set_basedir(const char *);
+static int set_basedir(const char *, int);
static int treescan(void);
static size_t utf8(unsigned int, char [7]);
@@ -436,7 +436,7 @@ main(int argc, char *argv[])
* Most of these deal with a specific directory.
* Jump into that directory first.
*/
- if (OP_TEST != op && 0 == set_basedir(path_arg))
+ if (OP_TEST != op && 0 == set_basedir(path_arg, 1))
goto out;
if (dbopen(1)) {
@@ -502,12 +502,12 @@ main(int argc, char *argv[])
ohash_init(&mlinks, 6, &mlinks_info);
}
- if (0 == set_basedir(dirs.paths[j]))
- goto out;
+ if (0 == set_basedir(dirs.paths[j], argc > 0))
+ continue;
if (0 == treescan())
- goto out;
+ continue;
if (0 == dbopen(0))
- goto out;
+ continue;
mpages_merge(mc, mp);
if (warnings && !nodb &&
@@ -2343,7 +2343,7 @@ hash_free(void *p, void *arg)
}
static int
-set_basedir(const char *targetdir)
+set_basedir(const char *targetdir, int report_baddir)
{
static char startdir[PATH_MAX];
static int getcwd_status; /* 1 = ok, 2 = failure */
@@ -2396,12 +2396,16 @@ set_basedir(const char *targetdir)
* we can reliably check whether files are inside.
*/
if (NULL == realpath(targetdir, basedir)) {
- exitcode = (int)MANDOCLEVEL_BADARG;
- say("", "&%s: realpath", targetdir);
+ if (report_baddir || errno != ENOENT) {
+ exitcode = (int)MANDOCLEVEL_BADARG;
+ say("", "&%s: realpath", targetdir);
+ }
return(0);
} else if (-1 == chdir(basedir)) {
- exitcode = (int)MANDOCLEVEL_BADARG;
- say("", "&chdir");
+ if (report_baddir || errno != ENOENT) {
+ exitcode = (int)MANDOCLEVEL_BADARG;
+ say("", "&chdir");
+ }
return(0);
}
chdir_status = 1;