summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--Makefile.depend50
-rw-r--r--att.c1
-rw-r--r--demandoc.c5
-rw-r--r--lib.c1
-rw-r--r--main.c5
-rw-r--r--man.c61
-rw-r--r--man.h13
-rw-r--r--man_hash.c1
-rw-r--r--man_html.c53
-rw-r--r--man_macro.c57
-rw-r--r--man_term.c93
-rw-r--r--man_validate.c41
-rw-r--r--mandoc_headers.324
-rw-r--r--mandocdb.c45
-rw-r--r--mdoc.c73
-rw-r--r--mdoc.h18
-rw-r--r--mdoc_argv.c11
-rw-r--r--mdoc_hash.c1
-rw-r--r--mdoc_html.c107
-rw-r--r--mdoc_macro.c39
-rw-r--r--mdoc_man.c67
-rw-r--r--mdoc_term.c161
-rw-r--r--mdoc_validate.c97
-rw-r--r--read.c9
-rw-r--r--roff.h29
-rw-r--r--st.c1
-rw-r--r--tree.c77
28 files changed, 597 insertions, 549 deletions
diff --git a/Makefile b/Makefile
index cbaa6a4c..bfdd44bc 100644
--- a/Makefile
+++ b/Makefile
@@ -153,6 +153,7 @@ DISTFILES = INSTALL \
out.h \
predefs.in \
roff.7 \
+ roff.h \
st.in \
style.css \
tbl.3 \
@@ -273,7 +274,8 @@ WWW_MANS = apropos.1.html \
mandoc.h.html \
mandoc_aux.h.html \
mansearch.h.html \
- mdoc.h.html
+ mdoc.h.html \
+ roff.h.html
WWW_OBJS = mdocml.tar.gz \
mdocml.sha256
@@ -327,7 +329,7 @@ base-install: base-build
$(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
$(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
- $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
+ $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
$(DESTDIR)$(INCLUDEDIR)
$(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
$(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
diff --git a/Makefile.depend b/Makefile.depend
index b0de8570..025e46a9 100644
--- a/Makefile.depend
+++ b/Makefile.depend
@@ -1,4 +1,4 @@
-att.o: att.c config.h mdoc.h libmdoc.h
+att.o: att.c config.h roff.h mdoc.h libmdoc.h
cgi.o: cgi.c config.h mandoc.h mandoc_aux.h main.h manconf.h mansearch.h cgi.h
chars.o: chars.c config.h mandoc.h mandoc_aux.h libmandoc.h chars.in
compat_fgetln.o: compat_fgetln.c config.h
@@ -15,40 +15,40 @@ compat_strlcpy.o: compat_strlcpy.c config.h
compat_strsep.o: compat_strsep.c config.h
compat_strtonum.o: compat_strtonum.c config.h
compat_vasprintf.o: compat_vasprintf.c config.h
-demandoc.o: demandoc.c config.h man.h mdoc.h mandoc.h
+demandoc.o: demandoc.c config.h roff.h man.h mdoc.h mandoc.h
eqn.o: eqn.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h
eqn_html.o: eqn_html.c config.h mandoc.h out.h html.h
eqn_term.o: eqn_term.c config.h mandoc.h out.h term.h
-html.o: html.c config.h mandoc.h mandoc_aux.h out.h html.h main.h
-lib.o: lib.c config.h mdoc.h libmdoc.h lib.in
-main.o: main.c config.h mandoc.h mandoc_aux.h main.h mdoc.h man.h manconf.h mansearch.h
-man.o: man.c config.h man.h mandoc.h mandoc_aux.h libman.h libmandoc.h
-man_hash.o: man_hash.c config.h man.h libman.h
-man_html.o: man_html.c config.h mandoc_aux.h man.h out.h html.h main.h
-man_macro.o: man_macro.c config.h man.h mandoc.h libmandoc.h libman.h
-man_term.o: man_term.c config.h mandoc.h mandoc_aux.h out.h man.h term.h main.h
-man_validate.o: man_validate.c config.h man.h mandoc.h mandoc_aux.h libman.h libmandoc.h
+html.o: html.c config.h mandoc.h mandoc_aux.h out.h html.h manconf.h main.h
+lib.o: lib.c config.h roff.h mdoc.h libmdoc.h lib.in
+main.o: main.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h main.h manconf.h mansearch.h
+man.o: man.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h libman.h
+man_hash.o: man_hash.c config.h roff.h man.h libman.h
+man_html.o: man_html.c config.h mandoc_aux.h roff.h man.h out.h html.h main.h
+man_macro.o: man_macro.c config.h mandoc.h roff.h man.h libmandoc.h libman.h
+man_term.o: man_term.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h term.h main.h
+man_validate.o: man_validate.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h libman.h
mandoc.o: mandoc.c config.h mandoc.h mandoc_aux.h libmandoc.h
mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h
-mandocdb.o: mandocdb.c config.h compat_fts.h compat_ohash.h mdoc.h man.h mandoc.h mandoc_aux.h manconf.h mansearch.h
+mandocdb.o: mandocdb.c config.h compat_fts.h compat_ohash.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h manconf.h mansearch.h
manpage.o: manpage.c config.h manconf.h mansearch.h
manpath.o: manpath.c config.h mandoc_aux.h manconf.h
mansearch.o: mansearch.c config.h compat_ohash.h mandoc.h mandoc_aux.h manconf.h mansearch.h
mansearch_const.o: mansearch_const.c config.h mansearch.h
-mdoc.o: mdoc.c config.h mdoc.h mandoc.h mandoc_aux.h libmdoc.h libmandoc.h
-mdoc_argv.o: mdoc_argv.c config.h mdoc.h mandoc.h mandoc_aux.h libmdoc.h libmandoc.h
-mdoc_hash.o: mdoc_hash.c config.h mdoc.h libmdoc.h
-mdoc_html.o: mdoc_html.c config.h mandoc_aux.h mdoc.h out.h html.h main.h
-mdoc_macro.o: mdoc_macro.c config.h mdoc.h mandoc.h libmdoc.h libmandoc.h
-mdoc_man.o: mdoc_man.c config.h mandoc.h mandoc_aux.h out.h man.h mdoc.h main.h
-mdoc_term.o: mdoc_term.c config.h mandoc.h mandoc_aux.h out.h term.h mdoc.h main.h
-mdoc_validate.o: mdoc_validate.c config.h mdoc.h mandoc.h mandoc_aux.h libmdoc.h libmandoc.h
+mdoc.o: mdoc.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h libmdoc.h
+mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h libmdoc.h
+mdoc_hash.o: mdoc_hash.c config.h roff.h mdoc.h libmdoc.h
+mdoc_html.o: mdoc_html.c config.h mandoc_aux.h roff.h mdoc.h out.h html.h main.h
+mdoc_macro.o: mdoc_macro.c config.h mandoc.h roff.h mdoc.h libmandoc.h libmdoc.h
+mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h out.h main.h
+mdoc_term.o: mdoc_term.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h term.h main.h
+mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h libmdoc.h
msec.o: msec.c config.h mandoc.h libmandoc.h msec.in
out.o: out.c config.h mandoc_aux.h mandoc.h out.h
preconv.o: preconv.c config.h mandoc.h libmandoc.h
-read.o: read.c config.h mandoc.h mandoc_aux.h libmandoc.h mdoc.h man.h
+read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h libmandoc.h
roff.o: roff.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h predefs.in
-st.o: st.c config.h mdoc.h libmdoc.h st.in
+st.o: st.c config.h roff.h mdoc.h libmdoc.h st.in
tbl.o: tbl.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h
tbl_data.o: tbl_data.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h
tbl_html.o: tbl_html.c config.h mandoc.h out.h html.h
@@ -56,9 +56,9 @@ tbl_layout.o: tbl_layout.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h
tbl_opts.o: tbl_opts.c config.h mandoc.h libmandoc.h libroff.h
tbl_term.o: tbl_term.c config.h mandoc.h out.h term.h
term.o: term.c config.h mandoc.h mandoc_aux.h out.h term.h main.h
-term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h main.h
-term_ps.o: term_ps.c config.h mandoc_aux.h out.h term.h main.h
-tree.o: tree.c config.h mandoc.h mdoc.h man.h main.h
+term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h manconf.h main.h
+term_ps.o: term_ps.c config.h mandoc_aux.h out.h term.h manconf.h main.h
+tree.o: tree.c config.h mandoc.h roff.h mdoc.h man.h main.h
test-dirent-namlen.o: test-dirent-namlen.c
test-fgetln.o: test-fgetln.c
test-fts.o: test-fts.c
diff --git a/att.c b/att.c
index 8de0d797..4c72484f 100644
--- a/att.c
+++ b/att.c
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <string.h>
+#include "roff.h"
#include "mdoc.h"
#include "libmdoc.h"
diff --git a/demandoc.c b/demandoc.c
index f97952ba..f52f52fa 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <unistd.h>
+#include "roff.h"
#include "man.h"
#include "mdoc.h"
#include "mandoc.h"
@@ -239,7 +240,7 @@ pmdoc(const struct mdoc_node *p, int *line, int *col, int list)
for ( ; p; p = p->next) {
if (MDOC_LINE & p->flags)
pline(p->line, line, col, list);
- if (MDOC_TEXT == p->type)
+ if (ROFFT_TEXT == p->type)
pstring(p->string, p->pos, col, list);
if (p->child)
pmdoc(p->child, line, col, list);
@@ -253,7 +254,7 @@ pman(const struct man_node *p, int *line, int *col, int list)
for ( ; p; p = p->next) {
if (MAN_LINE & p->flags)
pline(p->line, line, col, list);
- if (MAN_TEXT == p->type)
+ if (ROFFT_TEXT == p->type)
pstring(p->string, p->pos, col, list);
if (p->child)
pman(p->child, line, col, list);
diff --git a/lib.c b/lib.c
index a4c8890f..bd1ce9fb 100644
--- a/lib.c
+++ b/lib.c
@@ -20,6 +20,7 @@
#include <string.h>
+#include "roff.h"
#include "mdoc.h"
#include "libmdoc.h"
diff --git a/main.c b/main.c
index a35c88fc..166dcf6b 100644
--- a/main.c
+++ b/main.c
@@ -34,11 +34,12 @@
#include <string.h>
#include <unistd.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "main.h"
+#include "mandoc.h"
+#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "main.h"
#include "manconf.h"
#include "mansearch.h"
diff --git a/man.c b/man.c
index d4e06dbc..640e96be 100644
--- a/man.c
+++ b/man.c
@@ -8,9 +8,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -27,11 +27,12 @@
#include <stdio.h>
#include <string.h>
-#include "man.h"
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libman.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "man.h"
#include "libmandoc.h"
+#include "libman.h"
const char *const __man_macronames[MAN_MAX] = {
"br", "TH", "SH", "SS",
@@ -53,7 +54,7 @@ static void man_breakscope(struct man *, enum mant);
static void man_descope(struct man *, int, int);
static void man_free1(struct man *);
static struct man_node *man_node_alloc(struct man *, int, int,
- enum man_type, enum mant);
+ enum roff_type, enum mant);
static void man_node_append(struct man *, struct man_node *);
static void man_node_free(struct man_node *);
static void man_node_unlink(struct man *,
@@ -121,7 +122,7 @@ int
man_parseln(struct man *man, int ln, char *buf, int offs)
{
- if (man->last->type != MAN_EQN || ln > man->last->line)
+ if (man->last->type != ROFFT_EQN || ln > man->last->line)
man->flags |= MAN_NEWLINE;
return (roff_getcontrol(man->roff, buf, &offs) ?
@@ -150,7 +151,7 @@ man_alloc1(struct man *man)
man->flags = 0;
man->last = mandoc_calloc(1, sizeof(struct man_node));
man->first = man->last;
- man->last->type = MAN_ROOT;
+ man->last->type = ROFFT_ROOT;
man->last->tok = MAN_MAX;
man->next = MAN_NEXT_CHILD;
}
@@ -162,7 +163,7 @@ man_node_append(struct man *man, struct man_node *p)
assert(man->last);
assert(man->first);
- assert(p->type != MAN_ROOT);
+ assert(p->type != ROFFT_ROOT);
switch (man->next) {
case MAN_NEXT_SIBLING:
@@ -183,16 +184,16 @@ man_node_append(struct man *man, struct man_node *p)
p->parent->nchild++;
switch (p->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
if (p->tok == MAN_SH || p->tok == MAN_SS)
man->flags &= ~MAN_LITERAL;
break;
- case MAN_HEAD:
- assert(p->parent->type == MAN_BLOCK);
+ case ROFFT_HEAD:
+ assert(p->parent->type == ROFFT_BLOCK);
p->parent->head = p;
break;
- case MAN_BODY:
- assert(p->parent->type == MAN_BLOCK);
+ case ROFFT_BODY:
+ assert(p->parent->type == ROFFT_BLOCK);
p->parent->body = p;
break;
default:
@@ -202,9 +203,9 @@ man_node_append(struct man *man, struct man_node *p)
man->last = p;
switch (p->type) {
- case MAN_TBL:
+ case ROFFT_TBL:
/* FALLTHROUGH */
- case MAN_TEXT:
+ case ROFFT_TEXT:
man_valid_post(man);
break;
default:
@@ -214,7 +215,7 @@ man_node_append(struct man *man, struct man_node *p)
static struct man_node *
man_node_alloc(struct man *man, int line, int pos,
- enum man_type type, enum mant tok)
+ enum roff_type type, enum mant tok)
{
struct man_node *p;
@@ -235,7 +236,7 @@ man_elem_alloc(struct man *man, int line, int pos, enum mant tok)
{
struct man_node *p;
- p = man_node_alloc(man, line, pos, MAN_ELEM, tok);
+ p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok);
man_node_append(man, p);
man->next = MAN_NEXT_CHILD;
}
@@ -245,7 +246,7 @@ man_head_alloc(struct man *man, int line, int pos, enum mant tok)
{
struct man_node *p;
- p = man_node_alloc(man, line, pos, MAN_HEAD, tok);
+ p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok);
man_node_append(man, p);
man->next = MAN_NEXT_CHILD;
}
@@ -255,7 +256,7 @@ man_body_alloc(struct man *man, int line, int pos, enum mant tok)
{
struct man_node *p;
- p = man_node_alloc(man, line, pos, MAN_BODY, tok);
+ p = man_node_alloc(man, line, pos, ROFFT_BODY, tok);
man_node_append(man, p);
man->next = MAN_NEXT_CHILD;
}
@@ -265,7 +266,7 @@ man_block_alloc(struct man *man, int line, int pos, enum mant tok)
{
struct man_node *p;
- p = man_node_alloc(man, line, pos, MAN_BLOCK, tok);
+ p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
man_node_append(man, p);
man->next = MAN_NEXT_CHILD;
}
@@ -275,7 +276,7 @@ man_word_alloc(struct man *man, int line, int pos, const char *word)
{
struct man_node *n;
- n = man_node_alloc(man, line, pos, MAN_TEXT, MAN_MAX);
+ n = man_node_alloc(man, line, pos, ROFFT_TEXT, MAN_MAX);
n->string = roff_strdup(man->roff, word);
man_node_append(man, n);
man->next = MAN_NEXT_SIBLING;
@@ -324,7 +325,7 @@ man_addeqn(struct man *man, const struct eqn *ep)
{
struct man_node *n;
- n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX);
+ n = man_node_alloc(man, ep->ln, ep->pos, ROFFT_EQN, MAN_MAX);
n->eqn = ep;
if (ep->ln > man->last->line)
n->flags |= MAN_LINE;
@@ -339,7 +340,7 @@ man_addspan(struct man *man, const struct tbl_span *sp)
struct man_node *n;
man_breakscope(man, MAN_MAX);
- n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX);
+ n = man_node_alloc(man, sp->line, 0, ROFFT_TBL, MAN_MAX);
n->span = sp;
man_node_append(man, n);
man->next = MAN_NEXT_SIBLING;
@@ -511,7 +512,7 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
if (man->quick && tok == MAN_SH) {
n = man->last;
- if (n->type == MAN_BODY &&
+ if (n->type == ROFFT_BODY &&
strcmp(n->prev->child->string, "NAME"))
return(2);
}
@@ -548,7 +549,7 @@ man_breakscope(struct man *man, enum mant tok)
if (man->flags & MAN_ELINE && (tok == MAN_MAX ||
! (man_macros[tok].flags & MAN_NSCOPED))) {
n = man->last;
- assert(n->type != MAN_TEXT);
+ assert(n->type != ROFFT_TEXT);
if (man_macros[n->tok].flags & MAN_NSCOPED)
n = n->parent;
@@ -570,14 +571,14 @@ man_breakscope(struct man *man, enum mant tok)
if (man->flags & MAN_BLINE && (tok == MAN_MAX ||
man_macros[tok].flags & MAN_BSCOPE)) {
n = man->last;
- if (n->type == MAN_TEXT)
+ if (n->type == ROFFT_TEXT)
n = n->parent;
if ( ! (man_macros[n->tok].flags & MAN_BSCOPE))
n = n->parent;
- assert(n->type == MAN_HEAD);
+ assert(n->type == ROFFT_HEAD);
n = n->parent;
- assert(n->type == MAN_BLOCK);
+ assert(n->type == ROFFT_BLOCK);
assert(man_macros[n->tok].flags & MAN_SCOPED);
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse,
@@ -645,7 +646,7 @@ man_deroff(char **dest, const struct man_node *n)
char *cp;
size_t sz;
- if (n->type != MAN_TEXT) {
+ if (n->type != ROFFT_TEXT) {
for (n = n->child; n; n = n->next)
man_deroff(dest, n);
return;
diff --git a/man.h b/man.h
index 08a1f752..65e31d91 100644
--- a/man.h
+++ b/man.h
@@ -58,17 +58,6 @@ enum mant {
MAN_MAX
};
-enum man_type {
- MAN_TEXT,
- MAN_ELEM,
- MAN_ROOT,
- MAN_BLOCK,
- MAN_HEAD,
- MAN_BODY,
- MAN_TBL,
- MAN_EQN
-};
-
struct man_meta {
char *msec; /* `TH' section (1, 3p, etc.) */
char *date; /* `TH' normalised date */
@@ -91,7 +80,7 @@ struct man_node {
#define MAN_VALID (1 << 0) /* has been validated */
#define MAN_EOS (1 << 2) /* at sentence boundary */
#define MAN_LINE (1 << 3) /* first macro/text on line */
- enum man_type type; /* AST node type */
+ enum roff_type type; /* AST node type */
char *string; /* TEXT node argument */
struct man_node *head; /* BLOCK node HEAD ptr */
struct man_node *tail; /* BLOCK node TAIL ptr */
diff --git a/man_hash.c b/man_hash.c
index a131d7a9..2f1bd876 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -23,6 +23,7 @@
#include <limits.h>
#include <string.h>
+#include "roff.h"
#include "man.h"
#include "libman.h"
diff --git a/man_html.c b/man_html.c
index 21c277f6..f3ec65a2 100644
--- a/man_html.c
+++ b/man_html.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -26,6 +26,7 @@
#include <string.h>
#include "mandoc_aux.h"
+#include "roff.h"
#include "man.h"
#include "out.h"
#include "html.h"
@@ -133,10 +134,10 @@ print_bvspace(struct html *h, const struct man_node *n)
{
if (n->body && n->body->child)
- if (MAN_TBL == n->body->child->type)
+ if (n->body->child->type == ROFFT_TBL)
return;
- if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
+ if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
if (NULL == n->prev)
return;
@@ -208,10 +209,10 @@ print_man_node(MAN_ARGS)
t = h->tags.head;
switch (n->type) {
- case MAN_ROOT:
+ case ROFFT_ROOT:
man_root_pre(man, n, mh, h);
break;
- case MAN_TEXT:
+ case ROFFT_TEXT:
if ('\0' == *n->string) {
print_paragraph(h);
return;
@@ -222,12 +223,12 @@ print_man_node(MAN_ARGS)
print_otag(h, TAG_BR, 0, NULL);
print_text(h, n->string);
return;
- case MAN_EQN:
+ case ROFFT_EQN:
if (n->flags & MAN_LINE)
putchar('\n');
print_eqn(h, n->eqn);
break;
- case MAN_TBL:
+ case ROFFT_TBL:
/*
* This will take care of initialising all of the table
* state data for the first table, then tearing it down
@@ -266,10 +267,10 @@ print_man_node(MAN_ARGS)
print_stagq(h, t);
switch (n->type) {
- case MAN_ROOT:
+ case ROFFT_ROOT:
man_root_post(man, n, mh, h);
break;
- case MAN_EQN:
+ case ROFFT_EQN:
break;
default:
if (mans[n->tok].post)
@@ -282,7 +283,7 @@ static int
a2width(const struct man_node *n, struct roffsu *su)
{
- if (MAN_TEXT != n->type)
+ if (n->type != ROFFT_TEXT)
return(0);
if (a2roffsu(n->string, su, SCALE_EN))
return(1);
@@ -384,12 +385,12 @@ man_SH_pre(MAN_ARGS)
{
struct htmlpair tag;
- if (MAN_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
mh->fl &= ~MANH_LITERAL;
PAIR_CLASS_INIT(&tag, "section");
print_otag(h, TAG_DIV, 1, &tag);
return(1);
- } else if (MAN_BODY == n->type)
+ } else if (n->type == ROFFT_BODY)
return(1);
print_otag(h, TAG_H1, 0, NULL);
@@ -468,12 +469,12 @@ man_SS_pre(MAN_ARGS)
{
struct htmlpair tag;
- if (MAN_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
mh->fl &= ~MANH_LITERAL;
PAIR_CLASS_INIT(&tag, "subsection");
print_otag(h, TAG_DIV, 1, &tag);
return(1);
- } else if (MAN_BODY == n->type)
+ } else if (n->type == ROFFT_BODY)
return(1);
print_otag(h, TAG_H2, 0, NULL);
@@ -484,9 +485,9 @@ static int
man_PP_pre(MAN_ARGS)
{
- if (MAN_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
- else if (MAN_BLOCK == n->type)
+ else if (n->type == ROFFT_BLOCK)
print_bvspace(h, n);
return(1);
@@ -497,10 +498,10 @@ man_IP_pre(MAN_ARGS)
{
const struct man_node *nn;
- if (MAN_BODY == n->type) {
+ if (n->type == ROFFT_BODY) {
print_otag(h, TAG_DD, 0, NULL);
return(1);
- } else if (MAN_HEAD != n->type) {
+ } else if (n->type != ROFFT_HEAD) {
print_otag(h, TAG_DL, 0, NULL);
return(1);
}
@@ -536,9 +537,9 @@ man_HP_pre(MAN_ARGS)
struct roffsu su;
const struct man_node *np;
- if (MAN_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
- else if (MAN_BLOCK != n->type)
+ else if (n->type != ROFFT_BLOCK)
return(1);
np = n->head->child;
@@ -637,9 +638,9 @@ man_RS_pre(MAN_ARGS)
struct htmlpair tag;
struct roffsu su;
- if (MAN_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
- else if (MAN_BODY == n->type)
+ else if (n->type == ROFFT_BODY)
return(1);
SCALE_HS_INIT(&su, INDENT);
@@ -659,15 +660,15 @@ man_UR_pre(MAN_ARGS)
struct htmlpair tag[2];
n = n->child;
- assert(MAN_HEAD == n->type);
+ assert(n->type == ROFFT_HEAD);
if (n->nchild) {
- assert(MAN_TEXT == n->child->type);
+ assert(n->child->type == ROFFT_TEXT);
PAIR_CLASS_INIT(&tag[0], "link-ext");
PAIR_HREF_INIT(&tag[1], n->child->string);
print_otag(h, TAG_A, 2, tag);
}
- assert(MAN_BODY == n->next->type);
+ assert(n->next->type == ROFFT_BODY);
if (n->next->nchild)
n = n->next;
diff --git a/man_macro.c b/man_macro.c
index b210edbe..fdf82ad8 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -8,9 +8,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -25,8 +25,9 @@
#include <stdlib.h>
#include <string.h>
-#include "man.h"
#include "mandoc.h"
+#include "roff.h"
+#include "man.h"
#include "libmandoc.h"
#include "libman.h"
@@ -43,11 +44,11 @@ static void in_line_eoln(MACRO_PROT_ARGS);
static int man_args(struct man *, int,
int *, char *, char **);
-static void rew_scope(enum man_type,
+static void rew_scope(enum roff_type,
struct man *, enum mant);
-static enum rew rew_dohalt(enum mant, enum man_type,
+static enum rew rew_dohalt(enum mant, enum roff_type,
const struct man_node *);
-static enum rew rew_block(enum mant, enum man_type,
+static enum rew rew_block(enum mant, enum roff_type,
const struct man_node *);
const struct man_macro __man_macros[MAN_MAX] = {
@@ -115,7 +116,7 @@ man_unscope(struct man *man, const struct man_node *to)
if (man->flags & MAN_ELINE)
man->flags &= ~MAN_ELINE;
else {
- assert(n->type == MAN_HEAD);
+ assert(n->type == ROFFT_HEAD);
n = n->parent;
man->flags &= ~MAN_BLINE;
}
@@ -124,7 +125,7 @@ man_unscope(struct man *man, const struct man_node *to)
man_node_delete(man, man->last);
continue;
}
- if (n->type == MAN_BLOCK &&
+ if (n->type == ROFFT_BLOCK &&
man_macros[n->tok].fp == blk_exp)
mandoc_msg(MANDOCERR_BLK_NOEND,
man->parse, n->line, n->pos,
@@ -155,11 +156,11 @@ man_unscope(struct man *man, const struct man_node *to)
}
static enum rew
-rew_block(enum mant ntok, enum man_type type, const struct man_node *n)
+rew_block(enum mant ntok, enum roff_type type, const struct man_node *n)
{
- if (type == MAN_BLOCK && ntok == n->parent->tok &&
- n->parent->type == MAN_BODY)
+ if (type == ROFFT_BLOCK && n->parent->tok == ntok &&
+ n->parent->type == ROFFT_BODY)
return(REW_REWIND);
return(ntok == n->tok ? REW_HALT : REW_NOHALT);
}
@@ -170,18 +171,18 @@ rew_block(enum mant ntok, enum man_type type, const struct man_node *n)
* sections and subsections).
*/
static enum rew
-rew_dohalt(enum mant tok, enum man_type type, const struct man_node *n)
+rew_dohalt(enum mant tok, enum roff_type type, const struct man_node *n)
{
enum rew c;
/* We cannot progress beyond the root ever. */
- if (MAN_ROOT == n->type)
+ if (n->type == ROFFT_ROOT)
return(REW_HALT);
assert(n->parent);
/* Normal nodes shouldn't go to the level of the root. */
- if (MAN_ROOT == n->parent->type)
+ if (n->parent->type == ROFFT_ROOT)
return(REW_REWIND);
/* Already-validated nodes should be closed out. */
@@ -243,7 +244,7 @@ rew_dohalt(enum mant tok, enum man_type type, const struct man_node *n)
* scopes. When a scope is closed, it must be validated and actioned.
*/
static void
-rew_scope(enum man_type type, struct man *man, enum mant tok)
+rew_scope(enum roff_type type, struct man *man, enum mant tok)
{
struct man_node *n;
enum rew c;
@@ -288,7 +289,7 @@ blk_close(MACRO_PROT_ARGS)
if ( ! man_args(man, line, pos, buf, &p))
break;
for (nn = man->last->parent; nn; nn = nn->parent)
- if (nn->tok == ntok && nn->type == MAN_BLOCK)
+ if (nn->tok == ntok && nn->type == ROFFT_BLOCK)
nrew++;
target = strtol(p, &p, 10);
if (*p != '\0')
@@ -312,13 +313,13 @@ blk_close(MACRO_PROT_ARGS)
}
for (nn = man->last->parent; nn; nn = nn->parent)
- if (nn->tok == ntok && nn->type == MAN_BLOCK && ! --nrew)
+ if (nn->tok == ntok && nn->type == ROFFT_BLOCK && ! --nrew)
break;
if (nn == NULL) {
mandoc_msg(MANDOCERR_BLK_NOTOPEN, man->parse,
line, ppos, man_macronames[tok]);
- rew_scope(MAN_BLOCK, man, MAN_PP);
+ rew_scope(ROFFT_BLOCK, man, MAN_PP);
} else {
line = man->last->line;
ppos = man->last->pos;
@@ -341,7 +342,7 @@ blk_exp(MACRO_PROT_ARGS)
char *p;
int la;
- rew_scope(MAN_BLOCK, man, tok);
+ rew_scope(ROFFT_BLOCK, man, tok);
man_block_alloc(man, line, ppos, tok);
man_head_alloc(man, line, ppos, tok);
head = man->last;
@@ -360,8 +361,8 @@ blk_exp(MACRO_PROT_ARGS)
}
/*
- * Parse an implicit-block macro. These contain a MAN_HEAD and a
- * MAN_BODY contained within a MAN_BLOCK. Rules for closing out other
+ * Parse an implicit-block macro. These contain a ROFFT_HEAD and a
+ * ROFFT_BODY contained within a ROFFT_BLOCK. Rules for closing out other
* scopes, such as `SH' closing out an `SS', are defined in the rew
* routines.
*/
@@ -372,8 +373,8 @@ blk_imp(MACRO_PROT_ARGS)
char *p;
struct man_node *n;
- rew_scope(MAN_BODY, man, tok);
- rew_scope(MAN_BLOCK, man, tok);
+ rew_scope(ROFFT_BODY, man, tok);
+ rew_scope(ROFFT_BLOCK, man, tok);
man_block_alloc(man, line, ppos, tok);
man_head_alloc(man, line, ppos, tok);
n = man->last;
@@ -401,7 +402,7 @@ blk_imp(MACRO_PROT_ARGS)
/* Close out the head and open the body. */
- rew_scope(MAN_HEAD, man, tok);
+ rew_scope(ROFFT_HEAD, man, tok);
man_body_alloc(man, line, ppos, tok);
}
@@ -434,7 +435,7 @@ in_line_eoln(MACRO_PROT_ARGS)
if ( ! man_args(man, line, pos, buf, &p))
break;
if (man_macros[tok].flags & MAN_JOIN &&
- man->last->type == MAN_TEXT)
+ man->last->type == ROFFT_TEXT)
man_word_append(man, p);
else
man_word_alloc(man, line, la, p);
@@ -461,7 +462,7 @@ in_line_eoln(MACRO_PROT_ARGS)
return;
}
- assert(man->last->type != MAN_ROOT);
+ assert(man->last->type != ROFFT_ROOT);
man->next = MAN_NEXT_SIBLING;
/*
@@ -473,7 +474,7 @@ in_line_eoln(MACRO_PROT_ARGS)
for ( ; man->last; man->last = man->last->parent) {
if (man->last == n)
break;
- if (man->last->type == MAN_ROOT)
+ if (man->last->type == ROFFT_ROOT)
break;
man_valid_post(man);
}
@@ -484,7 +485,7 @@ in_line_eoln(MACRO_PROT_ARGS)
* Same here regarding whether we're back at the root.
*/
- if (man->last->type != MAN_ROOT)
+ if (man->last->type != ROFFT_ROOT)
man_valid_post(man);
}
diff --git a/man_term.c b/man_term.c
index b747ba1e..f8a5fe1f 100644
--- a/man_term.c
+++ b/man_term.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -26,10 +26,11 @@
#include <stdlib.h>
#include <string.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "out.h"
+#include "mandoc.h"
+#include "roff.h"
#include "man.h"
+#include "out.h"
#include "term.h"
#include "main.h"
@@ -160,7 +161,7 @@ terminal_man(void *arg, const struct man *man)
if (p->synopsisonly) {
while (n != NULL) {
if (n->tok == MAN_SH &&
- n->child->child->type == MAN_TEXT &&
+ n->child->child->type == ROFFT_TEXT &&
!strcmp(n->child->child->string, "SYNOPSIS")) {
if (n->child->next->child != NULL)
print_man_nodelist(p, &mt,
@@ -197,10 +198,10 @@ print_bvspace(struct termp *p, const struct man_node *n, int pardist)
term_newln(p);
if (n->body && n->body->child)
- if (MAN_TBL == n->body->child->type)
+ if (n->body->child->type == ROFFT_TBL)
return;
- if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
+ if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
if (NULL == n->prev)
return;
@@ -269,7 +270,7 @@ pre_PD(DECL_ARGS)
mt->pardist = 1;
return(0);
}
- assert(MAN_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
if (a2roffsu(n->string, &su, SCALE_VS))
mt->pardist = term_vspan(p, &su);
return(0);
@@ -491,10 +492,10 @@ pre_HP(DECL_ARGS)
int len;
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
print_bvspace(p, n, mt->pardist);
return(1);
- case MAN_BODY:
+ case ROFFT_BODY:
break;
default:
return(0);
@@ -528,7 +529,7 @@ post_HP(DECL_ARGS)
{
switch (n->type) {
- case MAN_BODY:
+ case ROFFT_BODY:
term_newln(p);
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
p->trailspace = 0;
@@ -545,7 +546,7 @@ pre_PP(DECL_ARGS)
{
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
print_bvspace(p, n, mt->pardist);
break;
@@ -554,7 +555,7 @@ pre_PP(DECL_ARGS)
break;
}
- return(MAN_HEAD != n->type);
+ return(n->type != ROFFT_HEAD);
}
static int
@@ -565,14 +566,14 @@ pre_IP(DECL_ARGS)
int len, savelit;
switch (n->type) {
- case MAN_BODY:
+ case ROFFT_BODY:
p->flags |= TERMP_NOSPACE;
break;
- case MAN_HEAD:
+ case ROFFT_HEAD:
p->flags |= TERMP_NOBREAK;
p->trailspace = 1;
break;
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
print_bvspace(p, n, mt->pardist);
/* FALLTHROUGH */
default:
@@ -593,7 +594,7 @@ pre_IP(DECL_ARGS)
len = mt->lmargin[mt->lmargincur];
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
p->offset = mt->offset;
p->rmargin = mt->offset + len;
@@ -607,7 +608,7 @@ pre_IP(DECL_ARGS)
mt->fl |= MANT_LITERAL;
return(0);
- case MAN_BODY:
+ case ROFFT_BODY:
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin;
break;
@@ -623,13 +624,13 @@ post_IP(DECL_ARGS)
{
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
term_flushln(p);
p->flags &= ~TERMP_NOBREAK;
p->trailspace = 0;
p->rmargin = p->maxrmargin;
break;
- case MAN_BODY:
+ case ROFFT_BODY:
term_newln(p);
p->offset = mt->offset;
break;
@@ -646,14 +647,14 @@ pre_TP(DECL_ARGS)
int len, savelit;
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
p->flags |= TERMP_NOBREAK;
p->trailspace = 1;
break;
- case MAN_BODY:
+ case ROFFT_BODY:
p->flags |= TERMP_NOSPACE;
break;
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
print_bvspace(p, n, mt->pardist);
/* FALLTHROUGH */
default:
@@ -675,7 +676,7 @@ pre_TP(DECL_ARGS)
len = mt->lmargin[mt->lmargincur];
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
p->offset = mt->offset;
p->rmargin = mt->offset + len;
@@ -695,7 +696,7 @@ pre_TP(DECL_ARGS)
if (savelit)
mt->fl |= MANT_LITERAL;
return(0);
- case MAN_BODY:
+ case ROFFT_BODY:
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin;
p->trailspace = 0;
@@ -713,10 +714,10 @@ post_TP(DECL_ARGS)
{
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
term_flushln(p);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
term_newln(p);
p->offset = mt->offset;
break;
@@ -731,7 +732,7 @@ pre_SS(DECL_ARGS)
int i;
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
mt->fl &= ~MANT_LITERAL;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
mt->offset = term_len(p, p->defindent);
@@ -751,11 +752,11 @@ pre_SS(DECL_ARGS)
for (i = 0; i < mt->pardist; i++)
term_vspace(p);
break;
- case MAN_HEAD:
+ case ROFFT_HEAD:
term_fontrepl(p, TERMFONT_BOLD);
p->offset = term_len(p, 3);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
p->offset = mt->offset;
break;
default:
@@ -770,10 +771,10 @@ post_SS(DECL_ARGS)
{
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
term_newln(p);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
term_newln(p);
break;
default:
@@ -787,7 +788,7 @@ pre_SH(DECL_ARGS)
int i;
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
mt->fl &= ~MANT_LITERAL;
mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
mt->offset = term_len(p, p->defindent);
@@ -806,11 +807,11 @@ pre_SH(DECL_ARGS)
for (i = 0; i < mt->pardist; i++)
term_vspace(p);
break;
- case MAN_HEAD:
+ case ROFFT_HEAD:
term_fontrepl(p, TERMFONT_BOLD);
p->offset = 0;
break;
- case MAN_BODY:
+ case ROFFT_BODY:
p->offset = mt->offset;
break;
default:
@@ -825,10 +826,10 @@ post_SH(DECL_ARGS)
{
switch (n->type) {
- case MAN_HEAD:
+ case ROFFT_HEAD:
term_newln(p);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
term_newln(p);
break;
default:
@@ -842,10 +843,10 @@ pre_RS(DECL_ARGS)
struct roffsu su;
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
term_newln(p);
return(1);
- case MAN_HEAD:
+ case ROFFT_HEAD:
return(0);
default:
break;
@@ -876,9 +877,9 @@ post_RS(DECL_ARGS)
{
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
return;
- case MAN_HEAD:
+ case ROFFT_HEAD:
return;
default:
term_newln(p);
@@ -896,14 +897,14 @@ static int
pre_UR(DECL_ARGS)
{
- return (MAN_HEAD != n->type);
+ return (n->type != ROFFT_HEAD);
}
static void
post_UR(DECL_ARGS)
{
- if (MAN_BLOCK != n->type)
+ if (n->type != ROFFT_BLOCK)
return;
term_word(p, "<");
@@ -923,7 +924,7 @@ print_man_node(DECL_ARGS)
int c;
switch (n->type) {
- case MAN_TEXT:
+ case ROFFT_TEXT:
/*
* If we have a blank line, output a vertical space.
* If we have a space as the first character, break
@@ -938,14 +939,14 @@ print_man_node(DECL_ARGS)
term_word(p, n->string);
goto out;
- case MAN_EQN:
+ case ROFFT_EQN:
if ( ! (n->flags & MAN_LINE))
p->flags |= TERMP_NOSPACE;
term_eqn(p, n->eqn);
if (n->next != NULL && ! (n->next->flags & MAN_LINE))
p->flags |= TERMP_NOSPACE;
return;
- case MAN_TBL:
+ case ROFFT_TBL:
if (p->tbl.cols == NULL)
term_vspace(p);
term_tbl(p, n->span);
diff --git a/man_validate.c b/man_validate.c
index 93ee9b3f..8614708b 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -28,11 +28,12 @@
#include <string.h>
#include <time.h>
-#include "man.h"
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libman.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "man.h"
#include "libmandoc.h"
+#include "libman.h"
#define CHKARGS struct man *man, struct man_node *n
@@ -108,15 +109,15 @@ man_valid_post(struct man *man)
n->flags |= MAN_VALID;
switch (n->type) {
- case MAN_TEXT:
+ case ROFFT_TEXT:
check_text(man, n);
break;
- case MAN_ROOT:
+ case ROFFT_ROOT:
check_root(man, n);
break;
- case MAN_EQN:
+ case ROFFT_EQN:
/* FALLTHROUGH */
- case MAN_TBL:
+ case ROFFT_TBL:
break;
default:
cp = man_valids + n->tok;
@@ -186,7 +187,7 @@ static void
post_UR(CHKARGS)
{
- if (n->type == MAN_HEAD && n->child == NULL)
+ if (n->type == ROFFT_HEAD && n->child == NULL)
mandoc_vmsg(MANDOCERR_UR_NOHEAD, man->parse,
n->line, n->pos, "UR");
check_part(man, n);
@@ -243,7 +244,7 @@ static void
check_part(CHKARGS)
{
- if (n->type == MAN_BODY && n->child == NULL)
+ if (n->type == ROFFT_BODY && n->child == NULL)
mandoc_msg(MANDOCERR_BLK_EMPTY, man->parse,
n->line, n->pos, man_macronames[n->tok]);
}
@@ -253,17 +254,17 @@ check_par(CHKARGS)
{
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
if (0 == n->body->nchild)
man_node_delete(man, n);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
if (0 == n->nchild)
mandoc_vmsg(MANDOCERR_PAR_SKIP,
man->parse, n->line, n->pos,
"%s empty", man_macronames[n->tok]);
break;
- case MAN_HEAD:
+ case ROFFT_HEAD:
if (n->nchild)
mandoc_vmsg(MANDOCERR_ARG_SKIP,
man->parse, n->line, n->pos,
@@ -281,11 +282,11 @@ post_IP(CHKARGS)
{
switch (n->type) {
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
if (0 == n->head->nchild && 0 == n->body->nchild)
man_node_delete(man, n);
break;
- case MAN_BODY:
+ case ROFFT_BODY:
if (0 == n->parent->head->nchild && 0 == n->nchild)
mandoc_vmsg(MANDOCERR_PAR_SKIP,
man->parse, n->line, n->pos,
@@ -427,7 +428,7 @@ post_UC(CHKARGS)
n = n->child;
- if (NULL == n || MAN_TEXT != n->type)
+ if (n == NULL || n->type != ROFFT_TEXT)
p = bsd_versions[0];
else {
s = n->string;
@@ -464,7 +465,7 @@ post_AT(CHKARGS)
n = n->child;
- if (NULL == n || MAN_TEXT != n->type)
+ if (n == NULL || n->type != ROFFT_TEXT)
p = unix_versions[0];
else {
s = n->string;
@@ -474,7 +475,9 @@ post_AT(CHKARGS)
p = unix_versions[1];
else if (0 == strcmp(s, "5")) {
nn = n->next;
- if (nn && MAN_TEXT == nn->type && nn->string[0])
+ if (nn != NULL &&
+ nn->type == ROFFT_TEXT &&
+ nn->string[0] != '\0')
p = unix_versions[3];
else
p = unix_versions[2];
diff --git a/mandoc_headers.3 b/mandoc_headers.3
index 12879ea6..52ac2890 100644
--- a/mandoc_headers.3
+++ b/mandoc_headers.3
@@ -54,7 +54,6 @@ require inclusion of the header where that type is defined.
Each of the following headers can be included without including
any other mandoc header.
These headers should be included before any other mandoc headers.
-Afterwards, any other mandoc headers can be included as needed.
.Bl -tag -width Ds
.It Qq Pa mandoc_aux.h
Requires
@@ -117,16 +116,29 @@ and
from
.Pa libman.h
as opaque types for function prototypes.
+.It Qq Pa roff.h
+Provides
+.Vt enum roff_type .
+.El
+.Pp
+The following two require
+.Qq Pa roff.h
+but no other mandoc headers.
+Afterwards, any other mandoc headers can be included as needed.
+.Bl -tag -width Ds
.It Qq Pa mdoc.h
Requires
.In sys/types.h
for
-.Vt size_t .
+.Vt size_t
+and
+.Qq Pa roff.h
+for
+.Vt enum roff_type .
.Pp
Provides
.Vt enum mdoct ,
.Vt enum mdocargt ,
-.Vt enum mdoc_type ,
.Vt enum mdoc_sec ,
.Vt enum mdoc_endbody ,
.Vt enum mdoc_disp ,
@@ -163,9 +175,13 @@ When this header is included, the same file should not include
or
.Pa libroff.h .
.It Qq Pa man.h
+Requires
+.Qq Pa roff.h
+for
+.Vt enum roff_type .
+.Pp
Provides
.Vt enum mant ,
-.Vt enum man_type ,
.Vt struct man_meta ,
.Vt struct man_node ,
and the functions
diff --git a/mandocdb.c b/mandocdb.c
index 074c9ee7..83159210 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -46,10 +46,11 @@
#endif
#include <sqlite3.h>
+#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "roff.h"
#include "mdoc.h"
#include "man.h"
-#include "mandoc.h"
-#include "mandoc_aux.h"
#include "manconf.h"
#include "mansearch.h"
@@ -1436,7 +1437,7 @@ putmdockey(const struct mpage *mpage,
for ( ; NULL != n; n = n->next) {
if (NULL != n->child)
putmdockey(mpage, n->child, m);
- if (MDOC_TEXT == n->type)
+ if (n->type == ROFFT_TEXT)
putkey(mpage, n->string, m);
}
}
@@ -1460,13 +1461,13 @@ parse_man(struct mpage *mpage, const struct man_meta *meta,
* the correct section or not.
*/
- if (MAN_BODY == n->type && MAN_SH == n->tok) {
+ if (n->type == ROFFT_BODY && n->tok == MAN_SH) {
body = n;
assert(body->parent);
if (NULL != (head = body->parent->head) &&
1 == head->nchild &&
NULL != (head = (head->child)) &&
- MAN_TEXT == head->type &&
+ head->type == ROFFT_TEXT &&
0 == strcmp(head->string, "NAME") &&
NULL != body->child) {
@@ -1575,15 +1576,15 @@ parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
assert(NULL != n);
for (n = n->child; NULL != n; n = n->next) {
switch (n->type) {
- case MDOC_ELEM:
+ case ROFFT_ELEM:
/* FALLTHROUGH */
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
/* FALLTHROUGH */
- case MDOC_HEAD:
+ case ROFFT_HEAD:
/* FALLTHROUGH */
- case MDOC_BODY:
+ case ROFFT_BODY:
/* FALLTHROUGH */
- case MDOC_TAIL:
+ case ROFFT_TAIL:
if (NULL != mdocs[n->tok].fp)
if (0 == (*mdocs[n->tok].fp)(mpage, meta, n))
break;
@@ -1592,7 +1593,7 @@ parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
mdocs[n->tok].mask);
break;
default:
- assert(MDOC_ROOT != n->type);
+ assert(n->type != ROFFT_ROOT);
continue;
}
if (NULL != n->child)
@@ -1609,7 +1610,7 @@ parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
if (SEC_SYNOPSIS != n->sec ||
NULL == (n = n->child) ||
- MDOC_TEXT != n->type)
+ n->type != ROFFT_TEXT)
return(0);
/*
@@ -1620,7 +1621,7 @@ parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
if (strcmp("#include", n->string))
return(0);
- if (NULL == (n = n->next) || MDOC_TEXT != n->type)
+ if ((n = n->next) == NULL || n->type != ROFFT_TEXT)
return(0);
/*
@@ -1650,7 +1651,7 @@ parse_mdoc_fname(struct mpage *mpage, const struct mdoc_node *n)
char *cp;
size_t sz;
- if (n->type != MDOC_TEXT)
+ if (n->type != ROFFT_TEXT)
return;
/* Skip function pointer punctuation. */
@@ -1676,7 +1677,7 @@ parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
parse_mdoc_fname(mpage, n->child);
for (n = n->child->next; n != NULL; n = n->next)
- if (n->type == MDOC_TEXT)
+ if (n->type == ROFFT_TEXT)
putkey(mpage, n->string, TYPE_Fa);
return(0);
@@ -1687,7 +1688,7 @@ parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- if (n->type != MDOC_HEAD)
+ if (n->type != ROFFT_HEAD)
return(1);
if (n->child != NULL)
@@ -1721,7 +1722,7 @@ parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
mdoc_deroff(&mpage->desc, n);
return(0);
}
@@ -1733,7 +1734,7 @@ parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
if (SEC_NAME == n->sec)
putmdockey(mpage, n->child, NAME_TITLE);
- else if (SEC_SYNOPSIS == n->sec && MDOC_HEAD == n->type) {
+ else if (n->sec == SEC_SYNOPSIS && n->type == ROFFT_HEAD) {
if (n->child == NULL)
putkey(mpage, meta->name, NAME_SYN);
else
@@ -1742,7 +1743,7 @@ parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
if ( ! (mpage->name_head_done ||
n->child == NULL || n->child->string == NULL ||
strcasecmp(n->child->string, meta->title))) {
- putkey(mpage, n->child->string, NAME_HEAD);
+ putkey(mpage, n->child->string, ROFFT_HEAD);
mpage->name_head_done = 1;
}
return(0);
@@ -1753,7 +1754,7 @@ parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- return(SEC_CUSTOM == n->sec && MDOC_HEAD == n->type);
+ return(n->sec == SEC_CUSTOM && n->type == ROFFT_HEAD);
}
static int
@@ -1761,7 +1762,7 @@ parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- return(MDOC_HEAD == n->type);
+ return(n->type == ROFFT_HEAD);
}
static int
@@ -1769,7 +1770,7 @@ parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- return(MDOC_BODY == n->type);
+ return(n->type == ROFFT_BODY);
}
/*
diff --git a/mdoc.c b/mdoc.c
index f2f37efa..42739ee7 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -27,11 +27,12 @@
#include <string.h>
#include <time.h>
-#include "mdoc.h"
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libmdoc.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "mdoc.h"
#include "libmandoc.h"
+#include "libmdoc.h"
const char *const __mdoc_macronames[MDOC_MAX + 1] = {
"Ap", "Dd", "Dt", "Os",
@@ -88,7 +89,7 @@ static void mdoc_node_unlink(struct mdoc *,
static void mdoc_free1(struct mdoc *);
static void mdoc_alloc1(struct mdoc *);
static struct mdoc_node *node_alloc(struct mdoc *, int, int,
- enum mdoct, enum mdoc_type);
+ enum mdoct, enum roff_type);
static void node_append(struct mdoc *, struct mdoc_node *);
static int mdoc_ptext(struct mdoc *, int, char *, int);
static int mdoc_pmacro(struct mdoc *, int, char *, int);
@@ -138,7 +139,7 @@ mdoc_alloc1(struct mdoc *mdoc)
mdoc->lastnamed = mdoc->lastsec = SEC_NONE;
mdoc->last = mandoc_calloc(1, sizeof(struct mdoc_node));
mdoc->first = mdoc->last;
- mdoc->last->type = MDOC_ROOT;
+ mdoc->last->type = ROFFT_ROOT;
mdoc->last->tok = MDOC_MAX;
mdoc->next = MDOC_NEXT_CHILD;
}
@@ -202,7 +203,7 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
{
struct mdoc_node *n;
- n = node_alloc(mdoc, ep->ln, ep->pos, MDOC_MAX, MDOC_EQN);
+ n = node_alloc(mdoc, ep->ln, ep->pos, MDOC_MAX, ROFFT_EQN);
n->eqn = ep;
if (ep->ln > mdoc->last->line)
n->flags |= MDOC_LINE;
@@ -215,7 +216,7 @@ mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp)
{
struct mdoc_node *n;
- n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, MDOC_TBL);
+ n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, ROFFT_TBL);
n->span = sp;
node_append(mdoc, n);
mdoc->next = MDOC_NEXT_SIBLING;
@@ -229,7 +230,7 @@ int
mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs)
{
- if (mdoc->last->type != MDOC_EQN || ln > mdoc->last->line)
+ if (mdoc->last->type != ROFFT_EQN || ln > mdoc->last->line)
mdoc->flags |= MDOC_NEWLINE;
/*
@@ -281,7 +282,7 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
assert(mdoc->last);
assert(mdoc->first);
- assert(MDOC_ROOT != p->type);
+ assert(p->type != ROFFT_ROOT);
switch (mdoc->next) {
case MDOC_NEXT_SIBLING:
@@ -306,13 +307,13 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
*/
switch (p->type) {
- case MDOC_BODY:
+ case ROFFT_BODY:
if (ENDBODY_NOT != p->end)
break;
/* FALLTHROUGH */
- case MDOC_TAIL:
+ case ROFFT_TAIL:
/* FALLTHROUGH */
- case MDOC_HEAD:
+ case ROFFT_HEAD:
p->norm = p->parent->norm;
break;
default:
@@ -322,18 +323,18 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
mdoc_valid_pre(mdoc, p);
switch (p->type) {
- case MDOC_HEAD:
- assert(MDOC_BLOCK == p->parent->type);
+ case ROFFT_HEAD:
+ assert(p->parent->type == ROFFT_BLOCK);
p->parent->head = p;
break;
- case MDOC_TAIL:
- assert(MDOC_BLOCK == p->parent->type);
+ case ROFFT_TAIL:
+ assert(p->parent->type == ROFFT_BLOCK);
p->parent->tail = p;
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
if (p->end)
break;
- assert(MDOC_BLOCK == p->parent->type);
+ assert(p->parent->type == ROFFT_BLOCK);
p->parent->body = p;
break;
default:
@@ -343,9 +344,9 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
mdoc->last = p;
switch (p->type) {
- case MDOC_TBL:
+ case ROFFT_TBL:
/* FALLTHROUGH */
- case MDOC_TEXT:
+ case ROFFT_TEXT:
mdoc_valid_post(mdoc);
break;
default:
@@ -355,7 +356,7 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
static struct mdoc_node *
node_alloc(struct mdoc *mdoc, int line, int pos,
- enum mdoct tok, enum mdoc_type type)
+ enum mdoct tok, enum roff_type type)
{
struct mdoc_node *p;
@@ -384,7 +385,7 @@ mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
{
struct mdoc_node *p;
- p = node_alloc(mdoc, line, pos, tok, MDOC_TAIL);
+ p = node_alloc(mdoc, line, pos, tok, ROFFT_TAIL);
node_append(mdoc, p);
mdoc->next = MDOC_NEXT_CHILD;
}
@@ -396,7 +397,7 @@ mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
assert(mdoc->first);
assert(mdoc->last);
- p = node_alloc(mdoc, line, pos, tok, MDOC_HEAD);
+ p = node_alloc(mdoc, line, pos, tok, ROFFT_HEAD);
node_append(mdoc, p);
mdoc->next = MDOC_NEXT_CHILD;
return(p);
@@ -407,7 +408,7 @@ mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
{
struct mdoc_node *p;
- p = node_alloc(mdoc, line, pos, tok, MDOC_BODY);
+ p = node_alloc(mdoc, line, pos, tok, ROFFT_BODY);
node_append(mdoc, p);
mdoc->next = MDOC_NEXT_CHILD;
return(p);
@@ -421,7 +422,7 @@ mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok,
body->flags |= MDOC_ENDED;
body->parent->flags |= MDOC_ENDED;
- p = node_alloc(mdoc, line, pos, tok, MDOC_BODY);
+ p = node_alloc(mdoc, line, pos, tok, ROFFT_BODY);
p->body = body;
p->norm = body->norm;
p->end = end;
@@ -436,7 +437,7 @@ mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
{
struct mdoc_node *p;
- p = node_alloc(mdoc, line, pos, tok, MDOC_BLOCK);
+ p = node_alloc(mdoc, line, pos, tok, ROFFT_BLOCK);
p->args = args;
if (p->args)
(args->refcnt)++;
@@ -467,7 +468,7 @@ mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
{
struct mdoc_node *p;
- p = node_alloc(mdoc, line, pos, tok, MDOC_ELEM);
+ p = node_alloc(mdoc, line, pos, tok, ROFFT_ELEM);
p->args = args;
if (p->args)
(args->refcnt)++;
@@ -488,7 +489,7 @@ mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p)
{
struct mdoc_node *n;
- n = node_alloc(mdoc, line, pos, MDOC_MAX, MDOC_TEXT);
+ n = node_alloc(mdoc, line, pos, MDOC_MAX, ROFFT_TEXT);
n->string = roff_strdup(mdoc->roff, p);
node_append(mdoc, n);
mdoc->next = MDOC_NEXT_SIBLING;
@@ -513,7 +514,7 @@ static void
mdoc_node_free(struct mdoc_node *p)
{
- if (MDOC_BLOCK == p->type || MDOC_ELEM == p->type)
+ if (p->type == ROFFT_BLOCK || p->type == ROFFT_ELEM)
free(p->norm);
if (p->string)
free(p->string);
@@ -596,12 +597,12 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
/*
* Divert directly to list processing if we're encountering a
- * columnar MDOC_BLOCK with or without a prior MDOC_BLOCK entry
- * (a MDOC_BODY means it's already open, in which case we should
+ * columnar ROFFT_BLOCK with or without a prior ROFFT_BLOCK entry
+ * (a ROFFT_BODY means it's already open, in which case we should
* process within its context in the normal way).
*/
- if (n->tok == MDOC_Bl && n->type == MDOC_BODY &&
+ if (n->tok == MDOC_Bl && n->type == ROFFT_BODY &&
n->end == ENDBODY_NOT && n->norm->Bl.type == LIST_column) {
/* `Bl' is open without any children. */
mdoc->flags |= MDOC_FREECOL;
@@ -609,7 +610,7 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
return(1);
}
- if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
+ if (n->tok == MDOC_It && n->type == ROFFT_BLOCK &&
NULL != n->parent &&
MDOC_Bl == n->parent->tok &&
LIST_column == n->parent->norm->Bl.type) {
@@ -778,7 +779,7 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
* context around the parsed macro.
*/
- if (n->tok == MDOC_Bl && n->type == MDOC_BODY &&
+ if (n->tok == MDOC_Bl && n->type == ROFFT_BODY &&
n->end == ENDBODY_NOT && n->norm->Bl.type == LIST_column) {
mdoc->flags |= MDOC_FREECOL;
mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf);
@@ -791,7 +792,7 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
* then open an `It' block context around the parsed macro.
*/
- if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
+ if (n->tok == MDOC_It && n->type == ROFFT_BLOCK &&
NULL != n->parent &&
MDOC_Bl == n->parent->tok &&
LIST_column == n->parent->norm->Bl.type) {
@@ -865,7 +866,7 @@ mdoc_deroff(char **dest, const struct mdoc_node *n)
char *cp;
size_t sz;
- if (MDOC_TEXT != n->type) {
+ if (n->type != ROFFT_TEXT) {
for (n = n->child; n; n = n->next)
mdoc_deroff(dest, n);
return;
diff --git a/mdoc.h b/mdoc.h
index 54d80c45..9bf77063 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -174,18 +174,6 @@ enum mdocargt {
MDOC_ARG_MAX
};
-enum mdoc_type {
- MDOC_TEXT,
- MDOC_ELEM,
- MDOC_HEAD,
- MDOC_TAIL,
- MDOC_BODY,
- MDOC_BLOCK,
- MDOC_TBL,
- MDOC_EQN,
- MDOC_ROOT
-};
-
/*
* Section (named/unnamed) of `Sh'. Note that these appear in the
* conventional order imposed by mdoc.7. In the case of SEC_NONE, no
@@ -363,7 +351,7 @@ struct mdoc_node {
#define MDOC_BROKEN (1 << 5) /* must validate parent when ending */
#define MDOC_DELIMO (1 << 6)
#define MDOC_DELIMC (1 << 7)
- enum mdoc_type type; /* AST node type */
+ enum roff_type type; /* AST node type */
enum mdoc_sec sec; /* current named section */
union mdoc_data *norm; /* normalised args */
int prev_font; /* before entering this node */
diff --git a/mdoc_argv.c b/mdoc_argv.c
index c3c92a03..0f19f3c8 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -24,11 +24,12 @@
#include <stdio.h>
#include <string.h>
-#include "mdoc.h"
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libmdoc.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "mdoc.h"
#include "libmandoc.h"
+#include "libmdoc.h"
#define MULTI_STEP 5 /* pre-allocate argument values */
#define DELIMSZ 6 /* max possible size of a delimiter */
diff --git a/mdoc_hash.c b/mdoc_hash.c
index 55ac3509..eb90f010 100644
--- a/mdoc_hash.c
+++ b/mdoc_hash.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
+#include "roff.h"
#include "mdoc.h"
#include "libmdoc.h"
diff --git a/mdoc_html.c b/mdoc_html.c
index b89b8a0c..f5b41407 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -27,6 +27,7 @@
#include <unistd.h>
#include "mandoc_aux.h"
+#include "roff.h"
#include "mdoc.h"
#include "out.h"
#include "html.h"
@@ -390,10 +391,10 @@ print_mdoc_node(MDOC_ARGS)
n->flags &= ~MDOC_ENDED;
switch (n->type) {
- case MDOC_ROOT:
+ case ROFFT_ROOT:
child = mdoc_root_pre(meta, n, h);
break;
- case MDOC_TEXT:
+ case ROFFT_TEXT:
/* No tables in this mode... */
assert(NULL == h->tblt);
@@ -410,12 +411,12 @@ print_mdoc_node(MDOC_ARGS)
if (MDOC_DELIMO & n->flags)
h->flags |= HTML_NOSPACE;
return;
- case MDOC_EQN:
+ case ROFFT_EQN:
if (n->flags & MDOC_LINE)
putchar('\n');
print_eqn(h, n->eqn);
break;
- case MDOC_TBL:
+ case ROFFT_TBL:
/*
* This will take care of initialising all of the table
* state data for the first table, then tearing it down
@@ -450,10 +451,10 @@ print_mdoc_node(MDOC_ARGS)
print_stagq(h, t);
switch (n->type) {
- case MDOC_ROOT:
+ case ROFFT_ROOT:
mdoc_root_post(meta, n, h);
break;
- case MDOC_EQN:
+ case ROFFT_EQN:
break;
default:
if ( ! mdocs[n->tok].post || n->flags & MDOC_ENDED)
@@ -543,11 +544,11 @@ mdoc_sh_pre(MDOC_ARGS)
struct htmlpair tag;
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
PAIR_CLASS_INIT(&tag, "section");
print_otag(h, TAG_DIV, 1, &tag);
return(1);
- case MDOC_BODY:
+ case ROFFT_BODY:
if (n->sec == SEC_AUTHORS)
h->flags &= ~(HTML_SPLIT|HTML_NOSPLIT);
return(1);
@@ -558,7 +559,7 @@ mdoc_sh_pre(MDOC_ARGS)
bufinit(h);
bufcat(h, "x");
- for (n = n->child; n && MDOC_TEXT == n->type; ) {
+ for (n = n->child; n != NULL && n->type == ROFFT_TEXT; ) {
bufcat_id(h, n->string);
if (NULL != (n = n->next))
bufcat_id(h, " ");
@@ -578,17 +579,17 @@ mdoc_ss_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
PAIR_CLASS_INIT(&tag, "subsection");
print_otag(h, TAG_DIV, 1, &tag);
return(1);
- } else if (MDOC_BODY == n->type)
+ } else if (n->type == ROFFT_BODY)
return(1);
bufinit(h);
bufcat(h, "x");
- for (n = n->child; n && MDOC_TEXT == n->type; ) {
+ for (n = n->child; n != NULL && n->type == ROFFT_TEXT; ) {
bufcat_id(h, n->string);
if (NULL != (n = n->next))
bufcat_id(h, " ");
@@ -620,7 +621,7 @@ mdoc_fl_pre(MDOC_ARGS)
if ( ! (n->nchild == 0 &&
(n->next == NULL ||
- n->next->type == MDOC_TEXT ||
+ n->next->type == ROFFT_TEXT ||
n->next->flags & MDOC_LINE)))
h->flags |= HTML_NOSPACE;
@@ -632,7 +633,7 @@ mdoc_nd_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (MDOC_BODY != n->type)
+ if (n->type != ROFFT_BODY)
return(1);
/* XXX: this tag in theory can contain block elements. */
@@ -651,19 +652,19 @@ mdoc_nm_pre(MDOC_ARGS)
int len;
switch (n->type) {
- case MDOC_ELEM:
+ case ROFFT_ELEM:
synopsis_pre(h, n);
PAIR_CLASS_INIT(&tag, "name");
print_otag(h, TAG_B, 1, &tag);
if (NULL == n->child && meta->name)
print_text(h, meta->name);
return(1);
- case MDOC_HEAD:
+ case ROFFT_HEAD:
print_otag(h, TAG_TD, 0, NULL);
if (NULL == n->child && meta->name)
print_text(h, meta->name);
return(1);
- case MDOC_BODY:
+ case ROFFT_BODY:
print_otag(h, TAG_TD, 0, NULL);
return(1);
default:
@@ -675,7 +676,7 @@ mdoc_nm_pre(MDOC_ARGS)
print_otag(h, TAG_TABLE, 1, &tag);
for (len = 0, n = n->child; n; n = n->next)
- if (MDOC_TEXT == n->type)
+ if (n->type == ROFFT_TEXT)
len += html_strlen(n->string);
if (0 == len && meta->name)
@@ -836,7 +837,7 @@ mdoc_it_pre(MDOC_ARGS)
bufinit(h);
- if (MDOC_HEAD == n->type) {
+ if (n->type == ROFFT_HEAD) {
switch (type) {
case LIST_bullet:
/* FALLTHROUGH */
@@ -871,7 +872,7 @@ mdoc_it_pre(MDOC_ARGS)
default:
break;
}
- } else if (MDOC_BODY == n->type) {
+ } else if (n->type == ROFFT_BODY) {
switch (type) {
case LIST_bullet:
/* FALLTHROUGH */
@@ -935,13 +936,13 @@ mdoc_bl_pre(MDOC_ARGS)
struct roffsu su;
char buf[BUFSIZ];
- if (MDOC_BODY == n->type) {
+ if (n->type == ROFFT_BODY) {
if (LIST_column == n->norm->Bl.type)
print_otag(h, TAG_TBODY, 0, NULL);
return(1);
}
- if (MDOC_HEAD == n->type) {
+ if (n->type == ROFFT_HEAD) {
if (LIST_column != n->norm->Bl.type)
return(0);
@@ -1035,7 +1036,7 @@ mdoc_ex_pre(MDOC_ARGS)
nchild = n->nchild;
for (n = n->child; n; n = n->next) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
t = print_otag(h, TAG_B, 1, &tag);
print_text(h, n->string);
@@ -1075,7 +1076,7 @@ mdoc_d1_pre(MDOC_ARGS)
struct htmlpair tag[2];
struct roffsu su;
- if (MDOC_BLOCK != n->type)
+ if (n->type != ROFFT_BLOCK)
return(1);
SCALE_VS_INIT(&su, 0);
@@ -1128,13 +1129,13 @@ mdoc_bd_pre(MDOC_ARGS)
struct mdoc_node *nn;
struct roffsu su;
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
comp = n->norm->Bd.comp;
for (nn = n; nn && ! comp; nn = nn->parent) {
- if (MDOC_BLOCK != nn->type)
+ if (nn->type != ROFFT_BLOCK)
continue;
if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
comp = 1;
@@ -1353,7 +1354,7 @@ mdoc_fd_pre(MDOC_ARGS)
if (NULL == (n = n->child))
return(0);
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
if (strcmp(n->string, "#include")) {
PAIR_CLASS_INIT(&tag[0], "macro");
@@ -1366,7 +1367,7 @@ mdoc_fd_pre(MDOC_ARGS)
print_text(h, n->string);
if (NULL != (n = n->next)) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
/*
* XXX This is broken and not easy to fix.
@@ -1400,7 +1401,7 @@ mdoc_fd_pre(MDOC_ARGS)
}
for ( ; n; n = n->next) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
print_text(h, n->string);
}
@@ -1412,12 +1413,12 @@ mdoc_vt_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
synopsis_pre(h, n);
return(1);
- } else if (MDOC_ELEM == n->type) {
+ } else if (n->type == ROFFT_ELEM) {
synopsis_pre(h, n);
- } else if (MDOC_HEAD == n->type)
+ } else if (n->type == ROFFT_HEAD)
return(0);
PAIR_CLASS_INIT(&tag, "type");
@@ -1596,7 +1597,7 @@ mdoc_lk_pre(MDOC_ARGS)
if (NULL == (n = n->child))
return(0);
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
PAIR_CLASS_INIT(&tag[0], "link-ext");
PAIR_HREF_INIT(&tag[1], n->string);
@@ -1621,7 +1622,7 @@ mdoc_mt_pre(MDOC_ARGS)
PAIR_CLASS_INIT(&tag[0], "link-mail");
for (n = n->child; n; n = n->next) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
bufinit(h);
bufcat(h, "mailto:");
@@ -1642,12 +1643,12 @@ mdoc_fo_pre(MDOC_ARGS)
struct htmlpair tag;
struct tag *t;
- if (MDOC_BODY == n->type) {
+ if (n->type == ROFFT_BODY) {
h->flags |= HTML_NOSPACE;
print_text(h, "(");
h->flags |= HTML_NOSPACE;
return(1);
- } else if (MDOC_BLOCK == n->type) {
+ } else if (n->type == ROFFT_BLOCK) {
synopsis_pre(h, n);
return(1);
}
@@ -1668,7 +1669,7 @@ static void
mdoc_fo_post(MDOC_ARGS)
{
- if (MDOC_BODY != n->type)
+ if (n->type != ROFFT_BODY)
return;
h->flags |= HTML_NOSPACE;
print_text(h, ")");
@@ -1702,7 +1703,7 @@ mdoc_in_pre(MDOC_ARGS)
h->flags |= HTML_NOSPACE;
if (NULL != (n = n->child)) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
PAIR_CLASS_INIT(&tag[0], "link-includes");
@@ -1724,7 +1725,7 @@ mdoc_in_pre(MDOC_ARGS)
print_text(h, ">");
for ( ; n; n = n->next) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
print_text(h, n->string);
}
@@ -1823,9 +1824,9 @@ mdoc_bf_pre(MDOC_ARGS)
struct htmlpair tag[2];
struct roffsu su;
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
- else if (MDOC_BODY != n->type)
+ else if (n->type != ROFFT_BODY)
return(1);
if (FONT_Em == n->norm->Bf.font)
@@ -1882,7 +1883,7 @@ mdoc_rs_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (MDOC_BLOCK != n->type)
+ if (n->type != ROFFT_BLOCK)
return(1);
if (n->prev && SEC_SEE_ALSO == n->sec)
@@ -2048,11 +2049,11 @@ mdoc_bk_pre(MDOC_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
return(0);
- case MDOC_BODY:
+ case ROFFT_BODY:
if (n->parent->args || 0 == n->prev->nchild)
h->flags |= HTML_PREKEEP;
break;
@@ -2068,7 +2069,7 @@ static void
mdoc_bk_post(MDOC_ARGS)
{
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
}
@@ -2077,7 +2078,7 @@ mdoc_quote_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (MDOC_BODY != n->type)
+ if (n->type != ROFFT_BODY)
return(1);
switch (n->tok) {
@@ -2149,7 +2150,7 @@ static void
mdoc_quote_post(MDOC_ARGS)
{
- if (n->type != MDOC_BODY && n->type != MDOC_ELEM)
+ if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
return;
h->flags |= HTML_NOSPACE;
@@ -2214,7 +2215,7 @@ static int
mdoc_eo_pre(MDOC_ARGS)
{
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return(1);
if (n->end == ENDBODY_NOT &&
@@ -2234,7 +2235,7 @@ mdoc_eo_post(MDOC_ARGS)
{
int body, tail;
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return;
if (n->end != ENDBODY_NOT) {
diff --git a/mdoc_macro.c b/mdoc_macro.c
index bd98e583..5db1f23d 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -26,10 +26,11 @@
#include <string.h>
#include <time.h>
-#include "mdoc.h"
#include "mandoc.h"
-#include "libmdoc.h"
+#include "roff.h"
+#include "mdoc.h"
#include "libmandoc.h"
+#include "libmdoc.h"
static void blk_full(MACRO_PROT_ARGS);
static void blk_exp_close(MACRO_PROT_ARGS);
@@ -217,7 +218,7 @@ mdoc_macroend(struct mdoc *mdoc)
mdoc->last->parent : mdoc->last;
for ( ; n; n = n->parent)
- if (n->type == MDOC_BLOCK &&
+ if (n->type == ROFFT_BLOCK &&
mdoc_macros[n->tok].flags & MDOC_EXPLICIT)
mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse,
n->line, n->pos, mdoc_macronames[n->tok]);
@@ -287,10 +288,10 @@ rew_pending(struct mdoc *mdoc, const struct mdoc_node *n)
rew_last(mdoc, n);
switch (n->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
mdoc_body_alloc(mdoc, n->line, n->pos, n->tok);
return;
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
break;
default:
return;
@@ -303,8 +304,8 @@ rew_pending(struct mdoc *mdoc, const struct mdoc_node *n)
if ((n = n->parent) == NULL)
return;
- if (n->type == MDOC_BLOCK ||
- n->type == MDOC_HEAD) {
+ if (n->type == ROFFT_BLOCK ||
+ n->type == ROFFT_HEAD) {
if (n->flags & MDOC_ENDED)
break;
else
@@ -366,9 +367,9 @@ rew_elem(struct mdoc *mdoc, enum mdoct tok)
struct mdoc_node *n;
n = mdoc->last;
- if (MDOC_ELEM != n->type)
+ if (n->type != ROFFT_ELEM)
n = n->parent;
- assert(MDOC_ELEM == n->type);
+ assert(n->type == ROFFT_ELEM);
assert(tok == n->tok);
rew_last(mdoc, n);
}
@@ -387,7 +388,7 @@ dword(struct mdoc *mdoc, int line, int col, const char *p,
if (may_append &&
! (mdoc->flags & (MDOC_SYNOPSIS | MDOC_KEEP | MDOC_SMOFF)) &&
- d == DELIM_NONE && mdoc->last->type == MDOC_TEXT &&
+ d == DELIM_NONE && mdoc->last->type == ROFFT_TEXT &&
mdoc_isdelim(mdoc->last->string) == DELIM_NONE) {
mdoc_word_append(mdoc, p);
return;
@@ -522,13 +523,13 @@ blk_exp_close(MACRO_PROT_ARGS)
/* Remember the start of our own body. */
- if (n->type == MDOC_BODY && atok == n->tok) {
+ if (n->type == ROFFT_BODY && atok == n->tok) {
if (n->end == ENDBODY_NOT)
body = n;
continue;
}
- if (n->type != MDOC_BLOCK || n->tok == MDOC_Nm)
+ if (n->type != ROFFT_BLOCK || n->tok == MDOC_Nm)
continue;
if (n->tok == MDOC_It) {
@@ -873,7 +874,7 @@ blk_full(MACRO_PROT_ARGS)
n->flags |= MDOC_BROKEN;
continue;
}
- if (n->type != MDOC_BLOCK)
+ if (n->type != ROFFT_BLOCK)
continue;
if (tok == MDOC_It && n->tok == MDOC_Bl) {
@@ -1016,7 +1017,7 @@ blk_full(MACRO_PROT_ARGS)
/*
* Emit leading punctuation (i.e., punctuation before
- * the MDOC_HEAD) for non-phrase types.
+ * the ROFFT_HEAD) for non-phrase types.
*/
if (head == NULL &&
@@ -1086,7 +1087,7 @@ blk_full(MACRO_PROT_ARGS)
n->flags |= MDOC_BROKEN;
continue;
}
- if (n->type == MDOC_BLOCK &&
+ if (n->type == ROFFT_BLOCK &&
mdoc_macros[n->tok].flags & MDOC_EXPLICIT) {
n->flags = MDOC_BROKEN;
head->flags = MDOC_ENDED;
@@ -1171,7 +1172,7 @@ blk_part_imp(MACRO_PROT_ARGS)
n->flags |= MDOC_BROKEN;
continue;
}
- if (n->type == MDOC_BLOCK &&
+ if (n->type == ROFFT_BLOCK &&
mdoc_macros[n->tok].flags & MDOC_EXPLICIT) {
n->flags |= MDOC_BROKEN;
if ( ! (body->flags & MDOC_ENDED)) {
@@ -1452,7 +1453,7 @@ phrase_ta(MACRO_PROT_ARGS)
for (n = mdoc->last; n != NULL; n = n->parent) {
if (n->flags & MDOC_ENDED)
continue;
- if (n->tok == MDOC_It && n->type == MDOC_BODY)
+ if (n->tok == MDOC_It && n->type == ROFFT_BODY)
body = n;
if (n->tok == MDOC_Bl)
break;
diff --git a/mdoc_man.c b/mdoc_man.c
index 83be0298..005a5784 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -22,11 +22,12 @@
#include <stdio.h>
#include <string.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "out.h"
-#include "man.h"
+#include "mandoc.h"
+#include "roff.h"
#include "mdoc.h"
+#include "man.h"
+#include "out.h"
#include "main.h"
#define DECL_ARGS const struct mdoc_meta *meta, struct mdoc_node *n
@@ -492,7 +493,7 @@ print_width(const struct mdoc_bl *bl, const struct mdoc_node *child)
/* XXX Rough estimation, might have multiple parts. */
if (bl->type == LIST_enum)
chsz = (bl->count > 8) + 1;
- else if (child != NULL && child->type == MDOC_TEXT)
+ else if (child != NULL && child->type == ROFFT_TEXT)
chsz = strlen(child->string);
else
chsz = 0;
@@ -592,7 +593,7 @@ print_node(DECL_ARGS)
do_sub = 1;
n->flags &= ~MDOC_ENDED;
- if (MDOC_TEXT == n->type) {
+ if (n->type == ROFFT_TEXT) {
/*
* Make sure that we don't happen to start with a
* control character at the start of a line.
@@ -648,14 +649,14 @@ static int
cond_head(DECL_ARGS)
{
- return(MDOC_HEAD == n->type);
+ return(n->type == ROFFT_HEAD);
}
static int
cond_body(DECL_ARGS)
{
- return(MDOC_BODY == n->type);
+ return(n->type == ROFFT_BODY);
}
static int
@@ -778,7 +779,7 @@ static int
pre_sect(DECL_ARGS)
{
- if (MDOC_HEAD == n->type) {
+ if (n->type == ROFFT_HEAD) {
outflags |= MMAN_sp;
print_block(manacts[n->tok].prefix, 0);
print_word("");
@@ -795,7 +796,7 @@ static void
post_sect(DECL_ARGS)
{
- if (MDOC_HEAD != n->type)
+ if (n->type != ROFFT_HEAD)
return;
outflags &= ~MMAN_spc;
print_word("");
@@ -932,9 +933,9 @@ pre_bf(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
return(1);
- case MDOC_BODY:
+ case ROFFT_BODY:
break;
default:
return(0);
@@ -957,7 +958,7 @@ static void
post_bf(DECL_ARGS)
{
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
font_pop();
}
@@ -966,9 +967,9 @@ pre_bk(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
return(1);
- case MDOC_BODY:
+ case ROFFT_BODY:
outflags |= MMAN_Bk;
return(1);
default:
@@ -980,7 +981,7 @@ static void
post_bk(DECL_ARGS)
{
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
outflags &= ~MMAN_Bk;
}
@@ -1235,7 +1236,7 @@ post_fl(DECL_ARGS)
font_pop();
if ( ! (n->nchild ||
n->next == NULL ||
- n->next->type == MDOC_TEXT ||
+ n->next->type == ROFFT_TEXT ||
n->next->flags & MDOC_LINE))
outflags &= ~MMAN_spc;
}
@@ -1282,17 +1283,17 @@ pre_fo(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
pre_syn(n);
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
if (n->child == NULL)
return(0);
if (MDOC_SYNPRETTY & n->flags)
print_block(".HP 4n", MMAN_nl);
font_push('B');
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
outflags &= ~(MMAN_spc | MMAN_nl);
print_word("(");
outflags &= ~MMAN_spc;
@@ -1308,11 +1309,11 @@ post_fo(DECL_ARGS)
{
switch (n->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
if (n->child != NULL)
font_pop();
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
post_fn(meta, n);
break;
default:
@@ -1368,7 +1369,7 @@ pre_it(DECL_ARGS)
const struct mdoc_node *bln;
switch (n->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
outflags |= MMAN_PP | MMAN_nl;
bln = n->parent->parent;
if (0 == bln->norm->Bl.comp ||
@@ -1467,7 +1468,7 @@ post_it(DECL_ARGS)
bln = n->parent->parent;
switch (n->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
switch (bln->norm->Bl.type) {
case LIST_diag:
outflags &= ~MMAN_spc;
@@ -1480,7 +1481,7 @@ post_it(DECL_ARGS)
break;
}
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
switch (bln->norm->Bl.type) {
case LIST_bullet:
/* FALLTHROUGH */
@@ -1574,16 +1575,16 @@ pre_nm(DECL_ARGS)
{
char *name;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
outflags |= MMAN_Bk;
pre_syn(n);
}
- if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
+ if (n->type != ROFFT_ELEM && n->type != ROFFT_HEAD)
return(1);
name = n->child ? n->child->string : meta->name;
if (NULL == name)
return(0);
- if (MDOC_HEAD == n->type) {
+ if (n->type == ROFFT_HEAD) {
if (NULL == n->parent->prev)
outflags |= MMAN_sp;
print_block(".HP", 0);
@@ -1601,12 +1602,12 @@ post_nm(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
outflags &= ~MMAN_Bk;
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
/* FALLTHROUGH */
- case MDOC_ELEM:
+ case ROFFT_ELEM:
if (n->child != NULL || meta->name != NULL)
font_pop();
break;
@@ -1770,10 +1771,10 @@ pre_vt(DECL_ARGS)
if (MDOC_SYNPRETTY & n->flags) {
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
pre_syn(n);
return(1);
- case MDOC_BODY:
+ case ROFFT_BODY:
break;
default:
return(0);
@@ -1787,7 +1788,7 @@ static void
post_vt(DECL_ARGS)
{
- if (MDOC_SYNPRETTY & n->flags && MDOC_BODY != n->type)
+ if (n->flags & MDOC_SYNPRETTY && n->type != ROFFT_BODY)
return;
font_pop();
}
diff --git a/mdoc_term.c b/mdoc_term.c
index 0f23ec15..e00b78b0 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -8,9 +8,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -28,11 +28,12 @@
#include <stdlib.h>
#include <string.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "mdoc.h"
#include "out.h"
#include "term.h"
-#include "mdoc.h"
#include "main.h"
struct termpair {
@@ -331,7 +332,7 @@ print_mdoc_node(DECL_ARGS)
*/
switch (n->type) {
- case MDOC_TEXT:
+ case ROFFT_TEXT:
if (' ' == *n->string && MDOC_LINE & n->flags)
term_newln(p);
if (MDOC_DELIMC & n->flags)
@@ -340,14 +341,14 @@ print_mdoc_node(DECL_ARGS)
if (MDOC_DELIMO & n->flags)
p->flags |= TERMP_NOSPACE;
break;
- case MDOC_EQN:
+ case ROFFT_EQN:
if ( ! (n->flags & MDOC_LINE))
p->flags |= TERMP_NOSPACE;
term_eqn(p, n->eqn);
if (n->next != NULL && ! (n->next->flags & MDOC_LINE))
p->flags |= TERMP_NOSPACE;
break;
- case MDOC_TBL:
+ case ROFFT_TBL:
if (p->tbl.cols == NULL)
term_newln(p);
term_tbl(p, n->span);
@@ -367,11 +368,11 @@ print_mdoc_node(DECL_ARGS)
(ENDBODY_NOT == n->end ? n : n->body)->prev_font);
switch (n->type) {
- case MDOC_TEXT:
+ case ROFFT_TEXT:
break;
- case MDOC_TBL:
+ case ROFFT_TBL:
break;
- case MDOC_EQN:
+ case ROFFT_EQN:
break;
default:
if ( ! termacts[n->tok].post || MDOC_ENDED & n->flags)
@@ -568,9 +569,9 @@ print_bvspace(struct termp *p,
while (nn->prev == NULL) {
do {
nn = nn->parent;
- if (nn->type == MDOC_ROOT)
+ if (nn->type == ROFFT_ROOT)
return;
- } while (nn->type != MDOC_BLOCK);
+ } while (nn->type != ROFFT_BLOCK);
if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
return;
if (nn->tok == MDOC_It &&
@@ -614,7 +615,7 @@ termp_it_pre(DECL_ARGS)
int i, offset, width;
enum mdoc_list type;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
print_bvspace(p, n->parent->parent, n);
return(1);
}
@@ -666,7 +667,7 @@ termp_it_pre(DECL_ARGS)
switch (type) {
case LIST_column:
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
break;
/*
@@ -683,8 +684,8 @@ termp_it_pre(DECL_ARGS)
ncols == 5 ? term_len(p, 3) : term_len(p, 1);
/*
- * Calculate the offset by applying all prior MDOC_BODY,
- * so we stop at the MDOC_HEAD (NULL == nn->prev).
+ * Calculate the offset by applying all prior ROFFT_BODY,
+ * so we stop at the ROFFT_HEAD (nn->prev == NULL).
*/
for (i = 0, nn = n->prev;
@@ -734,11 +735,11 @@ termp_it_pre(DECL_ARGS)
switch (type) {
case LIST_diag:
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
term_word(p, "\\ \\ ");
break;
case LIST_inset:
- if (MDOC_BODY == n->type && n->parent->head->nchild)
+ if (n->type == ROFFT_BODY && n->parent->head->nchild)
term_word(p, "\\ ");
break;
default:
@@ -749,7 +750,7 @@ termp_it_pre(DECL_ARGS)
switch (type) {
case LIST_diag:
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
term_fontpush(p, TERMFONT_BOLD);
break;
default:
@@ -777,13 +778,13 @@ termp_it_pre(DECL_ARGS)
case LIST_hyphen:
if (width <= (int)term_len(p, 2))
p->flags |= TERMP_HANG;
- if (MDOC_HEAD != n->type)
+ if (n->type != ROFFT_HEAD)
break;
p->flags |= TERMP_NOBREAK;
p->trailspace = 1;
break;
case LIST_hang:
- if (MDOC_HEAD != n->type)
+ if (n->type != ROFFT_HEAD)
break;
/*
@@ -802,7 +803,7 @@ termp_it_pre(DECL_ARGS)
p->trailspace = 1;
break;
case LIST_tag:
- if (MDOC_HEAD != n->type)
+ if (n->type != ROFFT_HEAD)
break;
p->flags |= TERMP_NOBREAK | TERMP_BRIND;
@@ -812,7 +813,7 @@ termp_it_pre(DECL_ARGS)
p->flags |= TERMP_DANGLE;
break;
case LIST_column:
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
break;
if (NULL == n->next) {
@@ -825,7 +826,7 @@ termp_it_pre(DECL_ARGS)
break;
case LIST_diag:
- if (MDOC_HEAD != n->type)
+ if (n->type != ROFFT_HEAD)
break;
p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 1;
@@ -849,7 +850,7 @@ termp_it_pre(DECL_ARGS)
* don't want to recalculate rmargin and offsets when
* using `Bd' or `Bl' within `-hang' overstep lists.
*/
- if (MDOC_HEAD == n->type &&
+ if (n->type == ROFFT_HEAD &&
NULL != n->next &&
NULL != n->next->child &&
(MDOC_Bl == n->next->child->tok ||
@@ -865,7 +866,7 @@ termp_it_pre(DECL_ARGS)
case LIST_hyphen:
/* FALLTHROUGH */
case LIST_tag:
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
p->rmargin = p->offset + width;
else
p->offset += width;
@@ -877,7 +878,7 @@ termp_it_pre(DECL_ARGS)
* XXX - this behaviour is not documented: the
* right-most column is filled to the right margin.
*/
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
break;
if (NULL == n->next && p->rmargin < p->maxrmargin)
p->rmargin = p->maxrmargin;
@@ -891,7 +892,7 @@ termp_it_pre(DECL_ARGS)
* HEAD character (temporarily bold, in some cases).
*/
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
switch (type) {
case LIST_bullet:
term_fontpush(p, TERMFONT_BOLD);
@@ -929,11 +930,11 @@ termp_it_pre(DECL_ARGS)
case LIST_hyphen:
/* FALLTHROUGH */
case LIST_enum:
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
break;
case LIST_column:
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
break;
default:
@@ -948,7 +949,7 @@ termp_it_post(DECL_ARGS)
{
enum mdoc_list type;
- if (MDOC_BLOCK == n->type)
+ if (n->type == ROFFT_BLOCK)
return;
type = n->parent->parent->parent->norm->Bl.type;
@@ -959,11 +960,11 @@ termp_it_post(DECL_ARGS)
case LIST_diag:
/* FALLTHROUGH */
case LIST_inset:
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
term_newln(p);
break;
case LIST_column:
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
term_flushln(p);
break;
default:
@@ -987,12 +988,12 @@ termp_nm_pre(DECL_ARGS)
{
const char *cp;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
p->flags |= TERMP_PREKEEP;
return(1);
}
- if (MDOC_BODY == n->type) {
+ if (n->type == ROFFT_BODY) {
if (NULL == n->child)
return(0);
p->flags |= TERMP_NOSPACE;
@@ -1011,17 +1012,17 @@ termp_nm_pre(DECL_ARGS)
if (NULL == n->child && NULL == meta->name)
return(0);
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
synopsis_pre(p, n->parent);
- if (MDOC_HEAD == n->type &&
+ if (n->type == ROFFT_HEAD &&
NULL != n->next && NULL != n->next->child) {
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 1;
p->rmargin = p->offset + term_len(p, 1);
if (NULL == n->child) {
p->rmargin += term_strlen(p, meta->name);
- } else if (MDOC_TEXT == n->child->type) {
+ } else if (n->child->type == ROFFT_TEXT) {
p->rmargin += term_strlen(p, n->child->string);
if (n->child->next)
p->flags |= TERMP_HANG;
@@ -1041,14 +1042,14 @@ static void
termp_nm_post(DECL_ARGS)
{
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
- } else if (MDOC_HEAD == n->type &&
+ } else if (n->type == ROFFT_HEAD &&
NULL != n->next && NULL != n->next->child) {
term_flushln(p);
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
p->trailspace = 0;
- } else if (MDOC_BODY == n->type && n->child)
+ } else if (n->type == ROFFT_BODY && n->child != NULL)
term_flushln(p);
}
@@ -1061,7 +1062,7 @@ termp_fl_pre(DECL_ARGS)
if ( ! (n->nchild == 0 &&
(n->next == NULL ||
- n->next->type == MDOC_TEXT ||
+ n->next->type == ROFFT_TEXT ||
n->next->flags & MDOC_LINE)))
p->flags |= TERMP_NOSPACE;
@@ -1118,7 +1119,7 @@ termp_rs_pre(DECL_ARGS)
if (SEC_SEE_ALSO != n->sec)
return(1);
- if (MDOC_BLOCK == n->type && n->prev)
+ if (n->type == ROFFT_BLOCK && n->prev != NULL)
term_vspace(p);
return(1);
}
@@ -1214,7 +1215,7 @@ static int
termp_nd_pre(DECL_ARGS)
{
- if (n->type == MDOC_BODY)
+ if (n->type == ROFFT_BODY)
term_word(p, "\\(en");
return(1);
}
@@ -1223,14 +1224,14 @@ static int
termp_bl_pre(DECL_ARGS)
{
- return(MDOC_HEAD != n->type);
+ return(n->type != ROFFT_HEAD);
}
static void
termp_bl_post(DECL_ARGS)
{
- if (MDOC_BLOCK == n->type)
+ if (n->type == ROFFT_BLOCK)
term_newln(p);
}
@@ -1241,7 +1242,7 @@ termp_xr_pre(DECL_ARGS)
if (NULL == (n = n->child))
return(0);
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
term_word(p, n->string);
if (NULL == (n = n->next))
@@ -1251,7 +1252,7 @@ termp_xr_pre(DECL_ARGS)
term_word(p, "(");
p->flags |= TERMP_NOSPACE;
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
term_word(p, n->string);
p->flags |= TERMP_NOSPACE;
@@ -1321,13 +1322,13 @@ static int
termp_vt_pre(DECL_ARGS)
{
- if (MDOC_ELEM == n->type) {
+ if (n->type == ROFFT_ELEM) {
synopsis_pre(p, n);
return(termp_under_pre(p, pair, meta, n));
- } else if (MDOC_BLOCK == n->type) {
+ } else if (n->type == ROFFT_BLOCK) {
synopsis_pre(p, n);
return(1);
- } else if (MDOC_HEAD == n->type)
+ } else if (n->type == ROFFT_HEAD)
return(0);
return(termp_under_pre(p, pair, meta, n));
@@ -1361,7 +1362,7 @@ termp_sh_pre(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
/*
* Vertical space before sections, except
* when the previous section was empty.
@@ -1372,10 +1373,10 @@ termp_sh_pre(DECL_ARGS)
n->prev->body->child != NULL))
term_vspace(p);
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
term_fontpush(p, TERMFONT_BOLD);
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
p->offset = term_len(p, p->defindent);
if (SEC_AUTHORS == n->sec)
p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);
@@ -1391,10 +1392,10 @@ termp_sh_post(DECL_ARGS)
{
switch (n->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
term_newln(p);
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
term_newln(p);
p->offset = 0;
break;
@@ -1433,7 +1434,7 @@ static int
termp_d1_pre(DECL_ARGS)
{
- if (MDOC_BLOCK != n->type)
+ if (n->type != ROFFT_BLOCK)
return(1);
term_newln(p);
p->offset += term_len(p, p->defindent + 1);
@@ -1469,7 +1470,7 @@ termp_fn_pre(DECL_ARGS)
p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
}
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
term_fontpush(p, TERMFONT_BOLD);
term_word(p, n->string);
term_fontpop(p);
@@ -1486,7 +1487,7 @@ termp_fn_pre(DECL_ARGS)
p->flags |= TERMP_NOSPACE;
for (n = n->next; n; n = n->next) {
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
term_fontpush(p, TERMFONT_UNDER);
if (pretty)
p->flags |= TERMP_NBRWORD;
@@ -1543,10 +1544,10 @@ termp_bd_pre(DECL_ARGS)
struct mdoc_node *nn;
int offset;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
print_bvspace(p, n, n);
return(1);
- } else if (MDOC_HEAD == n->type)
+ } else if (n->type == ROFFT_HEAD)
return(0);
/* Handle the -offset argument. */
@@ -1590,7 +1591,7 @@ termp_bd_pre(DECL_ARGS)
for (nn = n->child; nn; nn = nn->next) {
if (DISP_centered == n->norm->Bd.type) {
- if (MDOC_TEXT == nn->type) {
+ if (nn->type == ROFFT_TEXT) {
len = term_strlen(p, nn->string);
p->offset = len >= rm ? 0 :
lm + len >= rm ? rm - len :
@@ -1643,7 +1644,7 @@ termp_bd_post(DECL_ARGS)
{
size_t rm, rmax;
- if (MDOC_BODY != n->type)
+ if (n->type != ROFFT_BODY)
return;
rm = p->rmargin;
@@ -1737,16 +1738,16 @@ termp_ss_pre(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
term_newln(p);
if (n->prev)
term_vspace(p);
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
term_fontpush(p, TERMFONT_BOLD);
p->offset = term_len(p, (p->defindent+1)/2);
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
p->offset = term_len(p, p->defindent);
break;
default:
@@ -1760,7 +1761,7 @@ static void
termp_ss_post(DECL_ARGS)
{
- if (n->type == MDOC_HEAD || n->type == MDOC_BODY)
+ if (n->type == ROFFT_HEAD || n->type == ROFFT_BODY)
term_newln(p);
}
@@ -1851,7 +1852,7 @@ static int
termp_quote_pre(DECL_ARGS)
{
- if (MDOC_BODY != n->type && MDOC_ELEM != n->type)
+ if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
return(1);
switch (n->tok) {
@@ -1918,7 +1919,7 @@ static void
termp_quote_post(DECL_ARGS)
{
- if (n->type != MDOC_BODY && n->type != MDOC_ELEM)
+ if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
return;
p->flags |= TERMP_NOSPACE;
@@ -1986,7 +1987,7 @@ static int
termp_eo_pre(DECL_ARGS)
{
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return(1);
if (n->end == ENDBODY_NOT &&
@@ -2007,7 +2008,7 @@ termp_eo_post(DECL_ARGS)
{
int body, tail;
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return;
if (n->end != ENDBODY_NOT) {
@@ -2034,10 +2035,10 @@ termp_fo_pre(DECL_ARGS)
pretty = MDOC_SYNPRETTY & n->flags;
- if (MDOC_BLOCK == n->type) {
+ if (n->type == ROFFT_BLOCK) {
synopsis_pre(p, n);
return(1);
- } else if (MDOC_BODY == n->type) {
+ } else if (n->type == ROFFT_BODY) {
if (pretty) {
rmargin = p->rmargin;
p->rmargin = p->offset + term_len(p, 4);
@@ -2072,7 +2073,7 @@ static void
termp_fo_post(DECL_ARGS)
{
- if (MDOC_BODY != n->type)
+ if (n->type != ROFFT_BODY)
return;
p->flags |= TERMP_NOSPACE;
@@ -2089,9 +2090,9 @@ static int
termp_bf_pre(DECL_ARGS)
{
- if (MDOC_HEAD == n->type)
+ if (n->type == ROFFT_HEAD)
return(0);
- else if (MDOC_BODY != n->type)
+ else if (n->type != ROFFT_BODY)
return(1);
if (FONT_Em == n->norm->Bf.font)
@@ -2197,11 +2198,11 @@ termp_bk_pre(DECL_ARGS)
{
switch (n->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
return(0);
- case MDOC_BODY:
+ case ROFFT_BODY:
if (n->parent->args || 0 == n->prev->nchild)
p->flags |= TERMP_PREKEEP;
break;
@@ -2217,7 +2218,7 @@ static void
termp_bk_post(DECL_ARGS)
{
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 11365302..9cbb7437 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -8,9 +8,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -31,11 +31,12 @@
#include <string.h>
#include <time.h>
-#include "mdoc.h"
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libmdoc.h"
+#include "mandoc.h"
+#include "roff.h"
+#include "mdoc.h"
#include "libmandoc.h"
+#include "libmdoc.h"
/* FIXME: .Bl -diag can't have non-text children in HEAD. */
@@ -297,15 +298,15 @@ mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
v_pre p;
switch (n->type) {
- case MDOC_TEXT:
+ case ROFFT_TEXT:
if (n->sec != SEC_SYNOPSIS || n->parent->tok != MDOC_Fd)
check_text(mdoc, n->line, n->pos, n->string);
/* FALLTHROUGH */
- case MDOC_TBL:
+ case ROFFT_TBL:
/* FALLTHROUGH */
- case MDOC_EQN:
+ case ROFFT_EQN:
/* FALLTHROUGH */
- case MDOC_ROOT:
+ case ROFFT_ROOT:
return;
default:
break;
@@ -329,13 +330,13 @@ mdoc_valid_post(struct mdoc *mdoc)
n->flags |= MDOC_VALID | MDOC_ENDED;
switch (n->type) {
- case MDOC_TEXT:
+ case ROFFT_TEXT:
/* FALLTHROUGH */
- case MDOC_EQN:
+ case ROFFT_EQN:
/* FALLTHROUGH */
- case MDOC_TBL:
+ case ROFFT_TBL:
break;
- case MDOC_ROOT:
+ case ROFFT_ROOT:
post_root(mdoc);
break;
default:
@@ -400,11 +401,11 @@ pre_display(PRE_ARGS)
{
struct mdoc_node *node;
- if (MDOC_BLOCK != n->type)
+ if (n->type != ROFFT_BLOCK)
return;
for (node = mdoc->last->parent; node; node = node->parent)
- if (MDOC_BLOCK == node->type)
+ if (node->type == ROFFT_BLOCK)
if (MDOC_Bd == node->tok)
break;
@@ -422,7 +423,7 @@ pre_bl(PRE_ARGS)
enum mdocargt mdoclt;
enum mdoc_list lt;
- if (n->type != MDOC_BLOCK)
+ if (n->type != ROFFT_BLOCK)
return;
/*
@@ -605,7 +606,7 @@ pre_bd(PRE_ARGS)
pre_literal(mdoc, n);
- if (n->type != MDOC_BLOCK)
+ if (n->type != ROFFT_BLOCK)
return;
for (i = 0; n->args && i < (int)n->args->argc; i++) {
@@ -718,7 +719,7 @@ static void
pre_obsolete(PRE_ARGS)
{
- if (MDOC_ELEM == n->type || MDOC_BLOCK == n->type)
+ if (n->type == ROFFT_ELEM || n->type == ROFFT_BLOCK)
mandoc_msg(MANDOCERR_MACRO_OBS, mdoc->parse,
n->line, n->pos, mdoc_macronames[n->tok]);
}
@@ -777,10 +778,10 @@ post_bf(POST_ARGS)
*/
np = mdoc->last;
- if (MDOC_HEAD != np->type)
+ if (np->type != ROFFT_HEAD)
return;
- assert(MDOC_BLOCK == np->parent->type);
+ assert(np->parent->type == ROFFT_BLOCK);
assert(MDOC_Bf == np->parent->tok);
/* Check the number of arguments. */
@@ -835,7 +836,7 @@ post_lb(POST_ARGS)
char *libname;
n = mdoc->last->child;
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
if (NULL == (stdlibname = mdoc_a2lib(n->string)))
mandoc_asprintf(&libname,
@@ -890,7 +891,7 @@ post_fo(POST_ARGS)
n = mdoc->last;
- if (n->type != MDOC_HEAD)
+ if (n->type != ROFFT_HEAD)
return;
if (n->child == NULL) {
@@ -943,11 +944,11 @@ post_vt(POST_ARGS)
* specifically the BODY, should only have TEXT children.
*/
- if (MDOC_BODY != mdoc->last->type)
+ if (mdoc->last->type != ROFFT_BODY)
return;
for (n = mdoc->last->child; n; n = n->next)
- if (MDOC_TEXT != n->type)
+ if (n->type != ROFFT_TEXT)
mandoc_msg(MANDOCERR_VT_CHILD, mdoc->parse,
n->line, n->pos, mdoc_macronames[n->tok]);
}
@@ -981,7 +982,7 @@ post_nd(POST_ARGS)
n = mdoc->last;
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return;
if (n->child == NULL)
@@ -998,7 +999,7 @@ post_d1(POST_ARGS)
n = mdoc->last;
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return;
if (n->child == NULL)
@@ -1015,7 +1016,7 @@ post_literal(POST_ARGS)
n = mdoc->last;
- if (n->type != MDOC_BODY)
+ if (n->type != ROFFT_BODY)
return;
if (n->child == NULL)
@@ -1086,7 +1087,7 @@ post_at(POST_ARGS)
*/
n = n->child;
- assert(MDOC_TEXT == n->type);
+ assert(n->type == ROFFT_TEXT);
if (NULL == (std_att = mdoc_a2att(n->string))) {
mandoc_vmsg(MANDOCERR_AT_BAD, mdoc->parse,
n->line, n->pos, "At %s", n->string);
@@ -1118,7 +1119,7 @@ static void
post_en(POST_ARGS)
{
- if (MDOC_BLOCK == mdoc->last->type)
+ if (mdoc->last->type == ROFFT_BLOCK)
mdoc->last->norm->Es = mdoc->last_es;
}
@@ -1137,7 +1138,7 @@ post_it(POST_ARGS)
struct mdoc_node *nbl, *nit, *nch;
nit = mdoc->last;
- if (nit->type != MDOC_BLOCK)
+ if (nit->type != ROFFT_BLOCK)
return;
nbl = nit->parent->parent;
@@ -1184,7 +1185,7 @@ post_it(POST_ARGS)
assert(nit->head->child == NULL);
for (i = 0, nch = nit->child; nch; nch = nch->next)
- if (nch->type == MDOC_BODY)
+ if (nch->type == ROFFT_BODY)
i++;
if (i < cols || i > cols + 1)
@@ -1298,13 +1299,13 @@ post_bl_block_tag(POST_ARGS)
if (MDOC_It != nn->tok)
continue;
- assert(MDOC_BLOCK == nn->type);
+ assert(nn->type == ROFFT_BLOCK);
nn = nn->head->child;
if (nn == NULL)
break;
- if (MDOC_TEXT == nn->type) {
+ if (nn->type == ROFFT_TEXT) {
sz = strlen(nn->string) + 1;
break;
}
@@ -1412,13 +1413,13 @@ post_bl(POST_ARGS)
nbody = mdoc->last;
switch (nbody->type) {
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
post_bl_block(mdoc);
return;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
post_bl_head(mdoc);
return;
- case MDOC_BODY:
+ case ROFFT_BODY:
break;
default:
return;
@@ -1493,7 +1494,7 @@ post_bk(POST_ARGS)
n = mdoc->last;
- if (n->type == MDOC_BLOCK && n->body->child == NULL) {
+ if (n->type == ROFFT_BLOCK && n->body->child == NULL) {
mandoc_msg(MANDOCERR_BLK_EMPTY,
mdoc->parse, n->line, n->pos, "Bk");
mdoc_node_delete(mdoc, n);
@@ -1512,7 +1513,7 @@ post_sm(struct mdoc *mdoc)
return;
}
- assert(nch->type == MDOC_TEXT);
+ assert(nch->type == ROFFT_TEXT);
if ( ! strcmp(nch->string, "on")) {
mdoc->flags &= ~MDOC_SMOFF;
@@ -1579,7 +1580,7 @@ post_st(POST_ARGS)
n = mdoc->last;
nch = n->child;
- assert(MDOC_TEXT == nch->type);
+ assert(nch->type == ROFFT_TEXT);
if (NULL == (p = mdoc_a2st(nch->string))) {
mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse,
@@ -1599,7 +1600,7 @@ post_rs(POST_ARGS)
np = mdoc->last;
- if (np->type != MDOC_BODY)
+ if (np->type != ROFFT_BODY)
return;
if (np->child == NULL) {
@@ -1692,7 +1693,7 @@ post_hyph(POST_ARGS)
char *cp;
for (nch = mdoc->last->child; nch != NULL; nch = nch->next) {
- if (nch->type != MDOC_TEXT)
+ if (nch->type != ROFFT_TEXT)
continue;
cp = nch->string;
if (*cp == '\0')
@@ -1721,10 +1722,10 @@ post_sh(POST_ARGS)
post_ignpar(mdoc);
switch (mdoc->last->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
post_sh_head(mdoc);
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
switch (mdoc->lastsec) {
case SEC_NAME:
post_sh_name(mdoc);
@@ -1830,7 +1831,7 @@ post_sh_see_also(POST_ARGS)
lastpunct = "none";
continue;
}
- if (n->type != MDOC_TEXT)
+ if (n->type != ROFFT_TEXT)
break;
for (name = n->string; *name != '\0'; name++)
if (isalpha((const unsigned char)*name))
@@ -1989,10 +1990,10 @@ post_ignpar(POST_ARGS)
struct mdoc_node *np;
switch (mdoc->last->type) {
- case MDOC_HEAD:
+ case ROFFT_HEAD:
post_hyph(mdoc);
return;
- case MDOC_BODY:
+ case ROFFT_BODY:
break;
default:
return;
@@ -2023,7 +2024,7 @@ pre_par(PRE_ARGS)
if (NULL == mdoc->last)
return;
- if (MDOC_ELEM != n->type && MDOC_BLOCK != n->type)
+ if (n->type != ROFFT_ELEM && n->type != ROFFT_BLOCK)
return;
/*
@@ -2088,7 +2089,7 @@ pre_literal(PRE_ARGS)
pre_display(mdoc, n);
- if (MDOC_BODY != n->type)
+ if (n->type != ROFFT_BODY)
return;
/*
diff --git a/read.c b/read.c
index 511ce45e..e611ff70 100644
--- a/read.c
+++ b/read.c
@@ -8,9 +8,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -37,11 +37,12 @@
#include <string.h>
#include <unistd.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
-#include "libmandoc.h"
+#include "mandoc.h"
+#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "libmandoc.h"
#define REPARSE_LIMIT 1000
diff --git a/roff.h b/roff.h
new file mode 100644
index 00000000..e9566c1a
--- /dev/null
+++ b/roff.h
@@ -0,0 +1,29 @@
+/* $OpenBSD$ */
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014, 2015 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
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * 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.
+ */
+
+enum roff_type {
+ ROFFT_ROOT,
+ ROFFT_BLOCK,
+ ROFFT_HEAD,
+ ROFFT_BODY,
+ ROFFT_TAIL,
+ ROFFT_ELEM,
+ ROFFT_TEXT,
+ ROFFT_TBL,
+ ROFFT_EQN
+};
diff --git a/st.c b/st.c
index d66d10af..965764ca 100644
--- a/st.c
+++ b/st.c
@@ -20,6 +20,7 @@
#include <string.h>
+#include "roff.h"
#include "mdoc.h"
#include "libmdoc.h"
diff --git a/tree.c b/tree.c
index af479d5a..cbea48ce 100644
--- a/tree.c
+++ b/tree.c
@@ -7,9 +7,9 @@
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -26,6 +26,7 @@
#include <time.h>
#include "mandoc.h"
+#include "roff.h"
#include "mdoc.h"
#include "man.h"
#include "main.h"
@@ -66,33 +67,33 @@ print_mdoc(const struct mdoc_node *n, int indent)
t = p = NULL;
switch (n->type) {
- case MDOC_ROOT:
+ case ROFFT_ROOT:
t = "root";
break;
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
t = "block";
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
t = "block-head";
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
if (n->end)
t = "body-end";
else
t = "block-body";
break;
- case MDOC_TAIL:
+ case ROFFT_TAIL:
t = "block-tail";
break;
- case MDOC_ELEM:
+ case ROFFT_ELEM:
t = "elem";
break;
- case MDOC_TEXT:
+ case ROFFT_TEXT:
t = "text";
break;
- case MDOC_TBL:
+ case ROFFT_TBL:
break;
- case MDOC_EQN:
+ case ROFFT_EQN:
t = "eqn";
break;
default:
@@ -101,38 +102,38 @@ print_mdoc(const struct mdoc_node *n, int indent)
}
switch (n->type) {
- case MDOC_TEXT:
+ case ROFFT_TEXT:
p = n->string;
break;
- case MDOC_BODY:
+ case ROFFT_BODY:
p = mdoc_macronames[n->tok];
break;
- case MDOC_HEAD:
+ case ROFFT_HEAD:
p = mdoc_macronames[n->tok];
break;
- case MDOC_TAIL:
+ case ROFFT_TAIL:
p = mdoc_macronames[n->tok];
break;
- case MDOC_ELEM:
+ case ROFFT_ELEM:
p = mdoc_macronames[n->tok];
if (n->args) {
argv = n->args->argv;
argc = n->args->argc;
}
break;
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
p = mdoc_macronames[n->tok];
if (n->args) {
argv = n->args->argv;
argc = n->args->argc;
}
break;
- case MDOC_TBL:
+ case ROFFT_TBL:
break;
- case MDOC_EQN:
+ case ROFFT_EQN:
p = "EQ";
break;
- case MDOC_ROOT:
+ case ROFFT_ROOT:
p = "root";
break;
default:
@@ -169,7 +170,7 @@ print_mdoc(const struct mdoc_node *n, int indent)
print_box(n->eqn->root->first, indent + 4);
if (n->child)
print_mdoc(n->child, indent +
- (n->type == MDOC_BLOCK ? 2 : 4));
+ (n->type == ROFFT_BLOCK ? 2 : 4));
if (n->next)
print_mdoc(n->next, indent);
}
@@ -186,27 +187,27 @@ print_man(const struct man_node *n, int indent)
t = p = NULL;
switch (n->type) {
- case MAN_ROOT:
+ case ROFFT_ROOT:
t = "root";
break;
- case MAN_ELEM:
+ case ROFFT_ELEM:
t = "elem";
break;
- case MAN_TEXT:
+ case ROFFT_TEXT:
t = "text";
break;
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
t = "block";
break;
- case MAN_HEAD:
+ case ROFFT_HEAD:
t = "block-head";
break;
- case MAN_BODY:
+ case ROFFT_BODY:
t = "block-body";
break;
- case MAN_TBL:
+ case ROFFT_TBL:
break;
- case MAN_EQN:
+ case ROFFT_EQN:
t = "eqn";
break;
default:
@@ -215,24 +216,24 @@ print_man(const struct man_node *n, int indent)
}
switch (n->type) {
- case MAN_TEXT:
+ case ROFFT_TEXT:
p = n->string;
break;
- case MAN_ELEM:
+ case ROFFT_ELEM:
/* FALLTHROUGH */
- case MAN_BLOCK:
+ case ROFFT_BLOCK:
/* FALLTHROUGH */
- case MAN_HEAD:
+ case ROFFT_HEAD:
/* FALLTHROUGH */
- case MAN_BODY:
+ case ROFFT_BODY:
p = man_macronames[n->tok];
break;
- case MAN_ROOT:
+ case ROFFT_ROOT:
p = "root";
break;
- case MAN_TBL:
+ case ROFFT_TBL:
break;
- case MAN_EQN:
+ case ROFFT_EQN:
p = "EQ";
break;
default:
@@ -256,7 +257,7 @@ print_man(const struct man_node *n, int indent)
print_box(n->eqn->root->first, indent + 4);
if (n->child)
print_man(n->child, indent +
- (n->type == MAN_BLOCK ? 2 : 4));
+ (n->type == ROFFT_BLOCK ? 2 : 4));
if (n->next)
print_man(n->next, indent);
}