source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: In man(1) mode, change to the right directory before starting
@ 2014-09-01 22:45 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-09-01 22:45 UTC (permalink / raw)
  To: source

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-01 22:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-01 22:45 mdocml: In man(1) mode, change to the right directory before starting schwarze

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).