aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--mandocdb.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 4d90a81e..ff50c7dd 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.220.2.7 2017/01/11 17:46:54 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.220.2.8 2017/01/27 13:59:28 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -908,6 +908,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,