From 5204d1c426410b5a281d0a6a71a408443dcf3104 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 5 Jul 2014 12:33:55 +0000 Subject: Cleanup with respect to bad macro arguments. * Fix .Sm with invalid arg: move arg out and toggle mode. * Promote "unknown standard" from WARNING to ERROR, it loses information. * Delete MANDOCERR_BADWIDTH, it would only indicate a mandoc(1) bug. * Do not report MANDOCERR_BL_LATETYPE when there is no type at all. * Mention macro names, arguments and fallbacks. --- regress/usr.bin/mandoc/mdoc/At/Makefile | 5 +- regress/usr.bin/mandoc/mdoc/At/invalid.out_lint | 1 + regress/usr.bin/mandoc/mdoc/Bd/Makefile | 6 +- regress/usr.bin/mandoc/mdoc/Bd/badargs.in | 18 +++- regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii | 11 ++- regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint | 5 +- regress/usr.bin/mandoc/mdoc/Bd/notype.in | 13 --- regress/usr.bin/mandoc/mdoc/Bd/notype.out_ascii | 12 --- regress/usr.bin/mandoc/mdoc/Bd/notype.out_lint | 2 - regress/usr.bin/mandoc/mdoc/Bl/badargs.in | 11 ++- regress/usr.bin/mandoc/mdoc/Bl/badargs.out_ascii | 5 +- regress/usr.bin/mandoc/mdoc/Bl/badargs.out_lint | 10 +- regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint | 1 - regress/usr.bin/mandoc/mdoc/Sm/Makefile | 5 +- regress/usr.bin/mandoc/mdoc/Sm/badarg.in | 14 +++ regress/usr.bin/mandoc/mdoc/Sm/badarg.out_ascii | 9 ++ regress/usr.bin/mandoc/mdoc/Sm/badarg.out_lint | 2 + regress/usr.bin/mandoc/mdoc/St/badargs.out_lint | 2 +- regress/usr.bin/mandoc/roff/Makefile | 4 +- regress/usr.bin/mandoc/roff/ft/Makefile | 6 ++ regress/usr.bin/mandoc/roff/ft/badargs.in | 15 +++ regress/usr.bin/mandoc/roff/ft/badargs.out_ascii | 13 +++ regress/usr.bin/mandoc/roff/ft/badargs.out_lint | 1 + usr.bin/mandoc/man_validate.c | 6 +- usr.bin/mandoc/mandoc.h | 19 ++-- usr.bin/mandoc/mdoc_validate.c | 119 ++++++++++++----------- usr.bin/mandoc/read.c | 13 ++- 27 files changed, 202 insertions(+), 126 deletions(-) create mode 100644 regress/usr.bin/mandoc/mdoc/At/invalid.out_lint delete mode 100644 regress/usr.bin/mandoc/mdoc/Bd/notype.in delete mode 100644 regress/usr.bin/mandoc/mdoc/Bd/notype.out_ascii delete mode 100644 regress/usr.bin/mandoc/mdoc/Bd/notype.out_lint create mode 100644 regress/usr.bin/mandoc/mdoc/Sm/badarg.in create mode 100644 regress/usr.bin/mandoc/mdoc/Sm/badarg.out_ascii create mode 100644 regress/usr.bin/mandoc/mdoc/Sm/badarg.out_lint create mode 100644 regress/usr.bin/mandoc/roff/ft/Makefile create mode 100644 regress/usr.bin/mandoc/roff/ft/badargs.in create mode 100644 regress/usr.bin/mandoc/roff/ft/badargs.out_ascii create mode 100644 regress/usr.bin/mandoc/roff/ft/badargs.out_lint diff --git a/regress/usr.bin/mandoc/mdoc/At/Makefile b/regress/usr.bin/mandoc/mdoc/At/Makefile index 30342545728..6c3629959d3 100644 --- a/regress/usr.bin/mandoc/mdoc/At/Makefile +++ b/regress/usr.bin/mandoc/mdoc/At/Makefile @@ -1,5 +1,6 @@ -# $OpenBSD: Makefile,v 1.1 2010/12/04 14:49:40 schwarze Exp $ +# $OpenBSD: Makefile,v 1.2 2014/07/05 12:33:54 schwarze Exp $ -REGRESS_TARGETS=invalid +REGRESS_TARGETS = invalid +LINT_TARGETS = invalid .include diff --git a/regress/usr.bin/mandoc/mdoc/At/invalid.out_lint b/regress/usr.bin/mandoc/mdoc/At/invalid.out_lint new file mode 100644 index 00000000000..d9ae9e94ca6 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/At/invalid.out_lint @@ -0,0 +1 @@ +mandoc: invalid.in:15:5: WARNING: unknown AT&T UNIX version: murks diff --git a/regress/usr.bin/mandoc/mdoc/Bd/Makefile b/regress/usr.bin/mandoc/mdoc/Bd/Makefile index f13a8ad186c..8eb348c0962 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Bd/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.12 2014/07/05 01:11:33 schwarze Exp $ +# $OpenBSD: Makefile,v 1.13 2014/07/05 12:33:54 schwarze Exp $ REGRESS_TARGETS = blank nested spacing -REGRESS_TARGETS += notype badargs empty offset-empty +REGRESS_TARGETS += badargs empty offset-empty REGRESS_TARGETS += break broken -LINT_TARGETS = nested notype badargs break broken +LINT_TARGETS = nested badargs break broken # groff defect: # - a display breaking another block continues indefinitely diff --git a/regress/usr.bin/mandoc/mdoc/Bd/badargs.in b/regress/usr.bin/mandoc/mdoc/Bd/badargs.in index 5177d9c6e13..95d5b3cef5e 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/badargs.in +++ b/regress/usr.bin/mandoc/mdoc/Bd/badargs.in @@ -1,4 +1,4 @@ -.Dd July 4, 2014 +.Dd July 5, 2014 .Dt BD-BADARGS 1 .Os OpenBSD .Sh NAME @@ -10,8 +10,22 @@ trailing -offset: is ignored .Ed tail argument -double -compact and -offset +double -compact and -offset: .Bd -ragged -compact -offset 42n -compact -offset 6n last wins .Ed +no type: +.Bd -offset 0n +displayed +text +.Ed +double type: +.Bd -ragged -compact -unfilled +ragged +unfilled +.Ed +.Bd -unfilled -compact -ragged +unfilled +ragged +.Ed diff --git a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii index c0ecc18ca48..56e551737e0 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_ascii @@ -7,7 +7,14 @@ DDEESSCCRRIIPPTTIIOONN trailing -offset: is ignored - double -compact and -offset + double -compact and -offset: last wins + no type: -OpenBSD July 4, 2014 OpenBSD + displayed text + double type: + ragged unfilled + unfilled + ragged + +OpenBSD July 5, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint index 83076847fba..d295d9f3457 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bd/badargs.out_lint @@ -1,4 +1,7 @@ -mandoc: badargs.in:9:20: WARNING: skipping empty argument: Bd -offset +mandoc: badargs.in:9:20: WARNING: empty argument, using 0n: Bd -offset mandoc: badargs.in:12:2: ERROR: skipping all arguments: Ed tail argument mandoc: badargs.in:14:43: WARNING: duplicate argument: Bd -compact mandoc: badargs.in:14:51: WARNING: duplicate argument: Bd -offset 6n +mandoc: badargs.in:19:2: WARNING: missing display type, using -ragged +mandoc: badargs.in:24:2: WARNING: skipping duplicate display type: unfilled +mandoc: badargs.in:28:2: WARNING: skipping duplicate display type: ragged diff --git a/regress/usr.bin/mandoc/mdoc/Bd/notype.in b/regress/usr.bin/mandoc/mdoc/Bd/notype.in deleted file mode 100644 index f59cb6be4d1..00000000000 --- a/regress/usr.bin/mandoc/mdoc/Bd/notype.in +++ /dev/null @@ -1,13 +0,0 @@ -.Dd July 4, 2014 -.Dt BD-NOTYPE 1 -.Os OpenBSD -.Sh NAME -.Nm Bd-notype -.Nd no type specified for a display -.Sh DESCRIPTION -initial text -.Bd -offset 0n -displayed -text -.Ed some arguments -final text diff --git a/regress/usr.bin/mandoc/mdoc/Bd/notype.out_ascii b/regress/usr.bin/mandoc/mdoc/Bd/notype.out_ascii deleted file mode 100644 index 92f0d8e27e0..00000000000 --- a/regress/usr.bin/mandoc/mdoc/Bd/notype.out_ascii +++ /dev/null @@ -1,12 +0,0 @@ -BD-NOTYPE(1) OpenBSD Reference Manual BD-NOTYPE(1) - -NNAAMMEE - BBdd--nnoottyyppee - no type specified for a display - -DDEESSCCRRIIPPTTIIOONN - initial text - - displayed text - final text - -OpenBSD July 4, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bd/notype.out_lint b/regress/usr.bin/mandoc/mdoc/Bd/notype.out_lint deleted file mode 100644 index 4735ba3bd04..00000000000 --- a/regress/usr.bin/mandoc/mdoc/Bd/notype.out_lint +++ /dev/null @@ -1,2 +0,0 @@ -mandoc: notype.in:9:2: WARNING: missing display type, using -ragged -mandoc: notype.in:12:2: ERROR: skipping all arguments: Ed some arguments diff --git a/regress/usr.bin/mandoc/mdoc/Bl/badargs.in b/regress/usr.bin/mandoc/mdoc/Bl/badargs.in index 7424610b9fb..93a7de83d71 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/badargs.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/badargs.in @@ -1,4 +1,4 @@ -.Dd July 4, 2014 +.Dd July 5, 2014 .Dt BL-BADARGS 1 .Os OpenBSD .Sh NAME @@ -37,6 +37,15 @@ item Here we need a very long line. It must be sufficiently long such that it wraps the line. .El +double type: +.Bl -bullet -compact -enum +.It +bullet enum +.El +.Bl -enum -compact -bullet +.It +enum bullet +.El double arguments: .Bl -tag -compact -offset 20n -width 20n -compact -offset 2n -width 6n .It last diff --git a/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_ascii index f865b9680a5..c90878b15b2 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_ascii @@ -20,7 +20,10 @@ DDEESSCCRRIIPPTTIIOONN tag Here we need a very long line. It must be sufficiently long such that it wraps the line. + double type: + oo bullet enum + 1. enum bullet double arguments: last wins -OpenBSD July 4, 2014 OpenBSD +OpenBSD July 5, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_lint index dc119687440..5e92d00527f 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bl/badargs.out_lint @@ -4,7 +4,9 @@ mandoc: badargs.in:18:17: WARNING: empty argument, using 0n: Bl -width mandoc: badargs.in:27:19: WARNING: empty argument, using 0n: Bl -width mandoc: badargs.in:31:17: WARNING: empty argument, using 0n: Bl -width mandoc: badargs.in:35:16: WARNING: empty argument, using 0n: Bl -width -mandoc: badargs.in:41:51: WARNING: duplicate argument: Bl -compact -mandoc: badargs.in:41:59: WARNING: duplicate argument: Bl -offset 2n -mandoc: badargs.in:41:69: WARNING: duplicate argument: Bl -width 6n -mandoc: badargs.in:44:2: ERROR: skipping all arguments: El tail argument +mandoc: badargs.in:41:2: WARNING: skipping duplicate list type: enum +mandoc: badargs.in:45:2: WARNING: skipping duplicate list type: bullet +mandoc: badargs.in:50:51: WARNING: duplicate argument: Bl -compact +mandoc: badargs.in:50:59: WARNING: duplicate argument: Bl -offset 2n +mandoc: badargs.in:50:69: WARNING: duplicate argument: Bl -width 6n +mandoc: badargs.in:53:2: ERROR: skipping all arguments: El tail argument diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint index 649ef14f21d..b0faa945b2c 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint @@ -1,4 +1,3 @@ mandoc: notype.in:9:2: WARNING: list type is not the first argument: offset mandoc: notype.in:12:2: ERROR: skipping all arguments: El tail argument -mandoc: notype.in:14:2: WARNING: list type is not the first argument: offset mandoc: notype.in:14:2: ERROR: missing list type, using -item diff --git a/regress/usr.bin/mandoc/mdoc/Sm/Makefile b/regress/usr.bin/mandoc/mdoc/Sm/Makefile index ef3a2de066f..3c84d66c66e 100644 --- a/regress/usr.bin/mandoc/mdoc/Sm/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Sm/Makefile @@ -1,6 +1,7 @@ -# $OpenBSD: Makefile,v 1.5 2014/07/02 19:54:39 schwarze Exp $ +# $OpenBSD: Makefile,v 1.6 2014/07/05 12:33:54 schwarze Exp $ -REGRESS_TARGETS = noarg scope spacing-No spacing-Op +REGRESS_TARGETS = noarg badarg scope spacing-No spacing-Op +LINT_TARGETS = badarg SKIP_TMAN ?= scope diff --git a/regress/usr.bin/mandoc/mdoc/Sm/badarg.in b/regress/usr.bin/mandoc/mdoc/Sm/badarg.in new file mode 100644 index 00000000000..8684965e55f --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Sm/badarg.in @@ -0,0 +1,14 @@ +.Dd July 3, 2014 +.Dt SM-BADARG 1 +.Os OpenBSD +.Sh NAME +.Nm Sm-badarg +.Nd spacing macro with invalid arguments +.Sh DESCRIPTION +.Fl f Ar on +.Sm off +.Fl f Ar off +.Sm bad +.Fl f Ar bad Pq on +.Sm bad +.Fl f Ar bad Pq off diff --git a/regress/usr.bin/mandoc/mdoc/Sm/badarg.out_ascii b/regress/usr.bin/mandoc/mdoc/Sm/badarg.out_ascii new file mode 100644 index 00000000000..7251472d8e3 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Sm/badarg.out_ascii @@ -0,0 +1,9 @@ +SM-BADARG(1) OpenBSD Reference Manual SM-BADARG(1) + +NNAAMMEE + SSmm--bbaaddaarrgg - spacing macro with invalid arguments + +DDEESSCCRRIIPPTTIIOONN + --ff _o_n --ff_o_f_f bad --ff _b_a_d (on) bad--ff_b_a_d(off) + +OpenBSD July 3, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Sm/badarg.out_lint b/regress/usr.bin/mandoc/mdoc/Sm/badarg.out_lint new file mode 100644 index 00000000000..54644f3446b --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Sm/badarg.out_lint @@ -0,0 +1,2 @@ +mandoc: badarg.in:11:5: WARNING: invalid Boolean argument: Sm bad +mandoc: badarg.in:13:5: WARNING: invalid Boolean argument: Sm bad diff --git a/regress/usr.bin/mandoc/mdoc/St/badargs.out_lint b/regress/usr.bin/mandoc/mdoc/St/badargs.out_lint index bb81925fb1e..f4ebc6e7ef3 100644 --- a/regress/usr.bin/mandoc/mdoc/St/badargs.out_lint +++ b/regress/usr.bin/mandoc/mdoc/St/badargs.out_lint @@ -1,2 +1,2 @@ -mandoc: badargs.in:12:2: WARNING: unknown standard specifier +mandoc: badargs.in:12:5: ERROR: unknown standard specifier: -murks mandoc: badargs.in:15:2: WARNING: skipping empty macro: St diff --git a/regress/usr.bin/mandoc/roff/Makefile b/regress/usr.bin/mandoc/roff/Makefile index 439457f2827..3ce943bd302 100644 --- a/regress/usr.bin/mandoc/roff/Makefile +++ b/regress/usr.bin/mandoc/roff/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.16 2014/06/20 18:27:51 schwarze Exp $ +# $OpenBSD: Makefile,v 1.17 2014/07/05 12:33:54 schwarze Exp $ SUBDIR = args cond esc string -SUBDIR += br cc de ds it ll na nr ps rm sp +SUBDIR += br cc de ds ft it ll na nr ps rm sp .include "../Makefile.sub" .include diff --git a/regress/usr.bin/mandoc/roff/ft/Makefile b/regress/usr.bin/mandoc/roff/ft/Makefile new file mode 100644 index 00000000000..f57fe72ba71 --- /dev/null +++ b/regress/usr.bin/mandoc/roff/ft/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1 2014/07/05 12:33:54 schwarze Exp $ + +REGRESS_TARGETS = badargs +LINT_TARGETS = badargs + +.include diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.in b/regress/usr.bin/mandoc/roff/ft/badargs.in new file mode 100644 index 00000000000..a42557d418c --- /dev/null +++ b/regress/usr.bin/mandoc/roff/ft/badargs.in @@ -0,0 +1,15 @@ +.TH "FT-BADARGS" 1 "July 5, 2014" OpenBSD +.SH NAME +ft-badargs \(en font request with bad arguments +.SH DESCRIPTION +default font +.ft B +bold +.ft foo +still bold +.ft I +italic +.ft P +back to bold +.ft +back to italic diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii b/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii new file mode 100644 index 00000000000..dc3050e34d9 --- /dev/null +++ b/regress/usr.bin/mandoc/roff/ft/badargs.out_ascii @@ -0,0 +1,13 @@ +FT-BADARGS(1) OpenBSD Reference Manual FT-BADARGS(1) + + + +NNAAMMEE + ft-badargs - font request with bad arguments + +DDEESSCCRRIIPPTTIIOONN + default font bboolldd ssttiillll bboolldd _i_t_a_l_i_c bbaacckk ttoo bboolldd _b_a_c_k _t_o _i_t_a_l_i_c + + + +OpenBSD July 5, 2014 FT-BADARGS(1) diff --git a/regress/usr.bin/mandoc/roff/ft/badargs.out_lint b/regress/usr.bin/mandoc/roff/ft/badargs.out_lint new file mode 100644 index 00000000000..7a71655a48d --- /dev/null +++ b/regress/usr.bin/mandoc/roff/ft/badargs.out_lint @@ -0,0 +1 @@ +mandoc: badargs.in:8:2: WARNING: unknown font, skipping request: ft foo diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index e42f9acb79e..4c2867c3354 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.69 2014/07/04 16:11:41 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.70 2014/07/05 12:33:54 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -299,8 +299,8 @@ post_ft(CHKARGS) } if (0 == ok) { - mandoc_vmsg(MANDOCERR_BADFONT, man->parse, n->line, - n->pos, "%s", cp); + mandoc_vmsg(MANDOCERR_FT_BAD, man->parse, + n->line, n->pos, "ft %s", cp); *cp = '\0'; } diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index e3cdd684e9a..bad134ddc8c 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.79 2014/07/05 01:11:33 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.80 2014/07/05 12:33:54 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -91,23 +91,21 @@ enum mandocerr { MANDOCERR_ARGCWARN, /* argument count wrong */ MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged */ MANDOCERR_BL_LATETYPE, /* list type is not the first argument: arg */ - MANDOCERR_BL_WIDTH, /* missing -width in -tag list, using 8n */ + MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ MANDOCERR_IT_NOHEAD, /* empty head in list item: type */ MANDOCERR_IT_NOBODY, /* empty list item: type */ MANDOCERR_BF_NOFONT, /* missing font type, using \fR */ - MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */ + MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: macro font */ MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ /* related to bad macro arguments */ MANDOCERR_IGNARGV, /* skipping argument */ MANDOCERR_ARG_REP, /* duplicate argument: macro arg */ - MANDOCERR_DISPREP, /* duplicate display type */ - MANDOCERR_LISTREP, /* duplicate list type */ - MANDOCERR_BADATT, /* unknown AT&T UNIX version */ - MANDOCERR_BADBOOL, /* bad Boolean value */ - MANDOCERR_BADFONT, /* unknown font */ - MANDOCERR_BADSTANDARD, /* unknown standard specifier */ - MANDOCERR_BADWIDTH, /* bad width argument */ + MANDOCERR_BD_REP, /* skipping duplicate display type: type */ + MANDOCERR_BL_REP, /* skipping duplicate list type: type */ + MANDOCERR_AT_BAD, /* unknown AT&T UNIX version: version */ + MANDOCERR_SM_BAD, /* invalid Boolean argument: macro arg */ + MANDOCERR_FT_BAD, /* unknown font, skipping request: request font */ /* related to plain text */ MANDOCERR_NOBLANKLN, /* blank line in non-literal context */ @@ -145,6 +143,7 @@ enum mandocerr { MANDOCERR_REQUEST, /* NOT IMPLEMENTED: skipping request */ MANDOCERR_ARGCOUNT, /* argument count wrong */ MANDOCERR_RS_SKIP, /* skipping invalid content in .Rs block: macro */ + MANDOCERR_ST_BAD, /* unknown standard specifier: standard */ MANDOCERR_STRAYTA, /* skipping column outside column list */ MANDOCERR_NOSCOPE, /* skipping end of block that is not open */ MANDOCERR_SCOPEBROKEN, /* missing end of block */ diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 67ca6daa37c..f2c98fb0187 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.145 2014/07/05 01:11:33 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.146 2014/07/05 12:33:54 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -692,35 +692,32 @@ pre_bl(PRE_ARGS) default: continue; } + if (LIST__NONE == lt) + continue; /* Check: multiple list types. */ - if (LIST__NONE != lt && n->norm->Bl.type != LIST__NONE) - mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP); - - /* Assign list type. */ - - if (LIST__NONE != lt && n->norm->Bl.type == LIST__NONE) { - n->norm->Bl.type = lt; - /* Set column information, too. */ - if (LIST_column == lt) { - n->norm->Bl.ncols = - n->args->argv[i].sz; - n->norm->Bl.cols = (void *) - n->args->argv[i].value; - } + if (LIST__NONE != n->norm->Bl.type) { + mandoc_msg(MANDOCERR_BL_REP, + mdoc->parse, n->line, n->pos, + mdoc_argnames[argv->arg]); + continue; } /* The list type should come first. */ - if (n->norm->Bl.type == LIST__NONE) - if (n->norm->Bl.width || - n->norm->Bl.offs || - n->norm->Bl.comp) - mandoc_msg(MANDOCERR_BL_LATETYPE, - mdoc->parse, n->line, n->pos, - mdoc_argnames[n->args->argv[0].arg]); - continue; + if (n->norm->Bl.width || + n->norm->Bl.offs || + n->norm->Bl.comp) + mandoc_msg(MANDOCERR_BL_LATETYPE, + mdoc->parse, n->line, n->pos, + mdoc_argnames[n->args->argv[0].arg]); + + n->norm->Bl.type = lt; + if (LIST_column == lt) { + n->norm->Bl.ncols = argv->sz; + n->norm->Bl.cols = (void *)argv->value; + } } /* Allow lists to default to LIST_item. */ @@ -740,7 +737,7 @@ pre_bl(PRE_ARGS) switch (n->norm->Bl.type) { case LIST_tag: if (NULL == n->norm->Bl.width) - mdoc_nmsg(mdoc, n, MANDOCERR_BL_WIDTH); + mdoc_nmsg(mdoc, n, MANDOCERR_BL_NOWIDTH); break; case LIST_column: /* FALLTHROUGH */ @@ -842,16 +839,15 @@ pre_bd(PRE_ARGS) abort(); /* NOTREACHED */ } + if (DISP__NONE == dt) + continue; - /* Check whether a type has already been assigned. */ - - if (DISP__NONE != dt && n->norm->Bd.type != DISP__NONE) - mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP); - - /* Make our type assignment. */ - - if (DISP__NONE != dt && n->norm->Bd.type == DISP__NONE) + if (DISP__NONE == n->norm->Bd.type) n->norm->Bd.type = dt; + else + mandoc_msg(MANDOCERR_BD_REP, + mdoc->parse, n->line, n->pos, + mdoc_argnames[argv->arg]); } if (DISP__NONE == n->norm->Bd.type) { @@ -1218,7 +1214,8 @@ post_at(POST_ARGS) assert(MDOC_TEXT == n->type); if (NULL == (std_att = mdoc_a2att(n->string))) { - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADATT); + mandoc_msg(MANDOCERR_AT_BAD, mdoc->parse, + n->line, n->pos, n->string); mandoc_asprintf(&att, "AT&T UNIX %s", n->string); } else att = mandoc_strdup(std_att); @@ -1421,10 +1418,8 @@ post_bl_block_width(POST_ARGS) width = 6; else if (MDOC_MAX == (tok = mdoc_hash_find(n->norm->Bl.width))) return(1); - else if (0 == (width = macro2len(tok))) { - mdoc_nmsg(mdoc, n, MANDOCERR_BADWIDTH); - return(1); - } + else + width = macro2len(tok); /* The value already exists: free and reallocate it. */ @@ -1655,30 +1650,37 @@ post_bl(POST_ARGS) static int ebool(struct mdoc *mdoc) { + struct mdoc_node *nch; + enum mdoct tok; + + tok = mdoc->last->tok; + nch = mdoc->last->child; - if (NULL == mdoc->last->child) { - if (MDOC_Sm == mdoc->last->tok) + if (NULL == nch) { + if (MDOC_Sm == tok) mdoc->flags ^= MDOC_SMOFF; return(1); } check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_LT, 2); - assert(MDOC_TEXT == mdoc->last->child->type); + assert(MDOC_TEXT == nch->type); - if (0 == strcmp(mdoc->last->child->string, "on")) { - if (MDOC_Sm == mdoc->last->tok) + if (0 == strcmp(nch->string, "on")) { + if (MDOC_Sm == tok) mdoc->flags &= ~MDOC_SMOFF; return(1); } - if (0 == strcmp(mdoc->last->child->string, "off")) { - if (MDOC_Sm == mdoc->last->tok) + if (0 == strcmp(nch->string, "off")) { + if (MDOC_Sm == tok) mdoc->flags |= MDOC_SMOFF; return(1); } - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADBOOL); - return(1); + mandoc_vmsg(MANDOCERR_SM_BAD, + mdoc->parse, nch->line, nch->pos, + "%s %s", mdoc_macronames[tok], nch->string); + return(mdoc_node_relink(mdoc, nch)); } static int @@ -1714,25 +1716,28 @@ post_root(POST_ARGS) static int post_st(POST_ARGS) { - struct mdoc_node *ch; + struct mdoc_node *n, *nch; const char *p; - if (NULL == (ch = mdoc->last->child)) { + n = mdoc->last; + nch = n->child; + + if (NULL == nch) { mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, - mdoc->last->line, mdoc->last->pos, - mdoc_macronames[mdoc->last->tok]); - mdoc_node_delete(mdoc, mdoc->last); + n->line, n->pos, mdoc_macronames[n->tok]); + mdoc_node_delete(mdoc, n); return(1); } - assert(MDOC_TEXT == ch->type); + assert(MDOC_TEXT == nch->type); - if (NULL == (p = mdoc_a2st(ch->string))) { - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADSTANDARD); - mdoc_node_delete(mdoc, mdoc->last); + if (NULL == (p = mdoc_a2st(nch->string))) { + mandoc_msg(MANDOCERR_ST_BAD, mdoc->parse, + nch->line, nch->pos, nch->string); + mdoc_node_delete(mdoc, n); } else { - free(ch->string); - ch->string = mandoc_strdup(p); + free(nch->string); + nch->string = mandoc_strdup(p); } return(1); diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 3642c63a027..b878966a834 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.40 2014/07/05 01:11:33 schwarze Exp $ */ +/* $Id: read.c,v 1.41 2014/07/05 12:33:54 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -137,13 +137,11 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { /* related to bad macro arguments */ "skipping argument", "duplicate argument", - "duplicate display type", - "duplicate list type", + "skipping duplicate display type", + "skipping duplicate list type", "unknown AT&T UNIX version", - "bad Boolean value", - "unknown font", - "unknown standard specifier", - "bad width argument", + "invalid Boolean argument", + "unknown font, skipping request", /* related to plain text */ "blank line in non-literal context", @@ -181,6 +179,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "NOT IMPLEMENTED, please use groff: skipping request", "argument count wrong", "skipping invalid content in .Rs block", + "unknown standard specifier", "skipping column outside column list", "skipping end of block that is not open", "missing end of block", -- cgit v1.2.3