diff options
-rw-r--r-- | man_html.c | 13 | ||||
-rw-r--r-- | man_macro.c | 4 | ||||
-rw-r--r-- | man_term.c | 15 | ||||
-rw-r--r-- | man_validate.c | 12 | ||||
-rw-r--r-- | mandocdb.c | 6 | ||||
-rw-r--r-- | mdoc_argv.c | 1 | ||||
-rw-r--r-- | mdoc_html.c | 17 | ||||
-rw-r--r-- | mdoc_macro.c | 11 | ||||
-rw-r--r-- | mdoc_man.c | 11 | ||||
-rw-r--r-- | mdoc_markdown.c | 18 | ||||
-rw-r--r-- | mdoc_state.c | 5 | ||||
-rw-r--r-- | mdoc_term.c | 20 | ||||
-rw-r--r-- | mdoc_validate.c | 23 | ||||
-rw-r--r-- | regress/eqn/define/infinite.out_lint | 8 | ||||
-rw-r--r-- | regress/eqn/define/invalid.out_lint | 10 | ||||
-rw-r--r-- | regress/eqn/over/noarg.out_lint | 2 | ||||
-rw-r--r-- | regress/mdoc/Pp/arg.out_lint | 2 | ||||
-rw-r--r-- | regress/roff/cond/close.out_lint | 2 | ||||
-rw-r--r-- | regress/roff/cond/if.out_lint | 4 | ||||
-rw-r--r-- | regress/roff/de/escname.out_lint | 4 | ||||
-rw-r--r-- | regress/roff/de/indir.out_lint | 4 | ||||
-rw-r--r-- | regress/roff/ig/basic.out_lint | 4 | ||||
-rw-r--r-- | regress/roff/it/badarg.out_lint | 4 | ||||
-rw-r--r-- | regress/roff/tr/args.out_lint | 2 | ||||
-rw-r--r-- | regress/tbl/data/block_unclosed.out_lint | 4 | ||||
-rw-r--r-- | regress/tbl/data/empty.out_lint | 2 | ||||
-rw-r--r-- | roff.c | 31 | ||||
-rw-r--r-- | roff.h | 7 |
28 files changed, 168 insertions, 78 deletions
@@ -92,7 +92,6 @@ static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { man_I_pre, NULL }, /* I */ { man_alt_pre, NULL }, /* IR */ { man_alt_pre, NULL }, /* RI */ - { man_br_pre, NULL }, /* br */ { man_br_pre, NULL }, /* sp */ { NULL, NULL }, /* nf */ { NULL, NULL }, /* fi */ @@ -305,6 +304,18 @@ print_man_node(MAN_ARGS) print_tblclose(h); t = h->tag; + if (n->tok < ROFF_MAX) { + switch(n->tok) { + case ROFF_br: + man_br_pre(man, n, h); + break; + default: + abort(); + } + break; + } + + assert(n->tok >= MAN_TH && n->tok < MAN_MAX); if (mans[n->tok].pre) child = (*mans[n->tok].pre)(man, n, h); diff --git a/man_macro.c b/man_macro.c index 3adacc72..21dd3d92 100644 --- a/man_macro.c +++ b/man_macro.c @@ -61,7 +61,6 @@ const struct man_macro __man_macros[MAN_MAX - MAN_TH] = { { in_line_eoln, MAN_SCOPED | MAN_JOIN }, /* I */ { in_line_eoln, 0 }, /* IR */ { in_line_eoln, 0 }, /* RI */ - { in_line_eoln, MAN_NSCOPED }, /* br */ { in_line_eoln, MAN_NSCOPED }, /* sp */ { in_line_eoln, MAN_NSCOPED }, /* nf */ { in_line_eoln, MAN_NSCOPED }, /* fi */ @@ -328,8 +327,7 @@ in_line_eoln(MACRO_PROT_ARGS) n = man->last; for (;;) { - if (buf[*pos] != '\0' && (tok == MAN_br || - tok == MAN_fi || tok == MAN_nf)) { + if (buf[*pos] != '\0' && (tok == MAN_fi || tok == MAN_nf)) { mandoc_vmsg(MANDOCERR_ARG_SKIP, man->parse, line, *pos, "%s %s", roff_name[tok], buf + *pos); @@ -116,7 +116,6 @@ static const struct termact __termacts[MAN_MAX - MAN_TH] = { { pre_I, NULL, 0 }, /* I */ { pre_alternate, NULL, 0 }, /* IR */ { pre_alternate, NULL, 0 }, /* RI */ - { pre_sp, NULL, MAN_NOTEXT }, /* br */ { pre_sp, NULL, MAN_NOTEXT }, /* sp */ { pre_literal, NULL, 0 }, /* nf */ { pre_literal, NULL, 0 }, /* fi */ @@ -458,7 +457,7 @@ pre_sp(DECL_ARGS) } } - if (n->tok == MAN_br) + if (n->tok == ROFF_br) len = 0; else if (n->child == NULL) len = 1; @@ -987,6 +986,18 @@ print_man_node(DECL_ARGS) break; } + if (n->tok < ROFF_MAX) { + switch (n->tok) { + case ROFF_br: + pre_sp(p, mt, n, meta); + break; + default: + abort(); + } + return; + } + + assert(n->tok >= MAN_TH && n->tok <= MAN_MAX); if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) term_fontrepl(p, TERMFONT_NONE); diff --git a/man_validate.c b/man_validate.c index 3cf82f92..c038b887 100644 --- a/man_validate.c +++ b/man_validate.c @@ -75,7 +75,6 @@ static const v_check __man_valids[MAN_MAX - MAN_TH] = { NULL, /* I */ NULL, /* IR */ NULL, /* RI */ - post_vs, /* br */ post_vs, /* sp */ NULL, /* nf */ NULL, /* fi */ @@ -126,6 +125,17 @@ man_node_validate(struct roff_man *man) case ROFFT_TBL: break; default: + if (n->tok < ROFF_MAX) { + switch (n->tok) { + case ROFF_br: + post_vs(man, n); + break; + default: + abort(); + } + break; + } + assert(n->tok >= MAN_TH && n->tok < MAN_MAX); cp = man_valids + n->tok; if (*cp) (*cp)(man, n); @@ -302,7 +302,6 @@ static const struct mdoc_handler __mdocs[MDOC_MAX - MDOC_Dd] = { { NULL, 0, 0 }, /* En */ { NULL, TYPE_Dx, NODE_NOSRC }, /* Dx */ { NULL, 0, 0 }, /* %Q */ - { NULL, 0, 0 }, /* br */ { NULL, 0, 0 }, /* sp */ { NULL, 0, 0 }, /* %U */ { NULL, 0, 0 }, /* Ta */ @@ -1547,8 +1546,11 @@ parse_mdoc(struct mpage *mpage, const struct roff_meta *meta, { for (n = n->child; n != NULL; n = n->next) { - if (n->tok == TOKEN_NONE || n->flags & mdocs[n->tok].taboo) + if (n->tok == TOKEN_NONE || + n->tok < ROFF_MAX || + n->flags & mdocs[n->tok].taboo) continue; + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); switch (n->type) { case ROFFT_ELEM: case ROFFT_BLOCK: diff --git a/mdoc_argv.c b/mdoc_argv.c index 7d9eb8cd..bf5d370f 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -263,7 +263,6 @@ static const struct mdocarg __mdocargs[MDOC_MAX - MDOC_Dd] = { { ARGSFL_DELIM, NULL }, /* En */ { ARGSFL_DELIM, NULL }, /* Dx */ { ARGSFL_NONE, NULL }, /* %Q */ - { ARGSFL_NONE, NULL }, /* br */ { ARGSFL_NONE, NULL }, /* sp */ { ARGSFL_NONE, NULL }, /* %U */ { ARGSFL_NONE, NULL }, /* Ta */ diff --git a/mdoc_html.c b/mdoc_html.c index 1a8f7d76..f4fc9699 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -237,7 +237,6 @@ static const struct htmlmdoc __mdocs[MDOC_MAX - MDOC_Dd] = { {mdoc_quote_pre, mdoc_quote_post}, /* En */ {mdoc_xx_pre, NULL}, /* Dx */ {mdoc__x_pre, mdoc__x_post}, /* %Q */ - {mdoc_sp_pre, NULL}, /* br */ {mdoc_sp_pre, NULL}, /* sp */ {mdoc__x_pre, mdoc__x_post}, /* %U */ {NULL, NULL}, /* Ta */ @@ -394,6 +393,16 @@ print_mdoc_node(MDOC_ARGS) t = h->tag; } assert(h->tblt == NULL); + if (n->tok < ROFF_MAX) { + switch(n->tok) { + case ROFF_br: + mdoc_sp_pre(meta, n, h); + break; + default: + abort(); + } + break; + } assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); if (mdocs[n->tok].pre != NULL && (n->end == ENDBODY_NOT || n->child != NULL)) @@ -415,7 +424,9 @@ print_mdoc_node(MDOC_ARGS) case ROFFT_EQN: break; default: - if (mdocs[n->tok].post == NULL || n->flags & NODE_ENDED) + if (n->tok < ROFF_MAX || + mdocs[n->tok].post == NULL || + n->flags & NODE_ENDED) break; (*mdocs[n->tok].post)(meta, n, h); if (n->end != ENDBODY_NOT) @@ -1005,7 +1016,7 @@ mdoc_bd_pre(MDOC_ARGS) */ switch (nn->tok) { case MDOC_Sm: - case MDOC_br: + case ROFF_br: case MDOC_sp: case MDOC_Bl: case MDOC_D1: diff --git a/mdoc_macro.c b/mdoc_macro.c index b7c29e7c..09184fe8 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -197,7 +197,6 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX - MDOC_Dd] = { { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* En */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Dx */ { in_line_eoln, MDOC_JOIN }, /* %Q */ - { in_line_eoln, 0 }, /* br */ { in_line_eoln, 0 }, /* sp */ { in_line_eoln, 0 }, /* %U */ { phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */ @@ -251,7 +250,7 @@ lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p) if (res != TOKEN_NONE) { if (mdoc_macros[res].flags & MDOC_CALLABLE) return res; - if (res != MDOC_br && res != MDOC_sp && res != MDOC_ll) + if (res != MDOC_sp && res != MDOC_ll) mandoc_msg(MANDOCERR_MACRO_CALL, mdoc->parse, line, ppos, p); } @@ -682,8 +681,8 @@ blk_exp_close(MACRO_PROT_ARGS) * Stray .Ec without previous .Eo: * Break the output line, keep the arguments. */ - roff_elem_alloc(mdoc, line, ppos, MDOC_br); - rew_elem(mdoc, MDOC_br); + roff_elem_alloc(mdoc, line, ppos, ROFF_br); + rew_elem(mdoc, ROFF_br); } } else if (endbody == NULL) { rew_last(mdoc, body); @@ -1023,8 +1022,8 @@ blk_full(MACRO_PROT_ARGS) if (tok == MDOC_It && (n == NULL || n->tok != MDOC_Bl)) { mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse, line, ppos, "It %s", buf + *pos); - roff_elem_alloc(mdoc, line, ppos, MDOC_br); - rew_elem(mdoc, MDOC_br); + roff_elem_alloc(mdoc, line, ppos, ROFF_br); + rew_elem(mdoc, ROFF_br); return; } } @@ -20,6 +20,7 @@ #include <assert.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include "mandoc_aux.h" @@ -238,7 +239,6 @@ static const struct manact __manacts[MDOC_MAX - MDOC_Dd] = { { cond_body, pre_en, post_en, NULL, NULL }, /* En */ { NULL, NULL, NULL, NULL, NULL }, /* Dx */ { NULL, NULL, post_percent, NULL, NULL }, /* %Q */ - { NULL, pre_br, NULL, NULL, NULL }, /* br */ { NULL, pre_sp, post_sp, NULL, NULL }, /* sp */ { NULL, NULL, post_percent, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ @@ -651,7 +651,16 @@ print_node(DECL_ARGS) outflags &= ~(MMAN_spc | MMAN_spc_force); else if (outflags & MMAN_Sm) outflags |= MMAN_spc; + } else if (n->tok < ROFF_MAX) { + switch (n->tok) { + case ROFF_br: + pre_br(meta, n); + break; + default: + abort(); + } } else { + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); /* * Conditionally run the pre-node action handler for a * node. diff --git a/mdoc_markdown.c b/mdoc_markdown.c index bee8f916..07eb6a31 100644 --- a/mdoc_markdown.c +++ b/mdoc_markdown.c @@ -19,6 +19,7 @@ #include <assert.h> #include <ctype.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include "mandoc_aux.h" @@ -222,7 +223,6 @@ static const struct md_act __md_acts[MDOC_MAX - MDOC_Dd] = { { md_cond_body, md_pre_En, md_post_En, NULL, NULL }, /* En */ { NULL, NULL, NULL, NULL, NULL }, /* Dx */ { NULL, NULL, md_post_pc, NULL, NULL }, /* %Q */ - { NULL, md_pre_br, NULL, NULL, NULL }, /* br */ { NULL, md_pre_Pp, NULL, NULL, NULL }, /* sp */ { NULL, md_pre_Lk, md_post_pc, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ @@ -310,8 +310,7 @@ md_node(struct roff_node *n) process_children = 1; n->flags &= ~NODE_ENDED; - switch (n->type) { - case ROFFT_TEXT: + if (n->type == ROFFT_TEXT) { if (n->flags & NODE_DELIMC) outflags &= ~(MD_spc | MD_spc_force); else if (outflags & MD_Sm) @@ -321,14 +320,21 @@ md_node(struct roff_node *n) outflags &= ~(MD_spc | MD_spc_force); else if (outflags & MD_Sm) outflags |= MD_spc; - break; - default: + } else if (n->tok < ROFF_MAX) { + switch (n->tok) { + case ROFF_br: + md_pre_br(n); + break; + default: + abort(); + } + } else { + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); act = md_acts + n->tok; cond = act->cond == NULL || (*act->cond)(n); if (cond && act->pre != NULL && (n->end == ENDBODY_NOT || n->child != NULL)) process_children = (*act->pre)(n); - break; } if (process_children && n->child != NULL) diff --git a/mdoc_state.c b/mdoc_state.c index fb21a36e..99230b22 100644 --- a/mdoc_state.c +++ b/mdoc_state.c @@ -16,6 +16,7 @@ */ #include <sys/types.h> +#include <assert.h> #include <stdlib.h> #include <string.h> @@ -154,7 +155,6 @@ static const state_handler __state_handlers[MDOC_MAX - MDOC_Dd] = { NULL, /* En */ NULL, /* Dx */ NULL, /* %Q */ - NULL, /* br */ NULL, /* sp */ NULL, /* %U */ NULL, /* Ta */ @@ -168,9 +168,10 @@ mdoc_state(struct roff_man *mdoc, struct roff_node *n) { state_handler handler; - if (n->tok == TOKEN_NONE) + if (n->tok == TOKEN_NONE || n->tok < ROFF_MAX) return; + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); if ( ! (mdoc_macros[n->tok].flags & MDOC_PROLOGUE)) mdoc->flags |= MDOC_PBODY; diff --git a/mdoc_term.c b/mdoc_term.c index efa6e09d..849fc894 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -244,7 +244,6 @@ static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = { { termp_quote_pre, termp_quote_post }, /* En */ { termp_xx_pre, termp_xx_post }, /* Dx */ { NULL, termp____post }, /* %Q */ - { termp_sp_pre, NULL }, /* br */ { termp_sp_pre, NULL }, /* sp */ { NULL, termp____post }, /* %U */ { NULL, NULL }, /* Ta */ @@ -365,6 +364,17 @@ print_mdoc_node(DECL_ARGS) term_tbl(p, n->span); break; default: + if (n->tok < ROFF_MAX) { + switch (n->tok) { + case ROFF_br: + termp_sp_pre(p, &npair, meta, n); + break; + default: + abort(); + } + break; + } + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); if (termacts[n->tok].pre != NULL && (n->end == ENDBODY_NOT || n->child != NULL)) chld = (*termacts[n->tok].pre) @@ -386,7 +396,9 @@ print_mdoc_node(DECL_ARGS) case ROFFT_EQN: break; default: - if (termacts[n->tok].post == NULL || n->flags & NODE_ENDED) + if (n->tok < ROFF_MAX || + termacts[n->tok].post == NULL || + n->flags & NODE_ENDED) break; (void)(*termacts[n->tok].post)(p, &npair, meta, n); @@ -1504,7 +1516,7 @@ termp_bd_pre(DECL_ARGS) */ switch (nn->tok) { case MDOC_Sm: - case MDOC_br: + case ROFF_br: case MDOC_sp: case MDOC_Bl: case MDOC_D1: @@ -1666,7 +1678,7 @@ termp_sp_pre(DECL_ARGS) } else len = 1; break; - case MDOC_br: + case ROFF_br: len = 0; break; default: diff --git a/mdoc_validate.c b/mdoc_validate.c index ed1c8017..485b1689 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -227,7 +227,6 @@ static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] = { post_en, /* En */ post_xx, /* Dx */ NULL, /* %Q */ - post_par, /* br */ post_par, /* sp */ NULL, /* %U */ NULL, /* Ta */ @@ -327,6 +326,18 @@ mdoc_node_validate(struct roff_man *mdoc) /* Call the macro's postprocessor. */ + if (n->tok < ROFF_MAX) { + switch(n->tok) { + case ROFF_br: + post_par(mdoc); + break; + default: + abort(); + } + break; + } + + assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); p = mdoc_valids + n->tok; if (*p) (*p)(mdoc); @@ -1310,7 +1321,7 @@ post_bl_block(POST_ARGS) switch (nc->tok) { case MDOC_Pp: case MDOC_Lp: - case MDOC_br: + case ROFF_br: break; default: nc = NULL; @@ -2064,7 +2075,7 @@ post_prevpar(POST_ARGS) if (n->prev->tok != MDOC_Pp && n->prev->tok != MDOC_Lp && - n->prev->tok != MDOC_br) + n->prev->tok != ROFF_br) return; if (n->tok == MDOC_Bl && n->norm->Bl.comp) return; @@ -2085,7 +2096,7 @@ post_par(POST_ARGS) struct roff_node *np; np = mdoc->last; - if (np->tok != MDOC_br && np->tok != MDOC_sp) + if (np->tok != ROFF_br && np->tok != MDOC_sp) post_prevpar(mdoc); if (np->tok == MDOC_sp) { @@ -2103,8 +2114,8 @@ post_par(POST_ARGS) if (np->tok != MDOC_Sh && np->tok != MDOC_Ss) return; } else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp && - (mdoc->last->tok != MDOC_br || - (np->tok != MDOC_sp && np->tok != MDOC_br))) + (mdoc->last->tok != ROFF_br || + (np->tok != MDOC_sp && np->tok != ROFF_br))) return; mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, diff --git a/regress/eqn/define/infinite.out_lint b/regress/eqn/define/infinite.out_lint index cb5a0048..8843358a 100644 --- a/regress/eqn/define/infinite.out_lint +++ b/regress/eqn/define/infinite.out_lint @@ -1,4 +1,4 @@ -mandoc: infinite.in:9:1: ERROR: input stack limit exceeded, infinite loop? -mandoc: infinite.in:15:1: ERROR: input stack limit exceeded, infinite loop? -mandoc: infinite.in:21:1: ERROR: input stack limit exceeded, infinite loop? -mandoc: infinite.in:27:1: ERROR: input stack limit exceeded, infinite loop? +mandoc: infinite.in:9:2: ERROR: input stack limit exceeded, infinite loop? +mandoc: infinite.in:15:2: ERROR: input stack limit exceeded, infinite loop? +mandoc: infinite.in:21:2: ERROR: input stack limit exceeded, infinite loop? +mandoc: infinite.in:27:2: ERROR: input stack limit exceeded, infinite loop? diff --git a/regress/eqn/define/invalid.out_lint b/regress/eqn/define/invalid.out_lint index 3f230400..b8b9858d 100644 --- a/regress/eqn/define/invalid.out_lint +++ b/regress/eqn/define/invalid.out_lint @@ -1,5 +1,5 @@ -mandoc: invalid.in:9:1: WARNING: skipping empty request: define -mandoc: invalid.in:15:1: WARNING: skipping empty request: define bruch -mandoc: invalid.in:21:1: WARNING: skipping empty request: undef -mandoc: invalid.in:27:1: WARNING: skipping empty request: tdefine -mandoc: invalid.in:33:1: WARNING: skipping empty request: tdefine +mandoc: invalid.in:9:2: WARNING: skipping empty request: define +mandoc: invalid.in:15:2: WARNING: skipping empty request: define bruch +mandoc: invalid.in:21:2: WARNING: skipping empty request: undef +mandoc: invalid.in:27:2: WARNING: skipping empty request: tdefine +mandoc: invalid.in:33:2: WARNING: skipping empty request: tdefine diff --git a/regress/eqn/over/noarg.out_lint b/regress/eqn/over/noarg.out_lint index aabfc30b..34cc2490 100644 --- a/regress/eqn/over/noarg.out_lint +++ b/regress/eqn/over/noarg.out_lint @@ -1 +1 @@ -mandoc: noarg.in:9:1: WARNING: missing eqn box, using "": over +mandoc: noarg.in:9:2: WARNING: missing eqn box, using "": over diff --git a/regress/mdoc/Pp/arg.out_lint b/regress/mdoc/Pp/arg.out_lint index 2e0a2f63..58b97965 100644 --- a/regress/mdoc/Pp/arg.out_lint +++ b/regress/mdoc/Pp/arg.out_lint @@ -1,3 +1,3 @@ +mandoc: arg.in:11:5: ERROR: skipping all arguments: br drop this mandoc: arg.in:9:2: ERROR: skipping all arguments: Pp drop -mandoc: arg.in:11:2: ERROR: skipping all arguments: br drop mandoc: arg.in:13:8: ERROR: skipping excess arguments: sp ... drop diff --git a/regress/roff/cond/close.out_lint b/regress/roff/cond/close.out_lint index e3419dba..c59a98d7 100644 --- a/regress/roff/cond/close.out_lint +++ b/regress/roff/cond/close.out_lint @@ -1 +1 @@ -mandoc: close.in:14:1: ERROR: appending missing end of block: if +mandoc: close.in:14:2: ERROR: appending missing end of block: if diff --git a/regress/roff/cond/if.out_lint b/regress/roff/cond/if.out_lint index bb8e2d3a..22f112d5 100644 --- a/regress/roff/cond/if.out_lint +++ b/regress/roff/cond/if.out_lint @@ -1,2 +1,2 @@ -mandoc: if.in:14:1: WARNING: conditional request controls empty scope: if -mandoc: if.in:16:1: WARNING: conditional request controls empty scope: if +mandoc: if.in:14:2: WARNING: conditional request controls empty scope: if +mandoc: if.in:16:2: WARNING: conditional request controls empty scope: if diff --git a/regress/roff/de/escname.out_lint b/regress/roff/de/escname.out_lint index b4dd49a0..f0fd2109 100644 --- a/regress/roff/de/escname.out_lint +++ b/regress/roff/de/escname.out_lint @@ -1,8 +1,8 @@ -mandoc: escname.in:21:1: ERROR: escaped character not allowed in a name: first\e +mandoc: escname.in:21:2: ERROR: escaped character not allowed in a name: first\e mandoc: escname.in:31:19: ERROR: escaped character not allowed in a name: first\e mandoc: escname.in:32:2: ERROR: skipping unknown macro: .first mandoc: escname.in:34:2: ERROR: skipping unknown macro: .first\\second mandoc: escname.in:37:5: ERROR: skipping excess arguments: .de ... excess arguments mandoc: escname.in:40:1: ERROR: escaped character not allowed in a name: witharg\( mandoc: escname.in:42:1: ERROR: escaped character not allowed in a name: de\e -mandoc: escname.in:42:1: WARNING: skipping empty request: de +mandoc: escname.in:42:2: WARNING: skipping empty request: de diff --git a/regress/roff/de/indir.out_lint b/regress/roff/de/indir.out_lint index 43194fea..96f42d1d 100644 --- a/regress/roff/de/indir.out_lint +++ b/regress/roff/de/indir.out_lint @@ -1,4 +1,4 @@ mandoc: indir.in:18:11: WARNING: undefined string, using "": myie mandoc: indir.in:25:6: WARNING: undefined string, using "": myim -mandoc: indir.in:25:1: WARNING: skipping empty request: dei -mandoc: indir.in:29:1: WARNING: skipping empty request: dei +mandoc: indir.in:25:2: WARNING: skipping empty request: dei +mandoc: indir.in:29:2: WARNING: skipping empty request: dei diff --git a/regress/roff/ig/basic.out_lint b/regress/roff/ig/basic.out_lint index 2b03b9cf..7c068e87 100644 --- a/regress/roff/ig/basic.out_lint +++ b/regress/roff/ig/basic.out_lint @@ -1,3 +1,3 @@ mandoc: basic.in:19:5: ERROR: skipping excess arguments: .ig ... excess -mandoc: basic.in:24:1: ERROR: skipping end of block that is not open: .. -mandoc: basic.in:26:1: ERROR: appending missing end of block: ig +mandoc: basic.in:24:2: ERROR: skipping end of block that is not open: .. +mandoc: basic.in:26:2: ERROR: appending missing end of block: ig diff --git a/regress/roff/it/badarg.out_lint b/regress/roff/it/badarg.out_lint index d2d4edb3..ac526c6b 100644 --- a/regress/roff/it/badarg.out_lint +++ b/regress/roff/it/badarg.out_lint @@ -1,2 +1,2 @@ -mandoc: badarg.in:12:1: ERROR: skipping request without numeric argument: it mytrap -mandoc: badarg.in:15:1: ERROR: skipping request without numeric argument: it +mandoc: badarg.in:12:2: ERROR: skipping request without numeric argument: it mytrap +mandoc: badarg.in:15:2: ERROR: skipping request without numeric argument: it diff --git a/regress/roff/tr/args.out_lint b/regress/roff/tr/args.out_lint index dec14b80..e2883ef7 100644 --- a/regress/roff/tr/args.out_lint +++ b/regress/roff/tr/args.out_lint @@ -1,3 +1,3 @@ -mandoc: args.in:6:1: WARNING: skipping empty request: tr +mandoc: args.in:6:2: WARNING: skipping empty request: tr mandoc: args.in:8:5: WARNING: odd number of characters in request: tr x mandoc: args.in:14:7: WARNING: odd number of characters in request: tr z diff --git a/regress/tbl/data/block_unclosed.out_lint b/regress/tbl/data/block_unclosed.out_lint index 452cde4d..d1406948 100644 --- a/regress/tbl/data/block_unclosed.out_lint +++ b/regress/tbl/data/block_unclosed.out_lint @@ -1,2 +1,2 @@ -mandoc: block_unclosed.in:6:1: ERROR: data block open at end of tbl: TE -mandoc: block_unclosed.in: ERROR: data block open at end of tbl: T& +mandoc: block_unclosed.in:6:2: ERROR: data block open at end of tbl: TE +mandoc: block_unclosed.in:29:2: ERROR: data block open at end of tbl: T& diff --git a/regress/tbl/data/empty.out_lint b/regress/tbl/data/empty.out_lint index 153902d0..0244cdd7 100644 --- a/regress/tbl/data/empty.out_lint +++ b/regress/tbl/data/empty.out_lint @@ -1 +1 @@ -mandoc: empty.in:6:1: ERROR: tbl without any data cells +mandoc: empty.in:6:2: ERROR: tbl without any data cells @@ -77,6 +77,7 @@ struct roffreq { struct roff { struct mparse *parse; /* parse point */ + struct roff_man *man; /* mdoc or man parser */ struct roffnode *last; /* leaf of stack */ int *rstack; /* stack of inverted `ie' values */ struct ohash *reqtab; /* request lookup table */ @@ -146,7 +147,7 @@ static void roffnode_push(struct roff *, enum roff_tok, static enum rofferr roff_block(ROFF_ARGS); static enum rofferr roff_block_text(ROFF_ARGS); static enum rofferr roff_block_sub(ROFF_ARGS); -static enum rofferr roff_brp(ROFF_ARGS); +static enum rofferr roff_br(ROFF_ARGS); static enum rofferr roff_cblock(ROFF_ARGS); static enum rofferr roff_cc(ROFF_ARGS); static void roff_ccond(struct roff *, int, int); @@ -209,6 +210,7 @@ static enum rofferr roff_userdef(ROFF_ARGS); #define ROFFNUM_WHITE (1 << 1) /* Skip whitespace in roff_evalnum(). */ const char *__roff_name[MAN_MAX + 1] = { + "br", NULL, "ab", "ad", "af", "aln", "als", "am", "am1", "ami", "ami1", "as", "as1", "asciify", @@ -298,14 +300,14 @@ const char *__roff_name[MAN_MAX + 1] = { "Fr", "Ud", "Lb", "Lp", "Lk", "Mt", "Brq", "Bro", "Brc", "%C", "Es", "En", - "Dx", "%Q", "br", "sp", + "Dx", "%Q", "sp", "%U", "Ta", "ll", NULL, "TH", "SH", "SS", "TP", "LP", "PP", "P", "IP", "HP", "SM", "SB", "BI", "IB", "BR", "RB", "R", "B", "I", "IR", "RI", - "br", "sp", "nf", "fi", + "sp", "nf", "fi", "RE", "RS", "DT", "UC", "PD", "AT", "in", "ft", "OP", "EX", "EE", "UR", @@ -314,6 +316,8 @@ const char *__roff_name[MAN_MAX + 1] = { const char *const *roff_name = __roff_name; static struct roffmac roffs[TOKEN_NONE] = { + { roff_br, NULL, NULL, 0 }, /* br */ + { NULL, NULL, NULL, 0 }, /* ROFF_MAX */ { roff_unsupp, NULL, NULL, 0 }, /* ab */ { roff_line_ignore, NULL, NULL, 0 }, /* ad */ { roff_line_ignore, NULL, NULL, 0 }, /* af */ @@ -337,7 +341,7 @@ static struct roffmac roffs[TOKEN_NONE] = { { roff_unsupp, NULL, NULL, 0 }, /* break */ { roff_line_ignore, NULL, NULL, 0 }, /* breakchar */ { roff_line_ignore, NULL, NULL, 0 }, /* brnl */ - { roff_brp, NULL, NULL, 0 }, /* brp */ + { roff_br, NULL, NULL, 0 }, /* brp */ { roff_line_ignore, NULL, NULL, 0 }, /* brpnl */ { roff_unsupp, NULL, NULL, 0 }, /* c2 */ { roff_cc, NULL, NULL, 0 }, /* cc */ @@ -610,6 +614,8 @@ roffhash_alloc(enum roff_tok mintok, enum roff_tok maxtok) mandoc_ohash_init(htab, 8, offsetof(struct roffreq, name)); for (tok = mintok; tok < maxtok; tok++) { + if (roff_name[tok] == NULL) + continue; sz = strlen(roff_name[tok]); req = mandoc_malloc(sizeof(*req) + sz + 1); req->tok = tok; @@ -824,6 +830,7 @@ roff_man_alloc(struct roff *roff, struct mparse *parse, man->defos = defos; man->quick = quick; roff_man_alloc1(man); + roff->man = man; return man; } @@ -1473,7 +1480,7 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs) /* Execute a roff request or a user defined macro. */ - return (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs); + return (*roffs[t].proc)(r, t, buf, ln, spos, pos, offs); } void @@ -2633,7 +2640,7 @@ roff_T_(ROFF_ARGS) mandoc_msg(MANDOCERR_BLK_NOTOPEN, r->parse, ln, ppos, "T&"); else - tbl_restart(ppos, ln, r->tbl); + tbl_restart(ln, ppos, r->tbl); return ROFF_IGN; } @@ -2760,11 +2767,15 @@ roff_TS(ROFF_ARGS) } static enum rofferr -roff_brp(ROFF_ARGS) +roff_br(ROFF_ARGS) { - - buf->buf[pos - 1] = '\0'; - return ROFF_CONT; + roff_elem_alloc(r->man, ln, ppos, ROFF_br); + if (buf->buf[pos] != '\0') + mandoc_vmsg(MANDOCERR_ARG_SKIP, r->parse, ln, pos, + "%s %s", roff_name[tok], buf->buf + pos); + r->man->last->flags |= NODE_LINE | NODE_VALID | NODE_ENDED; + r->man->next = ROFF_NEXT_SIBLING; + return ROFF_IGN; } static enum rofferr @@ -66,7 +66,9 @@ enum roff_type { }; enum roff_tok { - ROFF_ab = 0, + ROFF_br = 0, + ROFF_MAX, + ROFF_ab, ROFF_ad, ROFF_af, ROFF_aln, @@ -86,7 +88,6 @@ enum roff_tok { ROFF_boxa, ROFF_bp, ROFF_BP, - /* MAN_br, MDOC_br */ ROFF_break, ROFF_breakchar, ROFF_brnl, @@ -428,7 +429,6 @@ enum roff_tok { MDOC_En, MDOC_Dx, MDOC__Q, - MDOC_br, MDOC_sp, MDOC__U, MDOC_Ta, @@ -454,7 +454,6 @@ enum roff_tok { MAN_I, MAN_IR, MAN_RI, - MAN_br, MAN_sp, MAN_nf, MAN_fi, |