version 1.353, 2020/08/07 20:56:55 |
version 1.355, 2021/06/02 18:28:19 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2012, 2014-2021 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
Line 93 struct outstate { |
|
Line 93 struct outstate { |
|
|
|
int mandocdb(int, char *[]); |
int mandocdb(int, char *[]); |
|
|
static void check_xr(void); |
static void check_xr(struct manpaths *); |
static int fs_lookup(const struct manpaths *, |
static int fs_lookup(const struct manpaths *, |
size_t ipath, const char *, |
size_t ipath, const char *, |
const char *, const char *, |
const char *, const char *, |
Line 104 static int fs_search(const struct mansearch *, |
|
Line 104 static int fs_search(const struct mansearch *, |
|
static void glob_esc(char **, const char *, const char *); |
static void glob_esc(char **, const char *, const char *); |
static void outdata_alloc(struct outstate *, struct manoutput *); |
static void outdata_alloc(struct outstate *, struct manoutput *); |
static void parse(struct mparse *, int, const char *, |
static void parse(struct mparse *, int, const char *, |
struct outstate *, struct manoutput *); |
struct outstate *, struct manconf *); |
static void passthrough(int, int); |
static void passthrough(int, int); |
static void process_onefile(struct mparse *, struct manpage *, |
static void process_onefile(struct mparse *, struct manpage *, |
int, struct outstate *, struct manconf *); |
int, struct outstate *, struct manconf *); |
Line 452 main(int argc, char *argv[]) |
|
Line 452 main(int argc, char *argv[]) |
|
|
|
/* Read the configuration file. */ |
/* 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); |
manconf_parse(&conf, conf_file, defpaths, auxpaths); |
|
|
/* man(1): Resolve each name individually. */ |
/* man(1): Resolve each name individually. */ |
Line 846 process_onefile(struct mparse *mp, struct manpage *res |
|
Line 847 process_onefile(struct mparse *mp, struct manpage *res |
|
if (outst->use_pager) { |
if (outst->use_pager) { |
outst->use_pager = 0; |
outst->use_pager = 0; |
outst->tag_files = term_tag_init(conf->output.outfilename, |
outst->tag_files = term_tag_init(conf->output.outfilename, |
|
outst->outtype == OUTT_HTML ? ".html" : "", |
conf->output.tagfilename); |
conf->output.tagfilename); |
#if HAVE_PLEDGE |
#if HAVE_PLEDGE |
if ((conf->output.outfilename != NULL || |
if ((conf->output.outfilename != NULL || |
Line 864 process_onefile(struct mparse *mp, struct manpage *res |
|
Line 866 process_onefile(struct mparse *mp, struct manpage *res |
|
} |
} |
|
|
if (resp->form == FORM_SRC) |
if (resp->form == FORM_SRC) |
parse(mp, fd, resp->file, outst, &conf->output); |
parse(mp, fd, resp->file, outst, conf); |
else { |
else { |
passthrough(fd, conf->output.synopsisonly); |
passthrough(fd, conf->output.synopsisonly); |
outst->had_output = 1; |
outst->had_output = 1; |
Line 885 process_onefile(struct mparse *mp, struct manpage *res |
|
Line 887 process_onefile(struct mparse *mp, struct manpage *res |
|
|
|
static void |
static void |
parse(struct mparse *mp, int fd, const char *file, |
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; |
static int previous; |
struct roff_meta *meta; |
struct roff_meta *meta; |
|
|
Line 912 parse(struct mparse *mp, int fd, const char *file, |
|
Line 915 parse(struct mparse *mp, int fd, const char *file, |
|
return; |
return; |
|
|
if (outst->outdata == NULL) |
if (outst->outdata == NULL) |
outdata_alloc(outst, outconf); |
outdata_alloc(outst, &conf->output); |
else if (outst->outtype == OUTT_HTML) |
else if (outst->outtype == OUTT_HTML) |
html_reset(outst->outdata); |
html_reset(outst->outdata); |
|
|
Line 969 parse(struct mparse *mp, int fd, const char *file, |
|
Line 972 parse(struct mparse *mp, int fd, const char *file, |
|
break; |
break; |
} |
} |
} |
} |
if (outconf->tag != NULL && outconf->tag_found == 0 && |
if (conf->output.tag != NULL && conf->output.tag_found == 0 && |
tag_exists(outconf->tag)) |
tag_exists(conf->output.tag)) |
outconf->tag_found = 1; |
conf->output.tag_found = 1; |
if (mandoc_msg_getmin() < MANDOCERR_STYLE) |
|
check_xr(); |
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 |
static void |
check_xr(void) |
check_xr(struct manpaths *paths) |
{ |
{ |
static struct manpaths paths; |
|
struct mansearch search; |
struct mansearch search; |
struct mandoc_xr *xr; |
struct mandoc_xr *xr; |
size_t sz; |
size_t sz; |
|
|
if (paths.sz == 0) |
|
manpath_base(&paths); |
|
|
|
for (xr = mandoc_xr_get(); xr != NULL; xr = xr->next) { |
for (xr = mandoc_xr_get(); xr != NULL; xr = xr->next) { |
if (xr->line == -1) |
if (xr->line == -1) |
continue; |
continue; |
|
|
search.outkey = NULL; |
search.outkey = NULL; |
search.argmode = ARG_NAME; |
search.argmode = ARG_NAME; |
search.firstmatch = 1; |
search.firstmatch = 1; |
if (mansearch(&search, &paths, 1, &xr->name, NULL, &sz)) |
if (mansearch(&search, paths, 1, &xr->name, NULL, &sz)) |
continue; |
continue; |
if (fs_search(&search, &paths, xr->name, NULL, &sz) != -1) |
if (fs_search(&search, paths, xr->name, NULL, &sz) != -1) |
continue; |
continue; |
if (xr->count == 1) |
if (xr->count == 1) |
mandoc_msg(MANDOCERR_XR_BAD, xr->line, |
mandoc_msg(MANDOCERR_XR_BAD, xr->line, |