=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.286 retrieving revision 1.293 diff -u -p -r1.286 -r1.293 --- mandoc/mdoc_validate.c 2015/04/18 16:06:41 1.286 +++ mandoc/mdoc_validate.c 2015/09/26 00:54:04 1.293 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.286 2015/04/18 16:06:41 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.293 2015/09/26 00:54:04 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -36,6 +36,7 @@ #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. */ @@ -106,7 +107,6 @@ 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_vt(POST_ARGS); static void pre_an(PRE_ARGS); static void pre_bd(PRE_ARGS); @@ -160,7 +160,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { pre_std, NULL }, /* Rv */ { NULL, post_st }, /* St */ { NULL, NULL }, /* Va */ - { NULL, post_vt }, /* Vt */ + { NULL, NULL }, /* Vt */ { NULL, NULL }, /* Xr */ { NULL, NULL }, /* %A */ { NULL, post_hyph }, /* %B */ /* FIXME: can be used outside Rs/Re. */ @@ -657,7 +657,6 @@ pre_bd(PRE_ARGS) break; default: abort(); - /* NOTREACHED */ } if (DISP__NONE == dt) continue; @@ -904,7 +903,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); @@ -932,28 +931,6 @@ post_fa(POST_ARGS) } static void -post_vt(POST_ARGS) -{ - const struct roff_node *n; - - /* - * The Vt macro comes in both ELEM and BLOCK form, both of which - * have different syntaxes (yet more context-sensitive - * behaviour). ELEM types must have a child, which is already - * guaranteed by the in_line parsing routine; BLOCK types, - * specifically the BODY, should only have TEXT children. - */ - - if (mdoc->last->type != ROFFT_BODY) - return; - - for (n = mdoc->last->child; n; n = n->next) - if (n->type != ROFFT_TEXT) - mandoc_msg(MANDOCERR_VT_CHILD, mdoc->parse, - n->line, n->pos, mdoc_macronames[n->tok]); -} - -static void post_nm(POST_ARGS) { struct roff_node *n; @@ -968,7 +945,7 @@ post_nm(POST_ARGS) if (NULL != mdoc->meta.name) return; - mdoc_deroff(&mdoc->meta.name, n); + deroff(&mdoc->meta.name, n); if (NULL == mdoc->meta.name) mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse, @@ -1050,17 +1027,16 @@ post_defaults(POST_ARGS) 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(); - /* NOTREACHED */ } mdoc->last = nn; } @@ -1075,7 +1051,7 @@ post_at(POST_ARGS) n = mdoc->last; if (n->child == NULL) { mdoc->next = ROFF_NEXT_CHILD; - mdoc_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX"); + roff_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX"); mdoc->last = n; return; } @@ -1246,7 +1222,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 +1244,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 +1333,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 +1374,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,7 +1473,7 @@ 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); } } @@ -1561,7 +1537,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 +1562,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 +1609,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 +1741,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 */ @@ -1881,7 +1858,7 @@ post_sh_head(POST_ARGS) secname = NULL; sec = SEC_CUSTOM; - mdoc_deroff(&secname, mdoc->last); + deroff(&secname, mdoc->last); sec = NULL == secname ? SEC_CUSTOM : a2sec(secname); /* The NAME should be first. */ @@ -2005,7 +1982,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 +1991,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 +2024,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 +2057,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 @@ -2109,7 +2086,6 @@ pre_literal(PRE_ARGS) break; default: abort(); - /* NOTREACHED */ } } @@ -2130,7 +2106,7 @@ post_dd(POST_ARGS) } datestr = NULL; - mdoc_deroff(&datestr, n); + deroff(&datestr, n); if (mdoc->quick) mdoc->meta.date = datestr; else { @@ -2139,7 +2115,7 @@ post_dd(POST_ARGS) free(datestr); } out: - mdoc_node_delete(mdoc, n); + roff_node_delete(mdoc, n); } static void @@ -2224,7 +2200,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 @@ -2265,7 +2241,7 @@ post_os(POST_ARGS) free(mdoc->meta.os); mdoc->meta.os = NULL; - mdoc_deroff(&mdoc->meta.os, n); + deroff(&mdoc->meta.os, n); if (mdoc->meta.os) goto out; @@ -2290,7 +2266,7 @@ post_os(POST_ARGS) #endif /*!OSNAME*/ out: - mdoc_node_delete(mdoc, n); + roff_node_delete(mdoc, n); } /* @@ -2314,7 +2290,7 @@ post_ex(POST_ARGS) } mdoc->next = ROFF_NEXT_CHILD; - mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name); + roff_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name); mdoc->last = n; }