aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-01-27 13:59:28 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-01-27 13:59:28 +0000
commitdbf34026888b6a38755a77b0bbaaabad1f6276cf (patch)
tree4332db0d68ea68a06892f68d80185287782fb589
parent2e67d7f4daa6b60e514753be3118fff268962f28 (diff)
downloadmandoc-dbf34026888b6a38755a77b0bbaaabad1f6276cf.tar.gz
mandoc-dbf34026888b6a38755a77b0bbaaabad1f6276cf.tar.zst
mandoc-dbf34026888b6a38755a77b0bbaaabad1f6276cf.zip
merge rev. 1.239: fix base directory detection for makewhatis -t
-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,