diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2020-07-21 15:10:01 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2020-07-21 15:10:01 +0000 |
commit | 34c3fd437f1b1a9f91c688bf395a99c631b642ed (patch) | |
tree | 457254f96054c09e8e8c023fc4e684b34c589021 /main.c | |
parent | eb396f5b0bb17fecfc3db0045d2979fa42d4478d (diff) | |
download | mandoc-34c3fd437f1b1a9f91c688bf395a99c631b642ed.tar.gz mandoc-34c3fd437f1b1a9f91c688bf395a99c631b642ed.tar.zst mandoc-34c3fd437f1b1a9f91c688bf395a99c631b642ed.zip |
undocumented options -O outfilename and -O tagfilename
to support regression testing without a tty;
no user visible change intended
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.351 2020/07/20 16:57:30 schwarze Exp $ */ +/* $Id: main.c,v 1.352 2020/07/21 15:10:01 schwarze Exp $ */ /* * Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> @@ -165,7 +165,7 @@ main(int argc, char *argv[]) return mandocdb(argc, argv); #if HAVE_PLEDGE - if (pledge("stdio rpath tmppath tty proc exec", NULL) == -1) { + if (pledge("stdio rpath wpath cpath tmppath tty proc exec", NULL) == -1) { mandoc_msg(MANDOCERR_PLEDGE, 0, 0, "%s", strerror(errno)); return mandoc_msg_getrc(); } @@ -373,7 +373,9 @@ main(int argc, char *argv[]) if (outmode == OUTMODE_FLN || outmode == OUTMODE_LST || - !isatty(STDOUT_FILENO)) + (conf.output.outfilename == NULL && + conf.output.tagfilename == NULL && + isatty(STDOUT_FILENO) == 0)) outst.use_pager = 0; if (outst.use_pager && @@ -387,12 +389,16 @@ main(int argc, char *argv[]) } #if HAVE_PLEDGE - if (outst.use_pager == 0) { - if (pledge("stdio rpath", NULL) == -1) { - mandoc_msg(MANDOCERR_PLEDGE, 0, 0, - "%s", strerror(errno)); - return mandoc_msg_getrc(); - } + if (outst.use_pager == 0) + c = pledge("stdio rpath", NULL); + else if (conf.output.outfilename != NULL || + conf.output.tagfilename != NULL) + c = pledge("stdio rpath wpath cpath", NULL); + else + c = pledge("stdio rpath tmppath tty proc exec", NULL); + if (c == -1) { + mandoc_msg(MANDOCERR_PLEDGE, 0, 0, "%s", strerror(errno)); + return mandoc_msg_getrc(); } #endif @@ -642,7 +648,9 @@ out: manconf_free(&conf); if (outst.tag_files != NULL) { - if (term_tag_close() != -1) + if (term_tag_close() != -1 && + conf.output.outfilename == NULL && + conf.output.tagfilename == NULL) run_pager(&outst, conf.output.tag); term_tag_unlink(); } else if (outst.had_output && outst.outtype != OUTT_LINT) @@ -837,7 +845,15 @@ process_onefile(struct mparse *mp, struct manpage *resp, int startdir, if (outst->use_pager) { outst->use_pager = 0; - outst->tag_files = term_tag_init(); + outst->tag_files = term_tag_init(conf->output.outfilename, + conf->output.tagfilename); + if ((conf->output.outfilename != NULL || + conf->output.tagfilename != NULL) && + pledge("stdio rpath cpath", NULL) == -1) { + mandoc_msg(MANDOCERR_PLEDGE, 0, 0, + "%s", strerror(errno)); + exit(mandoc_msg_getrc()); + } } if (outst->had_output && outst->outtype <= OUTT_UTF8) { if (outst->outdata == NULL) |