=================================================================== RCS file: /cvs/mandoc/mandocd.c,v retrieving revision 1.7 retrieving revision 1.13 diff -u -p -r1.7 -r1.13 --- mandoc/mandocd.c 2018/12/13 11:55:46 1.7 +++ mandoc/mandocd.c 2022/04/14 16:43:44 1.13 @@ -1,7 +1,7 @@ -/* $Id: mandocd.c,v 1.7 2018/12/13 11:55:46 schwarze Exp $ */ +/* $Id: mandocd.c,v 1.13 2022/04/14 16:43:44 schwarze Exp $ */ /* * Copyright (c) 2017 Michael Stapelberg - * Copyright (c) 2017 Ingo Schwarze + * Copyright (c) 2017, 2019, 2021 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -17,7 +17,7 @@ */ #include "config.h" -#if HAVE_CMSG_XPG42 +#if NEED_XPG4_2 #define _XPG4_2 #endif @@ -35,6 +35,10 @@ #include #include "mandoc.h" +#if DEBUG_MEMORY +#define DEBUG_NODEF 1 +#include "mandoc_dbg.h" +#endif #include "roff.h" #include "mdoc.h" #include "man.h" @@ -129,6 +133,10 @@ main(int argc, char *argv[]) int state, opt; enum outt outtype; +#if DEBUG_MEMORY + mandoc_dbg_init(argc, argv); +#endif + defos = NULL; outtype = OUTT_ASCII; while ((opt = getopt(argc, argv, "I:T:")) != -1) { @@ -171,8 +179,8 @@ main(int argc, char *argv[]) errx(1, "file descriptor %s %s", argv[1], errstr); mchars_alloc(); - parser = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1, - MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, defos); + parser = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 | + MPARSE_VALIDATE, MANDOC_OS_OTHER, defos); memset(&options, 0, sizeof(options)); switch (outtype) { @@ -213,6 +221,8 @@ main(int argc, char *argv[]) process(parser, outtype, formatter); mparse_reset(parser); + if (outtype == OUTT_HTML) + html_reset(formatter); fflush(stdout); fflush(stderr); @@ -238,41 +248,38 @@ main(int argc, char *argv[]) } mparse_free(parser); mchars_free(); +#if DEBUG_MEMORY + mandoc_dbg_finish(); +#endif return state == -1 ? 1 : 0; } static void process(struct mparse *parser, enum outt outtype, void *formatter) { - struct roff_man *man; + struct roff_meta *meta; mparse_readfd(parser, STDIN_FILENO, ""); - mparse_result(parser, &man, NULL); - - if (man == NULL) - return; - - if (man->macroset == MACROSET_MDOC) { - mdoc_validate(man); + meta = mparse_result(parser); + if (meta->macroset == MACROSET_MDOC) { switch (outtype) { case OUTT_ASCII: case OUTT_UTF8: - terminal_mdoc(formatter, man); + terminal_mdoc(formatter, meta); break; case OUTT_HTML: - html_mdoc(formatter, man); + html_mdoc(formatter, meta); break; } } - if (man->macroset == MACROSET_MAN) { - man_validate(man); + if (meta->macroset == MACROSET_MAN) { switch (outtype) { case OUTT_ASCII: case OUTT_UTF8: - terminal_man(formatter, man); + terminal_man(formatter, meta); break; case OUTT_HTML: - html_man(formatter, man); + html_man(formatter, meta); break; } }