From aa99c14ff671445ea1c08c9f21b1680c802cf32a Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 8 Aug 2014 15:45:58 +0000 Subject: [PATCH] Split MANDOCERR_IGNARGV into one message for .An and one for .Bl and report the macro name and argument. --- usr.bin/mandoc/mandoc.h | 5 +++-- usr.bin/mandoc/mdoc_validate.c | 32 ++++++++++++++++++++++---------- usr.bin/mandoc/read.c | 5 +++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index c98d5c2593e..0d6a7b4adf6 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.92 2014/08/08 15:42:39 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.93 2014/08/08 15:45:58 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -100,11 +100,12 @@ enum mandocerr { MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ /* related to bad arguments */ - MANDOCERR_IGNARGV, /* skipping argument */ MANDOCERR_ARG_QUOTE, /* unterminated quoted argument */ MANDOCERR_ARG_REP, /* duplicate argument: macro arg */ + MANDOCERR_AN_REP, /* skipping duplicate argument: An -arg */ MANDOCERR_BD_REP, /* skipping duplicate display type: type */ MANDOCERR_BL_REP, /* skipping duplicate list type: type */ + MANDOCERR_BL_SKIPW, /* skipping -width argument: Bl -type */ MANDOCERR_AT_BAD, /* unknown AT&T UNIX version: version */ MANDOCERR_RS_BAD, /* invalid content in Rs block: macro */ MANDOCERR_SM_BAD, /* invalid Boolean argument: macro arg */ diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 02fedf691ad..e394b70225d 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.155 2014/08/08 15:42:39 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.156 2014/08/08 15:45:58 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -564,8 +564,9 @@ static int pre_bl(PRE_ARGS) { struct mdoc_node *np; - struct mdoc_argv *argv; + struct mdoc_argv *argv, *wa; int i; + enum mdocargt mdoclt; enum mdoc_list lt; if (MDOC_BLOCK != n->type) { @@ -587,6 +588,8 @@ pre_bl(PRE_ARGS) * ones. If we find no list type, we default to LIST_item. */ + wa = n->args->argv; + mdoclt = MDOC_ARG_MAX; for (i = 0; n->args && i < (int)n->args->argc; i++) { argv = n->args->argv + i; lt = LIST__NONE; @@ -634,6 +637,7 @@ pre_bl(PRE_ARGS) n->norm->Bl.comp = 1; break; case MDOC_Width: + wa = argv; if (0 == argv->sz) { mandoc_msg(MANDOCERR_ARG_EMPTY, mdoc->parse, argv->line, @@ -667,6 +671,7 @@ pre_bl(PRE_ARGS) } if (LIST__NONE == lt) continue; + mdoclt = argv->arg; /* Check: multiple list types. */ @@ -722,7 +727,9 @@ pre_bl(PRE_ARGS) /* FALLTHROUGH */ case LIST_item: if (n->norm->Bl.width) - mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV); + mandoc_vmsg(MANDOCERR_BL_SKIPW, mdoc->parse, + wa->line, wa->pos, "Bl -%s", + mdoc_argnames[mdoclt]); break; case LIST_bullet: /* FALLTHROUGH */ @@ -834,18 +841,23 @@ pre_bd(PRE_ARGS) static int pre_an(PRE_ARGS) { - int i; + struct mdoc_argv *argv; + size_t i; - if (NULL == n->args) + if (n->args == NULL) return(1); - for (i = 1; i < (int)n->args->argc; i++) - mdoc_pmsg(mdoc, n->args->argv[i].line, - n->args->argv[i].pos, MANDOCERR_IGNARGV); + for (i = 1; i < n->args->argc; i++) { + argv = n->args->argv + i; + mandoc_vmsg(MANDOCERR_AN_REP, + mdoc->parse, argv->line, argv->pos, + "An -%s", mdoc_argnames[argv->arg]); + } - if (MDOC_Split == n->args->argv[0].arg) + argv = n->args->argv; + if (argv->arg == MDOC_Split) n->norm->An.auth = AUTH_split; - else if (MDOC_Nosplit == n->args->argv[0].arg) + else if (argv->arg == MDOC_Nosplit) n->norm->An.auth = AUTH_nosplit; else abort(); diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 5b57b500de5..7f202889025 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.53 2014/08/08 15:42:39 schwarze Exp $ */ +/* $Id: read.c,v 1.54 2014/08/08 15:45:58 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -136,11 +136,12 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "missing -std argument, adding it", /* related to bad macro arguments */ - "skipping argument", "unterminated quoted argument", "duplicate argument", + "skipping duplicate argument", "skipping duplicate display type", "skipping duplicate list type", + "skipping -width argument", "unknown AT&T UNIX version", "invalid content in Rs block", "invalid Boolean argument", -- 2.20.1