version 1.344, 2020/02/24 21:16:31 |
version 1.346, 2020/03/19 12:21:37 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
|
* Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze <schwarze@openbsd.org> |
|
* 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> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
* |
|
* Main program for mandoc(1), man(1), apropos(1), whatis(1), and help(1). |
*/ |
*/ |
#include "config.h" |
#include "config.h" |
|
|
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "man.h" |
#include "man.h" |
#include "mandoc_parse.h" |
#include "mandoc_parse.h" |
#include "tag.h" |
#include "term_tag.h" |
#include "main.h" |
#include "main.h" |
#include "manconf.h" |
#include "manconf.h" |
#include "mansearch.h" |
#include "mansearch.h" |
Line 598 main(int argc, char *argv[]) |
|
Line 600 main(int argc, char *argv[]) |
|
* readable: Maybe it won't be needed after all. |
* readable: Maybe it won't be needed after all. |
*/ |
*/ |
startdir = open(".", O_RDONLY | O_DIRECTORY); |
startdir = open(".", O_RDONLY | O_DIRECTORY); |
|
|
for (i = 0; i < ressz; i++) { |
for (i = 0; i < ressz; i++) { |
process_onefile(mp, res + i, startdir, &outst, &conf); |
process_onefile(mp, res + i, startdir, &outst, &conf); |
if (outst.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) |
if (outst.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) |
Line 608 main(int argc, char *argv[]) |
|
Line 609 main(int argc, char *argv[]) |
|
(void)fchdir(startdir); |
(void)fchdir(startdir); |
close(startdir); |
close(startdir); |
} |
} |
|
if (outst.outtype <= OUTT_UTF8) |
|
term_tag_finish(); |
if (outst.outdata != NULL) { |
if (outst.outdata != NULL) { |
switch (outst.outtype) { |
switch (outst.outtype) { |
case OUTT_HTML: |
case OUTT_HTML: |
|
|
|
|
if (outst.tag_files != NULL) { |
if (outst.tag_files != NULL) { |
fclose(stdout); |
fclose(stdout); |
tag_write(); |
|
run_pager(outst.tag_files); |
run_pager(outst.tag_files); |
tag_unlink(); |
term_tag_unlink(); |
} else if (outst.had_output && outst.outtype != OUTT_LINT) |
} else if (outst.had_output && outst.outtype != OUTT_LINT) |
mandoc_msg_summary(); |
mandoc_msg_summary(); |
|
|
Line 831 process_onefile(struct mparse *mp, struct manpage *res |
|
Line 832 process_onefile(struct mparse *mp, struct manpage *res |
|
} else |
} else |
fd = STDIN_FILENO; |
fd = STDIN_FILENO; |
|
|
if (outst->use_pager) { |
if (outst->outtype <= OUTT_UTF8) { |
outst->use_pager = 0; |
if (outst->use_pager) { |
outst->tag_files = tag_init(conf->output.tag); |
outst->use_pager = 0; |
|
outst->tag_files = term_tag_init(conf->output.tag); |
|
} |
|
if (outst->had_output) { |
|
if (outst->outdata == NULL) |
|
outdata_alloc(outst, &conf->output); |
|
terminal_sepline(outst->outdata); |
|
} |
} |
} |
|
|
if (outst->had_output && outst->outtype <= OUTT_UTF8) { |
|
if (outst->outdata == NULL) |
|
outdata_alloc(outst, &conf->output); |
|
terminal_sepline(outst->outdata); |
|
} |
|
|
|
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->output); |
else { |
else { |
Line 853 process_onefile(struct mparse *mp, struct manpage *res |
|
Line 855 process_onefile(struct mparse *mp, struct manpage *res |
|
if (outst->tag_files != NULL) { |
if (outst->tag_files != NULL) { |
mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s: %s", |
mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s: %s", |
outst->tag_files->ofn, strerror(errno)); |
outst->tag_files->ofn, strerror(errno)); |
tag_unlink(); |
term_tag_unlink(); |
outst->tag_files = NULL; |
outst->tag_files = NULL; |
} else |
} else |
mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s", |
mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s", |
Line 1278 spawn_pager(struct tag_files *tag_files) |
|
Line 1280 spawn_pager(struct tag_files *tag_files) |
|
_exit(mandoc_msg_getrc()); |
_exit(mandoc_msg_getrc()); |
} |
} |
close(tag_files->ofd); |
close(tag_files->ofd); |
assert(tag_files->tfd == -1); |
assert(tag_files->tfs == NULL); |
|
|
/* Do not start the pager before controlling the terminal. */ |
/* Do not start the pager before controlling the terminal. */ |
|
|