summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-04-02 22:06:18 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-04-02 22:06:18 +0000
commitf68738e465e4d800ca41fee5600460ce8b80b01d (patch)
tree57b05ac5d994f7bafb61503553b0dad41b4e9c91 /usr.bin/mandoc/mdoc_validate.c
parent3b3e2458469c3b7a54a16224bfa57e6e0c0d6b73 (diff)
Second step towards parser unification:
Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 4408402dcb1..624ee0c6313 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_validate.c,v 1.200 2015/04/02 21:03:18 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.201 2015/04/02 22:06:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -38,7 +38,7 @@
/* FIXME: .Bl -diag can't have non-text children in HEAD. */
-#define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n
+#define PRE_ARGS struct mdoc *mdoc, struct roff_node *n
#define POST_ARGS struct mdoc *mdoc
enum check_ineq {
@@ -57,11 +57,11 @@ struct valids {
static void check_text(struct mdoc *, int, int, char *);
static void check_argv(struct mdoc *,
- struct mdoc_node *, struct mdoc_argv *);
-static void check_args(struct mdoc *, struct mdoc_node *);
-static int child_an(const struct mdoc_node *);
-static enum mdoc_sec a2sec(const char *);
-static size_t macro2len(enum mdoct);
+ struct roff_node *, struct mdoc_argv *);
+static void check_args(struct mdoc *, struct roff_node *);
+static int child_an(const struct roff_node *);
+static enum roff_sec a2sec(const char *);
+static size_t macro2len(int);
static void rewrite_macro2len(char **);
static void post_an(POST_ARGS);
@@ -246,7 +246,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
#define RSORD_MAX 14 /* Number of `Rs' blocks. */
-static const enum mdoct rsord[RSORD_MAX] = {
+static const int rsord[RSORD_MAX] = {
MDOC__A,
MDOC__T,
MDOC__B,
@@ -291,7 +291,7 @@ static const char * const secnames[SEC__MAX] = {
void
-mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
+mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n)
{
v_pre p;
@@ -319,7 +319,7 @@ mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
void
mdoc_valid_post(struct mdoc *mdoc)
{
- struct mdoc_node *n;
+ struct roff_node *n;
v_post p;
n = mdoc->last;
@@ -360,7 +360,7 @@ mdoc_valid_post(struct mdoc *mdoc)
}
static void
-check_args(struct mdoc *mdoc, struct mdoc_node *n)
+check_args(struct mdoc *mdoc, struct roff_node *n)
{
int i;
@@ -373,7 +373,7 @@ check_args(struct mdoc *mdoc, struct mdoc_node *n)
}
static void
-check_argv(struct mdoc *mdoc, struct mdoc_node *n, struct mdoc_argv *v)
+check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v)
{
int i;
@@ -397,7 +397,7 @@ check_text(struct mdoc *mdoc, int ln, int pos, char *p)
static void
pre_display(PRE_ARGS)
{
- struct mdoc_node *node;
+ struct roff_node *node;
if (n->type != ROFFT_BLOCK)
return;
@@ -767,7 +767,7 @@ pre_dd(PRE_ARGS)
static void
post_bf(POST_ARGS)
{
- struct mdoc_node *np, *nch;
+ struct roff_node *np, *nch;
enum mdocargt arg;
/*
@@ -829,7 +829,7 @@ post_bf(POST_ARGS)
static void
post_lb(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
char *libname;
n = mdoc->last->child;
@@ -842,7 +842,7 @@ post_lb(POST_ARGS)
static void
post_eoln(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
n = mdoc->last;
if (n->child)
@@ -855,7 +855,7 @@ post_eoln(POST_ARGS)
static void
post_fname(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
const char *cp;
size_t pos;
@@ -878,7 +878,7 @@ post_fn(POST_ARGS)
static void
post_fo(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
n = mdoc->last;
@@ -904,7 +904,7 @@ post_fo(POST_ARGS)
static void
post_fa(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
const char *cp;
for (n = mdoc->last->child; n != NULL; n = n->next) {
@@ -925,7 +925,7 @@ post_fa(POST_ARGS)
static void
post_vt(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
/*
* The Vt macro comes in both ELEM and BLOCK form, both of which
@@ -947,7 +947,7 @@ post_vt(POST_ARGS)
static void
post_nm(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -969,7 +969,7 @@ post_nm(POST_ARGS)
static void
post_nd(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -986,7 +986,7 @@ post_nd(POST_ARGS)
static void
post_d1(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -1003,7 +1003,7 @@ post_d1(POST_ARGS)
static void
post_literal(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -1025,7 +1025,7 @@ post_literal(POST_ARGS)
static void
post_defaults(POST_ARGS)
{
- struct mdoc_node *nn;
+ struct roff_node *nn;
/*
* The `Ar' defaults to "file ..." if no value is provided as an
@@ -1059,7 +1059,7 @@ post_defaults(POST_ARGS)
static void
post_at(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
const char *std_att;
char *att;
@@ -1093,7 +1093,7 @@ post_at(POST_ARGS)
static void
post_an(POST_ARGS)
{
- struct mdoc_node *np, *nch;
+ struct roff_node *np, *nch;
np = mdoc->last;
nch = np->child;
@@ -1124,9 +1124,9 @@ post_es(POST_ARGS)
static void
post_it(POST_ARGS)
{
+ struct roff_node *nbl, *nit, *nch;
int i, cols;
enum mdoc_list lt;
- struct mdoc_node *nbl, *nit, *nch;
nit = mdoc->last;
if (nit->type != ROFFT_BLOCK)
@@ -1192,7 +1192,7 @@ post_it(POST_ARGS)
static void
post_bl_block(POST_ARGS)
{
- struct mdoc_node *n, *ni, *nc;
+ struct roff_node *n, *ni, *nc;
/*
* These are fairly complicated, so we've broken them into two
@@ -1253,7 +1253,7 @@ void
rewrite_macro2len(char **arg)
{
size_t width;
- enum mdoct tok;
+ int tok;
if (*arg == NULL)
return;
@@ -1271,7 +1271,7 @@ rewrite_macro2len(char **arg)
static void
post_bl_block_tag(POST_ARGS)
{
- struct mdoc_node *n, *nn;
+ struct roff_node *n, *nn;
size_t sz, ssz;
int i;
char buf[24];
@@ -1336,7 +1336,7 @@ post_bl_block_tag(POST_ARGS)
static void
post_bl_head(POST_ARGS)
{
- struct mdoc_node *nbl, *nh, *nch, *nnext;
+ struct roff_node *nbl, *nh, *nch, *nnext;
struct mdoc_argv *argv;
int i, j;
@@ -1398,9 +1398,9 @@ post_bl_head(POST_ARGS)
static void
post_bl(POST_ARGS)
{
- struct mdoc_node *nparent, *nprev; /* of the Bl block */
- struct mdoc_node *nblock, *nbody; /* of the Bl */
- struct mdoc_node *nchild, *nnext; /* of the Bl body */
+ struct roff_node *nparent, *nprev; /* of the Bl block */
+ struct roff_node *nblock, *nbody; /* of the Bl */
+ struct roff_node *nchild, *nnext; /* of the Bl body */
nbody = mdoc->last;
switch (nbody->type) {
@@ -1481,7 +1481,7 @@ post_bl(POST_ARGS)
static void
post_bk(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -1495,7 +1495,7 @@ post_bk(POST_ARGS)
static void
post_sm(struct mdoc *mdoc)
{
- struct mdoc_node *nch;
+ struct roff_node *nch;
nch = mdoc->last->child;
@@ -1525,7 +1525,7 @@ post_sm(struct mdoc *mdoc)
static void
post_root(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
/* Add missing prologue data. */
@@ -1565,7 +1565,7 @@ post_root(POST_ARGS)
static void
post_st(POST_ARGS)
{
- struct mdoc_node *n, *nch;
+ struct roff_node *n, *nch;
const char *p;
n = mdoc->last;
@@ -1586,7 +1586,7 @@ post_st(POST_ARGS)
static void
post_rs(POST_ARGS)
{
- struct mdoc_node *np, *nch, *next, *prev;
+ struct roff_node *np, *nch, *next, *prev;
int i, j;
np = mdoc->last;
@@ -1680,7 +1680,7 @@ post_rs(POST_ARGS)
static void
post_hyph(POST_ARGS)
{
- struct mdoc_node *nch;
+ struct roff_node *nch;
char *cp;
for (nch = mdoc->last->child; nch != NULL; nch = nch->next) {
@@ -1739,7 +1739,7 @@ post_sh(POST_ARGS)
static void
post_sh_name(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
int hasnm, hasnd;
hasnm = hasnd = 0;
@@ -1777,7 +1777,7 @@ post_sh_name(POST_ARGS)
static void
post_sh_see_also(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
const char *name, *sec;
const char *lastname, *lastsec, *lastpunct;
int cmp;
@@ -1837,7 +1837,7 @@ post_sh_see_also(POST_ARGS)
}
static int
-child_an(const struct mdoc_node *n)
+child_an(const struct roff_node *n)
{
for (n = n->child; n != NULL; n = n->next)
@@ -1858,10 +1858,10 @@ post_sh_authors(POST_ARGS)
static void
post_sh_head(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
const char *goodsec;
char *secname;
- enum mdoc_sec sec;
+ enum roff_sec sec;
/*
* Process a new section. Sections are either "named" or
@@ -1978,7 +1978,7 @@ post_sh_head(POST_ARGS)
static void
post_ignpar(POST_ARGS)
{
- struct mdoc_node *np;
+ struct roff_node *np;
switch (mdoc->last->type) {
case ROFFT_HEAD:
@@ -2044,7 +2044,7 @@ pre_par(PRE_ARGS)
static void
post_par(POST_ARGS)
{
- struct mdoc_node *np;
+ struct roff_node *np;
np = mdoc->last;
@@ -2107,7 +2107,7 @@ pre_literal(PRE_ARGS)
static void
post_dd(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
char *datestr;
if (mdoc->meta.date)
@@ -2136,7 +2136,7 @@ out:
static void
post_dt(POST_ARGS)
{
- struct mdoc_node *nn, *n;
+ struct roff_node *nn, *n;
const char *cp;
char *p;
@@ -2221,7 +2221,7 @@ out:
static void
post_bx(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
/*
* Make `Bx's second argument always start with an uppercase
@@ -2241,7 +2241,7 @@ post_os(POST_ARGS)
struct utsname utsname;
static char *defbuf;
#endif
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -2291,7 +2291,7 @@ out:
static void
post_ex(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -2309,20 +2309,20 @@ post_ex(POST_ARGS)
mdoc->last = n;
}
-static enum mdoc_sec
+static enum roff_sec
a2sec(const char *p)
{
int i;
for (i = 0; i < (int)SEC__MAX; i++)
if (secnames[i] && 0 == strcmp(p, secnames[i]))
- return((enum mdoc_sec)i);
+ return((enum roff_sec)i);
return(SEC_CUSTOM);
}
static size_t
-macro2len(enum mdoct macro)
+macro2len(int macro)
{
switch (macro) {