diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-09-01 22:45:12 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-09-01 22:45:12 +0000 |
commit | aef3c3a3dd053b131e6ac32dfe7dff053f52b2da (patch) | |
tree | 16d11df0ef521320ff48e22acb779784c6d1f547 | |
parent | 07b575ccc63acb54fa8e3c4036d68d45dee6cae8 (diff) |
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.
This lets man(1) find more Xenocara manuals, but not all of them yet.
Other issues remain that need to be fixed, too.
-rw-r--r-- | usr.bin/mandoc/main.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mansearch.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mansearch.h | 3 |
3 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 7ea39acb871..b914930cd3d 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.96 2014/08/30 18:04:52 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.97 2014/09/01 22:45:11 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -277,7 +277,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) { @@ -354,9 +353,11 @@ main(int argc, char *argv[]) while (argc) { 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 @@ -373,6 +374,7 @@ main(int argc, char *argv[]) out: if (search.argmode != ARG_FILE) { + manpath_free(&paths); mansearch_free(res, sz); mansearch_setup(0); } diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index f31a9fee232..043bfdf13f5 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.c,v 1.33 2014/08/27 00:06:08 schwarze Exp $ */ +/* $OpenBSD: mansearch.c,v 1.34 2014/09/01 22:45:11 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -327,6 +327,7 @@ mansearch(const struct mansearch *search, maxres, sizeof(struct manpage)); } mpage = *res + cur; + mpage->ipath = i; mpage->sec = 10; mpage->form = mp->form; buildnames(mpage, db, s, mp->pageid, diff --git a/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h index 1dd4c15fbb4..a24f9302105 100644 --- a/usr.bin/mandoc/mansearch.h +++ b/usr.bin/mandoc/mansearch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.h,v 1.12 2014/08/27 00:06:08 schwarze Exp $ */ +/* $OpenBSD: mansearch.h,v 1.13 2014/09/01 22:45:11 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -79,6 +79,7 @@ struct manpage { char *file; /* to be prefixed by manpath */ char *names; /* a list of names with sections */ char *output; /* user-defined additional output */ + size_t ipath; /* number of the manpath */ int sec; /* section number, 10 means invalid */ int form; /* 0 == catpage */ }; |