diff options
author | 2015-02-06 03:31:11 +0000 | |
---|---|---|
committer | 2015-02-06 03:31:11 +0000 | |
commit | afcd1f037b98fe634215da4a1c275e1c6bfb1886 (patch) | |
tree | b67a1fd40a9357c016cbbff0ada6ad1c236b7aa9 | |
parent | Remove route/netstat -f encap in favor of ipsecctl -s flow. (diff) | |
download | wireguard-openbsd-afcd1f037b98fe634215da4a1c275e1c6bfb1886.tar.xz wireguard-openbsd-afcd1f037b98fe634215da4a1c275e1c6bfb1886.zip |
better handle .Fo and .Fd without argument
better handle .Fo with more than one argument
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fd/Makefile | 8 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fd/empty.in | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fd/empty.out_ascii | 13 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fd/empty.out_lint | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fo/Makefile | 13 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fo/noarg.in | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fo/noarg.out_lint | 5 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fo/nohead.in | 13 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fo/nohead.out_ascii | 9 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Fo/nohead.out_lint | 1 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 8 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_man.c | 9 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 35 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 3 |
15 files changed, 105 insertions, 33 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Fd/Makefile b/regress/usr.bin/mandoc/mdoc/Fd/Makefile index 18ce23ac96d..7cd78c65b86 100644 --- a/regress/usr.bin/mandoc/mdoc/Fd/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Fd/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.2 2012/11/18 00:05:28 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2015/02/06 03:31:11 schwarze Exp $ -REGRESS_TARGETS = break font eos - -SKIP_TMAN = eos +REGRESS_TARGETS = break empty eos font +LINT_TARGETS = empty +SKIP_TMAN = eos .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/Fd/empty.in b/regress/usr.bin/mandoc/mdoc/Fd/empty.in new file mode 100644 index 00000000000..5951316dd29 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Fd/empty.in @@ -0,0 +1,14 @@ +.Dd February 5, 2015 +.Dt FD-EMPTY 1 +.Os OpenBSD +.Sh NAME +.Nm Fd-empty +.Nd empty preprocessor directive macros +.Sh SYNOPSIS +.In sys/types.h +.Fd +.In stdlib.h +.Sh DESCRIPTION +leading text +.Fd +trailing text diff --git a/regress/usr.bin/mandoc/mdoc/Fd/empty.out_ascii b/regress/usr.bin/mandoc/mdoc/Fd/empty.out_ascii new file mode 100644 index 00000000000..d525b4822eb --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Fd/empty.out_ascii @@ -0,0 +1,13 @@ +FD-EMPTY(1) General Commands Manual FD-EMPTY(1) + +NNAAMMEE + FFdd--eemmppttyy - empty preprocessor directive macros + +SSYYNNOOPPSSIISS + ##iinncclluuddee <<ssyyss//ttyyppeess..hh>> + ##iinncclluuddee <<ssttddlliibb..hh>> + +DDEESSCCRRIIPPTTIIOONN + leading text trailing text + +OpenBSD February 5, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Fd/empty.out_lint b/regress/usr.bin/mandoc/mdoc/Fd/empty.out_lint new file mode 100644 index 00000000000..15f762702f1 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Fd/empty.out_lint @@ -0,0 +1,2 @@ +mandoc: empty.in:9:2: WARNING: skipping empty macro: Fd +mandoc: empty.in:13:2: WARNING: skipping empty macro: Fd diff --git a/regress/usr.bin/mandoc/mdoc/Fo/Makefile b/regress/usr.bin/mandoc/mdoc/Fo/Makefile index 6a3c6bb5fa9..ec044d6faea 100644 --- a/regress/usr.bin/mandoc/mdoc/Fo/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Fo/Makefile @@ -1,11 +1,14 @@ -# $OpenBSD: Makefile,v 1.11 2014/11/20 00:30:34 schwarze Exp $ +# $OpenBSD: Makefile,v 1.12 2015/02/06 03:31:11 schwarze Exp $ -REGRESS_TARGETS = basic break eos font noarg obsolete punct section warn -LINT_TARGETS = noarg obsolete warn +REGRESS_TARGETS = basic break eos font noarg nohead +REGRESS_TARGETS += obsolete punct section warn +LINT_TARGETS = noarg nohead obsolete warn -# groff does not handle .nr nS +# groff-1.22.3 defects: +# - .Fo without an argument prints unbalanced parentheses +# - .nr nS is ignored -SKIP_GROFF ?= section +SKIP_GROFF = noarg section SKIP_TMAN = eos diff --git a/regress/usr.bin/mandoc/mdoc/Fo/noarg.in b/regress/usr.bin/mandoc/mdoc/Fo/noarg.in index fca1cd4a9d3..24eab0045bf 100644 --- a/regress/usr.bin/mandoc/mdoc/Fo/noarg.in +++ b/regress/usr.bin/mandoc/mdoc/Fo/noarg.in @@ -9,7 +9,7 @@ with arguments: .Ft int .Fn abs "int i" .Ft long -.Fo labs +.Fo labs bogus .Fa "long i" .Fc void function arguments: diff --git a/regress/usr.bin/mandoc/mdoc/Fo/noarg.out_lint b/regress/usr.bin/mandoc/mdoc/Fo/noarg.out_lint index 6c15847c0bd..e1947009774 100644 --- a/regress/usr.bin/mandoc/mdoc/Fo/noarg.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Fo/noarg.out_lint @@ -1,13 +1,10 @@ -mandoc: noarg.in:19:2: WARNING: argument count wrong: want more than 0 children (have 0) +mandoc: noarg.in:12:10: ERROR: skipping excess arguments: Fo ... bogus mandoc: noarg.in:23:2: WARNING: skipping empty macro: Fa -mandoc: noarg.in:22:2: WARNING: argument count wrong: want more than 0 children (have 0) mandoc: noarg.in:27:2: WARNING: skipping empty macro: Fn mandoc: noarg.in:29:2: WARNING: skipping empty macro: Ft mandoc: noarg.in:32:2: WARNING: skipping empty macro: Ft mandoc: noarg.in:34:2: WARNING: skipping empty macro: Ft -mandoc: noarg.in:35:2: WARNING: argument count wrong: want more than 0 children (have 0) mandoc: noarg.in:37:2: WARNING: skipping empty macro: Ft mandoc: noarg.in:39:2: WARNING: skipping empty macro: Fa -mandoc: noarg.in:38:2: WARNING: argument count wrong: want more than 0 children (have 0) mandoc: noarg.in:42:2: WARNING: skipping empty macro: Ft mandoc: noarg.in:43:2: WARNING: skipping empty macro: Fn diff --git a/regress/usr.bin/mandoc/mdoc/Fo/nohead.in b/regress/usr.bin/mandoc/mdoc/Fo/nohead.in new file mode 100644 index 00000000000..c41b5e6e049 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Fo/nohead.in @@ -0,0 +1,13 @@ +.Dd February 5, 2015 +.Dt FO-NOHEAD 1 +.Os OpenBSD +.Sh NAME +.Nm Fo-nohead +.Nd function block macro without head argument +.Sh DESCRIPTION +initial text +.Ft int +.Fo +.Fa int +.Fc +final text diff --git a/regress/usr.bin/mandoc/mdoc/Fo/nohead.out_ascii b/regress/usr.bin/mandoc/mdoc/Fo/nohead.out_ascii new file mode 100644 index 00000000000..c1ad57d7094 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Fo/nohead.out_ascii @@ -0,0 +1,9 @@ +FO-NOHEAD(1) General Commands Manual FO-NOHEAD(1) + +NNAAMMEE + FFoo--nnoohheeaadd - function block macro without head argument + +DDEESSCCRRIIPPTTIIOONN + initial text _i_n_t(_i_n_t) final text + +OpenBSD February 5, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Fo/nohead.out_lint b/regress/usr.bin/mandoc/mdoc/Fo/nohead.out_lint new file mode 100644 index 00000000000..aa0d5242483 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Fo/nohead.out_lint @@ -0,0 +1 @@ +mandoc: nohead.in:10:2: WARNING: missing function name, using "": Fo diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index a34095a48a2..3fc4aa4295b 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.138 2015/02/04 18:03:28 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.139 2015/02/06 03:31:11 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -98,6 +98,7 @@ enum mandocerr { MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */ MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ MANDOCERR_EX_NONAME, /* missing utility name, using "": Ex */ + MANDOCERR_FO_NOHEAD, /* missing function name, using "": Fo */ MANDOCERR_IT_NOHEAD, /* empty head in list item: Bl -type It */ MANDOCERR_IT_NOBODY, /* empty list item: Bl -type It */ MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */ diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index dbee618f9ac..58be4b69f64 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.133 2015/02/06 01:07:07 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.134 2015/02/06 03:31:11 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -1401,6 +1401,12 @@ in_line_eoln(MACRO_PROT_ARGS) rew_last(mdoc, mdoc->last->parent); } + if (buf[*pos] == '\0' && tok == MDOC_Fd) { + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + line, ppos, "Fd"); + return; + } + mdoc_argv(mdoc, line, tok, &arg, pos, buf); mdoc_elem_alloc(mdoc, line, ppos, tok, arg); if (parse_rest(mdoc, tok, line, pos, buf)) diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index e399e466ca3..07553485220 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_man.c,v 1.82 2015/02/01 23:10:15 schwarze Exp $ */ +/* $OpenBSD: mdoc_man.c,v 1.83 2015/02/06 03:31:11 schwarze Exp $ */ /* * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org> * @@ -1282,12 +1282,14 @@ pre_fo(DECL_ARGS) pre_syn(n); break; case MDOC_HEAD: + if (n->child == NULL) + return(0); if (MDOC_SYNPRETTY & n->flags) print_block(".HP 4n", MMAN_nl); font_push('B'); break; case MDOC_BODY: - outflags &= ~MMAN_spc; + outflags &= ~(MMAN_spc | MMAN_nl); print_word("("); outflags &= ~MMAN_spc; break; @@ -1303,7 +1305,8 @@ post_fo(DECL_ARGS) switch (n->type) { case MDOC_HEAD: - font_pop(); + if (n->child != NULL) + font_pop(); break; case MDOC_BODY: post_fn(meta, n); diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 196631e2519..da3b10946c1 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.189 2015/02/06 02:04:35 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.190 2015/02/06 03:31:11 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -65,7 +65,6 @@ static enum mdoc_sec a2sec(const char *); static size_t macro2len(enum mdoct); static void rewrite_macro2len(char **); -static void bwarn_ge1(POST_ARGS); static void ewarn_eq1(POST_ARGS); static void ewarn_ge1(POST_ARGS); @@ -149,7 +148,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Ev */ { pre_std, post_ex }, /* Ex */ { NULL, post_fa }, /* Fa */ - { NULL, ewarn_ge1 }, /* Fd */ + { NULL, NULL }, /* Fd */ { NULL, NULL }, /* Fl */ { NULL, post_fn }, /* Fn */ { NULL, NULL }, /* Ft */ @@ -400,12 +399,6 @@ check_count(struct mdoc *mdoc, enum mdoc_type type, } static void -bwarn_ge1(POST_ARGS) -{ - check_count(mdoc, MDOC_BODY, CHECK_GT, 0); -} - -static void ewarn_eq1(POST_ARGS) { check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); @@ -971,11 +964,27 @@ post_fn(POST_ARGS) static void post_fo(POST_ARGS) { + const struct mdoc_node *n; + + n = mdoc->last; + + if (n->type != MDOC_HEAD) + return; + + if (n->child == NULL) { + mandoc_msg(MANDOCERR_FO_NOHEAD, mdoc->parse, + n->line, n->pos, "Fo"); + return; + } + if (n->child != n->last) { + mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, + n->child->next->line, n->child->next->pos, + "Fo ... %s", n->child->next->string); + while (n->child != n->last) + mdoc_node_delete(mdoc, n->last); + } - check_count(mdoc, MDOC_HEAD, CHECK_EQ, 1); - bwarn_ge1(mdoc); - if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild) - post_fname(mdoc); + post_fname(mdoc); } static void diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index d70803bebd2..95fbee763f9 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.97 2015/02/04 18:03:28 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.98 2015/02/06 03:31:11 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -137,6 +137,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "list type is not the first argument", "missing -width in -tag list, using 8n", "missing utility name, using \"\"", + "missing function name, using \"\"", "empty head in list item", "empty list item", "missing font type, using \\fR", |