summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-12-09 00:53:11 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-12-09 00:53:11 +0000
commit553dab463f8ba9638e06c9426a90e9e192731ad9 (patch)
tree7bd203b6548dcdd243d1fed28555e6c455fa9c39 /usr.bin
parentd7af13907fde0259ef6420806227c1926bf88173 (diff)
In default mode, use realpath(3) on the "dir" arguments
and put canonicalized absolute pathnames into the database; from kristaps@.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mandocdb.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index 22e65e21bf3..312b38f707f 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.20 2011/12/08 02:14:00 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.21 2011/12/09 00:53:10 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -260,7 +260,9 @@ mandocdb(int argc, char *argv[])
struct manpaths dirs;
enum op op; /* current operation */
const char *dir;
- char ibuf[MAXPATHLEN], /* index fname */
+ char *cp;
+ char pbuf[PATH_MAX],
+ ibuf[MAXPATHLEN], /* index fname */
fbuf[MAXPATHLEN]; /* btree fname */
int ch, i, flags;
DB *idx, /* index database */
@@ -402,10 +404,15 @@ mandocdb(int argc, char *argv[])
*/
if (argc > 0) {
- dirs.paths = mandoc_malloc(argc * sizeof(char *));
+ dirs.paths = mandoc_calloc(argc, sizeof(char *));
dirs.sz = argc;
- for (i = 0; i < argc; i++)
- dirs.paths[i] = mandoc_strdup(argv[i]);
+ for (i = 0; i < argc; i++) {
+ if (NULL == (cp = realpath(argv[i], pbuf))) {
+ perror(argv[i]);
+ goto out;
+ }
+ dirs.paths[i] = mandoc_strdup(cp);
+ }
} else
manpath_parse(&dirs, NULL, NULL);