summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/eqn.c5
-rw-r--r--usr.bin/mandoc/man_validate.c8
-rw-r--r--usr.bin/mandoc/mandoc.h9
-rw-r--r--usr.bin/mandoc/mdoc_macro.c13
-rw-r--r--usr.bin/mandoc/mdoc_man.c12
-rw-r--r--usr.bin/mandoc/mdoc_validate.c51
-rw-r--r--usr.bin/mandoc/read.c9
-rw-r--r--usr.bin/mandoc/roff.c8
8 files changed, 65 insertions, 50 deletions
diff --git a/usr.bin/mandoc/eqn.c b/usr.bin/mandoc/eqn.c
index bd38431d1b1..4226671384f 100644
--- a/usr.bin/mandoc/eqn.c
+++ b/usr.bin/mandoc/eqn.c
@@ -1,4 +1,4 @@
-/* $Id: eqn.c,v 1.9 2014/04/23 21:06:33 schwarze Exp $ */
+/* $Id: eqn.c,v 1.10 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -296,7 +296,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/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index d1c69a4dabb..e42f9acb79e 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.68 2014/07/02 11:42:56 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.69 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -359,7 +359,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/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 1cab21d4555..63e84a82d02 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.77 2014/07/04 01:50:03 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.78 2014/07/04 16:11:41 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/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 97ed9daab10..1bf68f70b3b 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.92 2014/07/02 20:18:42 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.93 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -765,11 +765,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/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index bd6d38b23ac..b8041d58836 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.64 2014/07/02 19:54:39 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.65 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -1304,17 +1304,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');
@@ -1323,7 +1326,6 @@ pre_it(DECL_ARGS)
default:
return(1);
}
- outflags |= MMAN_nl;
default:
break;
}
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index a0b92f12b66..a1ff663a527 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.143 2014/07/04 01:50:03 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.144 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -80,7 +80,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);
@@ -133,7 +132,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 };
@@ -511,12 +510,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)
{
@@ -994,7 +987,7 @@ pre_dd(PRE_ARGS)
static int
post_bf(POST_ARGS)
{
- struct mdoc_node *np;
+ struct mdoc_node *np, *nch;
enum mdocargt arg;
/*
@@ -1021,18 +1014,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. */
@@ -1058,7 +1052,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);
}
@@ -1091,9 +1087,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);
}
@@ -1307,7 +1308,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/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 88f025b4eca..920cf2f6065 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.38 2014/07/04 01:50:03 schwarze Exp $ */
+/* $Id: read.c,v 1.39 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -129,7 +129,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 */
@@ -186,7 +187,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",
@@ -194,7 +196,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/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index e7ac91ec990..4514d50b4e1 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.89 2014/07/03 21:23:08 schwarze Exp $ */
+/* $Id: roff.c,v 1.90 2014/07/04 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -852,7 +852,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);
@@ -956,7 +957,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);
}