diff options
author | 2015-02-06 02:04:35 +0000 | |
---|---|---|
committer | 2015-02-06 02:04:35 +0000 | |
commit | b7530f2fd701a1770b910c4fa893500ec112f1f6 (patch) | |
tree | ac6e91b7a1c5db14e4756a4bfdaffd270cc3eee5 | |
parent | Rename SSL_CTX_use_certificate_chain() to SSL_CTX_use_certificate_chain_mem(). (diff) | |
download | wireguard-openbsd-b7530f2fd701a1770b910c4fa893500ec112f1f6.tar.xz wireguard-openbsd-b7530f2fd701a1770b910c4fa893500ec112f1f6.zip |
better handle empty .Bd .Bl .D1 .Dl blocks
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bl/Makefile | 4 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint | 11 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/D1/Makefile | 5 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/D1/spacing.in | 4 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/D1/spacing.out_ascii | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint | 1 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Dl/Makefile | 5 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Dl/spacing.in | 4 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Dl/spacing.out_ascii | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint | 1 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 84 |
12 files changed, 77 insertions, 50 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint b/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint index 0b70cc3ac40..8bcfc3d265f 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bd/blank.out_lint @@ -5,4 +5,4 @@ mandoc: blank.in:21:36: WARNING: whitespace at end of input line mandoc: blank.in:22:37: WARNING: whitespace at end of input line mandoc: blank.in:23:32: WARNING: whitespace at end of input line mandoc: blank.in:30:8: WARNING: whitespace at end of input line -mandoc: blank.in:30:2: WARNING: argument count wrong: want more than 0 children (have 0) +mandoc: blank.in:30:2: WARNING: skipping empty macro: Dl diff --git a/regress/usr.bin/mandoc/mdoc/Bl/Makefile b/regress/usr.bin/mandoc/mdoc/Bl/Makefile index 299bf820148..5e3d659572c 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Bl/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.27 2014/12/20 02:26:42 schwarze Exp $ +# $OpenBSD: Makefile,v 1.28 2015/02/06 02:04:35 schwarze Exp $ REGRESS_TARGETS = item inset diag ohang bullet dash enum hang tag REGRESS_TARGETS += column extend nested offset secstart @@ -8,7 +8,7 @@ REGRESS_TARGETS += empty noIt emptyhead emptytag emptyitem multitag REGRESS_TARGETS += bareIt bareTa unclosed break breakingIt broken LINT_TARGETS = column notype badargs -LINT_TARGETS += noIt emptyhead emptytag emptyitem +LINT_TARGETS += empty noIt emptyhead emptytag emptyitem LINT_TARGETS += bareIt bareTa break breakingIt broken # groff-1.22.3 defects: diff --git a/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint new file mode 100644 index 00000000000..837f5f5ec97 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bl/empty.out_lint @@ -0,0 +1,11 @@ +mandoc: empty.in:9:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:12:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:15:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:18:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:21:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:24:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:27:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:30:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:33:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:36:2: WARNING: skipping empty macro: Bl +mandoc: empty.in:39:2: WARNING: skipping empty macro: Bl diff --git a/regress/usr.bin/mandoc/mdoc/D1/Makefile b/regress/usr.bin/mandoc/mdoc/D1/Makefile index bb15b39277e..bed27d1b1f1 100644 --- a/regress/usr.bin/mandoc/mdoc/D1/Makefile +++ b/regress/usr.bin/mandoc/mdoc/D1/Makefile @@ -1,5 +1,6 @@ -# $OpenBSD: Makefile,v 1.1 2012/07/07 14:10:55 schwarze Exp $ +# $OpenBSD: Makefile,v 1.2 2015/02/06 02:04:35 schwarze Exp $ -REGRESS_TARGETS=spacing +REGRESS_TARGETS = spacing +LINT_TARGETS = spacing .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/D1/spacing.in b/regress/usr.bin/mandoc/mdoc/D1/spacing.in index bb74a11718f..3303dccc87b 100644 --- a/regress/usr.bin/mandoc/mdoc/D1/spacing.in +++ b/regress/usr.bin/mandoc/mdoc/D1/spacing.in @@ -1,4 +1,4 @@ -.Dd July 6, 2012 +.Dd February 5, 2015 .Dt D1-SPACING 1 .Os OpenBSD .Sh NAME @@ -7,4 +7,6 @@ .Sh DESCRIPTION preceding text .D1 spacing in and around one-line displays +empty display: +.D1 following text diff --git a/regress/usr.bin/mandoc/mdoc/D1/spacing.out_ascii b/regress/usr.bin/mandoc/mdoc/D1/spacing.out_ascii index ab9743dd0c8..becef1b8c8e 100644 --- a/regress/usr.bin/mandoc/mdoc/D1/spacing.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/D1/spacing.out_ascii @@ -6,6 +6,7 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN preceding text spacing in and around one-line displays + empty display: following text -OpenBSD July 6, 2012 OpenBSD +OpenBSD February 5, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint b/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint new file mode 100644 index 00000000000..5b2e9475191 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/D1/spacing.out_lint @@ -0,0 +1 @@ +mandoc: spacing.in:11:2: WARNING: skipping empty macro: D1 diff --git a/regress/usr.bin/mandoc/mdoc/Dl/Makefile b/regress/usr.bin/mandoc/mdoc/Dl/Makefile index bb15b39277e..bed27d1b1f1 100644 --- a/regress/usr.bin/mandoc/mdoc/Dl/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Dl/Makefile @@ -1,5 +1,6 @@ -# $OpenBSD: Makefile,v 1.1 2012/07/07 14:10:55 schwarze Exp $ +# $OpenBSD: Makefile,v 1.2 2015/02/06 02:04:35 schwarze Exp $ -REGRESS_TARGETS=spacing +REGRESS_TARGETS = spacing +LINT_TARGETS = spacing .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/Dl/spacing.in b/regress/usr.bin/mandoc/mdoc/Dl/spacing.in index 9e7c4cd9217..cc683872b5e 100644 --- a/regress/usr.bin/mandoc/mdoc/Dl/spacing.in +++ b/regress/usr.bin/mandoc/mdoc/Dl/spacing.in @@ -1,4 +1,4 @@ -.Dd July 6, 2012 +.Dd February 5, 2015 .Dt DL-SPACING 1 .Os OpenBSD .Sh NAME @@ -7,4 +7,6 @@ .Sh DESCRIPTION preceding text .Dl spacing in and around one-line literal displays +empty display: +.Dl following text diff --git a/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_ascii b/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_ascii index 017f679cc7f..db5958da118 100644 --- a/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_ascii @@ -6,6 +6,7 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN preceding text spacing in and around one-line literal displays + empty display: following text -OpenBSD July 6, 2012 OpenBSD +OpenBSD February 5, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint b/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint new file mode 100644 index 00000000000..937eae77481 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Dl/spacing.out_lint @@ -0,0 +1 @@ +mandoc: spacing.in:11:2: WARNING: skipping empty macro: Dl diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index d67b1ab8200..196631e2519 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.188 2015/02/06 01:07:07 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.189 2015/02/06 02:04:35 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -1063,26 +1063,40 @@ post_nd(POST_ARGS) static void post_d1(POST_ARGS) { + struct mdoc_node *n; + + n = mdoc->last; + + if (n->type != MDOC_BODY) + return; + + if (n->child == NULL) + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + n->line, n->pos, "D1"); - bwarn_ge1(mdoc); post_hyph(mdoc); } static void post_literal(POST_ARGS) { + struct mdoc_node *n; - bwarn_ge1(mdoc); + n = mdoc->last; - /* - * The `Dl' (note "el" not "one") and `Bd' macros unset the - * MDOC_LITERAL flag as they leave. Note that `Bd' only sets - * this in literal mode, but it doesn't hurt to just switch it - * off in general since displays can't be nested. - */ + if (n->type != MDOC_BODY) + return; + + if (n->child == NULL) + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + n->line, n->pos, mdoc_macronames[n->tok]); - if (MDOC_BODY == mdoc->last->type) - mdoc->flags &= ~MDOC_LITERAL; + if (n->tok == MDOC_Bd && + n->norm->Bd.type != DISP_literal && + n->norm->Bd.type != DISP_unfilled) + return; + + mdoc->flags &= ~MDOC_LITERAL; } static void @@ -1479,10 +1493,13 @@ post_bl(POST_ARGS) return; } - bwarn_ge1(mdoc); - nchild = nbody->child; - while (NULL != nchild) { + if (nchild == NULL) { + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + nbody->line, nbody->pos, "Bl"); + return; + } + while (nchild != NULL) { if (nchild->tok == MDOC_It || (nchild->tok == MDOC_Sm && nchild->next != NULL && @@ -1740,33 +1757,17 @@ post_rs(POST_ARGS) static void post_hyph(POST_ARGS) { - struct mdoc_node *n, *nch; + struct mdoc_node *nch; char *cp; - n = mdoc->last; - switch (n->type) { - case MDOC_HEAD: - if (MDOC_Sh == n->tok || MDOC_Ss == n->tok) - break; - return; - case MDOC_BODY: - if (MDOC_D1 == n->tok || MDOC_Nd == n->tok) - break; - return; - case MDOC_ELEM: - break; - default: - return; - } - - for (nch = n->child; nch; nch = nch->next) { - if (MDOC_TEXT != nch->type) + for (nch = mdoc->last->child; nch != NULL; nch = nch->next) { + if (nch->type != MDOC_TEXT) continue; cp = nch->string; - if ('\0' == *cp) + if (*cp == '\0') continue; - while ('\0' != *(++cp)) - if ('-' == *cp && + while (*(++cp) != '\0') + if (*cp == '-' && isalpha((unsigned char)cp[-1]) && isalpha((unsigned char)cp[1])) *cp = ASCII_HYPH; @@ -2060,10 +2061,15 @@ post_ignpar(POST_ARGS) { struct mdoc_node *np; - post_hyph(mdoc); - - if (MDOC_BODY != mdoc->last->type) + switch (mdoc->last->type) { + case MDOC_HEAD: + post_hyph(mdoc); + return; + case MDOC_BODY: + break; + default: return; + } if (NULL != (np = mdoc->last->child)) if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) { |