From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id e7c09c9b for ; Sat, 1 Jul 2017 07:03:01 -0500 (EST) Date: Sat, 1 Jul 2017 07:03:01 -0500 (EST) Message-Id: <4335762337567433968.enqueue@fantadrom.bsd.lv> X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: When checking the validity of cross references with -Tlint, X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- When checking the validity of cross references with -Tlint, fall back from database search to file system search just like man(1) does when looking up manuals. This is not too expensive because on a system having up-to-date mandoc.db(5) files, it only prolongs the time needed to check *invalid* references - and you are not supposed to have many of those, right? And on a system with missing or invalid mandoc.db(5) files, spending a bit of time and warning loudly about the real problem is also better than quickly issuing bogus warnings about cross references that are actually valid. Modified Files: -------------- mandoc: main.c Revision Data ------------- Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.294 retrieving revision 1.295 diff -Lmain.c -Lmain.c -u -p -r1.294 -r1.295 --- main.c +++ main.c @@ -92,7 +92,7 @@ static int fs_lookup(const struct man size_t ipath, const char *, const char *, const char *, struct manpage **, size_t *); -static void fs_search(const struct mansearch *, +static int fs_search(const struct mansearch *, const struct manpaths *, int, char**, struct manpage **, size_t *); static int koptions(int *, char *); @@ -669,6 +669,8 @@ fs_lookup(const struct manpaths *paths, found: warnx("outdated mandoc.db lacks %s(%s) entry, run %s %s", name, sec, BINM_MAKEWHATIS, paths->paths[ipath]); + if (res == NULL) + return 1; *res = mandoc_reallocarray(*res, ++*ressz, sizeof(struct manpage)); page = *res + (*ressz - 1); page->file = file; @@ -681,7 +683,7 @@ found: return 1; } -static void +static int fs_search(const struct mansearch *cfg, const struct manpaths *paths, int argc, char **argv, struct manpage **res, size_t *ressz) { @@ -693,7 +695,8 @@ fs_search(const struct mansearch *cfg, c assert(cfg->argmode == ARG_NAME); - *res = NULL; + if (res != NULL) + *res = NULL; *ressz = lastsz = 0; while (argc) { for (ipath = 0; ipath < paths->sz; ipath++) { @@ -701,19 +704,20 @@ fs_search(const struct mansearch *cfg, c if (fs_lookup(paths, ipath, cfg->sec, cfg->arch, *argv, res, ressz) && cfg->firstmatch) - return; + return 1; } else for (isec = 0; isec < nsec; isec++) if (fs_lookup(paths, ipath, sections[isec], cfg->arch, *argv, res, ressz) && cfg->firstmatch) - return; + return 1; } - if (*ressz == lastsz) + if (res != NULL && *ressz == lastsz) warnx("No entry for %s in the manual.", *argv); lastsz = *ressz; argv++; argc--; } + return 0; } static void @@ -826,6 +830,8 @@ check_xr(const char *file) search.argmode = ARG_NAME; search.firstmatch = 1; if (mansearch(&search, &paths, 1, &xr->name, NULL, &sz)) + continue; + if (fs_search(&search, &paths, 1, &xr->name, NULL, &sz)) continue; mandoc_asprintf(&cp, "Xr %s %s", xr->name, xr->sec); mmsg(MANDOCERR_XR_BAD, MANDOCLEVEL_STYLE, -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv