diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-12-08 01:00:58 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-12-08 01:00:58 +0000 |
commit | 07c982667cc6889ecd08dd76efca86b70f37611e (patch) | |
tree | 445dcd33c9ab93c2ee47e2bf5d7ac56c602ed3ac | |
parent | f6b6497b86fd99545be4c226abdff716e901d776 (diff) | |
download | mandoc-07c982667cc6889ecd08dd76efca86b70f37611e.tar.gz |
If arguments are passed to mandocdb(8) in "default" mode, then use
realpath() to convert them into absolute paths before putting the
traversed subdirectory filenames into the index.
-rw-r--r-- | mandocdb.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -272,7 +272,9 @@ main(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 */ @@ -413,10 +415,15 @@ main(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); |