diff options
-rw-r--r-- | eqn.c | 3 | ||||
-rw-r--r-- | man_validate.c | 6 | ||||
-rw-r--r-- | mandoc.h | 7 | ||||
-rw-r--r-- | mdoc_macro.c | 11 | ||||
-rw-r--r-- | mdoc_man.c | 10 | ||||
-rw-r--r-- | mdoc_validate.c | 49 | ||||
-rw-r--r-- | read.c | 7 | ||||
-rw-r--r-- | roff.c | 6 |
8 files changed, 57 insertions, 42 deletions
@@ -300,7 +300,8 @@ eqn_read(struct eqn_node **epp, int ln, p++; if ('\0' == *p) return(er); - mandoc_msg(MANDOCERR_ARGSLOST, ep->parse, ln, pos, NULL); + mandoc_vmsg(MANDOCERR_ARG_SKIP, ep->parse, + ln, pos, "EN %s", p); return(er); } diff --git a/man_validate.c b/man_validate.c index 72d8d023..fd9c4fc8 100644 --- a/man_validate.c +++ b/man_validate.c @@ -363,7 +363,11 @@ check_par(CHKARGS) break; case MAN_HEAD: if (n->nchild) - man_nmsg(man, n, MANDOCERR_ARGSLOST); + mandoc_vmsg(MANDOCERR_ARG_SKIP, + man->parse, n->line, n->pos, + "%s %s%s", man_macronames[n->tok], + n->child->string, + n->nchild > 1 ? " ..." : ""); break; default: break; @@ -93,7 +93,8 @@ enum mandocerr { MANDOCERR_BL_WIDTH, /* missing -width in -tag list, using 8n */ MANDOCERR_IT_NOHEAD, /* empty head in list item: type */ MANDOCERR_IT_NOBODY, /* empty list item: type */ - MANDOCERR_FONTTYPE, /* missing font type */ + MANDOCERR_BF_NOFONT, /* missing font type, using \fR */ + MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */ MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ /* related to bad macro arguments */ @@ -150,7 +151,8 @@ enum mandocerr { MANDOCERR_UNAME, /* uname(3) system call failed */ MANDOCERR_NUMERIC, /* request requires a numeric argument */ MANDOCERR_BL_NOTYPE, /* missing list type, using -item */ - MANDOCERR_ARGSLOST, /* line argument(s) will be lost */ + MANDOCERR_ARG_SKIP, /* skipping all arguments: macro args */ + MANDOCERR_ARG_EXCESS, /* skipping excess arguments: macro ... args */ MANDOCERR_FATAL, /* ===== start of fatal errors ===== */ @@ -158,7 +160,6 @@ enum mandocerr { MANDOCERR_NOTMANUAL, /* not a manual */ MANDOCERR_COLUMNS, /* column syntax is inconsistent */ MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */ - MANDOCERR_SYNTARGVCOUNT, /* argument count wrong, violates syntax */ MANDOCERR_SYNTCHILD, /* child violates parent syntax */ MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */ MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */ diff --git a/mdoc_macro.c b/mdoc_macro.c index 21ab591d..72476679 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -769,11 +769,12 @@ blk_exp_close(MACRO_PROT_ARGS) later = n; } - if ( ! (MDOC_CALLABLE & mdoc_macros[tok].flags)) { - /* FIXME: do this in validate */ - if (buf[*pos]) - mdoc_pmsg(mdoc, line, ppos, MANDOCERR_ARGSLOST); - + if ( ! (MDOC_PARSED & mdoc_macros[tok].flags)) { + if ('\0' != buf[*pos]) + mandoc_vmsg(MANDOCERR_ARG_SKIP, + mdoc->parse, line, ppos, + "%s %s", mdoc_macronames[tok], + buf + *pos); if ( ! rew_sub(MDOC_BODY, mdoc, tok, line, ppos)) return(0); return(rew_sub(MDOC_BLOCK, mdoc, tok, line, ppos)); @@ -1308,17 +1308,20 @@ pre_it(DECL_ARGS) else print_word("-"); font_pop(); - break; + outflags |= MMAN_nl; + return(0); case LIST_enum: print_width(bln->norm->Bl.width, NULL, 0); TPremain = 0; outflags |= MMAN_nl; print_count(&bln->norm->Bl.count); - break; + outflags |= MMAN_nl; + return(0); case LIST_hang: print_width(bln->norm->Bl.width, n->child, 6); TPremain = 0; - break; + outflags |= MMAN_nl; + return(1); case LIST_tag: print_width(bln->norm->Bl.width, n->child, 0); putchar('\n'); @@ -1327,7 +1330,6 @@ pre_it(DECL_ARGS) default: return(1); } - outflags |= MMAN_nl; default: break; } diff --git a/mdoc_validate.c b/mdoc_validate.c index b4055aec..07b59cc1 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -84,7 +84,6 @@ static int ewarn_le1(POST_ARGS); static int hwarn_eq0(POST_ARGS); static int hwarn_eq1(POST_ARGS); static int hwarn_ge1(POST_ARGS); -static int hwarn_le1(POST_ARGS); static int post_an(POST_ARGS); static int post_at(POST_ARGS); @@ -137,7 +136,7 @@ static int pre_std(PRE_ARGS); static v_post posts_an[] = { post_an, NULL }; static v_post posts_at[] = { post_at, post_defaults, NULL }; static v_post posts_bd[] = { post_literal, hwarn_eq0, bwarn_ge1, NULL }; -static v_post posts_bf[] = { hwarn_le1, post_bf, NULL }; +static v_post posts_bf[] = { post_bf, NULL }; static v_post posts_bk[] = { hwarn_eq0, bwarn_ge1, NULL }; static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL }; static v_post posts_bx[] = { post_bx, NULL }; @@ -515,12 +514,6 @@ hwarn_ge1(POST_ARGS) return(check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_GT, 0)); } -static int -hwarn_le1(POST_ARGS) -{ - return(check_count(mdoc, MDOC_HEAD, CHECK_WARN, CHECK_LT, 2)); -} - static void check_args(struct mdoc *mdoc, struct mdoc_node *n) { @@ -998,7 +991,7 @@ pre_dd(PRE_ARGS) static int post_bf(POST_ARGS) { - struct mdoc_node *np; + struct mdoc_node *np, *nch; enum mdocargt arg; /* @@ -1025,18 +1018,19 @@ post_bf(POST_ARGS) assert(MDOC_BLOCK == np->parent->type); assert(MDOC_Bf == np->parent->tok); - /* - * Cannot have both argument and parameter. - * If neither is specified, let it through with a warning. - */ + /* Check the number of arguments. */ - if (np->parent->args && np->child) { - mdoc_nmsg(mdoc, np, MANDOCERR_SYNTARGVCOUNT); - return(0); - } else if (NULL == np->parent->args && NULL == np->child) { - mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE); - return(1); + nch = np->child; + if (NULL == np->parent->args) { + if (NULL == nch) { + mdoc_nmsg(mdoc, np, MANDOCERR_BF_NOFONT); + return(1); + } + nch = nch->next; } + if (NULL != nch) + mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, + nch->line, nch->pos, "Bf ... %s", nch->string); /* Extract argument into data. */ @@ -1062,7 +1056,9 @@ post_bf(POST_ARGS) else if (0 == strcmp(np->child->string, "Sy")) np->norm->Bf.font = FONT_Sy; else - mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE); + mandoc_vmsg(MANDOCERR_BF_BADFONT, mdoc->parse, + np->child->line, np->child->pos, + "Bf %s", np->child->string); return(1); } @@ -1095,9 +1091,14 @@ post_lb(POST_ARGS) static int post_eoln(POST_ARGS) { + const struct mdoc_node *n; - if (mdoc->last->child) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST); + n = mdoc->last; + if (n->child) + mandoc_vmsg(MANDOCERR_ARG_SKIP, + mdoc->parse, n->line, n->pos, + "%s %s", mdoc_macronames[n->tok], + n->child->string); return(1); } @@ -1311,7 +1312,9 @@ post_it(POST_ARGS) /* FALLTHROUGH */ case LIST_item: if (NULL != nit->head->child) - mdoc_nmsg(mdoc, nit, MANDOCERR_ARGSLOST); + mandoc_vmsg(MANDOCERR_ARG_SKIP, + mdoc->parse, nit->line, nit->pos, + "It %s", nit->head->child->string); break; case LIST_column: cols = (int)nbl->norm->Bl.ncols; @@ -137,7 +137,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "missing -width in -tag list, using 8n", "empty head in list item", "empty list item", - "missing font type", + "missing font type, using \\fR", + "unknown font type, using \\fR", "missing -std argument, adding it", /* related to bad macro arguments */ @@ -194,7 +195,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "uname(3) system call failed", "request requires a numeric argument", "missing list type, using -item", - "line argument(s) will be lost", + "skipping all arguments", + "skipping excess arguments", "generic fatal error", @@ -202,7 +204,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "not a manual", "column syntax is inconsistent", "NOT IMPLEMENTED: .Bd -file", - "argument count wrong, violates syntax", "child violates parent syntax", "argument count wrong, violates syntax", "NOT IMPLEMENTED: .so with absolute path or \"..\"", @@ -856,7 +856,8 @@ roff_cblock(ROFF_ARGS) } if ((*bufp)[pos]) - mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL); + mandoc_vmsg(MANDOCERR_ARG_SKIP, r->parse, ln, pos, + ".. %s", *bufp + pos); roffnode_pop(r); roffnode_cleanscope(r); @@ -960,7 +961,8 @@ roff_block(ROFF_ARGS) r->last->end = mandoc_strndup(name, namesz); if ('\0' != *cp) - mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL); + mandoc_vmsg(MANDOCERR_ARG_EXCESS, r->parse, + ln, pos, ".%s ... %s", roffs[tok].name, cp); return(ROFF_IGN); } |