From 87affb6be521107f1dea4b65c49bd1e5cecc2ca0 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 27 Jan 2017 01:04:25 +0000 Subject: fix base directory detection for makewhatis -t --- mandocdb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'mandocdb.c') 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 * Copyright (c) 2011-2017 Ingo Schwarze @@ -871,6 +871,20 @@ filescan(const char *file) return; } + /* + * 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*. -- cgit v1.2.3-56-ge451