When man was "fixed" to chdir() to the man root as historical man does,

it broke the -M option on relative paths (the chdir works as it should,
but the relative man page path is still used whole in nroff).  This
repairs the situation by chopping the full pathname in half--one part
for the chdir, one part for the filename.
This commit is contained in:
tv 1997-11-23 23:24:14 +00:00
parent 754a245e76
commit 13b09649c2
1 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: man.c,v 1.9 1997/10/17 06:42:11 mikel Exp $ */
/* $NetBSD: man.c,v 1.10 1997/11/23 23:24:14 tv Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\n\
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
__RCSID("$NetBSD: man.c,v 1.9 1997/10/17 06:42:11 mikel Exp $");
__RCSID("$NetBSD: man.c,v 1.10 1997/11/23 23:24:14 tv Exp $");
#endif
#endif /* not lint */
@ -517,11 +517,13 @@ build_page(fmt, pathp)
continue;
/* skip the last two path components, page name and man[n] */
for (--b, n = 2; b != buf; b--)
for (--b, --p, n = 2; b != buf; b--, p--)
if (*b == '/')
if (--n == 0) {
*b = '\0';
(void) chdir(buf);
p++;
break;
}
@ -543,7 +545,7 @@ build_page(fmt, pathp)
exit(1);
}
(void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);
(void)snprintf(cmd, sizeof(cmd), buf, *pathp);
(void)snprintf(cmd, sizeof(cmd), buf, p);
(void)system(cmd);
(void)close(fd);
if ((*pathp = strdup(tpath)) == NULL) {