source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: In man(1) mode, change to the right directory before starting
Date: Mon, 1 Sep 2014 18:45:54 -0400 (EDT)	[thread overview]
Message-ID: <201409012245.s81Mjsxj032345@krisdoz.my.domain> (raw)

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        main.c
        mansearch.c
        mansearch.h

Revision Data
-------------
Index: mansearch.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lmansearch.h -Lmansearch.h -u -p -r1.16 -r1.17
--- mansearch.h
+++ mansearch.h
@@ -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 */
 };
Index: mansearch.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -Lmansearch.c -Lmansearch.c -u -p -r1.46 -r1.47
--- mansearch.c
+++ mansearch.c
@@ -335,6 +335,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,
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.188
retrieving revision 1.189
diff -Lmain.c -Lmain.c -u -p -r1.188 -r1.189
--- main.c
+++ 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);
 	}
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-09-01 22:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201409012245.s81Mjsxj032345@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).