aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-07-04 16:12:08 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-07-04 16:12:08 +0000
commit50b8b4d12d3828eef15079704fdc9586de75c7ef (patch)
tree3e223cee342e42199f2de9b6bcbb50544b658366
parent977b1ebb8e08cb6933cea2f78ab50687dcd69da7 (diff)
downloadmandoc-50b8b4d12d3828eef15079704fdc9586de75c7ef.tar.gz
mandoc-50b8b4d12d3828eef15079704fdc9586de75c7ef.tar.zst
mandoc-50b8b4d12d3828eef15079704fdc9586de75c7ef.zip
Clean up messages regarding excess arguments:
* Downgrade ".Bf -emphasis Em" from FATAL to WARNING. * Mention the macros, the arguments, and the fallbacks. * Hierarchical naming.
-rw-r--r--eqn.c5
-rw-r--r--man_validate.c8
-rw-r--r--mandoc.h9
-rw-r--r--mdoc_macro.c13
-rw-r--r--mdoc_man.c12
-rw-r--r--mdoc_validate.c51
-rw-r--r--read.c9
-rw-r--r--roff.c8
8 files changed, 65 insertions, 50 deletions
diff --git a/eqn.c b/eqn.c
index 57cbfca1..40199db8 100644
--- a/eqn.c
+++ b/eqn.c
@@ -1,4 +1,4 @@
-/* $Id: eqn.c,v 1.42 2014/04/23 21:06:41 schwarze Exp $ */
+/* $Id: eqn.c,v 1.43 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 61f8ef81..f4dcda15 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.96 2014/07/02 11:43:20 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.97 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;
diff --git a/mandoc.h b/mandoc.h
index 83e6d06d..869c1e93 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.133 2014/07/04 01:50:06 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.134 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 a4a4da01..2ccb5d8a 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.135 2014/07/02 20:19:11 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.136 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -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));
diff --git a/mdoc_man.c b/mdoc_man.c
index b6362f46..0482fb7f 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.65 2014/07/02 19:55:10 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.66 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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 42302cb5..da4ad5de 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.225 2014/07/04 01:50:07 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.226 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;
diff --git a/read.c b/read.c
index e33ab915..008fe2b2 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.60 2014/07/04 01:50:07 schwarze Exp $ */
+/* $Id: read.c,v 1.61 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 \"..\"",
diff --git a/roff.c b/roff.c
index 999fda5b..b76e6d8a 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.216 2014/07/03 21:23:54 schwarze Exp $ */
+/* $Id: roff.c,v 1.217 2014/07/04 16:12:08 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}