mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-20 00:33:57 +00:00
apropos/whatis: use output of manpath(1) to set defpaths if -M is not
specified. This fixes searching the paths specified in /usr/local/etc/man.d/*.conf, as currently apropos/whatis from mandoc suite aren't aware about them. PR: 227922 Reviewed by: bapt Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17454
This commit is contained in:
parent
9d5d89b209
commit
a10034cb47
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339385
|
@ -248,7 +248,13 @@ main(int argc, char *argv[])
|
||||||
outmode = OUTMODE_ALL;
|
outmode = OUTMODE_ALL;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
defpaths = strdup(optarg);
|
||||||
|
if (defpaths == NULL)
|
||||||
|
err(1, "strdup");
|
||||||
|
#else
|
||||||
defpaths = optarg;
|
defpaths = optarg;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
auxpaths = optarg;
|
auxpaths = optarg;
|
||||||
|
@ -380,9 +386,34 @@ main(int argc, char *argv[])
|
||||||
outmode == OUTMODE_ONE)
|
outmode == OUTMODE_ONE)
|
||||||
search.firstmatch = 1;
|
search.firstmatch = 1;
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
/*
|
||||||
|
* Use manpath(1) to populate defpaths if -M is not specified.
|
||||||
|
* Don't treat any failures as fatal.
|
||||||
|
*/
|
||||||
|
if (defpaths == NULL) {
|
||||||
|
FILE *fp;
|
||||||
|
size_t linecap = 0;
|
||||||
|
ssize_t linelen;
|
||||||
|
|
||||||
|
if ((fp = popen("/usr/bin/manpath -q", "r")) != NULL) {
|
||||||
|
if ((linelen = getline(&defpaths,
|
||||||
|
&linecap, fp)) > 0) {
|
||||||
|
/* Strip trailing newline */
|
||||||
|
defpaths[linelen - 1] = '\0';
|
||||||
|
}
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Access the mandoc database. */
|
/* Access the mandoc database. */
|
||||||
|
|
||||||
manconf_parse(&conf, conf_file, defpaths, auxpaths);
|
manconf_parse(&conf, conf_file, defpaths, auxpaths);
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
free(defpaths);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( ! mansearch(&search, &conf.manpath,
|
if ( ! mansearch(&search, &conf.manpath,
|
||||||
argc, argv, &res, &sz))
|
argc, argv, &res, &sz))
|
||||||
usage(search.argmode);
|
usage(search.argmode);
|
||||||
|
|
Loading…
Reference in a new issue