* mdocml: Clean up messages regarding excess arguments: * Downgrade ".Bf
@ 2014-07-04 16:12 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-07-04 16:12 UTC (permalink / raw)
To: source
Log Message:
-----------
Clean up messages regarding excess arguments:
* Downgrade ".Bf -emphasis Em" from FATAL to WARNING.
* Mention the macros, the arguments, and the fallbacks.
* Hierarchical naming.
Modified Files:
--------------
mdocml:
eqn.c
man_validate.c
mandoc.h
mdoc_macro.c
mdoc_man.c
mdoc_validate.c
read.c
roff.c
Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/eqn.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -Leqn.c -Leqn.c -u -p -r1.42 -r1.43
--- eqn.c
+++ eqn.c
@@ -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);
}
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.65 -r1.66
--- mdoc_man.c
+++ mdoc_man.c
@@ -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;
}
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.225
retrieving revision 1.226
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.225 -r1.226
--- mdoc_validate.c
+++ 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;
Index: mdoc_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_macro.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.135 -r1.136
--- mdoc_macro.c
+++ 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));
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.133
retrieving revision 1.134
diff -Lmandoc.h -Lmandoc.h -u -p -r1.133 -r1.134
--- mandoc.h
+++ mandoc.h
@@ -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 ".." */
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.216
retrieving revision 1.217
diff -Lroff.c -Lroff.c -u -p -r1.216 -r1.217
--- roff.c
+++ roff.c
@@ -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);
}
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -Lread.c -Lread.c -u -p -r1.60 -r1.61
--- read.c
+++ read.c
@@ -137,7 +137,8 @@ static const char * const mandocerrs[MAN
"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[MAN
"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[MAN
"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 \"..\"",
Index: man_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_validate.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -Lman_validate.c -Lman_validate.c -u -p -r1.96 -r1.97
--- man_validate.c
+++ 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;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-07-04 16:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-04 16:12 mdocml: Clean up messages regarding excess arguments: * Downgrade ".Bf schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).