summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-09-01 22:45:53 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-09-01 22:45:53 +0000
commit34f785b90475baa4a0b2012afc259927b0484605 (patch)
tree672023130caf49797bf4f1aefc8daca9e9292329 /main.c
parent24387bf29bff146c16b4c293b9c384cb99730d62 (diff)
downloadmandoc-34f785b90475baa4a0b2012afc259927b0484605.tar.gz
In man(1) mode, change to the right directory before starting the parser,
just like traditional man(1) does, such that .so links have a chance to work. After this point, we don't need the current directory for anything else before exit, so we don't need to worry about getting back and we can safely ignore failure.
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/main.c b/main.c
index a628cd86..4c71266f 100644
--- a/main.c
+++ b/main.c
@@ -284,7 +284,6 @@ main(int argc, char *argv[])
mansearch_setup(1);
if( ! mansearch(&search, &paths, argc, argv, &res, &sz))
usage(search.argmode);
- manpath_free(&paths);
resp = res;
if (sz == 0) {
@@ -367,9 +366,11 @@ main(int argc, char *argv[])
while (argc) {
#if HAVE_SQLITE3
if (resp != NULL) {
- if (resp->form)
+ if (resp->form) {
+ /* For .so only; ignore failure. */
+ chdir(paths.paths[resp->ipath]);
parse(&curp, -1, resp->file, &rc);
- else
+ } else
rc = passthrough(resp->file);
resp++;
} else
@@ -388,6 +389,7 @@ main(int argc, char *argv[])
#if HAVE_SQLITE3
out:
if (search.argmode != ARG_FILE) {
+ manpath_free(&paths);
mansearch_free(res, sz);
mansearch_setup(0);
}