diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-07-01 09:47:30 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-07-01 09:47:30 +0000 |
commit | a288316b2989716c6f4ed17dce8e778e9b6de9d7 (patch) | |
tree | fd723758e0cdfb5ee949c3eceaa129843f13d59b /mansearch.c | |
parent | 17984e1e0b09558f8bfb0a8ee9e49bc97e4a554e (diff) | |
download | mandoc-a288316b2989716c6f4ed17dce8e778e9b6de9d7.tar.gz |
Basic reporting of .Xrs to manual pages that don't exist
in the base system, inspired by mdoclint(1).
We are able to do this because (1) the -mdoc parser, the -Tlint validator,
and the man(1) manual page lookup code are all in the same program
and (2) the mandoc.db(5) database format allows fast lookup.
Feedback from, previous versions tested by, and OK jmc@.
A few features will be added to this in the tree, step by step.
Diffstat (limited to 'mansearch.c')
-rw-r--r-- | mansearch.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/mansearch.c b/mansearch.c index 26a7c23f..ddfe2f5d 100644 --- a/mansearch.c +++ b/mansearch.c @@ -104,7 +104,8 @@ mansearch(const struct mansearch *search, } cur = maxres = 0; - *res = NULL; + if (res != NULL) + *res = NULL; outkey = KEY_Nd; if (search->outkey != NULL) @@ -173,6 +174,10 @@ mansearch(const struct mansearch *search, lstmatch(search->arch, page->arch) == 0) continue; + if (res == NULL) { + cur = 1; + break; + } if (cur + 1 > maxres) { maxres += 1024; *res = mandoc_reallocarray(*res, @@ -204,12 +209,13 @@ mansearch(const struct mansearch *search, if (cur && search->firstmatch) break; } - qsort(*res, cur, sizeof(struct manpage), manpage_compare); + if (res != NULL) + qsort(*res, cur, sizeof(struct manpage), manpage_compare); if (chdir_status && getcwd_status && chdir(buf) == -1) warn("%s", buf); exprfree(e); *sz = cur; - return 1; + return res != NULL || cur; } /* |