summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-01-27 01:04:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-01-27 01:04:25 +0000
commitf4f3ff2a22776dac1056b1df38593aada770e186 (patch)
tree3a2b0909af5a84c68b0185584fb80ddace13aa9f /mandocdb.c
parentd82b8844224205bec613a0e8017033b2b8f7058f (diff)
downloadmandoc-f4f3ff2a22776dac1056b1df38593aada770e186.tar.gz
fix base directory detection for makewhatis -t
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/mandocdb.c b/mandocdb.c
index ad7292a3..0921f7d9 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -872,6 +872,20 @@ filescan(const char *file)
}
/*
+ * In test mode or when the original name is absolute
+ * but outside our tree, guess the base directory.
+ */
+
+ if (op == OP_TEST || (start == buf && *start == '/')) {
+ if (strncmp(buf, "man/", 4) == 0)
+ start = buf + 4;
+ else if ((start = strstr(buf, "/man/")) != NULL)
+ start += 5;
+ else
+ start = buf;
+ }
+
+ /*
* First try to guess our directory structure.
* If we find a separator, try to look for man* or cat*.
* If we find one of these and what's underneath is a directory,