=================================================================== RCS file: /cvs/mandoc/roff_validate.c,v retrieving revision 1.11 retrieving revision 1.15 diff -u -p -r1.11 -r1.15 --- mandoc/roff_validate.c 2018/12/04 02:53:51 1.11 +++ mandoc/roff_validate.c 2018/12/16 00:17:02 1.15 @@ -1,4 +1,4 @@ -/* $Id: roff_validate.c,v 1.11 2018/12/04 02:53:51 schwarze Exp $ */ +/* $Id: roff_validate.c,v 1.15 2018/12/16 00:17:02 schwarze Exp $ */ /* * Copyright (c) 2010, 2017, 2018 Ingo Schwarze * @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include "mandoc.h" @@ -64,9 +64,17 @@ roff_valid_br(ROFF_VALID_ARGS) struct roff_node *np; if (n->child != NULL) - mandoc_vmsg(MANDOCERR_ARG_SKIP, man->parse, + mandoc_msg(MANDOCERR_ARG_SKIP, n->line, n->pos, "br %s", n->child->string); + if (n->next != NULL && n->next->type == ROFFT_TEXT && + *n->next->string == ' ') { + mandoc_msg(MANDOCERR_PAR_SKIP, n->line, n->pos, + "br before text line with leading blank"); + roff_node_delete(man, n); + return; + } + if ((np = n->prev) == NULL) return; @@ -74,7 +82,7 @@ roff_valid_br(ROFF_VALID_ARGS) case ROFF_br: case ROFF_sp: case MDOC_Pp: - mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, + mandoc_msg(MANDOCERR_PAR_SKIP, n->line, n->pos, "br after %s", roff_name[np->tok]); roff_node_delete(man, n); break; @@ -96,32 +104,9 @@ roff_valid_ft(ROFF_VALID_ARGS) } cp = n->child->string; - switch (*cp) { - case '1': - case '2': - case '3': - case '4': - case 'I': - case 'P': - case 'R': - if (cp[1] == '\0') - return; - break; - case 'B': - if (cp[1] == '\0' || (cp[1] == 'I' && cp[2] == '\0')) - return; - break; - case 'C': - if (cp[1] != '\0' && cp[2] == '\0' && - strchr("BIRW", cp[1]) != NULL) - return; - break; - default: - break; - } - - mandoc_vmsg(MANDOCERR_FT_BAD, man->parse, - n->line, n->pos, "ft %s", cp); + if (mandoc_font(cp, (int)strlen(cp)) != ESCAPE_ERROR) + return; + mandoc_msg(MANDOCERR_FT_BAD, n->line, n->pos, "ft %s", cp); roff_node_delete(man, n); } @@ -131,7 +116,7 @@ roff_valid_sp(ROFF_VALID_ARGS) struct roff_node *np; if (n->child != NULL && n->child->next != NULL) - mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse, + mandoc_msg(MANDOCERR_ARG_EXCESS, n->child->next->line, n->child->next->pos, "sp ... %s", n->child->next->string); @@ -140,12 +125,12 @@ roff_valid_sp(ROFF_VALID_ARGS) switch (np->tok) { case ROFF_br: - mandoc_msg(MANDOCERR_PAR_SKIP, man->parse, + mandoc_msg(MANDOCERR_PAR_SKIP, np->line, np->pos, "br before sp"); roff_node_delete(man, np); break; case MDOC_Pp: - mandoc_msg(MANDOCERR_PAR_SKIP, man->parse, + mandoc_msg(MANDOCERR_PAR_SKIP, n->line, n->pos, "sp after Pp"); roff_node_delete(man, n); break;