aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-10-28 17:36:19 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-10-28 17:36:19 +0000
commitd0ac87d04f62f2c8e644686b707cb2602c2ddba6 (patch)
tree69a250d8b0b0b75bc58e1c8af72b3c3269561aed /main.c
parent5fa1bace54f386a9b3ce23690f136232e1e5bb2e (diff)
downloadmandoc-d0ac87d04f62f2c8e644686b707cb2602c2ddba6.tar.gz
mandoc-d0ac87d04f62f2c8e644686b707cb2602c2ddba6.tar.zst
mandoc-d0ac87d04f62f2c8e644686b707cb2602c2ddba6.zip
Make the character table available to libroff so it can check the
validity of character escape names and warn about unknown ones. This requires mchars_spec2cp() to report unknown names again. Fortunately, that doesn't require changing the calling code because according to groff, invalid character escapes should not produce output anyway, and now that we warn about them, that's fine.
Diffstat (limited to 'main.c')
-rw-r--r--main.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/main.c b/main.c
index d6e15b76..79a2ddd6 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.194 2014/10/25 01:03:52 schwarze Exp $ */
+/* $Id: main.c,v 1.195 2014/10/28 17:36:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -64,7 +64,6 @@ enum outt {
OUTT_TREE, /* -Ttree */
OUTT_MAN, /* -Tman */
OUTT_HTML, /* -Thtml */
- OUTT_XHTML, /* -Txhtml */
OUTT_LINT, /* -Tlint */
OUTT_PS, /* -Tps */
OUTT_PDF /* -Tpdf */
@@ -72,6 +71,7 @@ enum outt {
struct curparse {
struct mparse *mp;
+ struct mchars *mchars; /* character table */
enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
enum outt outtype; /* which output to use */
@@ -364,7 +364,9 @@ main(int argc, char *argv[])
if (use_pager && isatty(STDOUT_FILENO))
spawn_pager();
- curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos);
+ curp.mchars = mchars_alloc();
+ curp.mp = mparse_alloc(options, curp.wlevel, mmsg,
+ curp.mchars, defos);
/*
* Conditionally start up the lookaside buffer before parsing.
@@ -409,8 +411,8 @@ main(int argc, char *argv[])
if (curp.outfree)
(*curp.outfree)(curp.outdata);
- if (curp.mp)
- mparse_free(curp.mp);
+ mparse_free(curp.mp);
+ mchars_free(curp.mchars);
#if HAVE_SQLITE3
out:
@@ -495,32 +497,34 @@ parse(struct curparse *curp, int fd, const char *file,
if ( ! (curp->outman && curp->outmdoc)) {
switch (curp->outtype) {
- case OUTT_XHTML:
- curp->outdata = xhtml_alloc(curp->outopts);
- curp->outfree = html_free;
- break;
case OUTT_HTML:
- curp->outdata = html_alloc(curp->outopts);
+ curp->outdata = html_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = html_free;
break;
case OUTT_UTF8:
- curp->outdata = utf8_alloc(curp->outopts);
+ curp->outdata = utf8_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = ascii_free;
break;
case OUTT_LOCALE:
- curp->outdata = locale_alloc(curp->outopts);
+ curp->outdata = locale_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = ascii_free;
break;
case OUTT_ASCII:
- curp->outdata = ascii_alloc(curp->outopts);
+ curp->outdata = ascii_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = ascii_free;
break;
case OUTT_PDF:
- curp->outdata = pdf_alloc(curp->outopts);
+ curp->outdata = pdf_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = pspdf_free;
break;
case OUTT_PS:
- curp->outdata = ps_alloc(curp->outopts);
+ curp->outdata = ps_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = pspdf_free;
break;
default:
@@ -529,8 +533,6 @@ parse(struct curparse *curp, int fd, const char *file,
switch (curp->outtype) {
case OUTT_HTML:
- /* FALLTHROUGH */
- case OUTT_XHTML:
curp->outman = html_man;
curp->outmdoc = html_mdoc;
break;
@@ -665,7 +667,7 @@ toptions(struct curparse *curp, char *arg)
else if (0 == strcmp(arg, "locale"))
curp->outtype = OUTT_LOCALE;
else if (0 == strcmp(arg, "xhtml"))
- curp->outtype = OUTT_XHTML;
+ curp->outtype = OUTT_HTML;
else if (0 == strcmp(arg, "ps"))
curp->outtype = OUTT_PS;
else if (0 == strcmp(arg, "pdf"))