diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-09-01 22:45:53 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-09-01 22:45:53 +0000 |
commit | 3c042f1c04abf0fec8866a305452f7fd2ac8639c (patch) | |
tree | a70710051aa68570973231dbad3e5af7771599a2 /main.c | |
parent | baf73424c69a2aa19a4dbd317ca8b72d21c33c1b (diff) | |
download | mandoc-3c042f1c04abf0fec8866a305452f7fd2ac8639c.tar.gz mandoc-3c042f1c04abf0fec8866a305452f7fd2ac8639c.tar.zst mandoc-3c042f1c04abf0fec8866a305452f7fd2ac8639c.zip |
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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.188 2014/08/30 18:08:10 schwarze Exp $ */ +/* $Id: main.c,v 1.189 2014/09/01 22:45:53 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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); } |