summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/main.c b/main.c
index 96608fbe..9fb1726e 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
-/* $Id$ */
+/* $Id$ */
/*
- * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* 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>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,6 +15,8 @@
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* 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"
@@ -52,7 +54,7 @@
#include "mdoc.h"
#include "man.h"
#include "mandoc_parse.h"
-#include "tag.h"
+#include "term_tag.h"
#include "main.h"
#include "manconf.h"
#include "mansearch.h"
@@ -598,7 +600,6 @@ main(int argc, char *argv[])
* readable: Maybe it won't be needed after all.
*/
startdir = open(".", O_RDONLY | O_DIRECTORY);
-
for (i = 0; i < ressz; i++) {
process_onefile(mp, res + i, startdir, &outst, &conf);
if (outst.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK)
@@ -608,7 +609,6 @@ main(int argc, char *argv[])
(void)fchdir(startdir);
close(startdir);
}
-
if (outst.outdata != NULL) {
switch (outst.outtype) {
case OUTT_HTML:
@@ -617,6 +617,7 @@ main(int argc, char *argv[])
case OUTT_UTF8:
case OUTT_LOCALE:
case OUTT_ASCII:
+ term_tag_finish();
ascii_free(outst.outdata);
break;
case OUTT_PDF:
@@ -638,9 +639,8 @@ out:
if (outst.tag_files != NULL) {
fclose(stdout);
- tag_write();
run_pager(outst.tag_files);
- tag_unlink();
+ term_tag_unlink();
} else if (outst.had_output && outst.outtype != OUTT_LINT)
mandoc_msg_summary();
@@ -831,15 +831,16 @@ process_onefile(struct mparse *mp, struct manpage *resp, int startdir,
} else
fd = STDIN_FILENO;
- if (outst->use_pager) {
- outst->use_pager = 0;
- outst->tag_files = tag_init(conf->output.tag);
- }
-
- if (outst->had_output && outst->outtype <= OUTT_UTF8) {
- if (outst->outdata == NULL)
- outdata_alloc(outst, &conf->output);
- terminal_sepline(outst->outdata);
+ if (outst->outtype <= OUTT_UTF8) {
+ if (outst->use_pager) {
+ 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 (resp->form == FORM_SRC)
@@ -853,7 +854,7 @@ process_onefile(struct mparse *mp, struct manpage *resp, int startdir,
if (outst->tag_files != NULL) {
mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s: %s",
outst->tag_files->ofn, strerror(errno));
- tag_unlink();
+ term_tag_unlink();
outst->tag_files = NULL;
} else
mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s",
@@ -1278,7 +1279,7 @@ spawn_pager(struct tag_files *tag_files)
_exit(mandoc_msg_getrc());
}
close(tag_files->ofd);
- assert(tag_files->tfd == -1);
+ assert(tag_files->tfs == NULL);
/* Do not start the pager before controlling the terminal. */