summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/cgi.c30
-rw-r--r--usr.bin/mandoc/libman.h5
-rw-r--r--usr.bin/mandoc/libmdoc.h6
-rw-r--r--usr.bin/mandoc/main.c37
-rw-r--r--usr.bin/mandoc/main.h20
-rw-r--r--usr.bin/mandoc/man.c4
-rw-r--r--usr.bin/mandoc/man_html.c12
-rw-r--r--usr.bin/mandoc/man_macro.c4
-rw-r--r--usr.bin/mandoc/man_term.c11
-rw-r--r--usr.bin/mandoc/mandoc.c5
-rw-r--r--usr.bin/mandoc/mandoc_parse.h8
-rw-r--r--usr.bin/mandoc/mandocdb.c46
-rw-r--r--usr.bin/mandoc/mdoc.c4
-rw-r--r--usr.bin/mandoc/mdoc.h5
-rw-r--r--usr.bin/mandoc/mdoc_html.c12
-rw-r--r--usr.bin/mandoc/mdoc_macro.c4
-rw-r--r--usr.bin/mandoc/mdoc_man.c11
-rw-r--r--usr.bin/mandoc/mdoc_markdown.c20
-rw-r--r--usr.bin/mandoc/mdoc_state.c5
-rw-r--r--usr.bin/mandoc/mdoc_term.c12
-rw-r--r--usr.bin/mandoc/mdoc_validate.c6
-rw-r--r--usr.bin/mandoc/read.c48
-rw-r--r--usr.bin/mandoc/roff.c31
-rw-r--r--usr.bin/mandoc/roff.h45
-rw-r--r--usr.bin/mandoc/roff_int.h48
-rw-r--r--usr.bin/mandoc/tree.c12
26 files changed, 222 insertions, 229 deletions
diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c
index 706e924853b..79766a0b5d4 100644
--- a/usr.bin/mandoc/cgi.c
+++ b/usr.bin/mandoc/cgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cgi.c,v 1.101 2018/12/14 01:17:46 schwarze Exp $ */
+/* $OpenBSD: cgi.c,v 1.102 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017, 2018 Ingo Schwarze <schwarze@usta.de>
@@ -845,7 +845,7 @@ resp_format(const struct req *req, const char *file)
{
struct manoutput conf;
struct mparse *mp;
- struct roff_man *man;
+ struct roff_meta *meta;
void *vp;
int fd;
int usepath;
@@ -856,10 +856,11 @@ resp_format(const struct req *req, const char *file)
}
mchars_alloc();
- mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1,
- MANDOC_OS_OTHER, req->q.manpath);
+ mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 |
+ MPARSE_VALIDATE, MANDOC_OS_OTHER, req->q.manpath);
mparse_readfd(mp, fd, file);
close(fd);
+ meta = mparse_result(mp);
memset(&conf, 0, sizeof(conf));
conf.fragment = 1;
@@ -870,24 +871,11 @@ resp_format(const struct req *req, const char *file)
scriptname, *scriptname == '\0' ? "" : "/",
usepath ? req->q.manpath : "", usepath ? "/" : "");
- mparse_result(mp, &man, NULL);
- if (man == NULL) {
- warnx("fatal mandoc error: %s/%s", req->q.manpath, file);
- pg_error_internal();
- mparse_free(mp);
- mchars_free();
- return;
- }
-
vp = html_alloc(&conf);
-
- if (man->macroset == MACROSET_MDOC) {
- mdoc_validate(man);
- html_mdoc(vp, man);
- } else {
- man_validate(man);
- html_man(vp, man);
- }
+ if (meta->macroset == MACROSET_MDOC)
+ html_mdoc(vp, meta);
+ else
+ html_man(vp, meta);
html_free(vp);
mparse_free(mp);
diff --git a/usr.bin/mandoc/libman.h b/usr.bin/mandoc/libman.h
index b62950fe3e8..3b6e222c986 100644
--- a/usr.bin/mandoc/libman.h
+++ b/usr.bin/mandoc/libman.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libman.h,v 1.58 2018/08/26 16:18:38 schwarze Exp $ */
+/* $OpenBSD: libman.h,v 1.59 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,6 +16,9 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+struct roff_node;
+struct roff_man;
+
#define MACRO_PROT_ARGS struct roff_man *man, \
enum roff_tok tok, \
int line, \
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index 6eab77501d4..0f3a241ae2b 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libmdoc.h,v 1.86 2018/12/21 16:58:49 schwarze Exp $ */
+/* $OpenBSD: libmdoc.h,v 1.87 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,6 +16,10 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+struct roff_node;
+struct roff_man;
+struct mdoc_arg;
+
#define MACRO_PROT_ARGS struct roff_man *mdoc, \
enum roff_tok tok, \
int line, \
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 47c989073ad..482337a53c7 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.217 2018/12/20 21:27:51 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.218 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -284,6 +284,9 @@ main(int argc, char *argv[])
}
}
+ if (curp.outtype != OUTT_TREE || !curp.outopts->noval)
+ options |= MPARSE_VALIDATE;
+
if (outmode == OUTMODE_FLN ||
outmode == OUTMODE_LST ||
!isatty(STDOUT_FILENO))
@@ -771,7 +774,7 @@ fs_search(const struct mansearch *cfg, const struct manpaths *paths,
static void
parse(struct curparse *curp, int fd, const char *file)
{
- struct roff_man *man;
+ struct roff_meta *meta;
/* Begin by parsing the file itself. */
@@ -793,49 +796,43 @@ parse(struct curparse *curp, int fd, const char *file)
if (curp->outdata == NULL)
outdata_alloc(curp);
- mparse_result(curp->mp, &man, NULL);
+ mandoc_xr_reset();
+ meta = mparse_result(curp->mp);
/* Execute the out device, if it exists. */
- if (man == NULL)
- return;
- mandoc_xr_reset();
- if (man->macroset == MACROSET_MDOC) {
- if (curp->outtype != OUTT_TREE || !curp->outopts->noval)
- mdoc_validate(man);
+ if (meta->macroset == MACROSET_MDOC) {
switch (curp->outtype) {
case OUTT_HTML:
- html_mdoc(curp->outdata, man);
+ html_mdoc(curp->outdata, meta);
break;
case OUTT_TREE:
- tree_mdoc(curp->outdata, man);
+ tree_mdoc(curp->outdata, meta);
break;
case OUTT_MAN:
- man_mdoc(curp->outdata, man);
+ man_mdoc(curp->outdata, meta);
break;
case OUTT_PDF:
case OUTT_ASCII:
case OUTT_UTF8:
case OUTT_LOCALE:
case OUTT_PS:
- terminal_mdoc(curp->outdata, man);
+ terminal_mdoc(curp->outdata, meta);
break;
case OUTT_MARKDOWN:
- markdown_mdoc(curp->outdata, man);
+ markdown_mdoc(curp->outdata, meta);
break;
default:
break;
}
}
- if (man->macroset == MACROSET_MAN) {
- if (curp->outtype != OUTT_TREE || !curp->outopts->noval)
- man_validate(man);
+ if (meta->macroset == MACROSET_MAN) {
switch (curp->outtype) {
case OUTT_HTML:
- html_man(curp->outdata, man);
+ html_man(curp->outdata, meta);
break;
case OUTT_TREE:
- tree_man(curp->outdata, man);
+ tree_man(curp->outdata, meta);
break;
case OUTT_MAN:
mparse_copy(curp->mp);
@@ -845,7 +842,7 @@ parse(struct curparse *curp, int fd, const char *file)
case OUTT_UTF8:
case OUTT_LOCALE:
case OUTT_PS:
- terminal_man(curp->outdata, man);
+ terminal_man(curp->outdata, meta);
break;
default:
break;
diff --git a/usr.bin/mandoc/main.h b/usr.bin/mandoc/main.h
index f23bb9e8e9c..10ad298012d 100644
--- a/usr.bin/mandoc/main.h
+++ b/usr.bin/mandoc/main.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.h,v 1.23 2018/08/23 19:32:03 schwarze Exp $ */
+/* $OpenBSD: main.h,v 1.24 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-struct roff_man;
+struct roff_meta;
struct manoutput;
/*
@@ -27,14 +27,14 @@ struct manoutput;
*/
void *html_alloc(const struct manoutput *);
-void html_mdoc(void *, const struct roff_man *);
-void html_man(void *, const struct roff_man *);
+void html_mdoc(void *, const struct roff_meta *);
+void html_man(void *, const struct roff_meta *);
void html_free(void *);
-void tree_mdoc(void *, const struct roff_man *);
-void tree_man(void *, const struct roff_man *);
+void tree_mdoc(void *, const struct roff_meta *);
+void tree_man(void *, const struct roff_meta *);
-void man_mdoc(void *, const struct roff_man *);
+void man_mdoc(void *, const struct roff_meta *);
void *locale_alloc(const struct manoutput *);
void *utf8_alloc(const struct manoutput *);
@@ -45,8 +45,8 @@ void *pdf_alloc(const struct manoutput *);
void *ps_alloc(const struct manoutput *);
void pspdf_free(void *);
-void terminal_mdoc(void *, const struct roff_man *);
-void terminal_man(void *, const struct roff_man *);
+void terminal_mdoc(void *, const struct roff_meta *);
+void terminal_man(void *, const struct roff_meta *);
void terminal_sepline(void *);
-void markdown_mdoc(void *, const struct roff_man *);
+void markdown_mdoc(void *, const struct roff_meta *);
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 62762f6605d..6bed70b9ea3 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.129 2018/12/14 05:17:45 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.130 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -370,7 +370,7 @@ void
man_validate(struct roff_man *man)
{
- man->last = man->first;
+ man->last = man->meta.first;
man_node_validate(man);
man->flags &= ~MAN_LITERAL;
}
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index a420656083d..79a24cb8b38 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_html.c,v 1.113 2018/12/15 23:33:20 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.114 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -137,7 +137,7 @@ print_bvspace(struct html *h, const struct roff_node *n)
}
void
-html_man(void *arg, const struct roff_man *man)
+html_man(void *arg, const struct roff_meta *man)
{
struct html *h;
struct roff_node *n;
@@ -152,16 +152,16 @@ html_man(void *arg, const struct roff_man *man)
if (n->type == ROFFT_COMMENT)
print_gen_comment(h, n);
t = print_otag(h, TAG_HEAD, "");
- print_man_head(&man->meta, h);
+ print_man_head(man, h);
print_tagq(h, t);
print_otag(h, TAG_BODY, "");
}
- man_root_pre(&man->meta, h);
+ man_root_pre(man, h);
t = print_otag(h, TAG_DIV, "c", "manual-text");
- print_man_nodelist(&man->meta, n, h);
+ print_man_nodelist(man, n, h);
print_tagq(h, t);
- man_root_post(&man->meta, h);
+ man_root_post(man, h);
print_tagq(h, NULL);
}
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c
index 057303c9dce..4aa496cf201 100644
--- a/usr.bin/mandoc/man_macro.c
+++ b/usr.bin/mandoc/man_macro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_macro.c,v 1.99 2018/12/21 16:58:49 schwarze Exp $ */
+/* $OpenBSD: man_macro.c,v 1.100 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -444,7 +444,7 @@ void
man_endparse(struct roff_man *man)
{
- man_unscope(man, man->first);
+ man_unscope(man, man->meta.first);
man->flags &= ~MAN_LITERAL;
}
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 11c5fb4770e..6983e3bbeb8 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.175 2018/12/13 11:55:14 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.176 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -145,7 +145,7 @@ man_term_act(enum roff_tok tok)
}
void
-terminal_man(void *arg, const struct roff_man *man)
+terminal_man(void *arg, const struct roff_meta *man)
{
struct termp *p;
struct roff_node *n;
@@ -174,18 +174,17 @@ terminal_man(void *arg, const struct roff_man *man)
!strcmp(n->child->child->string, "SYNOPSIS")) {
if (n->child->next->child != NULL)
print_man_nodelist(p, &mt,
- n->child->next->child,
- &man->meta);
+ n->child->next->child, man);
term_newln(p);
break;
}
n = n->next;
}
} else {
- term_begin(p, print_man_head, print_man_foot, &man->meta);
+ term_begin(p, print_man_head, print_man_foot, man);
p->flags |= TERMP_NOSPACE;
if (n != NULL)
- print_man_nodelist(p, &mt, n, &man->meta);
+ print_man_nodelist(p, &mt, n, man);
term_end(p);
}
p->defindent = save_defindent;
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index c3ded68e995..c3d71f4f44f 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.c,v 1.81 2018/12/18 21:58:41 schwarze Exp $ */
+/* $OpenBSD: mandoc.c,v 1.82 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -30,6 +30,7 @@
#include "mandoc.h"
#include "roff.h"
#include "libmandoc.h"
+#include "roff_int.h"
static int a2time(time_t *, const char *, const char *);
static char *time2a(time_t);
@@ -558,7 +559,7 @@ mandoc_normdate(struct roff_man *man, char *in, int ln, int pos)
mandoc_msg(MANDOCERR_DATE_BAD, ln, pos, "%s", in);
else if (t > time(NULL) + 86400)
mandoc_msg(MANDOCERR_DATE_FUTURE, ln, pos, "%s", in);
- else if (man->macroset == MACROSET_MDOC)
+ else if (man->meta.macroset == MACROSET_MDOC)
mandoc_msg(MANDOCERR_DATE_LEGACY, ln, pos, "Dd %s", in);
/* Use any non-mdoc(7) date verbatim. */
diff --git a/usr.bin/mandoc/mandoc_parse.h b/usr.bin/mandoc/mandoc_parse.h
index dab15d8de85..650b716c1ae 100644
--- a/usr.bin/mandoc/mandoc_parse.h
+++ b/usr.bin/mandoc/mandoc_parse.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc_parse.h,v 1.2 2018/12/14 01:17:46 schwarze Exp $ */
+/* $OpenBSD: mandoc_parse.h,v 1.3 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -28,10 +28,11 @@
#define MPARSE_QUICK (1 << 3) /* abort the parse early */
#define MPARSE_UTF8 (1 << 4) /* accept UTF-8 input */
#define MPARSE_LATIN1 (1 << 5) /* accept ISO-LATIN-1 input */
+#define MPARSE_VALIDATE (1 << 6) /* call validation functions */
+struct roff_meta;
struct mparse;
-struct roff_man;
struct mparse *mparse_alloc(int, enum mandoc_os, const char *);
void mparse_copy(const struct mparse *);
@@ -39,5 +40,4 @@ void mparse_free(struct mparse *);
int mparse_open(struct mparse *, const char *);
void mparse_readfd(struct mparse *, int, const char *);
void mparse_reset(struct mparse *);
-void mparse_result(struct mparse *,
- struct roff_man **, char **);
+struct roff_meta *mparse_result(struct mparse *);
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index a8154daada5..1af39e8095d 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.210 2018/12/14 01:17:46 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.211 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -323,6 +323,7 @@ mandocdb(int argc, char *argv[])
goto usage; \
} while (/*CONSTCOND*/0)
+ mparse_options = MPARSE_VALIDATE;
path_arg = NULL;
op = OP_DEFAULT;
@@ -1077,8 +1078,7 @@ mpages_merge(struct dba *dba, struct mparse *mp)
{
struct mpage *mpage, *mpage_dest;
struct mlink *mlink, *mlink_dest;
- struct roff_man *man;
- char *sodest;
+ struct roff_meta *meta;
char *cp;
int fd;
@@ -1091,8 +1091,7 @@ mpages_merge(struct dba *dba, struct mparse *mp)
mandoc_ohash_init(&names, 4, offsetof(struct str, key));
mandoc_ohash_init(&strings, 6, offsetof(struct str, key));
mparse_reset(mp);
- man = NULL;
- sodest = NULL;
+ meta = NULL;
if ((fd = mparse_open(mp, mlink->file)) == -1) {
say(mlink->file, "&open");
@@ -1107,14 +1106,14 @@ mpages_merge(struct dba *dba, struct mparse *mp)
mparse_readfd(mp, fd, mlink->file);
close(fd);
fd = -1;
- mparse_result(mp, &man, &sodest);
+ meta = mparse_result(mp);
}
- if (sodest != NULL) {
+ if (meta != NULL && meta->sodest != NULL) {
mlink_dest = ohash_find(&mlinks,
- ohash_qlookup(&mlinks, sodest));
+ ohash_qlookup(&mlinks, meta->sodest));
if (mlink_dest == NULL) {
- mandoc_asprintf(&cp, "%s.gz", sodest);
+ mandoc_asprintf(&cp, "%s.gz", meta->sodest);
mlink_dest = ohash_find(&mlinks,
ohash_qlookup(&mlinks, cp));
free(cp);
@@ -1151,39 +1150,36 @@ mpages_merge(struct dba *dba, struct mparse *mp)
mpage->mlinks = NULL;
}
goto nextpage;
- } else if (man != NULL && man->macroset == MACROSET_MDOC) {
- mdoc_validate(man);
+ } else if (meta != NULL && meta->macroset == MACROSET_MDOC) {
mpage->form = FORM_SRC;
- mpage->sec = man->meta.msec;
+ mpage->sec = meta->msec;
mpage->sec = mandoc_strdup(
mpage->sec == NULL ? "" : mpage->sec);
- mpage->arch = man->meta.arch;
+ mpage->arch = meta->arch;
mpage->arch = mandoc_strdup(
mpage->arch == NULL ? "" : mpage->arch);
- mpage->title = mandoc_strdup(man->meta.title);
- } else if (man != NULL && man->macroset == MACROSET_MAN) {
- man_validate(man);
- if (*man->meta.msec != '\0' ||
- *man->meta.title != '\0') {
+ mpage->title = mandoc_strdup(meta->title);
+ } else if (meta != NULL && meta->macroset == MACROSET_MAN) {
+ if (*meta->msec != '\0' || *meta->title != '\0') {
mpage->form = FORM_SRC;
- mpage->sec = mandoc_strdup(man->meta.msec);
+ mpage->sec = mandoc_strdup(meta->msec);
mpage->arch = mandoc_strdup(mlink->arch);
- mpage->title = mandoc_strdup(man->meta.title);
+ mpage->title = mandoc_strdup(meta->title);
} else
- man = NULL;
+ meta = NULL;
}
assert(mpage->desc == NULL);
- if (man == NULL) {
+ if (meta == NULL) {
mpage->form = FORM_CAT;
mpage->sec = mandoc_strdup(mlink->dsec);
mpage->arch = mandoc_strdup(mlink->arch);
mpage->title = mandoc_strdup(mlink->name);
parse_cat(mpage, fd);
- } else if (man->macroset == MACROSET_MDOC)
- parse_mdoc(mpage, &man->meta, man->first);
+ } else if (meta->macroset == MACROSET_MDOC)
+ parse_mdoc(mpage, meta, meta->first);
else
- parse_man(mpage, &man->meta, man->first);
+ parse_man(mpage, meta, meta->first);
if (mpage->desc == NULL) {
mpage->desc = mandoc_strdup(mlink->name);
if (warnings)
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index c10266e78be..2764dc04614 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc.c,v 1.160 2018/12/14 05:17:45 schwarze Exp $ */
+/* $OpenBSD: mdoc.c,v 1.161 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -431,7 +431,7 @@ void
mdoc_validate(struct roff_man *mdoc)
{
- mdoc->last = mdoc->first;
+ mdoc->last = mdoc->meta.first;
mdoc_node_validate(mdoc);
mdoc_state_reset(mdoc);
}
diff --git a/usr.bin/mandoc/mdoc.h b/usr.bin/mandoc/mdoc.h
index 9897f383a7f..aa4a5ec6fee 100644
--- a/usr.bin/mandoc/mdoc.h
+++ b/usr.bin/mandoc/mdoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc.h,v 1.70 2017/04/24 23:06:09 schwarze Exp $ */
+/* $OpenBSD: mdoc.h,v 1.71 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,6 +16,9 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+struct roff_node;
+struct roff_man;
+
enum mdocargt {
MDOC_Split, /* -split */
MDOC_Nosplit, /* -nospli */
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index e8c7e6b78e9..6bb983eb6d2 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.195 2018/12/25 00:05:38 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.196 2018/12/30 00:48:47 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -281,7 +281,7 @@ synopsis_pre(struct html *h, const struct roff_node *n)
}
void
-html_mdoc(void *arg, const struct roff_man *mdoc)
+html_mdoc(void *arg, const struct roff_meta *mdoc)
{
struct html *h;
struct roff_node *n;
@@ -296,16 +296,16 @@ html_mdoc(void *arg, const struct roff_man *mdoc)
if (n->type == ROFFT_COMMENT)
print_gen_comment(h, n);
t = print_otag(h, TAG_HEAD, "");
- print_mdoc_head(&mdoc->meta, h);
+ print_mdoc_head(mdoc, h);
print_tagq(h, t);
print_otag(h, TAG_BODY, "");
}
- mdoc_root_pre(&mdoc->meta, h);
+ mdoc_root_pre(mdoc, h);
t = print_otag(h, TAG_DIV, "c", "manual-text");
- print_mdoc_nodelist(&mdoc->meta, n, h);
+ print_mdoc_nodelist(mdoc, n, h);
print_tagq(h, t);
- mdoc_root_post(&mdoc->meta, h);
+ mdoc_root_post(mdoc, h);
print_tagq(h, NULL);
}
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 5ae8a3a4d96..5b946635872 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_macro.c,v 1.185 2018/12/21 16:58:49 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.186 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -231,7 +231,7 @@ mdoc_endparse(struct roff_man *mdoc)
/* Rewind to the first. */
- rew_last(mdoc, mdoc->first);
+ rew_last(mdoc, mdoc->meta.first);
mdoc_state_reset(mdoc);
}
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 17446b70f2a..a573de7f108 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.128 2018/12/15 19:30:19 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.129 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -600,7 +600,7 @@ print_count(int *count)
}
void
-man_mdoc(void *arg, const struct roff_man *mdoc)
+man_mdoc(void *arg, const struct roff_meta *mdoc)
{
struct roff_node *n;
@@ -613,9 +613,8 @@ man_mdoc(void *arg, const struct roff_man *mdoc)
}
printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
- mdoc->meta.title,
- (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec),
- mdoc->meta.date, mdoc->meta.os, mdoc->meta.vol);
+ mdoc->title, (mdoc->msec == NULL ? "" : mdoc->msec),
+ mdoc->date, mdoc->os, mdoc->vol);
/* Disable hyphenation and if nroff, disable justification. */
printf(".nh\n.if n .ad l");
@@ -627,7 +626,7 @@ man_mdoc(void *arg, const struct roff_man *mdoc)
*fontqueue.tail = 'R';
}
for (; n != NULL; n = n->next)
- print_node(&mdoc->meta, n);
+ print_node(mdoc, n);
putchar('\n');
}
diff --git a/usr.bin/mandoc/mdoc_markdown.c b/usr.bin/mandoc/mdoc_markdown.c
index ffb28bd704a..e6ac6f945d0 100644
--- a/usr.bin/mandoc/mdoc_markdown.c
+++ b/usr.bin/mandoc/mdoc_markdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_markdown.c,v 1.29 2018/12/15 19:30:19 schwarze Exp $ */
+/* $OpenBSD: mdoc_markdown.c,v 1.30 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -261,21 +261,21 @@ md_act(enum roff_tok tok)
}
void
-markdown_mdoc(void *arg, const struct roff_man *mdoc)
+markdown_mdoc(void *arg, const struct roff_meta *mdoc)
{
outflags = MD_Sm;
- md_word(mdoc->meta.title);
- if (mdoc->meta.msec != NULL) {
+ md_word(mdoc->title);
+ if (mdoc->msec != NULL) {
outflags &= ~MD_spc;
md_word("(");
- md_word(mdoc->meta.msec);
+ md_word(mdoc->msec);
md_word(")");
}
md_word("-");
- md_word(mdoc->meta.vol);
- if (mdoc->meta.arch != NULL) {
+ md_word(mdoc->vol);
+ if (mdoc->arch != NULL) {
md_word("(");
- md_word(mdoc->meta.arch);
+ md_word(mdoc->arch);
md_word(")");
}
outflags |= MD_sp;
@@ -283,9 +283,9 @@ markdown_mdoc(void *arg, const struct roff_man *mdoc)
md_nodelist(mdoc->first->child);
outflags |= MD_sp;
- md_word(mdoc->meta.os);
+ md_word(mdoc->os);
md_word("-");
- md_word(mdoc->meta.date);
+ md_word(mdoc->date);
putchar('\n');
}
diff --git a/usr.bin/mandoc/mdoc_state.c b/usr.bin/mandoc/mdoc_state.c
index 44905b6a676..6deb3d4e7bc 100644
--- a/usr.bin/mandoc/mdoc_state.c
+++ b/usr.bin/mandoc/mdoc_state.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: mdoc_state.c,v 1.11 2018/12/14 01:17:46 schwarze Exp $ */
+/* $OpenBSD: mdoc_state.c,v 1.12 2018/12/30 00:48:48 schwarze Exp $ */
/*
- * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -25,6 +25,7 @@
#include "roff.h"
#include "mdoc.h"
#include "libmandoc.h"
+#include "roff_int.h"
#include "libmdoc.h"
#define STATE_ARGS struct roff_man *mdoc, struct roff_node *n
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 075c09a0b89..f5c26d5fbde 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.269 2018/12/13 11:55:14 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.270 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -249,7 +249,7 @@ static int fn_prio;
void
-terminal_mdoc(void *arg, const struct roff_man *mdoc)
+terminal_mdoc(void *arg, const struct roff_meta *mdoc)
{
struct roff_node *n;
struct termp *p;
@@ -267,8 +267,7 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc)
if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
if (n->child->next->child != NULL)
print_mdoc_nodelist(p, NULL,
- &mdoc->meta,
- n->child->next->child);
+ mdoc, n->child->next->child);
term_newln(p);
break;
}
@@ -278,8 +277,7 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc)
save_defindent = p->defindent;
if (p->defindent == 0)
p->defindent = 5;
- term_begin(p, print_mdoc_head, print_mdoc_foot,
- &mdoc->meta);
+ term_begin(p, print_mdoc_head, print_mdoc_foot, mdoc);
while (n != NULL &&
(n->type == ROFFT_COMMENT ||
n->flags & NODE_NOPRT))
@@ -287,7 +285,7 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc)
if (n != NULL) {
if (n->tok != MDOC_Sh)
term_vspace(p);
- print_mdoc_nodelist(p, NULL, &mdoc->meta, n);
+ print_mdoc_nodelist(p, NULL, mdoc, n);
}
term_end(p);
p->defindent = save_defindent;
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 8abf8107971..8a76a27f74b 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_validate.c,v 1.280 2018/12/14 05:17:45 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.281 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -1937,7 +1937,7 @@ post_root(POST_ARGS)
while (*arch != NULL && strcmp(*arch, mdoc->meta.arch))
arch++;
if (*arch == NULL) {
- n = mdoc->first->child;
+ n = mdoc->meta.first->child;
while (n->tok != MDOC_Dt ||
n->child == NULL ||
n->child->next == NULL ||
@@ -1953,7 +1953,7 @@ post_root(POST_ARGS)
/* Check that we begin with a proper `Sh'. */
- n = mdoc->first->child;
+ n = mdoc->meta.first->child;
while (n != NULL &&
(n->type == ROFFT_COMMENT ||
(n->tok >= MDOC_Dd &&
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index dae214b2d51..f9c7996e358 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.179 2018/12/20 21:27:51 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.180 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -45,7 +45,6 @@
struct mparse {
struct roff *roff; /* roff parser (!NULL) */
struct roff_man *man; /* man parser */
- char *sodest; /* filename pointed to by .so */
struct buf *primary; /* buffer currently being parsed */
struct buf *secondary; /* copy of top level input */
struct buf *loop; /* open .while request line */
@@ -121,15 +120,15 @@ choose_parser(struct mparse *curp)
}
if (format == MPARSE_MDOC) {
- curp->man->macroset = MACROSET_MDOC;
+ curp->man->meta.macroset = MACROSET_MDOC;
if (curp->man->mdocmac == NULL)
curp->man->mdocmac = roffhash_alloc(MDOC_Dd, MDOC_MAX);
} else {
- curp->man->macroset = MACROSET_MAN;
+ curp->man->meta.macroset = MACROSET_MAN;
if (curp->man->manmac == NULL)
curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
}
- curp->man->first->tok = TOKEN_NONE;
+ curp->man->meta.first->tok = TOKEN_NONE;
}
/*
@@ -332,9 +331,9 @@ rerun:
case ROFF_IGN:
break;
case ROFF_CONT:
- if (curp->man->macroset == MACROSET_NONE)
+ if (curp->man->meta.macroset == MACROSET_NONE)
choose_parser(curp);
- if ((curp->man->macroset == MACROSET_MDOC ?
+ if ((curp->man->meta.macroset == MACROSET_MDOC ?
mdoc_parseln(curp->man, curp->line, ln.buf, of) :
man_parseln(curp->man, curp->line, ln.buf, of)
) == 2)
@@ -363,7 +362,8 @@ rerun:
case ROFF_SO:
if ( ! (curp->options & MPARSE_SO) &&
(i >= blk.sz || blk.buf[i] == '\0')) {
- curp->sodest = mandoc_strdup(ln.buf + of);
+ curp->man->meta.sodest =
+ mandoc_strdup(ln.buf + of);
goto out;
}
if ((fd = mparse_open(curp, ln.buf + of)) != -1) {
@@ -524,9 +524,9 @@ read_whole_file(struct mparse *curp, int fd, struct buf *fb, int *with_mmap)
static void
mparse_end(struct mparse *curp)
{
- if (curp->man->macroset == MACROSET_NONE)
- curp->man->macroset = MACROSET_MAN;
- if (curp->man->macroset == MACROSET_MDOC)
+ if (curp->man->meta.macroset == MACROSET_NONE)
+ curp->man->meta.macroset = MACROSET_MAN;
+ if (curp->man->meta.macroset == MACROSET_MDOC)
mdoc_endparse(curp->man);
else
man_endparse(curp->man);
@@ -649,15 +649,15 @@ mparse_alloc(int options, enum mandoc_os os_e, const char *os_s)
curp->man = roff_man_alloc(curp->roff, curp->os_s,
curp->options & MPARSE_QUICK ? 1 : 0);
if (curp->options & MPARSE_MDOC) {
- curp->man->macroset = MACROSET_MDOC;
+ curp->man->meta.macroset = MACROSET_MDOC;
if (curp->man->mdocmac == NULL)
curp->man->mdocmac = roffhash_alloc(MDOC_Dd, MDOC_MAX);
} else if (curp->options & MPARSE_MAN) {
- curp->man->macroset = MACROSET_MAN;
+ curp->man->meta.macroset = MACROSET_MAN;
if (curp->man->manmac == NULL)
curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
}
- curp->man->first->tok = TOKEN_NONE;
+ curp->man->meta.first->tok = TOKEN_NONE;
curp->man->meta.os_e = os_e;
return curp;
}
@@ -669,8 +669,6 @@ mparse_reset(struct mparse *curp)
roff_man_reset(curp->man);
free_buf_list(curp->secondary);
curp->secondary = NULL;
- free(curp->sodest);
- curp->sodest = NULL;
curp->gzip = 0;
}
@@ -682,21 +680,19 @@ mparse_free(struct mparse *curp)
roff_man_free(curp->man);
roff_free(curp->roff);
free_buf_list(curp->secondary);
- free(curp->sodest);
free(curp);
}
-void
-mparse_result(struct mparse *curp, struct roff_man **man,
- char **sodest)
+struct roff_meta *
+mparse_result(struct mparse *curp)
{
-
- if (sodest && NULL != (*sodest = curp->sodest)) {
- *man = NULL;
- return;
+ if (curp->options & MPARSE_VALIDATE) {
+ if (curp->man->meta.macroset == MACROSET_MDOC)
+ mdoc_validate(curp->man);
+ else
+ man_validate(curp->man);
}
- if (man)
- *man = curp->man;
+ return &curp->man->meta;
}
void
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 880c935dfc4..419fd3db0d6 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.227 2018/12/21 16:58:49 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.228 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -805,9 +805,8 @@ roff_alloc(int options)
static void
roff_man_free1(struct roff_man *man)
{
-
- if (man->first != NULL)
- roff_node_delete(man, man->first);
+ if (man->meta.first != NULL)
+ roff_node_delete(man, man->meta.first);
free(man->meta.msec);
free(man->meta.vol);
free(man->meta.os);
@@ -815,19 +814,19 @@ roff_man_free1(struct roff_man *man)
free(man->meta.title);
free(man->meta.name);
free(man->meta.date);
+ free(man->meta.sodest);
}
static void
roff_man_alloc1(struct roff_man *man)
{
-
memset(&man->meta, 0, sizeof(man->meta));
- man->first = mandoc_calloc(1, sizeof(*man->first));
- man->first->type = ROFFT_ROOT;
- man->last = man->first;
+ man->meta.first = mandoc_calloc(1, sizeof(*man->meta.first));
+ man->meta.first->type = ROFFT_ROOT;
+ man->last = man->meta.first;
man->last_es = NULL;
man->flags = 0;
- man->macroset = MACROSET_NONE;
+ man->meta.macroset = MACROSET_NONE;
man->lastsec = man->lastnamed = SEC_NONE;
man->next = ROFF_NEXT_CHILD;
}
@@ -835,7 +834,6 @@ roff_man_alloc1(struct roff_man *man)
void
roff_man_reset(struct roff_man *man)
{
-
roff_man_free1(man);
roff_man_alloc1(man);
}
@@ -843,7 +841,6 @@ roff_man_reset(struct roff_man *man)
void
roff_man_free(struct roff_man *man)
{
-
roff_man_free1(man);
free(man);
}
@@ -1018,7 +1015,7 @@ roff_addtbl(struct roff_man *man, int line, struct tbl_node *tbl)
struct roff_node *n;
struct tbl_span *span;
- if (man->macroset == MACROSET_MAN)
+ if (man->meta.macroset == MACROSET_MAN)
man_breakscope(man, ROFF_TS);
while ((span = tbl_span(tbl)) != NULL) {
n = roff_node_alloc(man, line, 0, ROFFT_TBL, TOKEN_NONE);
@@ -1062,8 +1059,8 @@ roff_node_unlink(struct roff_man *man, struct roff_node *n)
man->next = ROFF_NEXT_SIBLING;
}
}
- if (man->first == n)
- man->first = NULL;
+ if (man->meta.first == n)
+ man->meta.first = NULL;
}
void
@@ -3279,7 +3276,7 @@ roff_EQ(ROFF_ARGS)
{
struct roff_node *n;
- if (r->man->macroset == MACROSET_MAN)
+ if (r->man->meta.macroset == MACROSET_MAN)
man_breakscope(r->man, ROFF_EQ);
n = roff_node_alloc(r->man, ln, ppos, ROFFT_EQN, TOKEN_NONE);
if (ln > r->man->last->line)
@@ -4019,7 +4016,7 @@ roff_getstrn(struct roff *r, const char *name, size_t len,
break;
}
}
- if (r->man->macroset != MACROSET_MAN) {
+ if (r->man->meta.macroset != MACROSET_MAN) {
for (tok = MDOC_Dd; tok < MDOC_MAX; tok++) {
if (strncmp(name, roff_name[tok], len) != 0 ||
roff_name[tok][len] != '\0')
@@ -4033,7 +4030,7 @@ roff_getstrn(struct roff *r, const char *name, size_t len,
}
}
}
- if (r->man->macroset != MACROSET_MDOC) {
+ if (r->man->meta.macroset != MACROSET_MDOC) {
for (tok = MAN_TH; tok < MAN_MAX; tok++) {
if (strncmp(name, roff_name[tok], len) != 0 ||
roff_name[tok][len] != '\0')
diff --git a/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h
index 2d562908bc3..f68981dbe73 100644
--- a/usr.bin/mandoc/roff.h
+++ b/usr.bin/mandoc/roff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.h,v 1.47 2018/12/14 06:33:03 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.48 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -21,6 +21,8 @@
struct ohash;
struct mdoc_arg;
union mdoc_data;
+struct tbl_span;
+struct eqn_box;
enum roff_macroset {
MACROSET_NONE = 0,
@@ -478,11 +480,6 @@ enum roff_tok {
MAN_MAX
};
-enum roff_next {
- ROFF_NEXT_SIBLING = 0,
- ROFF_NEXT_CHILD
-};
-
/*
* Indicates that a BODY's formatting has ended, but
* the scope is still open. Used for badly nested blocks.
@@ -534,6 +531,7 @@ struct roff_node {
};
struct roff_meta {
+ struct roff_node *first; /* The first node parsed. */
char *msec; /* Manual section, usually a digit. */
char *vol; /* Manual volume title. */
char *os; /* Operating system. */
@@ -541,47 +539,14 @@ struct roff_meta {
char *title; /* Manual title, usually CAPS. */
char *name; /* Leading manual name. */
char *date; /* Normalized date. */
+ char *sodest; /* .so target file name or NULL. */
int hasbody; /* Document is not empty. */
int rcsids; /* Bits indexed by enum mandoc_os. */
enum mandoc_os os_e; /* Operating system. */
-};
-
-struct roff_man {
- struct roff_meta meta; /* Document meta-data. */
- struct roff *roff; /* Roff parser state data. */
- struct ohash *mdocmac; /* Mdoc macro lookup table. */
- struct ohash *manmac; /* Man macro lookup table. */
- const char *os_s; /* Default operating system. */
- struct roff_node *first; /* The first node parsed. */
- struct roff_node *last; /* The last node parsed. */
- struct roff_node *last_es; /* The most recent Es node. */
- int quick; /* Abort parse early. */
- int flags; /* Parse flags. */
-#define MDOC_LITERAL (1 << 1) /* In a literal scope. */
-#define MDOC_PBODY (1 << 2) /* In the document body. */
-#define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
-#define MDOC_PHRASE (1 << 4) /* In a Bl -column phrase. */
-#define MDOC_PHRASELIT (1 << 5) /* Literal within a phrase. */
-#define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
-#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
-#define MDOC_KEEP (1 << 8) /* In a word keep. */
-#define MDOC_SMOFF (1 << 9) /* Spacing is off. */
-#define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
-#define MAN_ELINE (1 << 11) /* Next-line element scope. */
-#define MAN_BLINE (1 << 12) /* Next-line block scope. */
-#define MDOC_PHRASEQF (1 << 13) /* Quote first word encountered. */
-#define MDOC_PHRASEQL (1 << 14) /* Quote last word of this phrase. */
-#define MDOC_PHRASEQN (1 << 15) /* Quote first word of the next phrase. */
-#define MAN_LITERAL MDOC_LITERAL
-#define MAN_NEWLINE MDOC_NEWLINE
enum roff_macroset macroset; /* Kind of high-level macros used. */
- enum roff_sec lastsec; /* Last section seen. */
- enum roff_sec lastnamed; /* Last standard section seen. */
- enum roff_next next; /* Where to put the next node. */
};
extern const char *const *roff_name;
void deroff(char **, const struct roff_node *);
-void roff_validate(struct roff_man *);
diff --git a/usr.bin/mandoc/roff_int.h b/usr.bin/mandoc/roff_int.h
index 220e99e5464..c3928e30452 100644
--- a/usr.bin/mandoc/roff_int.h
+++ b/usr.bin/mandoc/roff_int.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_int.h,v 1.11 2018/12/13 06:17:17 schwarze Exp $ */
+/* $OpenBSD: roff_int.h,v 1.12 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -18,6 +18,50 @@
* Parser internals shared by multiple parsers.
*/
+struct ohash;
+struct roff_node;
+struct roff_meta;
+struct roff;
+struct mdoc_arg;
+
+enum roff_next {
+ ROFF_NEXT_SIBLING = 0,
+ ROFF_NEXT_CHILD
+};
+
+struct roff_man {
+ struct roff_meta meta; /* Public parse results. */
+ struct roff *roff; /* Roff parser state data. */
+ struct ohash *mdocmac; /* Mdoc macro lookup table. */
+ struct ohash *manmac; /* Man macro lookup table. */
+ const char *os_s; /* Default operating system. */
+ struct roff_node *last; /* The last node parsed. */
+ struct roff_node *last_es; /* The most recent Es node. */
+ int quick; /* Abort parse early. */
+ int flags; /* Parse flags. */
+#define MDOC_LITERAL (1 << 1) /* In a literal scope. */
+#define MDOC_PBODY (1 << 2) /* In the document body. */
+#define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
+#define MDOC_PHRASE (1 << 4) /* In a Bl -column phrase. */
+#define MDOC_PHRASELIT (1 << 5) /* Literal within a phrase. */
+#define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
+#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
+#define MDOC_KEEP (1 << 8) /* In a word keep. */
+#define MDOC_SMOFF (1 << 9) /* Spacing is off. */
+#define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
+#define MAN_ELINE (1 << 11) /* Next-line element scope. */
+#define MAN_BLINE (1 << 12) /* Next-line block scope. */
+#define MDOC_PHRASEQF (1 << 13) /* Quote first word encountered. */
+#define MDOC_PHRASEQL (1 << 14) /* Quote last word of this phrase. */
+#define MDOC_PHRASEQN (1 << 15) /* Quote first word of the next phrase. */
+#define MAN_LITERAL MDOC_LITERAL
+#define MAN_NEWLINE MDOC_NEWLINE
+ enum roff_sec lastsec; /* Last section seen. */
+ enum roff_sec lastnamed; /* Last standard section seen. */
+ enum roff_next next; /* Where to put the next node. */
+};
+
+
struct roff_node *roff_node_alloc(struct roff_man *, int, int,
enum roff_type, int);
void roff_node_append(struct roff_man *, struct roff_node *);
@@ -36,6 +80,8 @@ struct ohash *roffhash_alloc(enum roff_tok, enum roff_tok);
enum roff_tok roffhash_find(struct ohash *, const char *, size_t);
void roffhash_free(struct ohash *);
+void roff_validate(struct roff_man *);
+
/*
* Functions called from roff.c need to be declared here,
* not in libmdoc.h or libman.h, even if they are specific
diff --git a/usr.bin/mandoc/tree.c b/usr.bin/mandoc/tree.c
index bab922bf5a7..a4051d33494 100644
--- a/usr.bin/mandoc/tree.c
+++ b/usr.bin/mandoc/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.49 2018/12/13 05:13:15 schwarze Exp $ */
+/* $OpenBSD: tree.c,v 1.50 2018/12/30 00:48:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -39,18 +39,18 @@ static void print_span(const struct tbl_span *, int);
void
-tree_mdoc(void *arg, const struct roff_man *mdoc)
+tree_mdoc(void *arg, const struct roff_meta *mdoc)
{
- print_meta(&mdoc->meta);
+ print_meta(mdoc);
putchar('\n');
print_mdoc(mdoc->first->child, 0);
}
void
-tree_man(void *arg, const struct roff_man *man)
+tree_man(void *arg, const struct roff_meta *man)
{
- print_meta(&man->meta);
- if (man->meta.hasbody == 0)
+ print_meta(man);
+ if (man->hasbody == 0)
puts("body = empty");
putchar('\n');
print_man(man->first->child, 0);