=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.285 retrieving revision 1.290 diff -u -p -r1.285 -r1.290 --- mandoc/mdoc_validate.c 2015/04/02 22:48:17 1.285 +++ mandoc/mdoc_validate.c 2015/04/20 09:48:53 1.290 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.285 2015/04/02 22:48:17 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.290 2015/04/20 09:48:53 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -36,12 +36,13 @@ #include "roff.h" #include "mdoc.h" #include "libmandoc.h" +#include "roff_int.h" #include "libmdoc.h" /* FIXME: .Bl -diag can't have non-text children in HEAD. */ -#define PRE_ARGS struct mdoc *mdoc, struct roff_node *n -#define POST_ARGS struct mdoc *mdoc +#define PRE_ARGS struct roff_man *mdoc, struct roff_node *n +#define POST_ARGS struct roff_man *mdoc enum check_ineq { CHECK_LT, @@ -57,10 +58,10 @@ struct valids { v_post post; }; -static void check_text(struct mdoc *, int, int, char *); -static void check_argv(struct mdoc *, +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 mdoc *, struct roff_node *); +static void check_args(struct roff_man *, struct roff_node *); static int child_an(const struct roff_node *); static enum roff_sec a2sec(const char *); static size_t macro2len(int); @@ -293,7 +294,7 @@ static const char * const secnames[SEC__MAX] = { void -mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n) +mdoc_valid_pre(struct roff_man *mdoc, struct roff_node *n) { v_pre p; @@ -319,7 +320,7 @@ mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n) } void -mdoc_valid_post(struct mdoc *mdoc) +mdoc_valid_post(struct roff_man *mdoc) { struct roff_node *n; v_post p; @@ -362,7 +363,7 @@ mdoc_valid_post(struct mdoc *mdoc) } static void -check_args(struct mdoc *mdoc, struct roff_node *n) +check_args(struct roff_man *mdoc, struct roff_node *n) { int i; @@ -375,7 +376,7 @@ check_args(struct mdoc *mdoc, struct roff_node *n) } static void -check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v) +check_argv(struct roff_man *mdoc, struct roff_node *n, struct mdoc_argv *v) { int i; @@ -384,7 +385,7 @@ check_argv(struct mdoc *mdoc, struct roff_node *n, str } static void -check_text(struct mdoc *mdoc, int ln, int pos, char *p) +check_text(struct roff_man *mdoc, int ln, int pos, char *p) { char *cp; @@ -904,7 +905,7 @@ post_fo(POST_ARGS) n->child->next->line, n->child->next->pos, "Fo ... %s", n->child->next->string); while (n->child != n->last) - mdoc_node_delete(mdoc, n->last); + roff_node_delete(mdoc, n->last); } post_fname(mdoc); @@ -1046,17 +1047,17 @@ post_defaults(POST_ARGS) return; nn = mdoc->last; - mdoc->next = MDOC_NEXT_CHILD; + mdoc->next = ROFF_NEXT_CHILD; switch (nn->tok) { case MDOC_Ar: - mdoc_word_alloc(mdoc, nn->line, nn->pos, "file"); - mdoc_word_alloc(mdoc, nn->line, nn->pos, "..."); + roff_word_alloc(mdoc, nn->line, nn->pos, "file"); + roff_word_alloc(mdoc, nn->line, nn->pos, "..."); break; case MDOC_Pa: /* FALLTHROUGH */ case MDOC_Mt: - mdoc_word_alloc(mdoc, nn->line, nn->pos, "~"); + roff_word_alloc(mdoc, nn->line, nn->pos, "~"); break; default: abort(); @@ -1074,8 +1075,8 @@ post_at(POST_ARGS) n = mdoc->last; if (n->child == NULL) { - mdoc->next = MDOC_NEXT_CHILD; - mdoc_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX"); + mdoc->next = ROFF_NEXT_CHILD; + roff_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX"); mdoc->last = n; return; } @@ -1246,7 +1247,7 @@ post_bl_block(POST_ARGS) mdoc->parse, nc->line, nc->pos, "%s before It", mdoc_macronames[nc->tok]); - mdoc_node_delete(mdoc, nc); + roff_node_delete(mdoc, nc); } else break; nc = ni->body->last; @@ -1268,7 +1269,7 @@ rewrite_macro2len(char **arg) return; else if ( ! strcmp(*arg, "Ds")) width = 6; - else if ((tok = mdoc_hash_find(*arg)) == MDOC_MAX) + else if ((tok = mdoc_hash_find(*arg)) == TOKEN_NONE) return; else width = macro2len(tok); @@ -1357,7 +1358,7 @@ post_bl_head(POST_ARGS) mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, nch->line, nch->pos, "Bl ... %s", nch->string); while (nch != NULL) { - mdoc_node_delete(mdoc, nch); + roff_node_delete(mdoc, nch); nch = nh->child; } return; @@ -1398,7 +1399,7 @@ post_bl_head(POST_ARGS) argv->value[i++] = nch->string; nch->string = NULL; nnext = nch->next; - mdoc_node_delete(NULL, nch); + roff_node_delete(NULL, nch); } nh->nchild = 0; nh->child = NULL; @@ -1497,12 +1498,12 @@ post_bk(POST_ARGS) 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); + roff_node_delete(mdoc, n); } } static void -post_sm(struct mdoc *mdoc) +post_sm(struct roff_man *mdoc) { struct roff_node *nch; @@ -1561,7 +1562,8 @@ post_root(POST_ARGS) /* Check that we begin with a proper `Sh'. */ n = mdoc->first->child; - while (n != NULL && mdoc_macros[n->tok].flags & MDOC_PROLOGUE) + while (n != NULL && n->tok != TOKEN_NONE && + mdoc_macros[n->tok].flags & MDOC_PROLOGUE) n = n->next; if (n == NULL) @@ -1585,7 +1587,7 @@ post_st(POST_ARGS) if (NULL == (p = mdoc_a2st(nch->string))) { mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse, nch->line, nch->pos, "St %s", nch->string); - mdoc_node_delete(mdoc, n); + roff_node_delete(mdoc, n); } else { free(nch->string); nch->string = mandoc_strdup(p); @@ -1632,7 +1634,7 @@ post_rs(POST_ARGS) /* * Remove this child from the chain. This somewhat - * repeats mdoc_node_unlink(), but since we're + * repeats roff_node_unlink(), but since we're * just re-ordering, there's no need for the * full unlink process. */ @@ -1764,7 +1766,7 @@ post_sh_name(POST_ARGS) mandoc_msg(MANDOCERR_NAMESEC_ND, mdoc->parse, n->line, n->pos, NULL); break; - case MDOC_MAX: + case TOKEN_NONE: if (hasnm) break; /* FALLTHROUGH */ @@ -2005,7 +2007,7 @@ post_ignpar(POST_ARGS) mdoc->parse, np->line, np->pos, "%s after %s", mdoc_macronames[np->tok], mdoc_macronames[mdoc->last->tok]); - mdoc_node_delete(mdoc, np); + roff_node_delete(mdoc, np); } if (NULL != (np = mdoc->last->last)) @@ -2014,7 +2016,7 @@ post_ignpar(POST_ARGS) np->line, np->pos, "%s at the end of %s", mdoc_macronames[np->tok], mdoc_macronames[mdoc->last->tok]); - mdoc_node_delete(mdoc, np); + roff_node_delete(mdoc, np); } } @@ -2047,7 +2049,7 @@ pre_par(PRE_ARGS) mdoc->last->line, mdoc->last->pos, "%s before %s", mdoc_macronames[mdoc->last->tok], mdoc_macronames[n->tok]); - mdoc_node_delete(mdoc, mdoc->last); + roff_node_delete(mdoc, mdoc->last); } static void @@ -2080,7 +2082,7 @@ post_par(POST_ARGS) mdoc->last->line, mdoc->last->pos, "%s after %s", mdoc_macronames[mdoc->last->tok], mdoc_macronames[np->tok]); - mdoc_node_delete(mdoc, mdoc->last); + roff_node_delete(mdoc, mdoc->last); } static void @@ -2139,7 +2141,7 @@ post_dd(POST_ARGS) free(datestr); } out: - mdoc_node_delete(mdoc, n); + roff_node_delete(mdoc, n); } static void @@ -2224,7 +2226,7 @@ post_dt(POST_ARGS) nn->line, nn->pos, "Dt ... %s", nn->string); out: - mdoc_node_delete(mdoc, n); + roff_node_delete(mdoc, n); } static void @@ -2290,7 +2292,7 @@ post_os(POST_ARGS) #endif /*!OSNAME*/ out: - mdoc_node_delete(mdoc, n); + roff_node_delete(mdoc, n); } /* @@ -2313,8 +2315,8 @@ post_ex(POST_ARGS) return; } - mdoc->next = MDOC_NEXT_CHILD; - mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name); + mdoc->next = ROFF_NEXT_CHILD; + roff_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name); mdoc->last = n; }