Module Name: src
Committed By: joerg
Date: Wed Feb 15 23:35:00 UTC 2012
Modified Files:
src/usr.sbin/makemandb: makemandb.c
Log Message:
Be a bit more friendly to man pages using the roff .so command by
changing the current directory to the parent of the man -p entry, e.g.
/usr/share/man for /usr/share/man1.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/makemandb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.2 src/usr.sbin/makemandb/makemandb.c:1.3
--- src/usr.sbin/makemandb/makemandb.c:1.2 Tue Feb 7 19:17:16 2012
+++ src/usr.sbin/makemandb/makemandb.c Wed Feb 15 23:35:00 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: makemandb.c,v 1.2 2012/02/07 19:17:16 joerg Exp $ */
+/* $NetBSD: makemandb.c,v 1.3 2012/02/15 23:35:00 joerg Exp $ */
/*
* Copyright (c) 2011 Abhinav Upadhyay <[email protected]>
* Copyright (c) 2011 Kristaps Dzonsons <[email protected]>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.2 2012/02/07 19:17:16 joerg Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.3 2012/02/15 23:35:00 joerg Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -26,6 +26,7 @@ __RCSID("$NetBSD: makemandb.c,v 1.2 2012
#include <ctype.h>
#include <dirent.h>
#include <err.h>
+#include <libgen.h>
#include <md5.h>
#include <stdio.h>
#include <stdlib.h>
@@ -291,7 +292,7 @@ main(int argc, char *argv[])
{
FILE *file;
const char *sqlstr, *manconf = NULL;
- char *line, *command;
+ char *line, *command, *parent;
char *errmsg;
int ch;
struct mparse *mp;
@@ -397,6 +398,9 @@ main(int argc, char *argv[])
while ((len = getline(&line, &linesize, file)) != -1) {
/* Replace the new line character at the end of string with '\0' */
line[len - 1] = '\0';
+ parent = estrdup(line);
+ chdir(dirname(parent));
+ free(parent);
/* Traverse the man page directories and parse the pages */
traversedir(line, db, mp);
}