-static int check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);
-static int check_stdarg(PRE_ARGS);
-static int check_text(struct mdoc *, int, int, const char *);
-static int check_argv(struct mdoc *,
- const struct mdoc_node *,
- const struct mdoc_argv *);
-static int check_args(struct mdoc *,
- const struct mdoc_node *);
-static int err_child_lt(struct mdoc *, const char *, int);
-static int warn_child_lt(struct mdoc *, const char *, int);
-static int err_child_gt(struct mdoc *, const char *, int);
-static int warn_child_gt(struct mdoc *, const char *, int);
-static int err_child_eq(struct mdoc *, const char *, int);
-static int warn_child_eq(struct mdoc *, const char *, int);
-static int warn_count(struct mdoc *, const char *,
- int, const char *, int);
-static int err_count(struct mdoc *, const char *,
- int, const char *, int);
-
-static int berr_ge1(POST_ARGS);
-static int bwarn_ge1(POST_ARGS);
-static int ebool(POST_ARGS);
-static int eerr_eq0(POST_ARGS);
-static int eerr_eq1(POST_ARGS);
-static int eerr_ge1(POST_ARGS);
-static int eerr_le1(POST_ARGS);
-static int ewarn_ge1(POST_ARGS);
-static int herr_eq0(POST_ARGS);
-static int herr_ge1(POST_ARGS);
-static int hwarn_eq1(POST_ARGS);
-static int hwarn_eq0(POST_ARGS);
-static int hwarn_le1(POST_ARGS);
-
-static int post_an(POST_ARGS);
-static int post_at(POST_ARGS);
-static int post_bf(POST_ARGS);
-static int post_bl(POST_ARGS);
-static int post_bl_head(POST_ARGS);
-static int post_it(POST_ARGS);
-static int post_lb(POST_ARGS);
-static int post_nm(POST_ARGS);
-static int post_root(POST_ARGS);
-static int post_rs(POST_ARGS);
-static int post_sh(POST_ARGS);
-static int post_sh_body(POST_ARGS);
-static int post_sh_head(POST_ARGS);
-static int post_st(POST_ARGS);
-static int post_vt(POST_ARGS);
-static int pre_an(PRE_ARGS);
-static int pre_bd(PRE_ARGS);
-static int pre_bl(PRE_ARGS);
-static int pre_dd(PRE_ARGS);
-static int pre_display(PRE_ARGS);
-static int pre_dt(PRE_ARGS);
-static int pre_it(PRE_ARGS);
-static int pre_os(PRE_ARGS);
-static int pre_rv(PRE_ARGS);
-static int pre_sh(PRE_ARGS);
-static int pre_ss(PRE_ARGS);
-
-static v_post posts_an[] = { post_an, NULL };
-static v_post posts_at[] = { post_at, NULL };
-static v_post posts_bd[] = { hwarn_eq0, bwarn_ge1, NULL };
-static v_post posts_bf[] = { hwarn_le1, post_bf, NULL };
-static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
-static v_post posts_bool[] = { eerr_eq1, ebool, NULL };
-static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
-static v_post posts_it[] = { post_it, NULL };
-static v_post posts_lb[] = { eerr_eq1, post_lb, NULL };
-static v_post posts_nd[] = { berr_ge1, NULL };
-static v_post posts_nm[] = { post_nm, NULL };
-static v_post posts_notext[] = { eerr_eq0, NULL };
-static v_post posts_rs[] = { berr_ge1, herr_eq0, post_rs, NULL };
-static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL };
-static v_post posts_sp[] = { eerr_le1, NULL };
-static v_post posts_ss[] = { herr_ge1, NULL };
-static v_post posts_st[] = { eerr_eq1, post_st, NULL };
-static v_post posts_text[] = { eerr_ge1, NULL };
-static v_post posts_text1[] = { eerr_eq1, NULL };
-static v_post posts_vt[] = { post_vt, NULL };
-static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL };
-static v_post posts_wtext[] = { ewarn_ge1, NULL };
-static v_post posts_xr[] = { ewarn_ge1, NULL };
-static v_pre pres_an[] = { pre_an, NULL };
-static v_pre pres_bd[] = { pre_display, pre_bd, NULL };
-static v_pre pres_bl[] = { pre_bl, NULL };
-static v_pre pres_d1[] = { pre_display, NULL };
-static v_pre pres_dd[] = { pre_dd, NULL };
-static v_pre pres_dt[] = { pre_dt, NULL };
-static v_pre pres_er[] = { NULL, NULL };
-static v_pre pres_ex[] = { NULL, NULL };
-static v_pre pres_fd[] = { NULL, NULL };
-static v_pre pres_it[] = { pre_it, NULL };
-static v_pre pres_lb[] = { NULL, NULL };
-static v_pre pres_os[] = { pre_os, NULL };
-static v_pre pres_rv[] = { pre_rv, NULL };
-static v_pre pres_sh[] = { pre_sh, NULL };
-static v_pre pres_ss[] = { pre_ss, NULL };
-
-const struct valids mdoc_valids[MDOC_MAX] = {
- { NULL, NULL }, /* Ap */
- { pres_dd, posts_text }, /* Dd */
- { pres_dt, NULL }, /* Dt */
- { pres_os, NULL }, /* Os */
- { pres_sh, posts_sh }, /* Sh */
- { pres_ss, posts_ss }, /* Ss */
- { NULL, posts_notext }, /* Pp */
- { pres_d1, posts_wline }, /* D1 */
- { pres_d1, posts_wline }, /* Dl */
- { pres_bd, posts_bd }, /* Bd */
- { NULL, NULL }, /* Ed */
- { pres_bl, posts_bl }, /* Bl */
- { NULL, NULL }, /* El */
- { pres_it, posts_it }, /* It */
- { NULL, posts_text }, /* Ad */
- { pres_an, posts_an }, /* An */
- { NULL, NULL }, /* Ar */
- { NULL, posts_text }, /* Cd */
- { NULL, NULL }, /* Cm */
- { NULL, NULL }, /* Dv */
- { pres_er, posts_text }, /* Er */
- { NULL, NULL }, /* Ev */
- { pres_ex, NULL }, /* Ex */
- { NULL, NULL }, /* Fa */
- { pres_fd, posts_wtext }, /* Fd */
- { NULL, NULL }, /* Fl */
- { NULL, posts_text }, /* Fn */
- { NULL, posts_wtext }, /* Ft */
- { NULL, posts_text }, /* Ic */
- { NULL, posts_text1 }, /* In */
- { NULL, NULL }, /* Li */
- { NULL, posts_nd }, /* Nd */
- { NULL, posts_nm }, /* Nm */
- { NULL, posts_wline }, /* Op */
- { NULL, NULL }, /* Ot */
- { NULL, NULL }, /* Pa */
- { pres_rv, NULL }, /* Rv */
- { NULL, posts_st }, /* St */
- { NULL, NULL }, /* Va */
- { NULL, posts_vt }, /* Vt */
- { NULL, posts_xr }, /* Xr */
- { NULL, posts_text }, /* %A */
- { NULL, posts_text }, /* %B */ /* FIXME: can be used outside Rs/Re. */
- { NULL, posts_text }, /* %D */ /* FIXME: check date with mandoc_a2time(). */
- { NULL, posts_text }, /* %I */
- { NULL, posts_text }, /* %J */
- { NULL, posts_text }, /* %N */
- { NULL, posts_text }, /* %O */
- { NULL, posts_text }, /* %P */
- { NULL, posts_text }, /* %R */
- { NULL, posts_text }, /* %T */ /* FIXME: can be used outside Rs/Re. */
- { NULL, posts_text }, /* %V */
- { NULL, NULL }, /* Ac */
- { NULL, NULL }, /* Ao */
- { NULL, posts_wline }, /* Aq */
- { NULL, posts_at }, /* At */
- { NULL, NULL }, /* Bc */
- { NULL, posts_bf }, /* Bf */
- { NULL, NULL }, /* Bo */
- { NULL, posts_wline }, /* Bq */
- { NULL, NULL }, /* Bsx */
- { NULL, NULL }, /* Bx */
- { NULL, posts_bool }, /* Db */
- { NULL, NULL }, /* Dc */
- { NULL, NULL }, /* Do */
- { NULL, posts_wline }, /* Dq */
- { NULL, NULL }, /* Ec */
- { NULL, NULL }, /* Ef */
- { NULL, NULL }, /* Em */
- { NULL, NULL }, /* Eo */
- { NULL, NULL }, /* Fx */
- { NULL, posts_text }, /* Ms */
- { NULL, posts_notext }, /* No */
- { NULL, posts_notext }, /* Ns */
- { NULL, NULL }, /* Nx */
- { NULL, NULL }, /* Ox */
- { NULL, NULL }, /* Pc */
- { NULL, posts_text1 }, /* Pf */
- { NULL, NULL }, /* Po */
- { NULL, posts_wline }, /* Pq */
- { NULL, NULL }, /* Qc */
- { NULL, posts_wline }, /* Ql */
- { NULL, NULL }, /* Qo */
- { NULL, posts_wline }, /* Qq */
- { NULL, NULL }, /* Re */
- { NULL, posts_rs }, /* Rs */
- { NULL, NULL }, /* Sc */
- { NULL, NULL }, /* So */
- { NULL, posts_wline }, /* Sq */
- { NULL, posts_bool }, /* Sm */
- { NULL, posts_text }, /* Sx */
- { NULL, posts_text }, /* Sy */
- { NULL, posts_text }, /* Tn */
- { NULL, NULL }, /* Ux */
- { NULL, NULL }, /* Xc */
- { NULL, NULL }, /* Xo */
- { NULL, posts_fo }, /* Fo */
- { NULL, NULL }, /* Fc */
- { NULL, NULL }, /* Oo */
- { NULL, NULL }, /* Oc */
- { NULL, posts_wline }, /* Bk */
- { NULL, NULL }, /* Ek */
- { NULL, posts_notext }, /* Bt */
- { NULL, NULL }, /* Hf */
- { NULL, NULL }, /* Fr */
- { NULL, posts_notext }, /* Ud */
- { pres_lb, posts_lb }, /* Lb */
- { NULL, posts_notext }, /* Lp */
- { NULL, posts_text }, /* Lk */
- { NULL, posts_text }, /* Mt */
- { NULL, posts_wline }, /* Brq */
- { NULL, NULL }, /* Bro */
- { NULL, NULL }, /* Brc */
- { NULL, posts_text }, /* %C */
- { NULL, NULL }, /* Es */
- { NULL, NULL }, /* En */
- { NULL, NULL }, /* Dx */
- { NULL, posts_text }, /* %Q */
- { NULL, posts_notext }, /* br */
- { NULL, posts_sp }, /* sp */
- { NULL, posts_text1 }, /* %U */
+typedef void (*v_post)(POST_ARGS);
+
+static int build_list(struct roff_man *, int);
+static void check_text(struct roff_man *, int, int, char *);
+static void check_argv(struct roff_man *,
+ struct roff_node *, struct mdoc_argv *);
+static void check_args(struct roff_man *, struct roff_node *);
+static int child_an(const struct roff_node *);
+static size_t macro2len(int);
+static void rewrite_macro2len(char **);
+
+static void post_an(POST_ARGS);
+static void post_an_norm(POST_ARGS);
+static void post_at(POST_ARGS);
+static void post_bd(POST_ARGS);
+static void post_bf(POST_ARGS);
+static void post_bk(POST_ARGS);
+static void post_bl(POST_ARGS);
+static void post_bl_block(POST_ARGS);
+static void post_bl_head(POST_ARGS);
+static void post_bl_norm(POST_ARGS);
+static void post_bx(POST_ARGS);
+static void post_defaults(POST_ARGS);
+static void post_display(POST_ARGS);
+static void post_dd(POST_ARGS);
+static void post_dt(POST_ARGS);
+static void post_en(POST_ARGS);
+static void post_es(POST_ARGS);
+static void post_eoln(POST_ARGS);
+static void post_ex(POST_ARGS);
+static void post_fa(POST_ARGS);
+static void post_fn(POST_ARGS);
+static void post_fname(POST_ARGS);
+static void post_fo(POST_ARGS);
+static void post_hyph(POST_ARGS);
+static void post_ignpar(POST_ARGS);
+static void post_it(POST_ARGS);
+static void post_lb(POST_ARGS);
+static void post_nd(POST_ARGS);
+static void post_nm(POST_ARGS);
+static void post_ns(POST_ARGS);
+static void post_obsolete(POST_ARGS);
+static void post_os(POST_ARGS);
+static void post_par(POST_ARGS);
+static void post_prevpar(POST_ARGS);
+static void post_root(POST_ARGS);
+static void post_rs(POST_ARGS);
+static void post_rv(POST_ARGS);
+static void post_sh(POST_ARGS);
+static void post_sh_head(POST_ARGS);
+static void post_sh_name(POST_ARGS);
+static void post_sh_see_also(POST_ARGS);
+static void post_sh_authors(POST_ARGS);
+static void post_sm(POST_ARGS);
+static void post_st(POST_ARGS);
+static void post_std(POST_ARGS);
+static void post_xr(POST_ARGS);
+static void post_xx(POST_ARGS);
+
+static v_post mdoc_valids[MDOC_MAX] = {
+ NULL, /* Ap */
+ post_dd, /* Dd */
+ post_dt, /* Dt */
+ post_os, /* Os */
+ post_sh, /* Sh */
+ post_ignpar, /* Ss */
+ post_par, /* Pp */
+ post_display, /* D1 */
+ post_display, /* Dl */
+ post_display, /* Bd */
+ NULL, /* Ed */
+ post_bl, /* Bl */
+ NULL, /* El */
+ post_it, /* It */
+ NULL, /* Ad */
+ post_an, /* An */
+ post_defaults, /* Ar */
+ NULL, /* Cd */
+ NULL, /* Cm */
+ NULL, /* Dv */
+ NULL, /* Er */
+ NULL, /* Ev */
+ post_ex, /* Ex */
+ post_fa, /* Fa */
+ NULL, /* Fd */
+ NULL, /* Fl */
+ post_fn, /* Fn */
+ NULL, /* Ft */
+ NULL, /* Ic */
+ NULL, /* In */
+ post_defaults, /* Li */
+ post_nd, /* Nd */
+ post_nm, /* Nm */
+ NULL, /* Op */
+ post_obsolete, /* Ot */
+ post_defaults, /* Pa */
+ post_rv, /* Rv */
+ post_st, /* St */
+ NULL, /* Va */
+ NULL, /* Vt */
+ post_xr, /* Xr */
+ NULL, /* %A */
+ post_hyph, /* %B */ /* FIXME: can be used outside Rs/Re. */
+ NULL, /* %D */
+ NULL, /* %I */
+ NULL, /* %J */
+ post_hyph, /* %N */
+ post_hyph, /* %O */
+ NULL, /* %P */
+ post_hyph, /* %R */
+ post_hyph, /* %T */ /* FIXME: can be used outside Rs/Re. */
+ NULL, /* %V */
+ NULL, /* Ac */
+ NULL, /* Ao */
+ NULL, /* Aq */
+ post_at, /* At */
+ NULL, /* Bc */
+ post_bf, /* Bf */
+ NULL, /* Bo */
+ NULL, /* Bq */
+ post_xx, /* Bsx */
+ post_bx, /* Bx */
+ post_obsolete, /* Db */
+ NULL, /* Dc */
+ NULL, /* Do */
+ NULL, /* Dq */
+ NULL, /* Ec */
+ NULL, /* Ef */
+ NULL, /* Em */
+ NULL, /* Eo */
+ post_xx, /* Fx */
+ NULL, /* Ms */
+ NULL, /* No */
+ post_ns, /* Ns */
+ post_xx, /* Nx */
+ post_xx, /* Ox */
+ NULL, /* Pc */
+ NULL, /* Pf */
+ NULL, /* Po */
+ NULL, /* Pq */
+ NULL, /* Qc */
+ NULL, /* Ql */
+ NULL, /* Qo */
+ NULL, /* Qq */
+ NULL, /* Re */
+ post_rs, /* Rs */
+ NULL, /* Sc */
+ NULL, /* So */
+ NULL, /* Sq */
+ post_sm, /* Sm */
+ post_hyph, /* Sx */
+ NULL, /* Sy */
+ NULL, /* Tn */
+ post_xx, /* Ux */
+ NULL, /* Xc */
+ NULL, /* Xo */
+ post_fo, /* Fo */
+ NULL, /* Fc */
+ NULL, /* Oo */
+ NULL, /* Oc */
+ post_bk, /* Bk */
+ NULL, /* Ek */
+ post_eoln, /* Bt */
+ NULL, /* Hf */
+ post_obsolete, /* Fr */
+ post_eoln, /* Ud */
+ post_lb, /* Lb */
+ post_par, /* Lp */
+ NULL, /* Lk */
+ post_defaults, /* Mt */
+ NULL, /* Brq */
+ NULL, /* Bro */
+ NULL, /* Brc */
+ NULL, /* %C */
+ post_es, /* Es */
+ post_en, /* En */
+ post_xx, /* Dx */
+ NULL, /* %Q */
+ post_par, /* br */
+ post_par, /* sp */
+ NULL, /* %U */
+ NULL, /* Ta */
+ NULL, /* ll */