From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20728 invoked from network); 2 Jun 2021 18:28:51 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2021 18:28:51 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 3b97cbd7 for ; Wed, 2 Jun 2021 13:28:50 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 7effbc66 for ; Wed, 2 Jun 2021 13:28:50 -0500 (EST) Date: Wed, 2 Jun 2021 13:28:50 -0500 (EST) 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: In -W style mode, check .Xr links along the full manpath because X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- In -W style mode, check .Xr links along the full manpath because that is more useful for validating manuals of non-base software. Nothing changes in -W all mode: by default for -T lint, we still assume we want to check base system conventions, including usually not wanting to link to non-base manual pages. The use case, a partial idea how to handle it, and a preliminary patch was originally presented by kn@, then refined by me. Final patch tested and OK'ed by kn@. Modified Files: -------------- mandoc: main.c mandoc.1 mandoc.h mandoc_msg.c Revision Data ------------- Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.354 retrieving revision 1.355 diff -Lmain.c -Lmain.c -u -p -r1.354 -r1.355 --- main.c +++ main.c @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze + * Copyright (c) 2010-2012, 2014-2021 Ingo Schwarze * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010 Joerg Sonnenberger * @@ -93,7 +93,7 @@ struct outstate { int mandocdb(int, char *[]); -static void check_xr(void); +static void check_xr(struct manpaths *); static int fs_lookup(const struct manpaths *, size_t ipath, const char *, const char *, const char *, @@ -104,7 +104,7 @@ static int fs_search(const struct man static void glob_esc(char **, const char *, const char *); static void outdata_alloc(struct outstate *, struct manoutput *); static void parse(struct mparse *, int, const char *, - struct outstate *, struct manoutput *); + struct outstate *, struct manconf *); static void passthrough(int, int); static void process_onefile(struct mparse *, struct manpage *, int, struct outstate *, struct manconf *); @@ -452,7 +452,8 @@ main(int argc, char *argv[]) /* Read the configuration file. */ - if (search.argmode != ARG_FILE) + if (search.argmode != ARG_FILE || + mandoc_msg_getmin() == MANDOCERR_STYLE) manconf_parse(&conf, conf_file, defpaths, auxpaths); /* man(1): Resolve each name individually. */ @@ -865,7 +866,7 @@ process_onefile(struct mparse *mp, struc } if (resp->form == FORM_SRC) - parse(mp, fd, resp->file, outst, &conf->output); + parse(mp, fd, resp->file, outst, conf); else { passthrough(fd, conf->output.synopsisonly); outst->had_output = 1; @@ -886,8 +887,9 @@ process_onefile(struct mparse *mp, struc static void parse(struct mparse *mp, int fd, const char *file, - struct outstate *outst, struct manoutput *outconf) + struct outstate *outst, struct manconf *conf) { + static struct manpaths basepaths; static int previous; struct roff_meta *meta; @@ -913,7 +915,7 @@ parse(struct mparse *mp, int fd, const c return; if (outst->outdata == NULL) - outdata_alloc(outst, outconf); + outdata_alloc(outst, &conf->output); else if (outst->outtype == OUTT_HTML) html_reset(outst->outdata); @@ -970,24 +972,25 @@ parse(struct mparse *mp, int fd, const c break; } } - if (outconf->tag != NULL && outconf->tag_found == 0 && - tag_exists(outconf->tag)) - outconf->tag_found = 1; - if (mandoc_msg_getmin() < MANDOCERR_STYLE) - check_xr(); + if (conf->output.tag != NULL && conf->output.tag_found == 0 && + tag_exists(conf->output.tag)) + conf->output.tag_found = 1; + + if (mandoc_msg_getmin() < MANDOCERR_STYLE) { + if (basepaths.sz == 0) + manpath_base(&basepaths); + check_xr(&basepaths); + } else if (mandoc_msg_getmin() < MANDOCERR_WARNING) + check_xr(&conf->manpath); } static void -check_xr(void) +check_xr(struct manpaths *paths) { - static struct manpaths paths; struct mansearch search; struct mandoc_xr *xr; size_t sz; - if (paths.sz == 0) - manpath_base(&paths); - for (xr = mandoc_xr_get(); xr != NULL; xr = xr->next) { if (xr->line == -1) continue; @@ -996,9 +999,9 @@ check_xr(void) search.outkey = NULL; search.argmode = ARG_NAME; search.firstmatch = 1; - if (mansearch(&search, &paths, 1, &xr->name, NULL, &sz)) + if (mansearch(&search, paths, 1, &xr->name, NULL, &sz)) continue; - if (fs_search(&search, &paths, xr->name, NULL, &sz) != -1) + if (fs_search(&search, paths, xr->name, NULL, &sz) != -1) continue; if (xr->count == 1) mandoc_msg(MANDOCERR_XR_BAD, xr->line, Index: mandoc_msg.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc_msg.c,v retrieving revision 1.12 retrieving revision 1.13 diff -Lmandoc_msg.c -Lmandoc_msg.c -u -p -r1.12 -r1.13 --- mandoc_msg.c +++ mandoc_msg.c @@ -55,7 +55,6 @@ static const char *const type_message[MA "unknown architecture", "operating system explicitly specified", "RCS id missing", - "referenced manual not found", "generic style suggestion", @@ -69,6 +68,7 @@ static const char *const type_message[MA "consider using OS macro", "errnos out of order", "duplicate errno", + "referenced manual not found", "trailing delimiter", "no blank before trailing delimiter", "fill mode already enabled, skipping", Index: mandoc.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc.h,v retrieving revision 1.269 retrieving revision 1.270 diff -Lmandoc.h -Lmandoc.h -u -p -r1.269 -r1.270 --- mandoc.h +++ mandoc.h @@ -54,7 +54,6 @@ enum mandocerr { MANDOCERR_ARCH_BAD, /* unknown architecture: Dt ... arch */ MANDOCERR_OS_ARG, /* operating system explicitly specified: Os ... */ MANDOCERR_RCS_MISSING, /* RCS id missing */ - MANDOCERR_XR_BAD, /* referenced manual not found: Xr name sec */ MANDOCERR_STYLE, /* ===== start of style suggestions ===== */ @@ -68,6 +67,7 @@ enum mandocerr { MANDOCERR_BX, /* consider using OS macro: macro */ MANDOCERR_ER_ORDER, /* errnos out of order: Er ... */ MANDOCERR_ER_REP, /* duplicate errno: Er ... */ + MANDOCERR_XR_BAD, /* referenced manual not found: Xr name sec */ MANDOCERR_DELIM, /* trailing delimiter: macro ... */ MANDOCERR_DELIM_NB, /* no blank before trailing delimiter: macro ... */ MANDOCERR_FI_SKIP, /* fill mode already enabled, skipping: fi */ Index: mandoc.1 =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc.1,v retrieving revision 1.248 retrieving revision 1.249 diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.248 -r1.249 --- mandoc.1 +++ mandoc.1 @@ -1,6 +1,6 @@ .\" $OpenBSD: mandoc.1,v 1.166 2020/02/15 15:28:01 schwarze Exp $ .\" -.\" Copyright (c) 2012, 2014-2020 Ingo Schwarze +.\" Copyright (c) 2012, 2014-2021 Ingo Schwarze .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -922,14 +922,6 @@ generated by CVS or .Ic NetBSD keyword substitution as conventionally used in these operating systems. -.It Sy "referenced manual not found" -.Pq mdoc -An -.Ic \&Xr -macro references a manual page that is not found in the base system. -The path to look for base system manuals is configurable at compile -time and defaults to -.Pa /usr/share/man : /usr/X11R6/man . .El .Ss Style suggestions .Bl -ohang @@ -1016,6 +1008,35 @@ list contains two consecutive entries describing the same .Ic \&Er number. +.It Sy "referenced manual not found" +.Pq mdoc +An +.Ic \&Xr +macro references a manual page that was not found. +When running with +.Fl W Cm base , +the search is restricted to the base system, by default to +.Pa /usr/share/man : Ns Pa /usr/X11R6/man . +This path can be configured at compile time using the +.Dv MANPATH_BASE +preprocessor macro. +When running with +.Fl W Cm style , +the search is done along the full search path as described in the +.Xr man 1 +manual page, respecting the +.Fl m +and +.Fl M +command line options, the +.Ev MANPATH +environment variable, the +.Xr man.conf 5 +file and falling back to the default of +.Pa /usr/share/man : Ns Pa /usr/X11R6/man : Ns Pa /usr/local/man , +also configurable at compile time using the +.Dv MANPATH_DEFAULT +preprocessor macro. .It Sy "trailing delimiter" .Pq mdoc The last argument of an -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv