aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit87affb6be521107f1dea4b65c49bd1e5cecc2ca0 (patch)
tree39963f77c172a648b4c86ea568698e742ffbc758 /mandocdb.c
parentefdbf67ae630d4b45c7dc163eff30e0a452d6062 (diff)
downloadmandoc-87affb6be521107f1dea4b65c49bd1e5cecc2ca0.tar.gz
mandoc-87affb6be521107f1dea4b65c49bd1e5cecc2ca0.tar.zst
mandoc-87affb6be521107f1dea4b65c49bd1e5cecc2ca0.zip
fix base directory detection for makewhatis -t
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/mandocdb.c b/mandocdb.c
index ba7dda30..6fa441bf 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.238 2017/01/27 00:56:32 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.239 2017/01/27 01:04:25 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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,